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