index.uvue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. <template>
  2. <uni-navbar-lite :showLeft=false title="工单"></uni-navbar-lite>
  3. <view class="list-page">
  4. <!-- 搜索栏 -->
  5. <view class="search-bar">
  6. <view class="search-box">
  7. <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
  8. <input class="search-input" type="text" placeholder="搜索工单编码、风机编号" v-model="keyword" @confirm="handleSearch" @blur="handleSearch" />
  9. <text v-if="keyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
  10. </view>
  11. </view>
  12. <view class="status-bar">
  13. <scroll-view class="scroll-view_H" direction="horizontal" show-scrollbar="false">
  14. <view class="scroll-view-item_H uni-bg-red">
  15. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'all'}" @click="switchStatus('all')">全部</text>
  16. </view>
  17. <!-- <view class="scroll-view-item_H uni-bg-green" v-if="checkPermi(['gxt:maintenance:order:edit','gxt:repairOrder:edit']) && !dealLoad">
  18. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_issue,accept_return'}" @click="switchStatus('to_issue,accept_return')">待下发</text>
  19. </view> -->
  20. <view class="scroll-view-item_H uni-bg-green" v-if="checkPermi(['gxt:maintenance:order:accept','gxt:repairOrder:accept']) && !dealLoad">
  21. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'assigned'}" @click="switchStatus('assigned')">待接单</text>
  22. </view>
  23. <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:suspend','gxt:repairOrder:suspend']) && !dealLoad">
  24. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_finish'}" @click="switchStatus('to_finish')">待结单</text>
  25. </view>
  26. <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:approve','gxt:repairOrder:approve']) && !dealLoad">
  27. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'to_approve'}" @click="switchStatus('to_approve')">待审批</text>
  28. </view>
  29. <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:resume','gxt:repairOrder:resume']) && !dealLoad">
  30. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'suspended'}" @click="switchStatus('suspended')">已挂起</text>
  31. </view>
  32. <view class="scroll-view-item_H" v-if="checkPermi(['gxt:maintenance:order:restart','gxt:repairOrder:restart']) && !dealLoad">
  33. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'completed'}" @click="switchStatus('completed')">已完成</text>
  34. </view>
  35. <view class="scroll-view-item_H" v-if="dealLoad">
  36. <text class="status-txt" :class="{'stauts-sel': currentStatus === 'pending'}" @click="switchStatus('pending')">待处理</text>
  37. </view>
  38. </scroll-view>
  39. </view>
  40. <!-- 列表内容 -->
  41. <common-list
  42. :dataList="dataList"
  43. :loading="loading"
  44. :refreshing="refreshing"
  45. :hasMore="hasMore"
  46. @refresh="handleRefresh"
  47. @loadMore="loadMore"
  48. @itemClick="handleView"
  49. >
  50. <template #default="{ item, index }">
  51. <view class="list-item">
  52. <view class="item-container">
  53. <view class="item-header">
  54. <!-- <image class="location-icon" src="/static/images/workbench/list/2.png" mode="aspectFit"></image>
  55. <text class="item-title">{{ getOrderType(item) }}</text>
  56. <text class="detail-link">类型 ›</text> -->
  57. <text class="item-title">{{ getWorkOrderProjectNo(item) }}-{{ getPcsDeviceName(item) }}{{ getOrderType(item) }}</text>
  58. <text class="status-tag" :class="getStatusClass(item)">{{ getWorkOrderStatus(item) }}</text>
  59. </view>
  60. <view class="info-row">
  61. <view class="info-label">
  62. <text class="text-gray">{{ getDisplayTime(item) }}</text>
  63. </view>
  64. <view class="info-value">
  65. <!-- <button
  66. v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'')"
  67. class="btn-primary info-value"
  68. @click.stop="handleItemClick(item,'')"
  69. >
  70. 接单
  71. </button>
  72. <button
  73. v-else-if="getOrderStatus(item) == 'to_approve' && canHandleOrder(item,'')"
  74. class="btn-primary info-value"
  75. @click.stop="handleItemClick(item,'')"
  76. >
  77. 审批
  78. </button>
  79. <button
  80. v-else-if="getOrderStatus(item) == 'suspended' && canHandleOrder(item,'')"
  81. class="btn-primary info-value"
  82. @click.stop="handleItemClick(item,'')"
  83. >
  84. 恢复
  85. </button>
  86. <button
  87. v-else-if="getOrderStatus(item) == 'return' && canHandleOrder(item,'acceptReturn')"
  88. class="btn-primary info-value"
  89. @click.stop="handleItemClick(item,'acceptReturn')"
  90. >
  91. 退回
  92. </button>
  93. <button
  94. v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'acceptReturn')"
  95. class="btn-primary info-value"
  96. @click.stop="handleItemClick(item,'acceptReturn')"
  97. >
  98. 退回
  99. </button> -->
  100. </view>
  101. </view>
  102. <view class="btn-group">
  103. <view
  104. v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'accept')"
  105. class="btn-primary info-value"
  106. @click.stop="handleItemClick(item,'')"
  107. >
  108. <text class="btn-text">接单</text>
  109. </view>
  110. <view
  111. v-if="getOrderStatus(item) == 'to_approve' && canHandleOrder(item,'')"
  112. class="btn-primary info-value"
  113. @click.stop="handleItemClick(item,'')"
  114. >
  115. <text class="btn-text">审批</text>
  116. </view>
  117. <view
  118. v-if="getOrderStatus(item) == 'suspended' && canHandleOrder(item,'')"
  119. class="btn-primary info-value"
  120. @click.stop="handleItemClick(item,'')"
  121. >
  122. <text class="btn-text">恢复</text>
  123. </view>
  124. <view
  125. v-if="getOrderStatus(item) == 'return' && canHandleOrder(item,'acceptReturn')"
  126. class="btn-primary info-value"
  127. @click.stop="handleItemClick(item,'acceptReturn')"
  128. >
  129. <text class="btn-text">退回</text>
  130. </view>
  131. <view
  132. v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'acceptReturn')"
  133. class="btn-primary info-value"
  134. @click.stop="handleItemClick(item,'acceptReturn')"
  135. >
  136. <text class="btn-text">退回</text>
  137. </view>
  138. <view
  139. v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'return')"
  140. class="btn-primary info-value"
  141. @click.stop="handleItemClick(item, 'return')"
  142. >
  143. <text class="btn-text">退回</text>
  144. </view>
  145. <view
  146. v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'suspend')"
  147. class="btn-primary info-value"
  148. @click.stop="handleItemClick(item, 'suspend')"
  149. >
  150. <text class="btn-text">挂起</text>
  151. </view>
  152. <view
  153. v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'finalize')"
  154. class="btn-primary info-value"
  155. @click.stop="handleItemClick(item, 'finalize')"
  156. >
  157. <text class="btn-text">复启</text>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </template>
  163. </common-list>
  164. <custom-tabbar :current="1" />
  165. </view>
  166. </template>
  167. <script setup lang="uts">
  168. import { ref, onBeforeUnmount, onMounted } from 'vue'
  169. import type { acceptOrderInfo } from '../../types/order'
  170. import type { SysDictData, DictDataResponse } from '../../types/dict'
  171. import { getOrderList } from '../../api/order/list'
  172. import { getDictDataByType } from '../../api/dict/index'
  173. import {checkPermi} from '../../utils/storage'
  174. // 列表数据
  175. const dataList = ref<acceptOrderInfo[]>([])
  176. let keyword = ref<string>("")
  177. const page = ref<number>(1)
  178. const pageSize: number = 10
  179. const hasMore = ref<boolean>(true)
  180. const loading = ref<boolean>(false)
  181. const refreshing = ref<boolean>(false)
  182. const total = ref<number>(0)
  183. let currentStatus = ref<string>('') // 添加状态管理
  184. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  185. // 添加字典加载状态
  186. const dictLoaded = ref<boolean>(false)
  187. // 待处理工单加载
  188. const dealLoad = ref<boolean>(false)
  189. type StatusItem = {
  190. key: string,
  191. permis: string[],
  192. condition: () => boolean
  193. }
  194. const statusConfig: StatusItem[] = [
  195. { key: 'all', permis: ['gxt:order:all'], condition: () => !dealLoad.value },
  196. { key: 'assigned', permis: ['gxt:maintenance:order:accept','gxt:repairOrder:accept'], condition: () => !dealLoad.value },
  197. { key: 'to_finish', permis: ['gxt:maintenance:order:suspend','gxt:repairOrder:suspend'], condition: () => !dealLoad.value },
  198. { key: 'to_approve', permis: ['gxt:maintenance:order:approve','gxt:repairOrder:approve'], condition: () => !dealLoad.value },
  199. { key: 'suspended', permis: ['gxt:maintenance:order:resume','gxt:repairOrder:resume'], condition: () => !dealLoad.value },
  200. { key: 'completed', permis: ['gxt:maintenance:order:restart','gxt:repairOrder:restart'], condition: () => !dealLoad.value }
  201. ]
  202. const getOrderStatus = (item: any | null): string => {
  203. if (item == null) return ''
  204. const orderItem = item as acceptOrderInfo
  205. return orderItem.workOrderStatus ?? ''
  206. }
  207. // 获取工单状态字典列表
  208. const loadStatusDictList = async (): Promise<void> => {
  209. try {
  210. const result = await getDictDataByType('gxt_work_order_status')
  211. const resultObj = result as UTSJSONObject
  212. if (resultObj['code'] == 200) {
  213. const data = resultObj['data'] as any[]
  214. const dictData: SysDictData[] = []
  215. if (data.length > 0) {
  216. for (let i = 0; i < data.length; i++) {
  217. const item = data[i] as UTSJSONObject
  218. // 只提取需要的字段
  219. const dictItem: SysDictData = {
  220. dictValue: item['dictValue'] as string | null,
  221. dictLabel: item['dictLabel'] as string | null,
  222. dictCode: null,
  223. dictSort: null,
  224. dictType: null,
  225. cssClass: null,
  226. listClass: null,
  227. isDefault: null,
  228. status: null,
  229. default: null,
  230. createTime: null,
  231. remark: null
  232. }
  233. dictData.push(dictItem)
  234. }
  235. }
  236. statusDictList.value = dictData
  237. dictLoaded.value = true
  238. }
  239. } catch (e: any) {
  240. console.error('获取工单状态字典失败:', e.message)
  241. dictLoaded.value = true
  242. }
  243. }
  244. const getFirstVisibleStatus = (): string => {
  245. for (const item of statusConfig) {
  246. const hasPerm = item.permis.length === 0 || checkPermi(item.permis)
  247. const meetsCondition = item.condition()
  248. if (hasPerm && meetsCondition) {
  249. // if (hasPerm) {
  250. return item.key as string
  251. }
  252. }
  253. return 'all' // fallback,理论上不会走到这里
  254. }
  255. let loadCount = 0
  256. // 加载列表数据
  257. const loadData = async (isRefresh: boolean | null): Promise<void> => {
  258. const id = ++loadCount
  259. console.log(`【loadData #${id}】开始, isRefresh=${isRefresh}`)
  260. if (loading.value) {
  261. // 如果正在加载,直接重置刷新状态
  262. refreshing.value = false
  263. return
  264. }
  265. try {
  266. loading.value = true
  267. // 处理默认值
  268. const shouldRefresh = isRefresh != null ? isRefresh : false
  269. if (shouldRefresh) {
  270. page.value = 1
  271. }
  272. // 调用 API,传递关键字参数
  273. const searchKeyword = keyword.value.length > 0 ? keyword.value : null
  274. const result = await getOrderList(page.value, pageSize, searchKeyword, currentStatus.value)
  275. // 提取响应数据
  276. const resultObj = result as UTSJSONObject
  277. const code = resultObj['code'] as number
  278. const responseData = resultObj['rows'] as any[]
  279. const responseTotal = resultObj['total'] as number
  280. if (code == 200) {
  281. // 将 any[] 转换为 acceptOrderInfo[]
  282. const newData: acceptOrderInfo[] = []
  283. for (let i = 0; i < responseData.length; i++) {
  284. const item = responseData[i] as UTSJSONObject
  285. const orderItem: acceptOrderInfo = {
  286. orderType: item['orderType'] as Number,
  287. id: item['id'] as Number,
  288. teamLeaderId: item['teamLeaderId'] != null ? (item['teamLeaderId'] as Number) : 0,
  289. acceptUserId: item['acceptUserId'] != null ? (item['acceptUserId'] as Number) : 0,
  290. teamLeaderName: item['teamLeaderName'] as string | null,
  291. acceptUserName: item['acceptUserName'] as string | null,
  292. acceptTime: item['acceptTime'] as string | null,
  293. assignTime: item['assignTime'] as string | null,
  294. assignUserName: item['assignUserName'] as string | null,
  295. status: (item['status']==null)?0:item['status'] as Number,
  296. workOrderProjectNo: item['workOrderProjectNo'] as string | null,
  297. workOrderStatus: item['workOrderStatus'] as string | null,
  298. gxtCenterId: item['gxtCenterId'] as Number | 0,
  299. gxtCenter: item['gxtCenter'] as string | null,
  300. pcsStationId: item['pcsStationId'] as Number | 0,
  301. pcsStationName: item['pcsStationName'] as string | null,
  302. pcsDeviceId: item['pcsDeviceId'] as Number | 0,
  303. pcsDeviceName: item['pcsDeviceName'] as string | null,
  304. brand: item['brand'] as string | null,
  305. model: item['model'] as string | null,
  306. createTime: item['createTime'] as string | null,
  307. suspendReason: item['suspendReason'] as string | null,
  308. rejectionReason: item['rejectionReason'] as string | null,
  309. updateTime: item['updateTime'] as string | null, // 新增字段
  310. workEndTime: item['workEndTime'] as string | null // 新增字段
  311. }
  312. newData.push(orderItem)
  313. }
  314. // 不再在前端过滤,直接使用API返回的数据
  315. if (shouldRefresh) {
  316. dataList.value = newData
  317. } else {
  318. dataList.value = [...dataList.value, ...newData]
  319. }
  320. total.value = responseTotal
  321. hasMore.value = dataList.value.length < responseTotal
  322. // 通知首页更新待接单数量
  323. if (currentStatus.value === 'assigned') {
  324. uni.$emit('refreshAssignedCount')
  325. }
  326. } else {
  327. const msg = resultObj['msg'] as string | null
  328. uni.showToast({
  329. title: msg ?? '加载失败',
  330. icon: 'none'
  331. })
  332. }
  333. } catch (e: any) {
  334. uni.showToast({
  335. title: e.message ?? '加载失败',
  336. icon: 'none'
  337. })
  338. } finally {
  339. loading.value = false
  340. // #ifdef WEB
  341. // Web 平台立即重置
  342. refreshing.value = false
  343. // #endif
  344. // #ifndef WEB
  345. // App 平台延迟重置刷新状态,确保 UI 更新
  346. setTimeout(() => {
  347. refreshing.value = false
  348. }, 100)
  349. // #endif
  350. }
  351. // #ifdef WEB
  352. // Web 平台额外确保重置
  353. refreshing.value = false
  354. // #endif
  355. }
  356. // 辅助函数:从 any 类型提取属性
  357. const getOrderType = (item: any | null): string => {
  358. if (item == null) return ''
  359. const orderInfoItem = item as acceptOrderInfo
  360. return orderInfoItem.orderType == 1?"维修工单":"维保工单";
  361. }
  362. const getWorkOrderProjectNo = (item: any | null): string | null => {
  363. if (item == null) return ''
  364. const orderInfoItem = item as acceptOrderInfo
  365. return orderInfoItem.workOrderProjectNo
  366. }
  367. const getPcsStationName = (item: any | null): string | null=> {
  368. if (item == null) return ''
  369. const orderInfoItem = item as acceptOrderInfo
  370. return orderInfoItem.pcsStationName
  371. }
  372. const getPcsDeviceName = (item: any | null): string | null=> {
  373. if (item == null) return ''
  374. const orderInfoItem = item as acceptOrderInfo
  375. return orderInfoItem.pcsDeviceName
  376. }
  377. const getAssignTime = (item: any | null): string|null => {
  378. if (item == null) return null
  379. const orderInfoItem = item as acceptOrderInfo
  380. return orderInfoItem.assignTime
  381. }
  382. const getAcceptTime = (item: any | null): string|null => {
  383. if (item == null) return null
  384. const orderInfoItem = item as acceptOrderInfo
  385. return orderInfoItem.acceptTime
  386. }
  387. const getCreateTime = (item: any | null): string|null => {
  388. if (item == null) return null
  389. const orderInfoItem = item as acceptOrderInfo
  390. return orderInfoItem.createTime
  391. }
  392. // 根据状态显示不同的时间
  393. const getDisplayTime = (item: any | null): string|null => {
  394. if (item == null) return null
  395. const orderInfoItem = item as acceptOrderInfo
  396. // 如果是"待接单"状态,显示派单时间
  397. if (orderInfoItem.workOrderStatus == 'assigned') {
  398. return '下发时间:' + orderInfoItem.assignTime
  399. } else if(orderInfoItem.workOrderStatus == 'to_finish') {
  400. if(orderInfoItem.workEndTime != null) {
  401. return '结束时间:' + orderInfoItem.workEndTime
  402. }
  403. return '接单时间:' + orderInfoItem.acceptTime
  404. } else if(orderInfoItem.workOrderStatus == 'to_approve') {
  405. return '申请挂起时间:' + orderInfoItem.updateTime
  406. } else if(orderInfoItem.workOrderStatus == 'suspended') {
  407. return '审批通过时间:' + orderInfoItem.updateTime
  408. } else if(orderInfoItem.workOrderStatus == 'return' || orderInfoItem.workOrderStatus == 'accept_return') {
  409. return '退回时间:' + orderInfoItem.updateTime
  410. } else if(orderInfoItem.workOrderStatus == 'completed') {
  411. return '结单时间:' + orderInfoItem.updateTime
  412. } else if(orderInfoItem.workOrderStatus == 'archived') {
  413. return '归档时间:' + orderInfoItem.updateTime
  414. }
  415. // 默认显示创建时间
  416. return '创建时间:' + orderInfoItem.createTime
  417. }
  418. const getWorkOrderStatus = (item: any | null): string | null => {
  419. if (item == null) return ''
  420. const orderInfoItem = item as acceptOrderInfo
  421. const rawStatus = orderInfoItem.workOrderStatus
  422. if (rawStatus==null) return ''
  423. // 如果字典尚未加载,返回原始值
  424. if (!dictLoaded.value) {
  425. return rawStatus
  426. }
  427. // 查找字典中对应的标签
  428. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  429. return dictItem!=null ? dictItem.dictLabel : rawStatus
  430. }
  431. const getStatusClass = (item: any | null): string => {
  432. if (item == null) return ''
  433. const orderInfoItem = item as acceptOrderInfo
  434. const rawStatus = orderInfoItem.workOrderStatus
  435. if (rawStatus==null) return ''
  436. // const status = rawStatus
  437. // 返回对应的状态类名
  438. return `status-${rawStatus}`
  439. }
  440. // 切换状态
  441. const switchStatus = (status: string): void => {
  442. currentStatus.value = status
  443. page.value = 1
  444. loadData(true)
  445. }
  446. // 下拉刷新
  447. const handleRefresh = async (): Promise<void> => {
  448. refreshing.value = true
  449. await loadData(true as boolean | null)
  450. }
  451. // 加载更多
  452. const loadMore = (): void => {
  453. if (!hasMore.value || loading.value) {
  454. return
  455. }
  456. page.value++
  457. loadData(false as boolean | null)
  458. }
  459. // 搜索
  460. const handleSearch = (): void => {
  461. page.value = 1
  462. loadData(true as boolean | null)
  463. }
  464. const handleSearchOnBlur = (): void => {
  465. handleSearch()
  466. }
  467. // 方法:判断当前工单是否显示操作按钮(基于 orderType)
  468. const canHandleOrder = (item: any | null, buttonType: string | ''): boolean => {
  469. if (item == null) return false
  470. let permit: string[] = []
  471. const orderItem = item as acceptOrderInfo
  472. if(orderItem.workOrderStatus == 'assigned' && buttonType != '' && buttonType == "acceptReturn" && orderItem.orderType == 1) {
  473. // 接单退回
  474. permit = ['gxt:repairOrder:acceptReturn']
  475. } else if(orderItem.workOrderStatus == 'assigned' && buttonType != '' && buttonType == "accept") {
  476. // 接单
  477. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:accept'] : ['gxt:repairOrder:accept']
  478. } else if(orderItem.workOrderStatus == 'to_finish') {
  479. if(buttonType != '' && buttonType == "suspend") {
  480. // 挂起
  481. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:suspend'] : ['gxt:repairOrder:suspend']
  482. } else if(buttonType != '' && buttonType == "return" && orderItem.orderType == 1) {
  483. // 退回
  484. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:return'] : ['gxt:repairOrder:return']
  485. } else if(buttonType != '' && buttonType == "finalize" && orderItem.orderType == 1) {
  486. // 复启
  487. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:finalize'] : ['gxt:repairOrder:finalize']
  488. }
  489. } else if(orderItem.workOrderStatus == 'to_approve') {
  490. // 审批
  491. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:approve'] : ['gxt:repairOrder:approve']
  492. } else if(orderItem.workOrderStatus == 'suspended') {
  493. // 恢复
  494. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:resume'] : ['gxt:repairOrder:resume']
  495. } else if(orderItem.workOrderStatus == 'return') {
  496. // 接单退回
  497. permit = ['gxt:repairOrder:acceptReturn']
  498. }
  499. else {
  500. return false
  501. }
  502. // const orderType = (item as acceptOrderInfo).orderType
  503. return checkPermi(permit)
  504. }
  505. // 点击列表项
  506. const handleItemClick = (item: any | null, buttonType: string | ''): void => {
  507. if (item == null) return
  508. const orderItem = item as acceptOrderInfo
  509. // if(currentStatus.value === '' || currentStatus.value === 'completed' || currentStatus.value === 'all') {
  510. // // 传递orderType参数以便详情页决定调用哪个API
  511. // uni.navigateTo({
  512. // url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
  513. // })
  514. // } else
  515. if(orderItem.workOrderStatus == 'assigned') {
  516. if(buttonType != '' && buttonType == "acceptReturn") {
  517. // 跳转到退回页面
  518. uni.navigateTo({
  519. url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  520. })
  521. } else {
  522. // 跳转到接单页面
  523. uni.navigateTo({
  524. url: `/pages/order/detail/acceptIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  525. })
  526. }
  527. } else if(orderItem.workOrderStatus == 'to_finish') {
  528. if(buttonType != '' && buttonType == "suspend") {
  529. // 跳转到待结单页面
  530. uni.navigateTo({
  531. url: `/pages/order/detail/suspendIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  532. })
  533. } else if(buttonType != '' && buttonType == "return") {
  534. // 跳转到退回页面
  535. uni.navigateTo({
  536. url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  537. })
  538. } else if(buttonType != '' && buttonType == "finalize") {
  539. // 跳转到复启页面
  540. uni.navigateTo({
  541. url: `/pages/order/detail/resetIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  542. })
  543. }
  544. } else if(orderItem.workOrderStatus == 'to_approve') {
  545. // 跳转到待审批页面
  546. uni.navigateTo({
  547. url: `/pages/order/detail/approveIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  548. })
  549. } else if(orderItem.workOrderStatus == 'suspended') {
  550. // 跳转到恢复页面
  551. uni.navigateTo({
  552. url: `/pages/order/detail/resumeIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  553. })
  554. } else if(orderItem.workOrderStatus == 'return') {
  555. // 跳转到退回页面
  556. uni.navigateTo({
  557. url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  558. })
  559. } else {
  560. uni.navigateTo({
  561. url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
  562. })
  563. }
  564. }
  565. // 点击列表项
  566. const handleView = (item: any | null): void => {
  567. if (item == null) return
  568. const orderItem = item as acceptOrderInfo
  569. uni.navigateTo({
  570. url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
  571. })
  572. }
  573. // 查看工单详情
  574. const showWorkOrderDetail = (item: any | null): void => {
  575. if (item == null) return
  576. const orderItem = item as acceptOrderInfo
  577. uni.navigateTo({
  578. url: `/pages/workbench/detail/index?id=${orderItem.id}`
  579. })
  580. }
  581. // 清空搜索
  582. const clearSearch = (): void => {
  583. keyword.value = ""
  584. page.value = 1
  585. loadData(true)
  586. }
  587. // 初始化
  588. // onMounted(() => {
  589. onLoad((options: any) => {
  590. const params = options as UTSJSONObject
  591. const isDeal = params['isDeal'] as string | null
  592. if(isDeal != null) {
  593. dealLoad.value = true;
  594. }
  595. loadStatusDictList()
  596. // 自动选中第一个可显示的状态
  597. // currentStatus.value = getFirstVisibleStatus()
  598. currentStatus.value = 'all'
  599. loadData(true as boolean | null)
  600. // 监听首页切换状态事件
  601. uni.$on('switchOrderStatus', (status: string) => {
  602. switchStatus(status)
  603. })
  604. // 监听接单成功的事件,刷新列表
  605. uni.$on('refreshOrderList', () => {
  606. page.value = 1
  607. loadData(true)
  608. })
  609. })
  610. // 组件卸载前清理事件监听
  611. onBeforeUnmount(() => {
  612. refreshing.value = false
  613. loading.value = false
  614. // 移除事件监听
  615. uni.$off('refreshOrderList',{})
  616. uni.$off('switchOrderStatus',{})
  617. })
  618. </script>
  619. <style lang="scss">
  620. .list-page {
  621. flex: 1;
  622. background-color: #e8f0f9;
  623. }
  624. .search-bar {
  625. padding: 20rpx 30rpx;
  626. background-color: #d7eafe;
  627. }
  628. .search-box {
  629. flex-direction: row;
  630. align-items: center;
  631. height: 72rpx;
  632. padding: 0 24rpx;
  633. background-color: #f5f5f5;
  634. border-radius: 36rpx;
  635. .search-icon {
  636. width: 32rpx;
  637. height: 32rpx;
  638. margin-right: 12rpx;
  639. }
  640. .search-input {
  641. flex: 1;
  642. font-size: 28rpx;
  643. color: #333333;
  644. }
  645. .clear-icon {
  646. margin-left: 12rpx;
  647. font-size: 28rpx;
  648. color: #999999;
  649. }
  650. }
  651. .status-bar{
  652. padding-bottom: 10px;
  653. padding-left:30rpx;
  654. background-color: #d7eafe;
  655. }
  656. .status-box {
  657. flex-direction: row;
  658. align-items: center;
  659. height: 72rpx;
  660. flex: 1;
  661. .status-txt{
  662. padding: 8px 12px;
  663. text-align: center;
  664. margin-right: 12rpx;
  665. border-radius: 36rpx;
  666. background-color: #fff;
  667. font-size: 28rpx;
  668. // cursor: pointer;
  669. }
  670. .stauts-sel{
  671. background-color: #007AFF;
  672. color: #fff;
  673. }
  674. }
  675. .list-item {
  676. margin: 24rpx 30rpx;
  677. background-color: #ffffff;
  678. border-radius: 16rpx;
  679. }
  680. .item-container {
  681. padding: 30rpx;
  682. }
  683. .item-header {
  684. flex-direction: row;
  685. align-items: center;
  686. margin-bottom: 16rpx;
  687. .location-icon {
  688. width: 32rpx;
  689. height: 32rpx;
  690. margin-right: 8rpx;
  691. }
  692. .item-title {
  693. flex: 1;
  694. font-size: 32rpx;
  695. color: #333333;
  696. font-weight: bold;
  697. }
  698. .detail-link {
  699. font-size: 28rpx;
  700. color: #999999;
  701. }
  702. }
  703. .item-address {
  704. font-size: 26rpx;
  705. color: #999999;
  706. margin-bottom: 20rpx;
  707. line-height: 40rpx;
  708. }
  709. .btn-primary {
  710. z-index: 999;
  711. border-radius: 10rpx;
  712. font-size: 24rpx;
  713. // white-space: nowrap;
  714. margin-left: 20rpx;
  715. background-color: #165DFF;
  716. line-height: 45rpx;
  717. color: #ffffff;
  718. .btn-text{
  719. color: #ffffff;
  720. font-size: 24rpx;
  721. padding: 5px 15px;
  722. }
  723. }
  724. .item-header {
  725. flex-direction: row;
  726. align-items: flex-start;
  727. margin-bottom: 16rpx;
  728. .item-title {
  729. font-size: 30rpx;
  730. color: #333333;
  731. font-weight: bold;
  732. flex-wrap: wrap;
  733. flex: 0 1 80%;
  734. min-width: 0;
  735. }
  736. .info-value {
  737. font-size: 28rpx;
  738. color: #999999;
  739. margin-left: auto;
  740. flex: 0 0 auto;
  741. white-space: nowrap;
  742. }
  743. }
  744. .info-row {
  745. flex-direction: row;
  746. justify-content: space-between;
  747. align-items: center;
  748. .info-label {
  749. font-size: 26rpx;
  750. color: #666;
  751. }
  752. .info-value {
  753. font-size: 26rpx;
  754. // color: #666;
  755. }
  756. }
  757. .text-gray{
  758. font-size: 26rpx;
  759. color: #666;
  760. }
  761. .status-tag {
  762. padding: 8rpx 20rpx;
  763. border-radius: 20rpx;
  764. font-size: 24rpx;
  765. white-space: nowrap;
  766. margin-left: 50rpx;
  767. border: 1rpx solid;
  768. }
  769. /* 待接单 */
  770. .status-assigned {
  771. background-color: #ebf5ff;
  772. color: #409eff;
  773. border-color: #d8ebff;
  774. }
  775. /* 待结单 */
  776. .status-to_finish {
  777. background-color: #fff7e6;
  778. color: #fa8c16;
  779. border-color: #ffd591;
  780. }
  781. /* 待审批 */
  782. .status-to_approve {
  783. background-color: #fff7e6;
  784. color: #fa8c16;
  785. border-color: #ffd591;
  786. }
  787. /* 已挂起 */
  788. .status-suspended {
  789. background-color: #fff2f0;
  790. color: #ff4d4f;
  791. border-color: #ffccc7;
  792. }
  793. /* 已完成 */
  794. .status-completed {
  795. background-color: #f0f9eb;
  796. color: #5cb87a;
  797. border-color: #c2e7b0;
  798. }
  799. /* 待下发 */
  800. .status-to_issue {
  801. background-color: #f4f4f5;
  802. color: #909399;
  803. border-color: #e9e9eb;
  804. }
  805. /* 已归档 */
  806. .status-archived {
  807. background-color: #f0f9eb;
  808. color: #5cb87a;
  809. border-color: #c2e7b0;
  810. }
  811. /* 退回 */
  812. .status-return {
  813. background-color: #fff2f0;
  814. color: #ff4d4f;
  815. border-color: #ffccc7;
  816. }
  817. /* 退回 */
  818. .status-accept_return {
  819. background-color: #fff2f0;
  820. color: #ff4d4f;
  821. border-color: #ffccc7;
  822. }
  823. /* 作废 */
  824. .status-invalid {
  825. background-color: #fff2f0;
  826. color: #ff4d4f;
  827. border-color: #ffccc7;
  828. }
  829. .scroll-view_H {
  830. width: 100%;
  831. flex-direction: row;
  832. }
  833. .scroll-view-item_H {
  834. justify-content: center;
  835. align-items: center;
  836. .status-txt{
  837. padding: 8px 12px;
  838. text-align: center;
  839. margin-right: 12rpx;
  840. border-radius: 36rpx;
  841. background-color: #fff;
  842. font-size: 28rpx;
  843. }
  844. .stauts-sel{
  845. background-color: #007AFF;
  846. color: #fff;
  847. }
  848. }
  849. .btn-group {
  850. flex-direction: row;
  851. align-items: center;
  852. justify-content: flex-end;
  853. margin-top: 20rpx;
  854. }
  855. </style>