index.uvue 34 KB

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