index.uvue 26 KB

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