pending.uvue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  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
  9. class="search-input"
  10. placeholder="搜索工单编码、风机编号"
  11. v-model="searchKeyword"
  12. @confirm="handleSearch"
  13. @blur="handleSearch"
  14. />
  15. <text v-if="searchKeyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
  16. </view>
  17. </view>
  18. <!-- 工单评分列表 -->
  19. <common-list
  20. :dataList="orderList"
  21. :loading="loading"
  22. :refreshing="refreshing"
  23. :hasMore="hasMore"
  24. @refresh="handleRefresh"
  25. @loadMore="loadMore"
  26. @itemClick="handleItemClick"
  27. class="list-with-padding"
  28. >
  29. <template #default="{ item, index }">
  30. <view class="list-item">
  31. <view class="item-container">
  32. <view class="item-header">
  33. <text class="item-title">{{ getPropertyValue(item, 'pcsStationName') }}{{ getPropertyValue(item, 'pcsDeviceName') }}{{ getWorkOrderTypeText(getPropertyValue(item, 'orderType')) }}</text>
  34. <!-- <text class="info-value">{{ getScoringStatus(item) }}</text> -->
  35. <text class="status-tag" :class="getStatusClass(item)">{{ getScoringStatus(item) }}</text>
  36. </view>
  37. <view class="info-row">
  38. <view class="info-label">
  39. <text class="text-gray">{{ getWorkOrderTypeInfo(item) }}</text>
  40. </view>
  41. <!-- <view class="info-value-row">
  42. <text v-if="getPropertyValue(item, 'score') !== ''" class="score-text">{{ formatNumber(parseFloat(getPropertyValue(item, 'score'))) }}</text>
  43. </view> -->
  44. </view>
  45. <view class="info-row">
  46. <view class="info-label">
  47. <text class="text-gray">工作结束时间: {{ getPropertyValue(item, 'realEndTime') }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. </common-list>
  54. <!-- 自定义时间选择弹窗 -->
  55. <l-popup v-model="showDatePickerPopup" position="bottom">
  56. <view class="date-picker-popup">
  57. <view class="popup-header">
  58. <text class="popup-title">选择年月</text>
  59. <view class="popup-actions">
  60. <text class="cancel-btn" @click="closeDatePicker">取消</text>
  61. </view>
  62. </view>
  63. <view class="date-picker-container">
  64. <view class="date-picker-item">
  65. <!-- <text class="date-label">选择年月</text> -->
  66. <view class="date-display" @click="openDatePicker">
  67. {{ customDate != null && customDate != '' ? customDate : '请选择年月' }}
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </l-popup>
  73. <!-- Date Picker -->
  74. <l-popup v-model="showDatePicker" position="bottom" :z-index="1000">
  75. <l-date-time-picker
  76. :mode="3"
  77. format="YYYY-MM"
  78. :modelValue="customDate"
  79. confirm-btn="确定"
  80. cancel-btn="取消"
  81. @confirm="onDateConfirm"
  82. @cancel="showDatePicker = false">
  83. </l-date-time-picker>
  84. </l-popup>
  85. </view>
  86. </template>
  87. <script setup lang="uts">
  88. import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
  89. import { listOrderScores, getOrderScoreStatistics, listMyRate } from '@/api/score/index'
  90. import { getDictDataByType } from '@/api/dict/index'
  91. import type { SysDictData } from '@/types/dict'
  92. // 数据状态
  93. const searchKeyword = ref<string>('')
  94. const statusFilter = ref<string>('')
  95. const selectedMonth = ref<string>('current')
  96. const loading = ref<boolean>(false)
  97. const refreshing = ref<boolean>(false)
  98. const hasMore = ref<boolean>(true)
  99. const orderList = ref<any[]>([])
  100. const currentPage = ref<number>(1)
  101. const totalScore = ref<number>(0)
  102. const maintenanceScore = ref<number>(0)
  103. const repairScore = ref<number>(0)
  104. const rank = ref<number | null>(null)
  105. const totalRankingUsers = ref<number | null>(null)
  106. const customDate = ref<string>('')
  107. // 防止重复请求的标志位
  108. const isSearching = ref<boolean>(false)
  109. // 添加防重复刷新的标志
  110. const isRefreshing = ref<boolean>(false)
  111. // 添加刷新时间戳,用于防抖
  112. const lastRefreshTime = ref<number>(0)
  113. // 添加防抖定时器
  114. let searchTimer: number | null = null
  115. // 弹窗显示状态
  116. const showDatePickerPopup = ref<boolean>(false)
  117. const showDatePicker = ref<boolean>(false)
  118. // 工单状态字典列表
  119. const statusDictList = ref<SysDictData[]>([])
  120. // 维保类型字典列表
  121. const inspectionTypeDictList = ref<SysDictData[]>([])
  122. // 检修类型字典列表
  123. const maintenanceTypeDictList = ref<SysDictData[]>([])
  124. const dictLoaded = ref<boolean>(false)
  125. // 计算属性
  126. const monthTitle = computed(() => {
  127. switch (selectedMonth.value) {
  128. case 'prev':
  129. return '上月'
  130. case 'current':
  131. return '本月'
  132. case 'custom':
  133. // 显示自定义选择的年月
  134. return (customDate.value != null && customDate.value != '') ? customDate.value : '自定义'
  135. default:
  136. return '本月'
  137. }
  138. })
  139. // 打开自定义日期选择弹窗
  140. function showCustomDatePicker() {
  141. showDatePickerPopup.value = true
  142. }
  143. function closeDatePicker() {
  144. showDatePicker.value = false
  145. showDatePickerPopup.value = false
  146. }
  147. // 打开日期选择器
  148. function openDatePicker() {
  149. showDatePicker.value = true
  150. }
  151. // 获取工单评分状态字典列表
  152. const loadStatusDictList = async (): Promise<void> => {
  153. try {
  154. const result = await getDictDataByType('gxt_scoring_status')
  155. const resultObj = result as UTSJSONObject
  156. if (resultObj['code'] == 200) {
  157. const data = resultObj['data'] as any[]
  158. const dictData: SysDictData[] = []
  159. if (data != null && data.length > 0) {
  160. for (let i = 0; i < data.length; i++) {
  161. const item = data[i] as UTSJSONObject
  162. // 只提取需要的字段
  163. const dictItem: SysDictData = {
  164. dictValue: item['dictValue'] as string | null,
  165. dictLabel: item['dictLabel'] as string | null,
  166. dictCode: null,
  167. dictSort: null,
  168. dictType: null,
  169. cssClass: null,
  170. listClass: null,
  171. isDefault: null,
  172. status: null,
  173. default: null,
  174. createTime: null,
  175. remark: null
  176. }
  177. dictData.push(dictItem)
  178. }
  179. }
  180. statusDictList.value = dictData
  181. }
  182. } catch (e: any) {
  183. console.error('获取工单评分状态字典失败:', e.message)
  184. }
  185. }
  186. // 获取维保类型字典列表
  187. const loadInspectionTypeDictList = async (): Promise<void> => {
  188. try {
  189. const result = await getDictDataByType('gxt_inspection_type')
  190. const resultObj = result as UTSJSONObject
  191. if (resultObj['code'] == 200) {
  192. const data = resultObj['data'] as any[]
  193. const dictData: SysDictData[] = []
  194. if (data != null && data.length > 0) {
  195. for (let i = 0; i < data.length; i++) {
  196. const item = data[i] as UTSJSONObject
  197. // 只提取需要的字段
  198. const dictItem: SysDictData = {
  199. dictValue: item['dictValue'] as string | null,
  200. dictLabel: item['dictLabel'] as string | null,
  201. dictCode: null,
  202. dictSort: null,
  203. dictType: null,
  204. cssClass: null,
  205. listClass: null,
  206. isDefault: null,
  207. status: null,
  208. default: null,
  209. createTime: null,
  210. remark: null
  211. }
  212. dictData.push(dictItem)
  213. }
  214. }
  215. inspectionTypeDictList.value = dictData
  216. }
  217. } catch (e: any) {
  218. console.error('获取维保类型字典失败:', e.message)
  219. }
  220. }
  221. // 获取检修类型字典列表
  222. const loadMaintenanceTypeDictList = async (): Promise<void> => {
  223. try {
  224. const result = await getDictDataByType('gxt_maintenance_type')
  225. const resultObj = result as UTSJSONObject
  226. if (resultObj['code'] == 200) {
  227. const data = resultObj['data'] as any[]
  228. const dictData: SysDictData[] = []
  229. if (data != null && data.length > 0) {
  230. for (let i = 0; i < data.length; i++) {
  231. const item = data[i] as UTSJSONObject
  232. // 只提取需要的字段
  233. const dictItem: SysDictData = {
  234. dictValue: item['dictValue'] as string | null,
  235. dictLabel: item['dictLabel'] as string | null,
  236. dictCode: null,
  237. dictSort: null,
  238. dictType: null,
  239. cssClass: null,
  240. listClass: null,
  241. isDefault: null,
  242. status: null,
  243. default: null,
  244. createTime: null,
  245. remark: null
  246. }
  247. dictData.push(dictItem)
  248. }
  249. }
  250. maintenanceTypeDictList.value = dictData
  251. }
  252. } catch (e: any) {
  253. console.error('获取检修类型字典失败:', e.message)
  254. }
  255. }
  256. // Helper function to safely extract properties from item
  257. function getPropertyValue(item: any | null, propertyName: string): string {
  258. if (item == null) return ''
  259. const itemObj = item as UTSJSONObject
  260. const value = itemObj[propertyName]
  261. return value != null ? '' + value : ''
  262. }
  263. // 获取工单类型文本
  264. function getWorkOrderTypeText(orderType: string | null): string {
  265. if (orderType != null) {
  266. if (orderType == "1") {
  267. return "维修工单"
  268. } else if (orderType == "2") {
  269. return "维保工单"
  270. }
  271. }
  272. return ""
  273. }
  274. // 获取工单类型相关信息(维保类型或检修类型)
  275. function getWorkOrderTypeInfo(item: any | null): string {
  276. if (item == null) return ''
  277. const orderType = getPropertyValue(item, 'orderType')
  278. // 维保工单显示维保类型
  279. if (orderType == "2") {
  280. const inspectionType = getPropertyValue(item, 'inspectionType')
  281. if (inspectionType != null && inspectionType != '') {
  282. // 如果字典尚未加载,返回原始值
  283. if (inspectionTypeDictList.value.length == 0) {
  284. return inspectionType
  285. }
  286. // 查找字典中对应的标签
  287. const dictItem = inspectionTypeDictList.value.find(dict => dict.dictValue == inspectionType)
  288. return (dictItem != null ? dictItem.dictLabel : inspectionType) as string
  289. }
  290. }
  291. // 维修工单显示检修类型
  292. else if (orderType == "1") {
  293. const maintenanceType = getPropertyValue(item, 'maintenanceType')
  294. if (maintenanceType != null && maintenanceType != '') {
  295. // 如果字典尚未加载,返回原始值
  296. if (maintenanceTypeDictList.value.length == 0) {
  297. return maintenanceType
  298. }
  299. // 查找字典中对应的标签
  300. const dictItem = maintenanceTypeDictList.value.find(dict => dict.dictValue == maintenanceType)
  301. return (dictItem != null ? dictItem.dictLabel : maintenanceType) as string
  302. }
  303. }
  304. return ""
  305. }
  306. // 获取工单状态文本
  307. function getScoringStatus(item: any | null): string | null {
  308. if (item == null) return ''
  309. const rawStatus = getPropertyValue(item, 'scoringStatus')
  310. if (rawStatus == null || rawStatus == '') return ''
  311. // 如果字典尚未加载,返回原始值
  312. if (!dictLoaded.value) {
  313. return rawStatus
  314. }
  315. // 查找字典中对应的标签
  316. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  317. return dictItem != null ? dictItem.dictLabel : rawStatus
  318. }
  319. // 获取工单评分状态文本
  320. function getOrderStatusText(status: string | null): string {
  321. const statusMap: UTSJSONObject = {
  322. '1': '待自评',
  323. '2': '待复评',
  324. '3': '待确认',
  325. '4': '待终评'
  326. }
  327. if (status == null) return ''
  328. const result = statusMap[status]
  329. return result != null ? result as string : '未知状态'
  330. }
  331. // 获取统计数据
  332. function getStatistics() {
  333. // Convert 'current' and 'prev' values to actual date strings
  334. let monthValue = '';
  335. if (selectedMonth.value === 'custom') {
  336. monthValue = customDate.value;
  337. } else if (selectedMonth.value === 'current') {
  338. const now = new Date();
  339. monthValue = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}`;
  340. } else if (selectedMonth.value === 'prev') {
  341. const now = new Date();
  342. const prevMonth = now.getMonth(); // getMonth() returns 0-11
  343. const prevYear = prevMonth === 0 ? now.getFullYear() - 1 : now.getFullYear();
  344. const monthStr = prevMonth === 0 ? '12' : prevMonth.toString().padStart(2, '0');
  345. monthValue = `${prevYear}-${monthStr}`;
  346. }
  347. const params: UTSJSONObject = {
  348. //scoringStatus: statusFilter.value,
  349. month: monthValue
  350. }
  351. getOrderScoreStatistics(params).then((response: any) => {
  352. const resultObj = response as UTSJSONObject
  353. const responseData = resultObj['data'] as UTSJSONObject
  354. if (responseData != null) {
  355. totalScore.value = (responseData['totalScore'] != null) ? parseFloat((responseData['totalScore'] as number).toFixed(2)) : 0
  356. maintenanceScore.value = (responseData['maintenanceScore'] != null) ? parseFloat((responseData['maintenanceScore'] as number).toFixed(2)) : 0
  357. repairScore.value = (responseData['repairScore'] != null) ? parseFloat((responseData['repairScore'] as number).toFixed(2)) : 0
  358. rank.value = (responseData['rank'] != null) ? responseData['rank'] as number : null
  359. totalRankingUsers.value = (responseData['totalRankingUsers'] != null) ? responseData['totalRankingUsers'] as number : null
  360. } else {
  361. totalScore.value = 0
  362. maintenanceScore.value = 0
  363. repairScore.value = 0
  364. rank.value = null
  365. totalRankingUsers.value = null
  366. }
  367. })
  368. }
  369. function onDateConfirm(value: string) {
  370. customDate.value = value
  371. showDatePicker.value = false
  372. showDatePickerPopup.value = false
  373. selectedMonth.value = 'custom'
  374. // 添加防重复调用检查
  375. if (loading.value) {
  376. return;
  377. }
  378. getStatistics()
  379. }
  380. // 方法
  381. function loadData(isRefresh: boolean, disablePullDown = false) {
  382. // 防止重复请求的核心机制 - 参考工单页面的简单有效方式
  383. if (loading.value) {
  384. // 确保刷新状态最终被重置,防止卡死
  385. if (!isRefresh) {
  386. refreshing.value = false;
  387. }
  388. return
  389. }
  390. const shouldRefresh = isRefresh !== false
  391. loading.value = true
  392. if (shouldRefresh && !disablePullDown) {
  393. currentPage.value = 1
  394. refreshing.value = true
  395. } else if (shouldRefresh && disablePullDown) {
  396. // 筛选条件变化时,重置页码但不触发下拉刷新
  397. currentPage.value = 1
  398. // 即使禁用下拉刷新,也要确保刷新状态最终被重置
  399. refreshing.value = false
  400. } else {
  401. // 对于加载更多操作,不需要显示下拉刷新状态
  402. refreshing.value = false;
  403. }
  404. // Convert 'current' and 'prev' values to actual date strings
  405. let monthValue = '';
  406. if (selectedMonth.value === 'custom') {
  407. monthValue = customDate.value;
  408. } else if (selectedMonth.value === 'current') {
  409. const now = new Date();
  410. const m = now.getMonth() + 1
  411. let mStr = m.toString()
  412. if (m < 10) {
  413. mStr = '0' + mStr
  414. }
  415. monthValue = `${now.getFullYear()}-${mStr}`;
  416. } else if (selectedMonth.value === 'prev') {
  417. const now = new Date();
  418. const prevMonth = now.getMonth(); // getMonth() returns 0-11
  419. const prevYear = prevMonth === 0 ? now.getFullYear() - 1 : now.getFullYear();
  420. let monthStr = prevMonth === 0 ? '12' : prevMonth.toString()
  421. if (prevMonth !== 0 && prevMonth < 10) {
  422. monthStr = '0' + monthStr
  423. }
  424. monthValue = `${prevYear}-${monthStr}`;
  425. }
  426. const params: UTSJSONObject = {
  427. pageNum: currentPage.value,
  428. pageSize: 10,
  429. keyword: searchKeyword.value,
  430. scoringStatus: 'to_self,to_re,to_confirm,to_final',
  431. month: monthValue
  432. }
  433. listMyRate(params).then((response: any) => {
  434. // 提取响应数据
  435. const resultObj = response as UTSJSONObject
  436. console.log('API响应数据:', resultObj)
  437. const responseData = resultObj['rows'] as any[]
  438. const responseTotal = resultObj['total'] as number
  439. if (shouldRefresh) {
  440. orderList.value = Array.isArray(responseData) ? responseData : []
  441. } else {
  442. const currentRows = Array.isArray(responseData) ? responseData : []
  443. orderList.value = [...orderList.value, ...currentRows]
  444. }
  445. hasMore.value = orderList.value.length < responseTotal
  446. }).catch((error) => {
  447. console.error('获取工单列表失败:', error);
  448. // 出错时也需要重置刷新状态
  449. if (shouldRefresh) {
  450. refreshing.value = false;
  451. isRefreshing.value = false;
  452. }
  453. }).finally(() => {
  454. // 无论成功还是失败,都重置所有加载状态
  455. loading.value = false;
  456. // 确保刷新状态最终被重置
  457. if (shouldRefresh) {
  458. refreshing.value = false;
  459. // 使用setTimeout确保状态彻底重置
  460. setTimeout(() => {
  461. isRefreshing.value = false;
  462. }, 50);
  463. }
  464. })
  465. }
  466. function handleSearch() {
  467. // 添加防重复调用检查
  468. if (loading.value) {
  469. return;
  470. }
  471. // 添加防抖和防止重复请求
  472. if (isSearching.value) {
  473. return
  474. }
  475. const timer = searchTimer
  476. if (timer != null) {
  477. clearTimeout(timer)
  478. searchTimer = null
  479. }
  480. searchTimer = setTimeout(() => {
  481. isSearching.value = true
  482. loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
  483. // 延迟重置标志位,确保请求发送后才允许下一次搜索
  484. setTimeout(() => {
  485. isSearching.value = false
  486. }, 100)
  487. }, 300)
  488. }
  489. function clearSearch() {
  490. // 添加防重复调用检查
  491. if (loading.value) {
  492. return;
  493. }
  494. // 添加防抖和防止重复请求
  495. if (isSearching.value) {
  496. return
  497. }
  498. const timer = searchTimer
  499. if (timer != null) {
  500. clearTimeout(timer)
  501. searchTimer = null
  502. }
  503. searchKeyword.value = ""
  504. searchTimer = setTimeout(() => {
  505. isSearching.value = true
  506. loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
  507. // 延迟重置标志位,确保请求发送后才允许下一次搜索
  508. setTimeout(() => {
  509. isSearching.value = false
  510. }, 100)
  511. }, 300)
  512. }
  513. function filterByStatus(status: string) {
  514. // 添加防重复调用检查
  515. if (loading.value) {
  516. return;
  517. }
  518. // 添加防止重复请求
  519. if (isSearching.value) {
  520. return
  521. }
  522. const timer = searchTimer
  523. if (timer != null) {
  524. clearTimeout(timer)
  525. searchTimer = null
  526. }
  527. statusFilter.value = status
  528. searchTimer = setTimeout(() => {
  529. isSearching.value = true
  530. loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
  531. getStatistics()
  532. // 延迟重置标志位,确保请求发送后才允许下一次搜索
  533. setTimeout(() => {
  534. isSearching.value = false
  535. }, 100)
  536. }, 300)
  537. }
  538. function changeMonth(month: string) {
  539. // 添加防重复调用检查
  540. if (loading.value) {
  541. return;
  542. }
  543. // 添加防止重复请求
  544. if (isSearching.value) {
  545. return
  546. }
  547. const timer = searchTimer
  548. if (timer != null) {
  549. clearTimeout(timer)
  550. searchTimer = null
  551. }
  552. selectedMonth.value = month
  553. searchTimer = setTimeout(() => {
  554. getStatistics()
  555. }, 300)
  556. }
  557. function loadMore() {
  558. console.log("loadMore被触发")
  559. if (!hasMore.value || loading.value) return
  560. currentPage.value++
  561. loadData(false)
  562. }
  563. function handleRefresh() {
  564. console.log("handleRefresh被触发")
  565. console.log("loading.value===",loading.value)
  566. console.log("isRefreshing.value===",isRefreshing.value)
  567. // 防抖处理,避免频繁触发
  568. const now = Date.now();
  569. if (now - lastRefreshTime.value < 1000) {
  570. console.log("刷新操作过于频繁,忽略本次触发");
  571. refreshing.value = false;
  572. return;
  573. }
  574. lastRefreshTime.value = now;
  575. // 添加防重复调用检查
  576. if (loading.value || isRefreshing.value) {
  577. // 如果已经在加载或正在刷新,直接重置刷新状态
  578. refreshing.value = false;
  579. return;
  580. }
  581. console.log("loading.value1===",loading.value)
  582. console.log("isRefreshing.value1===",isRefreshing.value)
  583. // 设置刷新标志
  584. isRefreshing.value = true;
  585. loadData(true); // 使用默认的下拉刷新行为
  586. // 确保在一定时间后重置刷新标志,防止意外情况
  587. setTimeout(() => {
  588. isRefreshing.value = false
  589. }, 100) // 延迟重置,确保状态完全更新
  590. }
  591. // 点击列表项
  592. function handleItemClick(item: any | null, index: number): void {
  593. if (item == null) return
  594. const itemObj = item as UTSJSONObject
  595. const id = itemObj.get('id')
  596. const orderType = itemObj.get('orderType')
  597. if (id != null && orderType != null) {
  598. // 转换为字符串
  599. const idStr = '' + id
  600. const orderTypeStr = '' + orderType
  601. uni.navigateTo({
  602. url: `/pages/score/detail/index?id=${idStr}&orderType=${orderTypeStr}`
  603. })
  604. }
  605. }
  606. function formatNumber(value: number | null) {
  607. if (value === null) return '0.0'
  608. return value.toFixed(2)
  609. }
  610. // 获取工单评分状态样式类
  611. function getStatusClass(item: any | null): string {
  612. if (item == null) return ''
  613. const rawStatus = getPropertyValue(item, 'scoringStatus')
  614. if (rawStatus == null || rawStatus == '') return ''
  615. return `status-${rawStatus}`
  616. }
  617. function formatDate(dateString: string) {
  618. if (dateString == '' || dateString == null) return ''
  619. const date = new Date(dateString)
  620. const year = date.getFullYear()
  621. const month = (date.getMonth() + 1).toString().padStart(2, '0')
  622. const day = date.getDate().toString().padStart(2, '0')
  623. const hours = date.getHours().toString().padStart(2, '0')
  624. const minutes = date.getMinutes().toString().padStart(2, '0')
  625. return `${year}-${month}-${day} ${hours}:${minutes}`
  626. }
  627. // 生命周期
  628. onMounted(() => {
  629. loadStatusDictList()
  630. loadInspectionTypeDictList()
  631. loadMaintenanceTypeDictList()
  632. loadData(false)
  633. getStatistics()
  634. dictLoaded.value = true
  635. })
  636. // 组件销毁时清除定时器
  637. onBeforeUnmount(() => {
  638. const timer = searchTimer
  639. if (timer != null) {
  640. clearTimeout(timer)
  641. searchTimer = null
  642. }
  643. // 如果组件销毁前还有未完成的刷新操作,确保状态被重置
  644. loading.value = false;
  645. refreshing.value = false;
  646. isRefreshing.value = false;
  647. })
  648. </script>
  649. <style lang="scss">
  650. .list-page {
  651. flex: 1;
  652. background-color: #e8f0f9;
  653. // padding-bottom: 150rpx; // 为底部 TabBar 留出空间
  654. }
  655. /* 搜索栏样式 */
  656. .search-bar {
  657. padding: 20rpx 30rpx;
  658. background-color: #d7eafe;
  659. }
  660. .search-box {
  661. flex-direction: row;
  662. align-items: center;
  663. height: 72rpx;
  664. padding: 0 24rpx;
  665. background-color: #f5f5f5;
  666. border-radius: 36rpx;
  667. .search-icon {
  668. width: 32rpx;
  669. height: 32rpx;
  670. margin-right: 12rpx;
  671. }
  672. .search-input {
  673. flex: 1;
  674. font-size: 28rpx;
  675. color: #333333;
  676. }
  677. .clear-icon {
  678. margin-left: 12rpx;
  679. font-size: 28rpx;
  680. color: #999999;
  681. }
  682. }
  683. /* 工单状态筛选 */
  684. .status-bar {
  685. padding-bottom: 10px;
  686. padding-left: 30rpx;
  687. background-color: #d7eafe;
  688. }
  689. .status-box {
  690. flex-direction: row;
  691. align-items: center;
  692. height: 72rpx;
  693. flex: 1;
  694. .status-txt {
  695. padding: 8px 12px;
  696. text-align: center;
  697. margin-right: 12rpx;
  698. border-radius: 36rpx;
  699. background-color: #fff;
  700. font-size: 28rpx;
  701. }
  702. .stauts-sel {
  703. background-color: #007AFF;
  704. color: #fff;
  705. }
  706. }
  707. /* 工分统计 */
  708. .stats-section {
  709. margin: 15rpx 30rpx;
  710. background-color: #ffffff;
  711. border-radius: 16rpx;
  712. padding: 20rpx;
  713. }
  714. .stats-header {
  715. flex-direction: row;
  716. justify-content: space-between;
  717. align-items: center;
  718. margin-bottom: 20rpx;
  719. }
  720. .stats-title {
  721. font-size: 32rpx;
  722. font-weight: bold;
  723. flex: 1;
  724. }
  725. .month-filters {
  726. flex-direction: row;
  727. justify-content: flex-end;
  728. }
  729. .month-filter {
  730. padding: 6rpx 16rpx;
  731. margin-left: 12rpx;
  732. font-size: 24rpx;
  733. border-radius: 24rpx;
  734. background-color: #f2f3f5;
  735. color: #666;
  736. white-space: nowrap;
  737. }
  738. .month-filter-sel {
  739. background-color: #165dff;
  740. color: white;
  741. }
  742. .stats-content {
  743. margin-top: 20rpx;
  744. flex-direction: column;
  745. }
  746. .total-score {
  747. margin-bottom: 30rpx;
  748. flex-direction: column;
  749. align-items: center;
  750. }
  751. .score-label {
  752. font-size: 28rpx;
  753. color: #666;
  754. display: flex;
  755. margin-bottom: 8rpx;
  756. }
  757. .score-value {
  758. display: flex;
  759. font-size: 48rpx;
  760. font-weight: bold;
  761. color: #165dff;
  762. line-height: 1.2;
  763. }
  764. .score-breakdown {
  765. flex-direction: row;
  766. justify-content: space-between;
  767. }
  768. .breakdown-item {
  769. flex: 1;
  770. flex-direction: column;
  771. align-items: center;
  772. }
  773. .breakdown-label {
  774. display: flex;
  775. font-size: 32rpx;
  776. font-weight: bold;
  777. color: #333;
  778. line-height: 1.4;
  779. }
  780. .breakdown-value {
  781. font-size: 28rpx;
  782. color: #666;
  783. display: flex;
  784. margin-bottom: 8rpx;
  785. }
  786. /* 列表项样式 */
  787. .list-item {
  788. margin: 12rpx 30rpx;
  789. background-color: #ffffff;
  790. border-radius: 16rpx;
  791. }
  792. .item-container {
  793. padding: 30rpx;
  794. }
  795. .item-header {
  796. flex-direction: row;
  797. align-items: flex-start;
  798. margin-bottom: 16rpx;
  799. .item-title {
  800. font-size: 30rpx;
  801. color: #333333;
  802. font-weight: bold;
  803. flex-wrap: wrap;
  804. flex: 0 1 70%;
  805. min-width: 0;
  806. }
  807. .info-value {
  808. font-size: 28rpx;
  809. color: #999999;
  810. margin-left: auto;
  811. flex: 0 0 auto;
  812. white-space: nowrap;
  813. }
  814. }
  815. .info-row {
  816. flex-direction: row;
  817. justify-content: space-between;
  818. align-items: center;
  819. .info-label {
  820. font-size: 26rpx;
  821. color: #666;
  822. }
  823. .info-value-row {
  824. flex-direction: row;
  825. align-items: center;
  826. }
  827. .score-text {
  828. font-size: 28rpx;
  829. color: #ff9900;
  830. font-weight: bold;
  831. margin-right: 20rpx;
  832. }
  833. .status-text {
  834. font-size: 24rpx;
  835. padding: 4rpx 12rpx;
  836. border-radius: 24rpx;
  837. background-color: #f2f3f5;
  838. color: #666;
  839. }
  840. }
  841. .text-gray{
  842. font-size: 26rpx;
  843. color: #666;
  844. }
  845. /* 日期选择弹窗 */
  846. .date-picker-popup {
  847. background-color: white;
  848. border-top-left-radius: 30rpx;
  849. border-top-right-radius: 30rpx;
  850. padding: 40rpx;
  851. padding-bottom: 40rpx;
  852. margin-bottom: 150rpx; /* 提高弹窗,避免被底部导航栏遮挡 */
  853. }
  854. .popup-header {
  855. display: flex;
  856. justify-content: space-between;
  857. align-items: center;
  858. margin-bottom: 40rpx;
  859. }
  860. .popup-title {
  861. font-size: 34rpx;
  862. font-weight: bold;
  863. }
  864. .popup-actions {
  865. display: flex;
  866. flex-direction: row;
  867. }
  868. .cancel-btn {
  869. color: #999;
  870. padding: 10rpx 20rpx;
  871. }
  872. .confirm-btn {
  873. color: #165dff;
  874. padding: 10rpx 20rpx;
  875. font-weight: bold;
  876. }
  877. .date-picker-container {
  878. padding: 20rpx 0;
  879. padding-bottom: env(safe-area-inset-bottom); // 适配安全区域
  880. }
  881. .date-picker-item {
  882. margin-bottom: 40rpx;
  883. }
  884. .date-label {
  885. display: flex;
  886. margin-bottom: 20rpx;
  887. font-size: 30rpx;
  888. color: #333;
  889. }
  890. .date-display {
  891. width: 100%;
  892. padding: 20rpx;
  893. border: 2rpx solid #ddd;
  894. border-radius: 8rpx;
  895. font-size: 32rpx;
  896. color: #333;
  897. }
  898. // 添加底部填充的类
  899. .list-with-padding {
  900. padding-bottom: 40rpx;
  901. }
  902. /* 工单评分状态标签样式 */
  903. .status-tag {
  904. padding: 8rpx 20rpx;
  905. border-radius: 20rpx;
  906. font-size: 24rpx;
  907. white-space: nowrap;
  908. margin-left: 70rpx;
  909. border: 1rpx solid;
  910. }
  911. /* 待自评 */
  912. .status-to_self {
  913. background-color: #fff7e6;
  914. color: #fa8c16;
  915. border-color: #ffd591;
  916. }
  917. /* 待复评 */
  918. .status-to_re {
  919. background-color: #ebf5ff;
  920. color: #409eff;
  921. border-color: #d8ebff;
  922. }
  923. /* 待确认 */
  924. .status-to_confirm {
  925. background-color: #f0f9eb;
  926. color: #5cb87a;
  927. border-color: #c2e7b0;
  928. }
  929. /* 待终评 */
  930. .status-to_final {
  931. background-color: #ebf5ff;
  932. color: #409eff;
  933. border-color: #d8ebff;
  934. }
  935. /* 待归档 */
  936. .status-to_archive {
  937. background-color: #f0f9eb;
  938. color: #5cb87a;
  939. border-color: #c2e7b0;
  940. }
  941. /* 已归档 */
  942. .status-archived {
  943. background-color: #f0f9eb;
  944. color: #5cb87a;
  945. border-color: #c2e7b0;
  946. }
  947. </style>