| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028 |
- <template>
- <uni-navbar-lite :showLeft=false title="工单"></uni-navbar-lite>
- <view class="list-page">
- <!-- 搜索栏 -->
- <view class="search-bar">
- <view class="search-box">
- <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
- <input class="search-input" type="text" placeholder="搜索工单编码、风机编号" v-model="keyword" @confirm="handleSearch" @blur="handleSearch" />
- <text v-if="keyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
- </view>
- </view>
- <view class="status-bar">
- <scroll-view class="scroll-view_H" direction="horizontal" show-scrollbar="false">
- <view class="scroll-view-item_H uni-bg-red">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'all'}" @click="switchStatus('all')">全部</text>
- </view>
- <!-- <view class="scroll-view-item_H uni-bg-green" v-if="checkPermi(['gxt:maintenance:order:edit','gxt:repairOrder:edit']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_issue,accept_return'}" @click="switchStatus('to_issue,accept_return')">待下发</text>
- </view> -->
- <view class="scroll-view-item_H uni-bg-green" v-if="checkPermi(['gxt:maintenance:order:accept','gxt:repairOrder:accept']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'assigned'}" @click="switchStatus('assigned')">待接单</text>
- </view>
- <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:suspend','gxt:repairOrder:suspend']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_finish'}" @click="switchStatus('to_finish')">待结单</text>
- </view>
- <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:approve','gxt:repairOrder:approve']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_approve'}" @click="switchStatus('to_approve')">待审批</text>
- </view>
- <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:resume','gxt:repairOrder:resume']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'suspended'}" @click="switchStatus('suspended')">已挂起</text>
- </view>
- <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:autoResume','gxt:repairOrder:autoResume']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'auto_suspend'}" @click="switchStatus('auto_suspend')">自动挂起</text>
- </view>
- <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:restart','gxt:repairOrder:restart']) && !dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'completed'}" @click="switchStatus('completed')">已完成</text>
- </view>
- <view class="scroll-view-item_H" v-if="dealLoad">
- <text class="status-txt" :class="{'stauts-sel': currentStatus === 'pending'}" @click="switchStatus('pending')">待处理</text>
- </view>
- </scroll-view>
- </view>
- <!-- 列表内容 -->
- <common-list
- :dataList="dataList"
- :loading="loading"
- :refreshing="refreshing"
- :hasMore="hasMore"
- @refresh="handleRefresh"
- @loadMore="loadMore"
- @itemClick="handleView"
- >
- <template #default="{ item, index }">
- <view class="list-item">
- <view class="item-container">
- <view class="item-header">
- <text class="item-title">{{ getWorkOrderProjectNo(item) }}-{{ getPcsStationName(item) }}{{ getPcsDeviceName(item) }}{{ getOrderType(item) }}</text>
- <text class="status-tag" :class="getStatusClass(item)" >{{ getWorkOrderStatus(item) }}</text>
- <!-- <view class="status-view" :class="getStatusClass(item)"><text class="status-tag" :class="getStatusClass(item)" >{{ getWorkOrderStatus(item) }}</text></view> -->
- </view>
- <view class="info-row">
- <view class="info-label">
- <text class="text-gray">{{ getDisplayTime(item) }}</text>
- </view>
- </view>
- <view class="btn-group">
- <view
- v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'accept')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item,'')"
- >
- <text class="btn-text">接单</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'to_approve' && canHandleOrder(item,'')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item,'')"
- >
- <text class="btn-text">审批</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'suspended' && canHandleOrder(item,'')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item,'')"
- >
- <text class="btn-text">恢复</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'auto_suspend' && canHandleOrder(item,'')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item,'')"
- >
- <text class="btn-text">恢复</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'return' && canHandleOrder(item,'acceptReturn')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item,'acceptReturn')"
- >
- <text class="btn-text">退回</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'acceptReturn')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item,'acceptReturn')"
- >
- <text class="btn-text">退回</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'return')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item, 'return')"
- >
- <text class="btn-text">退回</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'suspend')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item, 'suspend')"
- >
- <text class="btn-text">挂起</text>
- </view>
- <view
- v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'finalize')"
- class="btn-primary info-value"
- @click.stop="handleItemClick(item, 'finalize')"
- >
- <text class="btn-text">复启</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- </common-list>
- <custom-tabbar :current="1" :hide0="tabbar[0]" :hide1="tabbar[1]" :hide2="tabbar[2]" :hide3="tabbar[3]"/>
- </view>
- </template>
- <script setup lang="uts">
- import { ref, onBeforeUnmount, onMounted, reactive } from 'vue'
- import type { acceptOrderInfo } from '../../types/order'
- import type { SysDictData, DictDataResponse } from '../../types/dict'
- import { getOrderList } from '../../api/order/list'
- import { getDictDataByType } from '../../api/dict/index'
- import {checkPermi, getUserInfo} from '../../utils/storage'
- const userId = ref<string>("")
- const roles = ref<string>('')
- // 列表数据
- const dataList = ref<acceptOrderInfo[]>([])
- let keyword = ref<string>("")
- const page = ref<number>(1)
- const pageSize: number = 10
- const hasMore = ref<boolean>(true)
- const loading = ref<boolean>(false)
- const refreshing = ref<boolean>(false)
- const total = ref<number>(0)
- let currentStatus = ref<string>('') // 添加状态管理
- const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
- const tabbar = reactive([1,1,1,1])
- // 添加防重复请求的标志位(参考score/pending.uvue的实现)
- const isSearching = ref<boolean>(false)
- // 添加防重复刷新的标志
- const isRefreshing = ref<boolean>(false)
- // 添加刷新时间戳,用于防抖
- const lastRefreshTime = ref<number>(0)
- // 添加字典加载状态
- const dictLoaded = ref<boolean>(false)
- // 待处理工单加载
- const dealLoad = ref<boolean>(false)
- type StatusItem = {
- key: string,
- permis: string[],
- condition: () => boolean
- }
- const statusConfig: StatusItem[] = [
- { key: 'all', permis: ['gxt:order:all'], condition: () => !dealLoad.value },
- { key: 'assigned', permis: ['gxt:maintenance:order:accept','gxt:repairOrder:accept'], condition: () => !dealLoad.value },
- { key: 'to_finish', permis: ['gxt:maintenance:order:suspend','gxt:repairOrder:suspend'], condition: () => !dealLoad.value },
- { key: 'to_approve', permis: ['gxt:maintenance:order:approve','gxt:repairOrder:approve'], condition: () => !dealLoad.value },
- { key: 'suspended', permis: ['gxt:maintenance:order:resume','gxt:repairOrder:resume'], condition: () => !dealLoad.value },
- { key: 'completed', permis: ['gxt:maintenance:order:restart','gxt:repairOrder:restart'], condition: () => !dealLoad.value }
- ]
- const getOrderStatus = (item: any | null): string => {
- if (item == null) return ''
- const orderItem = item as acceptOrderInfo
- return orderItem.workOrderStatus ?? ''
- }
- // 获取工单状态字典列表
- const loadStatusDictList = async (): Promise<void> => {
- try {
- const result = await getDictDataByType('gxt_work_order_status')
- const resultObj = result as UTSJSONObject
- if (resultObj['code'] == 200) {
- const data = resultObj['data'] as any[]
- const dictData: SysDictData[] = []
- if (data.length > 0) {
- for (let i = 0; i < data.length; i++) {
- const item = data[i] as UTSJSONObject
- // 只提取需要的字段
- const dictItem: SysDictData = {
- dictValue: item['dictValue'] as string | null,
- dictLabel: item['dictLabel'] as string | null,
- dictCode: null,
- dictSort: null,
- dictType: null,
- cssClass: null,
- listClass: null,
- isDefault: null,
- status: null,
- default: null,
- createTime: null,
- remark: null
- }
- dictData.push(dictItem)
- }
- }
- statusDictList.value = dictData
- dictLoaded.value = true
- }
- } catch (e: any) {
- console.error('获取工单状态字典失败:', e.message)
- dictLoaded.value = true
- }
- }
- const getFirstVisibleStatus = (): string => {
- for (const item of statusConfig) {
- const hasPerm = item.permis.length === 0 || checkPermi(item.permis)
- const meetsCondition = item.condition()
- if (hasPerm && meetsCondition) {
- // if (hasPerm) {
- return item.key as string
- }
- }
- return 'all' // fallback,理论上不会走到这里
- }
- let loadCount = 0
- // 加载列表数据
- const loadData = async (isRefresh: boolean | null, disablePullDown: boolean | null): Promise<void> => {
- const id = ++loadCount
- console.log(`【loadData #${id}】开始, isRefresh=${isRefresh}, disablePullDown=${disablePullDown}`)
- // 防止重复请求的核心机制(参考score/pending.uvue的实现)
- if (loading.value) {
- // 确保刷新状态最终被重置,防止卡死
- if (isRefresh != true) {
- refreshing.value = false;
- }
- return
- }
- const shouldRefresh = isRefresh != null ? isRefresh : false
- const shouldDisablePullDown = disablePullDown != null ? disablePullDown : false
- loading.value = true
- if (shouldRefresh && !shouldDisablePullDown) {
- page.value = 1
- refreshing.value = true
- } else if (shouldRefresh && shouldDisablePullDown) {
- // 状态切换时,重置页码但不触发动画
- page.value = 1
- // 即使禁用下拉刷新,也要确保刷新状态最终被重置
- refreshing.value = false
- } else {
- // 对于加载更多操作,不需要显示下拉刷新状态
- refreshing.value = false;
- }
- try {
- // 处理默认值
- const searchKeyword = keyword.value.length > 0 ? keyword.value : null
- const result = await getOrderList(page.value, pageSize, searchKeyword, currentStatus.value)
- // 提取响应数据
- const resultObj = result as UTSJSONObject
- const code = resultObj['code'] as number
- const responseData = resultObj['rows'] as any[]
- const responseTotal = resultObj['total'] as number
- if (code == 200) {
- // 将 any[] 转换为 acceptOrderInfo[]
- const newData: acceptOrderInfo[] = []
- for (let i = 0; i < responseData.length; i++) {
- const item = responseData[i] as UTSJSONObject
- const orderItem: acceptOrderInfo = {
- orderType: item['orderType'] as Number,
- id: item['id'] as Number,
- teamLeaderId: item['teamLeaderId'] != null ? (item['teamLeaderId'] as Number) : 0,
- acceptUserId: item['acceptUserId'] != null ? (item['acceptUserId'] as Number) : 0,
- teamLeaderName: item['teamLeaderName'] as string | null,
- acceptUserName: item['acceptUserName'] as string | null,
- acceptTime: item['acceptTime'] as string | null,
- assignTime: item['assignTime'] as string | null,
- assignUserName: item['assignUserName'] as string | null,
- status: (item['status']==null)?0:item['status'] as Number,
- workOrderProjectNo: item['workOrderProjectNo'] as string | null,
- workOrderStatus: item['workOrderStatus'] as string | null,
- gxtCenterId: item['gxtCenterId'] as Number | 0,
- gxtCenter: item['gxtCenter'] as string | null,
- pcsStationId: item['pcsStationId'] as Number | 0,
- pcsStationName: item['pcsStationName'] as string | null,
- pcsDeviceId: item['pcsDeviceId'] as Number | 0,
- pcsDeviceName: item['pcsDeviceName'] as string | null,
- brand: item['brand'] as string | null,
- model: item['model'] as string | null,
- createTime: item['createTime'] as string | null,
- suspendReason: item['suspendReason'] as string | null,
- rejectionReason: item['rejectionReason'] as string | null,
- updateTime: item['updateTime'] as string | null, // 新增字段
- workEndTime: item['workEndTime'] as string | null // 新增字段
- }
- newData.push(orderItem)
- }
- // 不再在前端过滤,直接使用API返回的数据
- if (shouldRefresh) {
- dataList.value = newData
- } else {
- dataList.value = [...dataList.value, ...newData]
- }
- total.value = responseTotal
- hasMore.value = dataList.value.length < responseTotal
- // 通知首页更新待接单数量
- if (currentStatus.value === 'assigned') {
- uni.$emit('refreshAssignedCount')
- }
- } else {
- const msg = resultObj['msg'] as string | null
- uni.showToast({
- title: msg ?? '加载失败',
- icon: 'none'
- })
- }
- } catch (e: any) {
- uni.showToast({
- title: e.message ?? '加载失败',
- icon: 'none'
- })
- } finally {
- loading.value = false
- // 确保刷新状态能结束(参考score/pending.uvue的实现)
- if (shouldRefresh) {
- refreshing.value = false;
- // 使用setTimeout确保状态彻底重置
- setTimeout(() => {
- isRefreshing.value = false;
- }, 50);
- }
- }
- }
- // 辅助函数:从 any 类型提取属性
- const getOrderType = (item: any | null): string => {
- if (item == null) return ''
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.orderType == 1?"维修工单":"维保工单";
- }
- const getWorkOrderProjectNo = (item: any | null): string | null => {
- if (item == null) return ''
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.workOrderProjectNo
- }
- const getPcsStationName = (item: any | null): string | null=> {
- if (item == null) return ''
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.pcsStationName
- }
- const getPcsDeviceName = (item: any | null): string | null=> {
- if (item == null) return ''
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.pcsDeviceName
- }
- const getAssignTime = (item: any | null): string|null => {
- if (item == null) return null
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.assignTime
- }
- const getAcceptTime = (item: any | null): string|null => {
- if (item == null) return null
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.acceptTime
- }
- const getCreateTime = (item: any | null): string|null => {
- if (item == null) return null
- const orderInfoItem = item as acceptOrderInfo
- return orderInfoItem.createTime
- }
- // 根据状态显示不同的时间
- const getDisplayTime = (item: any | null): string|null => {
- if (item == null) return null
- const orderInfoItem = item as acceptOrderInfo
- // 如果是"待接单"状态,显示派单时间
- if (orderInfoItem.workOrderStatus == 'assigned') {
- return '下发时间:' + orderInfoItem.assignTime
- } else if(orderInfoItem.workOrderStatus == 'to_finish') {
- if(orderInfoItem.workEndTime != null) {
- return '结束时间:' + orderInfoItem.workEndTime
- }
- return '接单时间:' + orderInfoItem.acceptTime
- } else if(orderInfoItem.workOrderStatus == 'to_approve') {
- return '申请挂起时间:' + orderInfoItem.updateTime
- } else if(orderInfoItem.workOrderStatus == 'suspended') {
- return '审批通过时间:' + orderInfoItem.updateTime
- } else if(orderInfoItem.workOrderStatus == 'return' || orderInfoItem.workOrderStatus == 'accept_return') {
- return '退回时间:' + orderInfoItem.updateTime
- } else if(orderInfoItem.workOrderStatus == 'completed') {
- return '结单时间:' + orderInfoItem.updateTime
- } else if(orderInfoItem.workOrderStatus == 'archived') {
- return '归档时间:' + orderInfoItem.updateTime
- }
- // 默认显示创建时间
- return '创建时间:' + orderInfoItem.createTime
- }
- const getWorkOrderStatus = (item: any | null): string | null => {
- if (item == null) return ''
- const orderInfoItem = item as acceptOrderInfo
- const rawStatus = orderInfoItem.workOrderStatus
- if (rawStatus==null) return ''
- // 如果字典尚未加载,返回原始值
- if (!dictLoaded.value) {
- return rawStatus
- }
- // 查找字典中对应的标签
- const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
- return dictItem!=null ? dictItem.dictLabel : rawStatus
- }
- const getStatusClass = (item: any | null): string => {
- if (item == null) return ''
- const orderInfoItem = item as acceptOrderInfo
- const rawStatus = orderInfoItem.workOrderStatus
- if (rawStatus==null) return ''
- // const status = rawStatus
- // 返回对应的状态类名
- return `status-${rawStatus}`
- }
- // 切换状态
- const switchStatus = (status: string): void => {
- // 添加防重复调用检查(参考score/pending.uvue的实现)
- if (loading.value) {
- return;
- }
- // 添加防重复请求检查
- if (isSearching.value) {
- return
- }
- isSearching.value = true
- currentStatus.value = status
- page.value = 1
- loadData(true, true) // 第二个参数为true表示禁用下拉刷新动画
- // 延迟重置标志位,确保请求发送后才允许下一次搜索
- setTimeout(() => {
- isSearching.value = false
- }, 100)
- }
- // 下拉刷新
- const handleRefresh = async (): Promise<void> => {
- console.log("handleRefresh被触发")
- console.log("loading.value===",loading.value)
- console.log("isRefreshing.value===",isRefreshing.value)
- // 防抖处理,避免频繁触发(参考score/pending.uvue的实现)
- const now = Date.now();
- if (now - lastRefreshTime.value < 1000) {
- refreshing.value = false;
- return;
- }
- lastRefreshTime.value = now;
- // 添加防重复调用检查
- if (loading.value || isRefreshing.value) {
- // 如果已经在加载或正在刷新,直接重置刷新状态
- refreshing.value = false;
- return;
- }
- console.log("loading.value1===",loading.value)
- console.log("isRefreshing.value1===",isRefreshing.value)
- // 设置刷新标志
- isRefreshing.value = true;
- try {
- await loadData(true, false); // 使用默认的下拉刷新行为
- } catch (error) {
- console.error('刷新失败:', error);
- refreshing.value = false;
- isRefreshing.value = false;
- }
- // 确保在一定时间后重置刷新标志,防止意外情况
- setTimeout(() => {
- isRefreshing.value = false
- }, 100) // 延迟重置,确保状态完全更新
- }
- // 加载更多
- const loadMore = (): void => {
- if (!hasMore.value || loading.value) {
- return
- }
- page.value++
- loadData(false, false)
- }
- // 搜索
- const handleSearch = (): void => {
- // 添加防重复调用检查(参考score/pending.uvue的实现)
- if (loading.value) {
- return;
- }
- // 添加防重复请求检查
- if (isSearching.value) {
- return
- }
- isSearching.value = true
- page.value = 1
- loadData(true, true) // 状态切换时禁用下拉刷新动画
- // 延迟重置标志位,确保请求发送后才允许下一次搜索
- setTimeout(() => {
- isSearching.value = false
- }, 100)
- }
- const handleSearchOnBlur = (): void => {
- handleSearch()
- }
- // 方法:判断当前工单是否显示操作按钮
- const canHandleOrder = (item: any | null, buttonType: string | ''): boolean => {
- if (item == null) return false
- let permit: string[] = []
- const orderItem = item as acceptOrderInfo
- if(orderItem.workOrderStatus == 'assigned' && buttonType != '' && buttonType == "acceptReturn" && orderItem.orderType == 1) {
- // 接单退回
- permit = ['gxt:repairOrder:acceptReturn']
- } else if(orderItem.workOrderStatus == 'assigned' && buttonType != '' && buttonType == "accept") {
- // 接单
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:accept'] : ['gxt:repairOrder:accept']
- } else if(orderItem.workOrderStatus == 'to_finish') {
- if(buttonType != '' && buttonType == "suspend" && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
- // 挂起
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:suspend'] : ['gxt:repairOrder:suspend']
- } else if(buttonType != '' && buttonType == "return" && orderItem.orderType == 1 && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
- // 退回
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:return'] : ['gxt:repairOrder:return']
- } else if(buttonType != '' && buttonType == "finalize" && orderItem.orderType == 1 && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
- // 复启
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:finalize'] : ['gxt:repairOrder:finalize']
- }
- } else if(orderItem.workOrderStatus == 'to_approve') {
- // 审批
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:approve'] : ['gxt:repairOrder:approve']
- } else if(orderItem.workOrderStatus == 'suspended' && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
- // 恢复
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:resume'] : ['gxt:repairOrder:resume']
- } else if(orderItem.workOrderStatus == 'return') {
- // 接单退回
- permit = ['gxt:repairOrder:acceptReturn']
- } else if(orderItem.workOrderStatus == 'auto_suspend') {
- // 自动挂起恢复
- permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:autoResume'] : ['gxt:repairOrder:autoResume']
- }
- else {
- return false
- }
- // const orderType = (item as acceptOrderInfo).orderType
- return checkPermi(permit)
- }
- // 点击列表项
- const handleItemClick = (item: any | null, buttonType: string | ''): void => {
- if (item == null) return
- const orderItem = item as acceptOrderInfo
- // if(currentStatus.value === '' || currentStatus.value === 'completed' || currentStatus.value === 'all') {
- // // 传递orderType参数以便详情页决定调用哪个API
- // uni.navigateTo({
- // url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
- // })
- // } else
- if(orderItem.workOrderStatus == 'assigned') {
- if(buttonType != '' && buttonType == "acceptReturn") {
- // 跳转到退回页面
- uni.navigateTo({
- url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- } else {
- // 跳转到接单页面
- uni.navigateTo({
- url: `/pages/order/detail/acceptIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- }
- } else if(orderItem.workOrderStatus == 'to_finish') {
- if(buttonType != '' && buttonType == "suspend") {
- // 跳转到待结单页面
- uni.navigateTo({
- url: `/pages/order/detail/suspendIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- } else if(buttonType != '' && buttonType == "return") {
- // 跳转到退回页面
- uni.navigateTo({
- url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- } else if(buttonType != '' && buttonType == "finalize") {
- // 跳转到复启页面
- uni.navigateTo({
- url: `/pages/order/detail/resetIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- }
- } else if(orderItem.workOrderStatus == 'to_approve') {
- // 跳转到待审批页面
- uni.navigateTo({
- url: `/pages/order/detail/approveIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- } else if(orderItem.workOrderStatus == 'suspended' || orderItem.workOrderStatus == 'auto_suspend') {
- // 跳转到恢复页面
- uni.navigateTo({
- url: `/pages/order/detail/resumeIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- } else if(orderItem.workOrderStatus == 'return') {
- // 跳转到退回页面
- uni.navigateTo({
- url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- } else {
- uni.navigateTo({
- url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- }
- }
- // 点击列表项
- const handleView = (item: any | null): void => {
- if (item == null) return
- const orderItem = item as acceptOrderInfo
- uni.navigateTo({
- url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
- })
- }
- // 查看工单详情
- const showWorkOrderDetail = (item: any | null): void => {
- if (item == null) return
- const orderItem = item as acceptOrderInfo
- uni.navigateTo({
- url: `/pages/workbench/detail/index?id=${orderItem.id}`
- })
- }
- // 清空搜索
- const clearSearch = (): void => {
- // 添加防重复调用检查(参考score/pending.uvue的实现)
- if (loading.value) {
- return;
- }
- // 添加防重复请求检查
- if (isSearching.value) {
- return
- }
- isSearching.value = true
- keyword.value = ""
- page.value = 1
- loadData(true, true) // 状态切换时禁用下拉刷新动画
- // 延迟重置标志位,确保请求发送后才允许下一次搜索
- setTimeout(() => {
- isSearching.value = false
- }, 100)
- }
- // 初始化
- // onMounted(() => {
- onLoad((options: any) => {
- // 检查权限设置tabbar
- tabbar[2] = checkPermi(['gxt:app:worktime']) ? 1 : 0
- tabbar[3] = checkPermi(['gxt:app:score']) ? 1 : 0
- const userInfo = getUserInfo()
- if (userInfo != null) {
- const userIdStr = userInfo['userId'].toString()
- userId.value = userIdStr
- roles.value = userInfo['roleNames'].toString()
- }
- const params = options as UTSJSONObject
- const isDeal = params['isDeal'] as string | null
- if(isDeal != null) {
- dealLoad.value = true;
- }
- loadStatusDictList()
- // 自动选中第一个可显示的状态
- // currentStatus.value = getFirstVisibleStatus()
- currentStatus.value = 'all'
- loadData(true, true) // 首次加载时禁用下拉刷新动画
- // 监听首页切换状态事件
- uni.$on('switchOrderStatus', (status: string) => {
- switchStatus(status)
- })
- // 监听接单成功的事件,刷新列表
- uni.$on('refreshOrderList', () => {
- page.value = 1
- loadData(true, false)
- })
- })
- // 组件卸载前清理事件监听
- onBeforeUnmount(() => {
- refreshing.value = false
- loading.value = false
- isRefreshing.value = false
- // 移除事件监听
- uni.$off('refreshOrderList',{})
- uni.$off('switchOrderStatus',{})
- })</script>
- <style lang="scss">
- .list-page {
- flex: 1;
- background-color: #e8f0f9;
- }
- .search-bar {
- padding: 20rpx 30rpx;
- background-color: #d7eafe;
- }
- .search-box {
- flex-direction: row;
- align-items: center;
- height: 72rpx;
- padding: 0 24rpx;
- background-color: #f5f5f5;
- border-radius: 36rpx;
- .search-icon {
- width: 32rpx;
- height: 32rpx;
- margin-right: 12rpx;
- }
- .search-input {
- flex: 1;
- font-size: 28rpx;
- color: #333333;
- }
- .clear-icon {
- margin-left: 12rpx;
- font-size: 28rpx;
- color: #999999;
- }
- }
- .status-bar{
- padding-bottom: 10px;
- padding-left:30rpx;
- background-color: #d7eafe;
- }
- .status-box {
- flex-direction: row;
- align-items: center;
- height: 72rpx;
- flex: 1;
- .status-txt{
- padding: 8px 12px;
- text-align: center;
- margin-right: 12rpx;
- border-radius: 36rpx;
- background-color: #fff;
- font-size: 28rpx;
- // cursor: pointer;
- }
- .stauts-sel{
- background-color: #007AFF;
- color: #fff;
- }
- }
- .list-item {
- margin: 24rpx 30rpx;
- background-color: #ffffff;
- border-radius: 16rpx;
- }
- .item-container {
- padding: 30rpx;
- }
- .item-address {
- font-size: 26rpx;
- color: #999999;
- margin-bottom: 20rpx;
- line-height: 40rpx;
- }
- .btn-primary {
- z-index: 999;
- border-radius: 10rpx;
- font-size: 24rpx;
- // white-space: nowrap;
- margin-left: 20rpx;
- background-color: #165DFF;
- line-height: 45rpx;
- color: #ffffff;
- .btn-text{
- color: #ffffff;
- font-size: 24rpx;
- padding: 5px 15px;
- }
- }
- .item-header {
- flex-direction: row;
- align-items: flex-start;
- margin-bottom: 16rpx;
- justify-content: space-between; /* 主轴两端对齐 */
- min-height: 55rpx;
- .item-title {
- font-size: 30rpx;
- color: #333333;
- font-weight: bold;
- flex-wrap: wrap;
- flex: 0 1 75%;
- min-width: 0;
- }
- .info-value {
- font-size: 28rpx;
- color: #999999;
- margin-left: auto;
- flex: 0 0 auto;
- white-space: nowrap;
- }
- }
- .info-row {
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- .info-label {
- font-size: 26rpx;
- color: #666;
- }
- .info-value {
- font-size: 26rpx;
- // color: #666;
- }
- }
- .text-gray{
- font-size: 26rpx;
- color: #666;
- }
- .status-view {
- border: 1rpx solid;
- border-radius: 20rpx;
- }
- .status-tag {
- padding: 8rpx 20rpx;
- border-radius: 20rpx;
- font-size: 24rpx;
- white-space: nowrap;
- // margin-left: 50rpx;
- // justify-content: flex-end;
- border: 1rpx solid;
- }
- /* 待接单 */
- .status-assigned {
- background-color: #ebf5ff;
- color: #409eff;
- border-color: #d8ebff;
- }
- /* 待结单 */
- .status-to_finish {
- background-color: #fff7e6;
- color: #fa8c16;
- border-color: #ffd591;
- }
- /* 待审批 */
- .status-to_approve {
- background-color: #fff7e6;
- color: #fa8c16;
- border-color: #ffd591;
- }
- /* 已挂起 */
- .status-suspended {
- background-color: #fff2f0;
- color: #ff4d4f;
- border-color: #ffccc7;
- }
- /* 自动挂起 */
- .status-auto_suspend {
- background-color: #fff2f0;
- color: #ff4d4f;
- border-color: #ffccc7;
- }
- /* 已完成 */
- .status-completed {
- background-color: #f0f9eb;
- color: #5cb87a;
- border-color: #c2e7b0;
- }
- /* 待下发 */
- .status-to_issue {
- background-color: #f4f4f5;
- color: #909399;
- border-color: #e9e9eb;
- }
- /* 已归档 */
- .status-archived {
- background-color: #f0f9eb;
- color: #5cb87a;
- border-color: #c2e7b0;
- }
- /* 退回 */
- .status-return {
- background-color: #fff2f0;
- color: #ff4d4f;
- border-color: #ffccc7;
- }
- /* 退回 */
- .status-accept_return {
- background-color: #fff2f0;
- color: #ff4d4f;
- border-color: #ffccc7;
- }
- /* 作废 */
- .status-invalid {
- background-color: #fff2f0;
- color: #ff4d4f;
- border-color: #ffccc7;
- }
- .scroll-view_H {
- width: 100%;
- flex-direction: row;
- }
- .scroll-view-item_H {
- justify-content: center;
- align-items: center;
- .status-txt{
- padding: 8px 12px;
- text-align: center;
- margin-right: 12rpx;
- border-radius: 36rpx;
- background-color: #fff;
- font-size: 28rpx;
- }
- .stauts-sel{
- background-color: #007AFF;
- color: #fff;
- }
- }
- .btn-group {
- flex-direction: row;
- align-items: center;
- justify-content: flex-end;
- margin-top: 20rpx;
- }
- </style>
|