pendingOrder.uvue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <template>
  2. <uni-navbar-lite :showLeft=true 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. <!-- 列表内容 -->
  13. <common-list
  14. :dataList="dataList"
  15. :loading="loading"
  16. :refreshing="refreshing"
  17. :hasMore="hasMore"
  18. @refresh="handleRefresh"
  19. @loadMore="loadMore"
  20. @itemClick="handleView"
  21. >
  22. <template #default="{ item, index }">
  23. <view class="list-item">
  24. <view class="item-container">
  25. <view class="item-header">
  26. <text class="item-title">{{ getWorkOrderProjectNo(item) }}-{{ getPcsDeviceName(item) }}{{ getOrderType(item) }}</text>
  27. <text class="status-tag" :class="getStatusClass(item)">{{ getWorkOrderStatus(item) }}</text>
  28. </view>
  29. <view class="info-row">
  30. <view class="info-label">
  31. <text class="text-gray">{{ getDisplayTime(item) }}</text>
  32. </view>
  33. </view>
  34. <view class="btn-group">
  35. <view
  36. v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'accept')"
  37. class="btn-primary info-value"
  38. @click.stop="handleItemClick(item,'')"
  39. >
  40. <text class="btn-text">接单</text>
  41. </view>
  42. <view
  43. v-if="getOrderStatus(item) == 'to_approve' && canHandleOrder(item,'')"
  44. class="btn-primary info-value"
  45. @click.stop="handleItemClick(item,'')"
  46. >
  47. <text class="btn-text">审批</text>
  48. </view>
  49. <view
  50. v-if="getOrderStatus(item) == 'suspended' && canHandleOrder(item,'')"
  51. class="btn-primary info-value"
  52. @click.stop="handleItemClick(item,'')"
  53. >
  54. <text class="btn-text">恢复</text>
  55. </view>
  56. <view
  57. v-if="getOrderStatus(item) == 'return' && canHandleOrder(item,'acceptReturn')"
  58. class="btn-primary info-value"
  59. @click.stop="handleItemClick(item,'acceptReturn')"
  60. >
  61. <text class="btn-text">退回</text>
  62. </view>
  63. <view
  64. v-if="getOrderStatus(item) == 'assigned' && canHandleOrder(item,'acceptReturn')"
  65. class="btn-primary info-value"
  66. @click.stop="handleItemClick(item,'acceptReturn')"
  67. >
  68. <text class="btn-text">退回</text>
  69. </view>
  70. <view
  71. v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'return')"
  72. class="btn-primary info-value"
  73. @click.stop="handleItemClick(item, 'return')"
  74. >
  75. <text class="btn-text">退回</text>
  76. </view>
  77. <view
  78. v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'suspend')"
  79. class="btn-primary info-value"
  80. @click.stop="handleItemClick(item, 'suspend')"
  81. >
  82. <text class="btn-text">挂起</text>
  83. </view>
  84. <view
  85. v-if="getOrderStatus(item) == 'to_finish' && canHandleOrder(item, 'finalize')"
  86. class="btn-primary info-value"
  87. @click.stop="handleItemClick(item, 'finalize')"
  88. >
  89. <text class="btn-text">复启</text>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </template>
  95. </common-list>
  96. </view>
  97. </template>
  98. <script setup lang="uts">
  99. import { ref, onBeforeUnmount, onMounted } from 'vue'
  100. import type { acceptOrderInfo } from '../../types/order'
  101. import type { SysDictData } from '../../types/dict'
  102. import { pendingList } from '../../api/order/list'
  103. import { getDictDataByType } from '../../api/dict/index'
  104. import {checkPermi, getUserInfo} from '../../utils/storage'
  105. const userId = ref<string>("")
  106. const roles = ref<string>('')
  107. // 列表数据
  108. const dataList = ref<acceptOrderInfo[]>([])
  109. let keyword = ref<string>("")
  110. const page = ref<number>(1)
  111. const pageSize: number = 10
  112. const hasMore = ref<boolean>(true)
  113. const loading = ref<boolean>(false)
  114. const refreshing = ref<boolean>(false)
  115. const total = ref<number>(0)
  116. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  117. // 添加字典加载状态
  118. const dictLoaded = ref<boolean>(false)
  119. // 添加防重复请求的标志位
  120. const isSearching = ref<boolean>(false)
  121. // 添加防重复刷新的标志
  122. const isRefreshing = ref<boolean>(false)
  123. // 添加刷新时间戳,用于防抖
  124. const lastRefreshTime = ref<number>(0)
  125. const getOrderStatus = (item: any | null): string => {
  126. if (item == null) return ''
  127. const orderItem = item as acceptOrderInfo
  128. return orderItem.workOrderStatus ?? ''
  129. }
  130. // 方法:判断当前工单是否显示操作按钮(基于 orderType)
  131. const canHandleOrder = (item: any | null, buttonType: string | ''): boolean => {
  132. if (item == null) return false
  133. let permit: string[] = []
  134. const orderItem = item as acceptOrderInfo
  135. if(orderItem.workOrderStatus == 'assigned' && buttonType != '' && buttonType == "acceptReturn" && orderItem.orderType == 1) {
  136. // 接单退回
  137. permit = ['gxt:repairOrder:acceptReturn']
  138. } else if(orderItem.workOrderStatus == 'assigned' && buttonType != '' && buttonType == "accept") {
  139. // 接单
  140. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:accept'] : ['gxt:repairOrder:accept']
  141. } else if(orderItem.workOrderStatus == 'to_finish') {
  142. if(buttonType != '' && buttonType == "suspend" && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
  143. // 挂起
  144. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:suspend'] : ['gxt:repairOrder:suspend']
  145. } else if(buttonType != '' && buttonType == "return" && orderItem.orderType == 1 && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
  146. // 退回
  147. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:return'] : ['gxt:repairOrder:return']
  148. } else if(buttonType != '' && buttonType == "finalize" && orderItem.orderType == 1 && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
  149. // 复启
  150. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:finalize'] : ['gxt:repairOrder:finalize']
  151. }
  152. } else if(orderItem.workOrderStatus == 'to_approve') {
  153. // 审批
  154. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:approve'] : ['gxt:repairOrder:approve']
  155. } else if(orderItem.workOrderStatus == 'suspended' && (orderItem.teamLeaderId == parseInt(userId.value) || roles.value.includes("管理员"))) {
  156. // 恢复
  157. permit = orderItem.orderType == 2 ? ['gxt:maintenance:order:resume'] : ['gxt:repairOrder:resume']
  158. } else if(orderItem.workOrderStatus == 'return') {
  159. // 接单退回
  160. permit = ['gxt:repairOrder:acceptReturn']
  161. }
  162. else {
  163. return false
  164. }
  165. // const orderType = (item as acceptOrderInfo).orderType
  166. return checkPermi(permit)
  167. }
  168. // 获取工单状态字典列表
  169. const loadStatusDictList = async (): Promise<void> => {
  170. try {
  171. const result = await getDictDataByType('gxt_work_order_status')
  172. const resultObj = result as UTSJSONObject
  173. if (resultObj['code'] == 200) {
  174. const data = resultObj['data'] as any[]
  175. const dictData: SysDictData[] = []
  176. if (data.length > 0) {
  177. for (let i = 0; i < data.length; i++) {
  178. const item = data[i] as UTSJSONObject
  179. // 只提取需要的字段
  180. const dictItem: SysDictData = {
  181. dictValue: item['dictValue'] as string | null,
  182. dictLabel: item['dictLabel'] as string | null,
  183. dictCode: null,
  184. dictSort: null,
  185. dictType: null,
  186. cssClass: null,
  187. listClass: null,
  188. isDefault: null,
  189. status: null,
  190. default: null,
  191. createTime: null,
  192. remark: null
  193. }
  194. dictData.push(dictItem)
  195. }
  196. }
  197. statusDictList.value = dictData
  198. dictLoaded.value = true
  199. }
  200. } catch (e: any) {
  201. console.error('获取工单状态字典失败:', e.message)
  202. dictLoaded.value = true
  203. }
  204. }
  205. // 加载列表数据
  206. const loadData = async (isRefresh: boolean | null, disablePullDown: boolean | null): Promise<void> => {
  207. // 防止重复请求的核心机制
  208. if (loading.value) {
  209. // 确保刷新状态最终被重置,防止卡死
  210. if (isRefresh != true) {
  211. refreshing.value = false;
  212. }
  213. return
  214. }
  215. const shouldRefresh = isRefresh != null ? isRefresh : false
  216. const disablePull = disablePullDown != null ? disablePullDown : false
  217. loading.value = true
  218. let refreshTimeout: number | null = null;
  219. if (shouldRefresh && !disablePull) {
  220. page.value = 1
  221. refreshing.value = true
  222. // 添加超时机制,确保刷新动画不会一直显示
  223. refreshTimeout = setTimeout(() => {
  224. if (refreshing.value) {
  225. refreshing.value = false;
  226. isRefreshing.value = false;
  227. console.log("刷新超时,强制结束刷新状态");
  228. uni.showToast({
  229. title: '刷新超时',
  230. icon: 'none'
  231. });
  232. }
  233. }, 10000); // 10秒超时
  234. } else if (shouldRefresh && disablePull) {
  235. // 状态切换时,重置页码但不触发动画
  236. page.value = 1
  237. // 即使禁用下拉刷新,也要确保刷新状态最终被重置
  238. refreshing.value = false
  239. } else {
  240. // 对于加载更多操作,不需要显示下拉刷新状态
  241. refreshing.value = false;
  242. }
  243. try {
  244. // 处理默认值
  245. const searchKeyword = keyword.value.length > 0 ? keyword.value : null
  246. const result = await pendingList(page.value, pageSize, searchKeyword)
  247. // 提取响应数据
  248. const resultObj = result as UTSJSONObject
  249. const code = resultObj['code'] as number
  250. const responseData = resultObj['rows'] as any[]
  251. const responseTotal = resultObj['total'] as number
  252. if (code == 200) {
  253. // 将 any[] 转换为 acceptOrderInfo[]
  254. const newData: acceptOrderInfo[] = []
  255. for (let i = 0; i < responseData.length; i++) {
  256. const item = responseData[i] as UTSJSONObject
  257. const orderItem: acceptOrderInfo = {
  258. orderType: item['orderType'] as Number,
  259. id: item['id'] as Number,
  260. teamLeaderId: item['teamLeaderId'] != null ? (item['teamLeaderId'] as Number) : 0,
  261. acceptUserId: item['acceptUserId'] != null ? (item['acceptUserId'] as Number) : 0,
  262. teamLeaderName: item['teamLeaderName'] as string | null,
  263. acceptUserName: item['acceptUserName'] as string | null,
  264. acceptTime: item['acceptTime'] as string | null,
  265. assignTime: item['assignTime'] as string | null,
  266. assignUserName: item['assignUserName'] as string | null,
  267. status: (item['status']==null)?0:item['status'] as Number,
  268. workOrderProjectNo: item['workOrderProjectNo'] as string | null,
  269. workOrderStatus: item['workOrderStatus'] as string | null,
  270. gxtCenterId: item['gxtCenterId'] as Number | 0,
  271. gxtCenter: item['gxtCenter'] as string | null,
  272. pcsStationId: item['pcsStationId'] as Number | 0,
  273. pcsStationName: item['pcsStationName'] as string | null,
  274. pcsDeviceId: item['pcsDeviceId'] as Number | 0,
  275. pcsDeviceName: item['pcsDeviceName'] as string | null,
  276. brand: item['brand'] as string | null,
  277. model: item['model'] as string | null,
  278. createTime: item['createTime'] as string | null,
  279. suspendReason: item['suspendReason'] as string | null,
  280. rejectionReason: item['rejectionReason'] as string | null,
  281. updateTime: item['updateTime'] as string | null, // 新增字段
  282. workEndTime: item['workEndTime'] as string | null // 新增字段
  283. }
  284. newData.push(orderItem)
  285. }
  286. if (shouldRefresh) {
  287. dataList.value = newData
  288. } else {
  289. dataList.value = [...dataList.value, ...newData]
  290. }
  291. total.value = responseTotal
  292. hasMore.value = dataList.value.length < responseTotal
  293. } else {
  294. const msg = resultObj['msg'] as string | null
  295. uni.showToast({
  296. title: msg ?? '加载失败',
  297. icon: 'none'
  298. })
  299. }
  300. } catch (e: any) {
  301. uni.showToast({
  302. title: e.message ?? '加载失败',
  303. icon: 'none'
  304. })
  305. } finally {
  306. loading.value = false
  307. // 清除超时定时器
  308. if (refreshTimeout != null) {
  309. clearTimeout(refreshTimeout);
  310. }
  311. // 确保刷新状态能结束
  312. if (shouldRefresh) {
  313. refreshing.value = false;
  314. // 使用setTimeout确保状态彻底重置
  315. setTimeout(() => {
  316. isRefreshing.value = false;
  317. refreshing.value = false; // 再次确保刷新状态被重置
  318. }, 50);
  319. }
  320. }
  321. }
  322. // 辅助函数:从 any 类型提取属性
  323. const getOrderType = (item: any | null): string => {
  324. if (item == null) return ''
  325. const orderInfoItem = item as acceptOrderInfo
  326. return orderInfoItem.orderType == 1?"维修工单":"维保工单";
  327. }
  328. const getWorkOrderProjectNo = (item: any | null): string | null => {
  329. if (item == null) return ''
  330. const orderInfoItem = item as acceptOrderInfo
  331. return orderInfoItem.workOrderProjectNo
  332. }
  333. const getPcsDeviceName = (item: any | null): string | null=> {
  334. if (item == null) return ''
  335. const orderInfoItem = item as acceptOrderInfo
  336. return orderInfoItem.pcsDeviceName
  337. }
  338. // 根据状态显示不同的时间
  339. const getDisplayTime = (item: any | null): string|null => {
  340. if (item == null) return null
  341. const orderInfoItem = item as acceptOrderInfo
  342. // 如果是"待接单"状态,显示派单时间
  343. if (orderInfoItem.workOrderStatus == 'assigned') {
  344. return '下发时间:' + orderInfoItem.assignTime
  345. } else if(orderInfoItem.workOrderStatus == 'to_finish') {
  346. if(orderInfoItem.workEndTime != null) {
  347. return '结束时间:' + orderInfoItem.workEndTime
  348. }
  349. return '接单时间:' + orderInfoItem.acceptTime
  350. } else if(orderInfoItem.workOrderStatus == 'to_approve') {
  351. return '申请挂起时间:' + orderInfoItem.updateTime
  352. } else if(orderInfoItem.workOrderStatus == 'suspended') {
  353. return '审批通过时间:' + orderInfoItem.updateTime
  354. } else if(orderInfoItem.workOrderStatus == 'return' || orderInfoItem.workOrderStatus == 'accept_return') {
  355. return '退回时间:' + orderInfoItem.updateTime
  356. } else if(orderInfoItem.workOrderStatus == 'completed') {
  357. return '结单时间:' + orderInfoItem.updateTime
  358. }
  359. // 默认显示创建时间
  360. return '创建时间:' + orderInfoItem.createTime
  361. }
  362. const getWorkOrderStatus = (item: any | null): string | null => {
  363. if (item == null) return ''
  364. const orderInfoItem = item as acceptOrderInfo
  365. const rawStatus = orderInfoItem.workOrderStatus
  366. if (rawStatus==null) return ''
  367. // 如果字典尚未加载,返回原始值
  368. if (!dictLoaded.value) {
  369. return rawStatus
  370. }
  371. // 查找字典中对应的标签
  372. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  373. return dictItem!=null ? dictItem.dictLabel : rawStatus
  374. }
  375. const getStatusClass = (item: any | null): string => {
  376. if (item == null) return ''
  377. const orderInfoItem = item as acceptOrderInfo
  378. const rawStatus = orderInfoItem.workOrderStatus
  379. if (rawStatus==null) return ''
  380. // const status = rawStatus
  381. // 返回对应的状态类名
  382. return `status-${rawStatus}`
  383. }
  384. // 下拉刷新
  385. const handleRefresh = async (): Promise<void> => {
  386. console.log("handleRefresh被触发")
  387. console.log("loading.value===",loading.value)
  388. console.log("isRefreshing.value===",isRefreshing.value)
  389. // 防抖处理,避免频繁触发
  390. const now = Date.now();
  391. if (now - lastRefreshTime.value < 1000) {
  392. console.log("刷新操作过于频繁,忽略本次触发");
  393. refreshing.value = false;
  394. return;
  395. }
  396. lastRefreshTime.value = now;
  397. // 添加防重复调用检查
  398. if (loading.value || isRefreshing.value) {
  399. // 如果已经在加载或正在刷新,直接重置刷新状态
  400. refreshing.value = false;
  401. return;
  402. }
  403. console.log("loading.value1===",loading.value)
  404. console.log("isRefreshing.value1===",isRefreshing.value)
  405. // 设置刷新标志
  406. isRefreshing.value = true;
  407. refreshing.value = true; // 确保刷新状态被设置
  408. // 添加超时机制,确保刷新动画不会一直显示
  409. const refreshTimeout = setTimeout(() => {
  410. if (refreshing.value || isRefreshing.value) {
  411. refreshing.value = false;
  412. isRefreshing.value = false;
  413. console.log("刷新操作超时,重置刷新状态");
  414. uni.showToast({
  415. title: '刷新超时',
  416. icon: 'none'
  417. });
  418. }
  419. }, 10000);
  420. try {
  421. await loadData(true, false); // 使用默认的下拉刷新行为
  422. } catch (error) {
  423. console.error('刷新失败:', error);
  424. refreshing.value = false;
  425. isRefreshing.value = false;
  426. } finally {
  427. clearTimeout(refreshTimeout);
  428. // 确保刷新状态最终被重置
  429. refreshing.value = false;
  430. isRefreshing.value = false;
  431. }
  432. // 额外的保险机制,确保在一定时间后重置刷新标志
  433. setTimeout(() => {
  434. refreshing.value = false;
  435. isRefreshing.value = false;
  436. }, 200) // 延迟重置,确保状态完全更新
  437. }
  438. // 加载更多
  439. const loadMore = (): void => {
  440. if (!hasMore.value || loading.value) {
  441. return
  442. }
  443. page.value++
  444. loadData(false, false) // 加载更多时不涉及下拉刷新动画
  445. }
  446. // 搜索
  447. const handleSearch = (): void => {
  448. // 添加防重复调用检查
  449. if (loading.value) {
  450. return;
  451. }
  452. // 添加防重复请求检查
  453. if (isSearching.value) {
  454. return
  455. }
  456. isSearching.value = true
  457. page.value = 1
  458. loadData(true, true) // 状态切换时禁用下拉刷新动画
  459. // 延迟重置标志位,确保请求发送后才允许下一次搜索
  460. setTimeout(() => {
  461. isSearching.value = false
  462. }, 100)
  463. }
  464. // 点击列表查看
  465. const handleView = (item: any | null): void => {
  466. if (item == null) return
  467. const orderItem = item as acceptOrderInfo
  468. uni.navigateTo({
  469. url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
  470. })
  471. }
  472. // 点击列表项
  473. const handleItemClick = (item: any | null, buttonType: string | ''): void => {
  474. if (item == null) return
  475. const orderItem = item as acceptOrderInfo
  476. if(orderItem.workOrderStatus == 'assigned') {
  477. if(buttonType != '' && buttonType == "acceptReturn") {
  478. // 跳转到退回页面
  479. uni.navigateTo({
  480. url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  481. })
  482. } else {
  483. // 跳转到接单页面
  484. uni.navigateTo({
  485. url: `/pages/order/detail/acceptIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  486. })
  487. }
  488. } else if(orderItem.workOrderStatus == 'to_finish') {
  489. if(buttonType != '' && buttonType == "suspend") {
  490. // 跳转到待结单页面
  491. uni.navigateTo({
  492. url: `/pages/order/detail/suspendIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  493. })
  494. } else if(buttonType != '' && buttonType == "return") {
  495. // 跳转到退回页面
  496. uni.navigateTo({
  497. url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  498. })
  499. } else if(buttonType != '' && buttonType == "finalize") {
  500. // 跳转到复启页面
  501. uni.navigateTo({
  502. url: `/pages/order/detail/resetIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  503. })
  504. }
  505. } else if(orderItem.workOrderStatus == 'to_approve') {
  506. // 跳转到待审批页面
  507. uni.navigateTo({
  508. url: `/pages/order/detail/approveIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  509. })
  510. } else if(orderItem.workOrderStatus == 'suspended') {
  511. // 跳转到恢复页面
  512. uni.navigateTo({
  513. url: `/pages/order/detail/resumeIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  514. })
  515. } else if(orderItem.workOrderStatus == 'return') {
  516. // 跳转到退回页面
  517. uni.navigateTo({
  518. url: `/pages/order/detail/returnIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  519. })
  520. } else {
  521. uni.navigateTo({
  522. url: `/pages/order/detail/index?id=${orderItem.id}&orderType=${orderItem.orderType}`
  523. })
  524. }
  525. }
  526. // 清空搜索
  527. const clearSearch = (): void => {
  528. // 添加防重复调用检查
  529. if (loading.value) {
  530. return;
  531. }
  532. // 添加防重复请求检查
  533. if (isSearching.value) {
  534. return
  535. }
  536. isSearching.value = true
  537. keyword.value = ""
  538. page.value = 1
  539. loadData(true, true) // 状态切换时禁用下拉刷新动画
  540. // 延迟重置标志位,确保请求发送后才允许下一次搜索
  541. setTimeout(() => {
  542. isSearching.value = false
  543. }, 100)
  544. }
  545. // 初始化
  546. onMounted(() => {
  547. const userInfo = getUserInfo()
  548. if (userInfo != null) {
  549. const userIdStr = userInfo['userId'].toString()
  550. userId.value = userIdStr
  551. roles.value = userInfo['roleNames'].toString()
  552. }
  553. loadStatusDictList()
  554. loadData(true, false)
  555. // 监听接单成功的事件,刷新列表
  556. uni.$on('refreshOrderList', () => {
  557. page.value = 1
  558. loadData(true, false)
  559. })
  560. })
  561. // 组件卸载前清理事件监听
  562. onBeforeUnmount(() => {
  563. // 确保所有状态都被重置
  564. refreshing.value = false
  565. loading.value = false
  566. isRefreshing.value = false
  567. // 移除事件监听
  568. uni.$off('refreshOrderList',{})
  569. })
  570. </script>
  571. <style lang="scss">
  572. .list-page {
  573. flex: 1;
  574. background-color: #e8f0f9;
  575. }
  576. .search-bar {
  577. padding: 20rpx 30rpx;
  578. background-color: #d7eafe;
  579. }
  580. .search-box {
  581. flex-direction: row;
  582. align-items: center;
  583. height: 72rpx;
  584. padding: 0 24rpx;
  585. background-color: #f5f5f5;
  586. border-radius: 36rpx;
  587. .search-icon {
  588. width: 32rpx;
  589. height: 32rpx;
  590. margin-right: 12rpx;
  591. }
  592. .search-input {
  593. flex: 1;
  594. font-size: 28rpx;
  595. color: #333333;
  596. }
  597. .clear-icon {
  598. margin-left: 12rpx;
  599. font-size: 28rpx;
  600. color: #999999;
  601. }
  602. }
  603. .list-item {
  604. margin: 24rpx 30rpx;
  605. background-color: #ffffff;
  606. border-radius: 16rpx;
  607. }
  608. .item-container {
  609. padding: 30rpx;
  610. }
  611. .item-header {
  612. flex-direction: row;
  613. align-items: flex-start;
  614. margin-bottom: 16rpx;
  615. justify-content: space-between;
  616. min-height: 55rpx;
  617. .item-title {
  618. font-size: 30rpx;
  619. color: #333333;
  620. font-weight: bold;
  621. flex-wrap: wrap;
  622. flex: 0 1 75%;
  623. min-width: 0;
  624. }
  625. .info-value {
  626. font-size: 28rpx;
  627. color: #999999;
  628. margin-left: auto;
  629. flex: 0 0 auto;
  630. white-space: nowrap;
  631. }
  632. }
  633. .info-row {
  634. flex-direction: row;
  635. justify-content: space-between;
  636. align-items: center;
  637. .info-label {
  638. font-size: 26rpx;
  639. color: #666;
  640. }
  641. .info-value {
  642. font-size: 26rpx;
  643. }
  644. }
  645. .text-gray{
  646. font-size: 26rpx;
  647. color: #666;
  648. }
  649. .status-tag {
  650. padding: 8rpx 20rpx;
  651. border-radius: 20rpx;
  652. font-size: 24rpx;
  653. white-space: nowrap;
  654. // margin-left: 20rpx;
  655. border: 1rpx solid;
  656. }
  657. /* 待接单 */
  658. .status-assigned {
  659. background-color: #ebf5ff;
  660. color: #409eff;
  661. border-color: #d8ebff;
  662. }
  663. /* 待结单 */
  664. .status-to_finish {
  665. background-color: #fff7e6;
  666. color: #fa8c16;
  667. border-color: #ffd591;
  668. }
  669. /* 待审批 */
  670. .status-to_approve {
  671. background-color: #fff7e6;
  672. color: #fa8c16;
  673. border-color: #ffd591;
  674. }
  675. /* 已挂起 */
  676. .status-suspended {
  677. background-color: #fff2f0;
  678. color: #ff4d4f;
  679. border-color: #ffccc7;
  680. }
  681. /* 已完成 */
  682. .status-completed {
  683. background-color: #f0f9eb;
  684. color: #5cb87a;
  685. border-color: #c2e7b0;
  686. }
  687. /* 待下发 */
  688. .status-to_issue {
  689. background-color: #f4f4f5;
  690. color: #909399;
  691. border-color: #e9e9eb;
  692. }
  693. /* 已归档 */
  694. .status-archived {
  695. background-color: #f0f9eb;
  696. color: #5cb87a;
  697. border-color: #c2e7b0;
  698. }
  699. /* 退回 */
  700. .status-return {
  701. background-color: #fff2f0;
  702. color: #ff4d4f;
  703. border-color: #ffccc7;
  704. }
  705. /* 退回 */
  706. .status-accept_return {
  707. background-color: #fff2f0;
  708. color: #ff4d4f;
  709. border-color: #ffccc7;
  710. }
  711. .btn-primary {
  712. z-index: 999;
  713. border-radius: 10rpx;
  714. font-size: 24rpx;
  715. // white-space: nowrap;
  716. margin-left: 20rpx;
  717. background-color: #165DFF;
  718. line-height: 45rpx;
  719. color: #ffffff;
  720. .btn-text{
  721. color: #ffffff;
  722. font-size: 24rpx;
  723. padding: 5px 15px;
  724. }
  725. }
  726. .btn-group {
  727. flex-direction: row;
  728. align-items: center;
  729. justify-content: flex-end;
  730. margin-top: 20rpx;
  731. }
  732. // /* 超时 */
  733. // .status-overdue {
  734. // background-color: #fff2f0;
  735. // color: #ff4d4f;
  736. // border-color: #ffccc7;
  737. // }
  738. </style>