index.uvue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. <template>
  2. <uni-navbar-lite :showLeft=false title="首页"></uni-navbar-lite>
  3. <view class="page-container">
  4. <!-- 背景图 -->
  5. <!-- <image class="bg-image" src="/static/images/index/1.png" mode="widthFix"></image> -->
  6. <!-- <view class="bg-color"></view> -->
  7. <scroll-view class="page-content">
  8. <view class="db-view">
  9. <view class="db-box" @click="navigateToOverdueOrders" v-if="checkPermi(['gxt:app:overdue'])" >
  10. <view class="db-block">
  11. <image class="db-image" src="/static/images/map/111.png"></image>
  12. </view>
  13. <view v-if="overdueCount > 0" class="badge">
  14. <text class="count">{{ overdueCount }}</text>
  15. </view>
  16. <text class="db-text">超时工单</text>
  17. </view>
  18. <view class="db-box" @click="navigateToAssignedOrders">
  19. <view class="db-block">
  20. <image class="db-image" src="/static/images/map/222.png"></image>
  21. </view>
  22. <view v-if="assignedCount > 0" class="badge">
  23. <text class="count">{{ assignedCount }}</text>
  24. </view>
  25. <text class="db-text">待处理工单</text>
  26. </view>
  27. <view class="db-box" @click="navigateToScoreOrders" v-if="checkPermi(['gxt:app:toScore'])">
  28. <view class="db-block">
  29. <image class="db-image" src="/static/images/map/333.png"></image>
  30. </view>
  31. <view v-if="selfScoreCount > 0" class="badge">
  32. <text class="count">{{ selfScoreCount }}</text>
  33. </view>
  34. <text class="db-text">待评分工单</text>
  35. </view>
  36. <view class="db-box" @click="navigateToSuspendedOrders" v-if="checkPermi(['gxt:app:toResume'])">
  37. <view class="db-block">
  38. <image class="db-image" src="/static/images/map/444.png"></image>
  39. </view>
  40. <view v-if="suspendedCount > 0" class="badge">
  41. <text class="count">{{ suspendedCount }}</text>
  42. </view>
  43. <text class="db-text">已挂起工单</text>
  44. </view>
  45. <view class="db-box" @click="navigateToApproveOrders" v-if="checkPermi(['gxt:app:toApprove'])">
  46. <view class="db-block">
  47. <image class="db-image" src="/static/images/map/555.png"></image>
  48. </view>
  49. <view v-if="approveCount > 0" class="badge">
  50. <text class="count">{{ approveCount }}</text>
  51. </view>
  52. <text class="db-text">待审批工单</text>
  53. </view>
  54. </view>
  55. <!-- <view>
  56. <button @click="handlePush">通知</button>
  57. </view> -->
  58. <!-- 即将超时工单列表 -->
  59. <!-- <view class="section-title-container" v-if="almostOverdueListData.length > 0">
  60. <view class="section-header">
  61. <text class="section-title">即将超时工单</text>
  62. <text class="view-all" @click="navigateToAlmostOverdueOrders">查看全部</text>
  63. </view>
  64. </view>
  65. <common-list
  66. v-if="almostOverdueListData.length > 0"
  67. :dataList="almostOverdueListData.slice(0, 2)"
  68. :loading="almostOverdueLoading"
  69. :hasMore="false"
  70. :refresherEnabled="false"
  71. :itemKey="'id'"
  72. @itemClick="handleAlmostOverdueItemClick"
  73. >
  74. <template #default="{ item }">
  75. <view class="list-item">
  76. <view class="item-container">
  77. <view class="item-header">
  78. <text class="item-title">{{ getPcsDeviceName(item) }}-{{ getStationName(item) }}</text>
  79. </view>
  80. <view class="info-row">
  81. <text class="text-gray">工单编码:{{ getWorkOrderProjectNo(item) }}</text>
  82. <text class="text-gray" :class="getRemarkClass(item)">{{ getRemark(item) }}</text>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <template #loadMore>
  88. <view></view>
  89. </template>
  90. </common-list> -->
  91. <!-- 超时工单列表 -->
  92. <view class="section-title-container">
  93. <view class="section-header">
  94. <text class="section-title">超时工单</text>
  95. <text class="view-all" @click="navigateToOverdueOrders" v-if="overdueListData.length > 0">查看全部</text>
  96. </view>
  97. </view>
  98. <template v-if="overdueListData.length > 0">
  99. <common-list
  100. :dataList="overdueListData.slice(0, 4)"
  101. :loading="overdueLoading"
  102. :hasMore="false"
  103. :refresherEnabled="false"
  104. :itemKey="'id'"
  105. @itemClick="handleOverdueItemClick"
  106. >
  107. <template #default="{ item }">
  108. <view class="list-item">
  109. <view class="item-container">
  110. <view class="item-header">
  111. <text class="item-title">{{ getPcsDeviceName(item) }}-{{ getStationName(item) }}</text>
  112. <!-- <text class="status-tag status-suspended">{{ getWorkOrderStatus(item) }}</text> -->
  113. </view>
  114. <view class="info-row">
  115. <text class="text-gray">工单编码:{{ getWorkOrderProjectNo(item) }}</text>
  116. <!-- <text class="text-gray overdue-title">{{ getRemark(item) }}</text> -->
  117. </view>
  118. <view class="info-row">
  119. <text class="overdue-title">{{ getRemark(item) }}</text>
  120. </view>
  121. </view>
  122. </view>
  123. </template>
  124. <template #loadMore>
  125. <view></view>
  126. </template>
  127. </common-list>
  128. </template>
  129. <template v-else>
  130. <view class="empty-tips">
  131. <text class="empty-text">暂无超时工单</text>
  132. </view>
  133. </template>
  134. </scroll-view>
  135. <!-- 底部 TabBar -->
  136. <custom-tabbar :current="0" :hide0="tabbar[0]" :hide1="tabbar[1]" :hide2="tabbar[2]" :hide3="tabbar[3]"/>
  137. </view>
  138. </template>
  139. <script setup lang="uts">
  140. import { ref, onMounted, reactive, onLoad, onShow, nextTick } from 'vue'
  141. import { getUserInfo,checkPermi } from '../../utils/storage'
  142. import FlowChart from '../../components/index/flow-chart/flow-chart.uvue'
  143. import { getOrderList, almostOverdueList, overdueList, pendingList } from '../../api/order/list'
  144. import { listMyRate } from '../../api/score/index'
  145. import type { SysDictData } from '../../types/dict'
  146. import { getDictDataByType } from '../../api/dict/index'
  147. // import {startKeepAlive,stopKeepAlive} from '@/uni_modules/ygtx-keepService'
  148. // import { RequestOption } from '@/uni_modules/ygtx-keepService/utssdk/interface.uts';
  149. import { getBaseUrl } from '../../utils/request'
  150. import { KeepLive } from '@/uni_modules/android-keeplive'
  151. import { getMyNotify, registerServer} from '../../api/index/index'
  152. // const handleStartKeepAlive = (userId: string) => {
  153. // let notifyUrl = getBaseUrl() + "/mobile/notify";
  154. // console.log("通知地址:" + notifyUrl)
  155. // const requestOption:RequestOption = {
  156. // requestUrl: notifyUrl, // 你的接口地址(必填)
  157. // requestData: JSON.stringify({ method: "get", data: userId }), // 请求数据(字符串格式,必填)
  158. // task_interval: 10000 // 任务间隔(毫秒,必填)
  159. // };
  160. // startKeepAlive(requestOption,
  161. // (res:any)=>{
  162. // console.log(res)
  163. // });
  164. // };
  165. const tabbar = reactive([1,1,1,1])
  166. // 用户名
  167. const userName = ref<string>('用户')
  168. // 待接单数量
  169. const assignedCount = ref<number>(0)
  170. // 待自评工单数量
  171. const selfScoreCount = ref<number>(0)
  172. // 超时工单数量
  173. const overdueCount = ref<number>(0)
  174. // 已挂起工单数量
  175. const suspendedCount = ref<number>(0)
  176. // 待审批工单数量
  177. const approveCount = ref<number>(0)
  178. // 即将超时工单列表
  179. const almostOverdueListData = ref<any[]>([])
  180. const almostOverdueLoading = ref<boolean>(false)
  181. // 超时工单列表
  182. const overdueListData = ref<any[]>([])
  183. const overdueLoading = ref<boolean>(false)
  184. // 维保类型字典列表
  185. const inspectionTypeList = ref<SysDictData[]>([])
  186. // 添加字典加载状态
  187. const dictLoaded = ref<boolean>(false)
  188. // 获取工单状态字典列表
  189. const loadStatusDictList = async (): Promise<void> => {
  190. try {
  191. const result = await getDictDataByType('gxt_inspection_type')
  192. const resultObj = result as UTSJSONObject
  193. if (resultObj['code'] == 200) {
  194. const data = resultObj['data'] as any[]
  195. const dictData: SysDictData[] = []
  196. if (data.length > 0) {
  197. for (let i = 0; i < data.length; i++) {
  198. const item = data[i] as UTSJSONObject
  199. // 只提取需要的字段
  200. const dictItem: SysDictData = {
  201. dictValue: item['dictValue'] as string | null,
  202. dictLabel: item['dictLabel'] as string | null,
  203. dictCode: null,
  204. dictSort: null,
  205. dictType: null,
  206. cssClass: null,
  207. listClass: null,
  208. isDefault: null,
  209. status: null,
  210. default: null,
  211. createTime: null,
  212. remark: null
  213. }
  214. dictData.push(dictItem)
  215. }
  216. }
  217. inspectionTypeList.value = dictData
  218. dictLoaded.value = true
  219. }
  220. } catch (e: any) {
  221. console.error('获取工单状态字典失败:', e.message)
  222. dictLoaded.value = true
  223. }
  224. }
  225. // 获取待接单数量
  226. const loadAssignedCount = async (): Promise<void> => {
  227. try {
  228. const result = await pendingList(1, 1, null)
  229. const resultObj = result as UTSJSONObject
  230. if (resultObj['code'] == 200) {
  231. const total = resultObj['total'] as number
  232. assignedCount.value = total
  233. }
  234. } catch (e: any) {
  235. console.error('获取待处理工单数量失败:', e.message)
  236. }
  237. }
  238. // 获取待自评工单数量
  239. const loadSelfScoreCount = async (): Promise<void> => {
  240. try {
  241. const params: UTSJSONObject = {
  242. pageNum: 1,
  243. pageSize: 1,
  244. scoringStatus: 'to_self,to_re,to_confirm,to_final'
  245. }
  246. const result = await listMyRate(params)
  247. const resultObj = result as UTSJSONObject
  248. if (resultObj['code'] == 200) {
  249. const total = resultObj['total'] as number
  250. selfScoreCount.value = total
  251. }
  252. } catch (e: any) {
  253. console.error('获取待自评工单数量失败:', e.message)
  254. }
  255. }
  256. // 获取超时工单数量
  257. const loadOverdueCount = async (): Promise<void> => {
  258. try {
  259. const result = await overdueList(1, 1, '') // 只需要获取总数,不需要具体数据
  260. const resultObj = result as UTSJSONObject
  261. if (resultObj['code'] == 200) {
  262. const total = resultObj['total'] as number
  263. overdueCount.value = total
  264. }
  265. } catch (e: any) {
  266. console.error('获取超时工单数量失败:', e.message)
  267. }
  268. }
  269. // 获取已挂起工单数量
  270. const loadSuspendedCount = async (): Promise<void> => {
  271. try {
  272. const result = await getOrderList(1, 1, '', "suspended,auto_suspend") // 只需要获取总数,不需要具体数据
  273. const resultObj = result as UTSJSONObject
  274. if (resultObj['code'] == 200) {
  275. const total = resultObj['total'] as number
  276. suspendedCount.value = total
  277. }
  278. } catch (e: any) {
  279. console.error('获取已挂起工单数量失败:', e.message)
  280. }
  281. }
  282. // 获取已挂起工单数量
  283. const loadApproveCount = async (): Promise<void> => {
  284. try {
  285. const result = await getOrderList(1, 1, '', "to_approve") // 只需要获取总数,不需要具体数据
  286. const resultObj = result as UTSJSONObject
  287. if (resultObj['code'] == 200) {
  288. const total = resultObj['total'] as number
  289. approveCount.value = total
  290. }
  291. } catch (e: any) {
  292. console.error('获取待审批工单数量失败:', e.message)
  293. }
  294. }
  295. // 获取即将超时工单列表
  296. const loadAlmostOverdueList = async (): Promise<void> => {
  297. try {
  298. almostOverdueLoading.value = true
  299. const result = await almostOverdueList(1, 2, '') // 获取前2条
  300. const resultObj = result as UTSJSONObject
  301. if (resultObj['code'] == 200) {
  302. const rows = resultObj['rows'] as any[]
  303. almostOverdueListData.value = rows
  304. }
  305. } catch (e: any) {
  306. console.error('获取即将超时工单列表失败:', e.message)
  307. } finally {
  308. almostOverdueLoading.value = false
  309. }
  310. }
  311. // 获取超时工单列表
  312. const loadOverdueList = async (): Promise<void> => {
  313. try {
  314. overdueLoading.value = true
  315. const result = await overdueList(1, 4, '') // 获取前2条
  316. const resultObj = result as UTSJSONObject
  317. if (resultObj['code'] == 200) {
  318. const data = resultObj['rows'] as any[]
  319. overdueListData.value = data
  320. }
  321. } catch (e: any) {
  322. console.error('获取超时工单列表失败:', e.message)
  323. } finally {
  324. overdueLoading.value = false
  325. }
  326. }
  327. // 跳转到待接单列表
  328. const navigateToAssignedOrders = (): void => {
  329. // 使用 redirectTo 而不是 switchTab,因为工单页面不是 tabBar 页面
  330. // uni.redirectTo({
  331. // url: '/pages/order/index?isDeal=1'
  332. // })
  333. // 跳转到待处理工单页面
  334. uni.navigateTo({
  335. url: '/pages/order/pendingOrder'
  336. })
  337. // // 延迟设置状态,确保页面已加载
  338. // setTimeout(() => {
  339. // uni.$emit('switchOrderStatus', 'deal')
  340. // }, 500)
  341. }
  342. // 跳转到评分工单列表
  343. const navigateToScoreOrders = (): void => {
  344. // 跳转到待评分工单页面
  345. uni.navigateTo({
  346. url: '/pages/score/pending'
  347. })
  348. // uni.redirectTo({
  349. // url: '/pages/score/index'
  350. // })
  351. // 延迟设置状态,确保页面已加载
  352. // setTimeout(() => {
  353. // uni.$emit('switchScoreStatus', 'to_self')
  354. // }, 500)
  355. }
  356. // 跳转到超时工单列表
  357. const navigateToOverdueOrders = (): void => {
  358. // 跳转到超时工单页面
  359. uni.navigateTo({
  360. url: '/pages/order/overdue'
  361. })
  362. }
  363. // 跳转到即将超时工单列表
  364. const navigateToAlmostOverdueOrders = (): void => {
  365. // 跳转到即将超时工单页面
  366. uni.navigateTo({
  367. url: '/pages/order/almostOverdue'
  368. })
  369. }
  370. // 跳转到已挂起工单列表
  371. const navigateToSuspendedOrders = (): void => {
  372. // 跳转到超时工单页面
  373. uni.navigateTo({
  374. url: '/pages/order/suspendedOrder'
  375. })
  376. }
  377. // 跳转到已挂起工单列表
  378. const navigateToApproveOrders = (): void => {
  379. // 跳转到超时工单页面
  380. uni.navigateTo({
  381. url: '/pages/order/approveOrder'
  382. })
  383. }
  384. const getNofiyMes = (): void=>{
  385. const userInfo = getUserInfo()
  386. if (userInfo != null) {
  387. const userId = userInfo['userId']?.toString()
  388. if(userId!=null){
  389. getMyNotify(userId).then((result:any) => {
  390. const jsonData = JSON.stringify(result)
  391. const respData = JSON.parse(jsonData) as UTSJSONObject
  392. if (respData['code'] == 200 &&
  393. respData.hasOwnProperty('data') && respData['data'] != null) {
  394. const data = respData['data'] as UTSJSONObject
  395. const badge = data["num"] as number
  396. setTimeout(() => {
  397. console.log("============:" + badge)
  398. if(badge > -1){
  399. uni.setAppBadgeNumber(badge);
  400. }
  401. if(data.hasOwnProperty("title") && data["title"] != null
  402. && data.hasOwnProperty("desc") && data["desc"] != null){
  403. const title = data["title"] as string
  404. const desc = data["desc"] as string
  405. uni.createPushMessage({
  406. title: title,
  407. content: desc,
  408. when: Date.now() + 10000,
  409. icon: "/static/login/2.png",
  410. sound: "system",
  411. success: (res) => {
  412. console.log('创建推送消息成功', res);
  413. },
  414. fail: (err) => {
  415. console.error('创建推送消息失败', err);
  416. }
  417. });
  418. }
  419. }, 0);
  420. }
  421. }).catch((error) => {
  422. console.error('Promise 执行失败:', error)
  423. });
  424. }
  425. }
  426. }
  427. const handleKeepAlive = ()=>{
  428. var keep=new KeepLive()
  429. keep.setTitle("工效通")
  430. keep.setContent("工效通正在运行")
  431. // keep.setLargeIcon("icon");
  432. keep.setSmallIcon("icon"); //图标名字 图标放在 插件下面的 uni_modules\android-keeplive\utssdk\app-android\res 文件夹下
  433. keep.onAddBackgroundCallback(function(res:boolean){
  434. console.log("后台运行 "+res)
  435. })
  436. keep.onAddScrrenListenerCallback(function(res:boolean){
  437. console.log("屏幕开启状态 "+res)
  438. })
  439. keep.setWakeLock(1,"keeptag");// 设置唤醒类型
  440. keep.setAutoStartEnable(true)
  441. keep.doStartApplicationWithPackageName("uni.app.UNI1050C07");
  442. if(!keep.checkAppNotification()){
  443. keep.onOpenNotificationSetting(function(res:boolean){
  444. keep.register();
  445. var ignoring= keep.isIgnoringBatteryOptimizations();
  446. if(!ignoring){
  447. keep.requestIgnoreBatteryOptimizations();
  448. }
  449. })
  450. }else{
  451. keep.register();
  452. var ignoring= keep.isIgnoringBatteryOptimizations();
  453. if(!ignoring){
  454. keep.requestIgnoreBatteryOptimizations();
  455. }
  456. }
  457. // keep.wifilock();
  458. // 稳定定时器 需要的用户使用(默认定时器1 )
  459. const is_time = uni.getStorageSync("notify_key")
  460. console.log("检查定时器" + is_time)
  461. if(is_time == "0"){
  462. console.log("启动定时器")
  463. keep.onStartCSystemTimer(10,function(){
  464. const is_login = uni.getStorageSync("login_key")
  465. console.log("onStartCSystemTimer:" + is_login);
  466. getNofiyMes();
  467. if(is_login == '1'){
  468. // 加载待接单数量
  469. loadAssignedCount()
  470. // 加载待自评工单数量
  471. loadSelfScoreCount()
  472. // 加载超时工单数量
  473. loadOverdueCount()
  474. // 加载已挂起工单数量
  475. loadSuspendedCount()
  476. // 加载待审批工单数量
  477. loadApproveCount()
  478. // 超时工单列表
  479. loadOverdueList()
  480. }
  481. keep.acquire(1000);// 唤醒一秒钟
  482. });
  483. uni.setStorageSync("notify_key", "1")
  484. }
  485. }
  486. // 辅助函数:从 any 类型提取属性
  487. const getWorkOrderProjectNo = (item: any | null): string | null => {
  488. if (item == null) return ''
  489. const orderInfoItem = item as UTSJSONObject
  490. return orderInfoItem['workOrderProjectNo'] as string != null ? orderInfoItem['workOrderProjectNo'] as string : ''
  491. }
  492. const getPcsDeviceName = (item: any | null): string | null=> {
  493. if (item == null) return ''
  494. const orderInfoItem = item as UTSJSONObject
  495. return orderInfoItem['pcsDeviceName'] as string != null ? orderInfoItem['pcsDeviceName'] as string : ''
  496. }
  497. const getStationName = (item: any | null): string | null=> {
  498. if (item == null) return ''
  499. const orderInfoItem = item as UTSJSONObject
  500. return orderInfoItem['pcsStationName'] as string != null ? orderInfoItem['pcsStationName'] as string : ''
  501. }
  502. const getCreateTime = (item: any | null): string|null => {
  503. if (item == null) return null
  504. const orderInfoItem = item as UTSJSONObject
  505. return orderInfoItem['createTime'] as string != null ? orderInfoItem['createTime'] as string : ''
  506. }
  507. const getRemark = (item: any | null): string|null => {
  508. if (item == null) return null
  509. const orderInfoItem = item as UTSJSONObject
  510. return orderInfoItem['remark'] as string != null ? orderInfoItem['remark'] as string : ''
  511. }
  512. // 根据剩余时间获取颜色类名
  513. const getRemarkClass = (item: any | null): string => {
  514. if (item == null) return ''
  515. const orderInfoItem = item as UTSJSONObject
  516. const remark = orderInfoItem['remark'] as string
  517. if (remark == null || remark.length === 0) return ''
  518. // 解析备注中的剩余时间(假设格式为包含数字和小时的字符串)
  519. // 例如:"剩余时间:5小时" 或 "还剩10小时"
  520. const timeMatch = remark.match(/(\d+(\.\d+)?)\s*(小时|时)/)
  521. if (timeMatch != null && timeMatch.length > 1 && timeMatch[1] != null) {
  522. const hours = parseFloat(timeMatch[1] as string)
  523. if (hours < 6) {
  524. return 'time-critical' // 红色
  525. } else if (hours < 12) {
  526. return 'time-warning' // 橙色
  527. } else if (hours < 24) {
  528. return 'time-notice' // 黄色
  529. }
  530. }
  531. return ''
  532. }
  533. // 辅助函数:从 any 类型提取属性
  534. const getOrderType = (item: any | null): string => {
  535. if (item == null) return ''
  536. const orderInfoItem = item as UTSJSONObject
  537. return orderInfoItem['orderType'] == 1?"维修工单":"维保工单";
  538. }
  539. const getInspectionType = (item: any | null): string | null => {
  540. if (item == null) return ''
  541. const orderInfoItem = item as UTSJSONObject
  542. const rawStatus = orderInfoItem['inspectionType']
  543. if (rawStatus==null) return ''
  544. // 如果字典尚未加载,返回原始值
  545. if (!dictLoaded.value) {
  546. return rawStatus
  547. }
  548. // 查找字典中对应的标签
  549. const dictItem = inspectionTypeList.value.find(dict => dict.dictValue == rawStatus)
  550. return dictItem!=null ? dictItem.dictLabel : rawStatus
  551. }
  552. // 即将超时工单点击事件
  553. const handleAlmostOverdueItemClick = (item: any, index: number): void => {
  554. if (item == null) return
  555. const orderItem = item as UTSJSONObject
  556. try {
  557. // 跳转到工单详情页
  558. uni.navigateTo({
  559. url: `/pages/order/detail/index?id=${orderItem['id']}&orderType=${orderItem['orderType']}`
  560. })
  561. } catch (e) {
  562. console.error('处理即将超时工单点击事件失败:', e)
  563. }
  564. }
  565. // 超时工单点击事件
  566. const handleOverdueItemClick = (item: any, index: number): void => {
  567. if (item == null) return
  568. const orderItem = item as UTSJSONObject
  569. const permit: string[] = orderItem['orderType'] == 2 ? ['gxt:maintenance:order:accept'] : ['gxt:repairOrder:accept']
  570. const isPermit: boolean = checkPermi(permit)
  571. try {
  572. if(isPermit) {
  573. // 跳转到工单接单页
  574. uni.navigateTo({
  575. url: `/pages/order/detail/acceptIndex?id=${orderItem['id']}&orderType=${orderItem['orderType']}`
  576. })
  577. } else {
  578. // 跳转到工单详情页
  579. uni.navigateTo({
  580. url: `/pages/order/detail/index?id=${orderItem['id']}&orderType=${orderItem['orderType']}`
  581. })
  582. }
  583. } catch (e) {
  584. console.error('处理超时工单点击事件失败:', e)
  585. }
  586. }
  587. const registerPush =() =>{
  588. console.log("获取CID")
  589. uni.getPushClientId({
  590. success: (res) => {
  591. console.log(res.cid);
  592. registerServer(res.cid).then((result:any) => {
  593. console.log("注册成功");
  594. });
  595. },
  596. fail(err) {
  597. console.log(err)
  598. }
  599. })
  600. }
  601. onShow(() => {
  602. // 重新加载所有计数
  603. loadAssignedCount()
  604. loadSelfScoreCount()
  605. loadOverdueCount()
  606. loadSuspendedCount()
  607. loadApproveCount()
  608. loadOverdueList()
  609. // 修复:使用从vue导入的nextTick,移除document操作
  610. nextTick(() => {
  611. // uts中无需手动操作DOM,nextTick已确保数据更新后DOM完成渲染
  612. console.log('数据更新完成,DOM已重新渲染')
  613. })
  614. })
  615. // 初始化
  616. //onMounted(() => {
  617. onLoad((options: any) => {
  618. // 检查权限设置tabbar
  619. tabbar[2] = checkPermi(['gxt:app:worktime']) ? 1 : 0
  620. tabbar[3] = checkPermi(['gxt:app:score']) ? 1 : 0
  621. const userInfo = getUserInfo()
  622. if (userInfo != null) {
  623. const realName = userInfo['nickName'] as string | null
  624. userName.value = realName ?? '用户'
  625. const userId = userInfo['userId']?.toString()
  626. if(userId!=null){
  627. console.log("监听:"+userId)
  628. handleKeepAlive()
  629. registerPush();
  630. }
  631. }
  632. // 加载待接单数量
  633. loadAssignedCount()
  634. // 加载待自评工单数量
  635. loadSelfScoreCount()
  636. // 加载超时工单数量
  637. loadOverdueCount()
  638. // 加载已挂起工单数量
  639. loadSuspendedCount()
  640. // 加载待审批工单数量
  641. loadApproveCount()
  642. // 加载即将超时工单列表
  643. // loadAlmostOverdueList()
  644. // 加载超时工单列表
  645. loadOverdueList()
  646. // 监听工单状态更新事件
  647. uni.$on('refreshAssignedCount', () => {
  648. loadAssignedCount()
  649. })
  650. // 监听评分工单状态更新事件
  651. uni.$on('refreshSelfScoreCount', () => {
  652. loadSelfScoreCount()
  653. })
  654. // 监听超时工单状态更新事件
  655. uni.$on('refreshOverdueCount', () => {
  656. loadOverdueCount()
  657. })
  658. // 监听接单成功的事件,刷新列表
  659. uni.$on('refreshOrderList', () => {
  660. loadOverdueList()
  661. })
  662. // 监听已挂起工单状态更新事件
  663. uni.$on('refreshSuspendedCount', () => {
  664. loadSuspendedCount()
  665. })
  666. // 监听待审批工单状态更新事件
  667. uni.$on('refreshApproveCount', () => {
  668. loadApproveCount()
  669. })
  670. })
  671. </script>
  672. <style lang="scss">
  673. .page-container {
  674. position: relative;
  675. flex: 1;
  676. // padding-top: env(safe-area-inset-top);
  677. background-color: #e8f0f9;
  678. z-index: 1; // 新增:基础层级
  679. }
  680. .bg-image {
  681. position: absolute;
  682. top: 0;
  683. left: 0;
  684. width: 100%;
  685. height: 100%;
  686. z-index: 0;
  687. }
  688. .bg-color {
  689. position: absolute;
  690. top: 0;
  691. left: 0;
  692. width: 100%;
  693. height: 100%;
  694. z-index: -1;
  695. background: #71a6e4;
  696. }
  697. .page-content {
  698. position: relative;
  699. flex: 1;
  700. margin-top: 30rpx;
  701. margin-bottom: 150rpx;
  702. // padding: 20rpx;
  703. z-index: 2;
  704. }
  705. .header {
  706. flex-direction: row;
  707. height: 40px;
  708. &-title {
  709. font-size: 40rpx;
  710. color: #ffffff;
  711. font-weight: bold;
  712. margin-bottom: 15rpx;
  713. }
  714. &-greeting {
  715. font-size: 28rpx;
  716. color: rgba(255, 255, 255, 0.9);
  717. }
  718. }
  719. .section-title {
  720. font-size: 32rpx;
  721. color: #333333;
  722. font-weight: bold;
  723. // margin-bottom: 20rpx;
  724. }
  725. .section-title-container {
  726. // margin-top: 20rpx;
  727. padding: 20rpx 30rpx;
  728. }
  729. .section-header {
  730. flex-direction: row;
  731. justify-content: space-between;
  732. align-items: center;
  733. }
  734. .view-all {
  735. font-size: 28rpx;
  736. color: #165dff;
  737. }
  738. /* 图表区域 */
  739. .chart-section {
  740. padding: 30rpx;
  741. margin-bottom: 20rpx;
  742. background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.9) 100%);
  743. box-shadow: 0 0 16rpx 0 rgba(0, 0, 0, 0.1);
  744. border-radius: 16rpx;
  745. }
  746. .db-view{
  747. display: flex;
  748. flex-direction: row;
  749. flex-wrap: wrap;
  750. justify-content: flex-start; // 或 space-around
  751. // justify-content: space-around; /* 自动分配间距,避免挤压 */
  752. align-items: center;
  753. padding: 0 20rpx; // 可选:避免贴边
  754. .db-box {
  755. background-color: #fff;
  756. width: 216rpx;
  757. display: flex;
  758. flex-direction: column; // 垂直排列:图标在上,文字在下
  759. justify-content: center;
  760. align-items: center;
  761. margin: 0 10rpx 20rpx 10rpx; // 左右间距(替代原来的 margin-left)
  762. border-radius: 5px;
  763. padding: 30rpx 10rpx; // 可选:增加内边距使内容不拥挤
  764. position: relative;
  765. .db-text {
  766. margin-top: 16rpx; // 图标与文字间距
  767. font-size: 24rpx; // 建议用 rpx,10px 太小了
  768. color: #333;
  769. }
  770. .db-image{
  771. width:100rpx;
  772. height:100rpx;
  773. }
  774. .db-block{
  775. position: relative;
  776. z-index: 6;
  777. }
  778. .badge {
  779. z-index: 7;
  780. position: absolute;
  781. top: 35rpx;
  782. right: 35rpx;
  783. background-color: #ff4d4f;
  784. border-radius: 40rpx;
  785. min-width: 40rpx;
  786. height: 40rpx;
  787. display: flex; // 启用 Flexbox 布局
  788. justify-content: center; // 水平居中
  789. align-items: center; // 垂直居中
  790. box-sizing: border-box; // 确保 padding 不影响整体尺寸
  791. padding: 0 12rpx;
  792. overflow: hidden;
  793. .count {
  794. // line-height: 40rpx;
  795. font-size: 26rpx;
  796. // text-align: center;
  797. color: #ffffff;
  798. }
  799. }
  800. }
  801. }
  802. .list-item {
  803. margin: 0 30rpx 24rpx 30rpx;
  804. background-color: #ffffff;
  805. border-radius: 16rpx;
  806. }
  807. .item-container {
  808. padding: 30rpx;
  809. }
  810. .item-header {
  811. flex-direction: row;
  812. align-items: center;
  813. margin-bottom: 16rpx;
  814. .item-title {
  815. flex: 1;
  816. font-size: 32rpx;
  817. color: #333333;
  818. font-weight: bold;
  819. }
  820. .detail-link {
  821. font-size: 28rpx;
  822. color: #999999;
  823. }
  824. }
  825. .btn-primary {
  826. font-size: 14px;
  827. background-color: #165DFF;
  828. color: #ffffff;
  829. }
  830. .info-row {
  831. flex-direction: row;
  832. justify-content: space-between;
  833. align-items: center;
  834. .info-label {
  835. font-size: 26rpx;
  836. color: #666;
  837. }
  838. .info-value {
  839. font-size: 26rpx;
  840. }
  841. }
  842. .text-gray{
  843. font-size: 26rpx;
  844. color: #666;
  845. }
  846. /* 剩余时间颜色样式 */
  847. .time-critical {
  848. color: #ff4d4f; /* 红色 */
  849. }
  850. .time-warning {
  851. color: #fa8c16; /* 橙色 */
  852. }
  853. .time-notice {
  854. color: #faad14; /* 黄色 */
  855. }
  856. .status-tag {
  857. padding: 8rpx 20rpx;
  858. border-radius: 20rpx;
  859. font-size: 24rpx;
  860. white-space: nowrap;
  861. margin-left: 20rpx;
  862. border: 1rpx solid;
  863. }
  864. /* 已超时工单标题红色样式 */
  865. .overdue-title {
  866. margin-top: 16rpx;
  867. font-size: 26rpx;
  868. color: #ff4d4f;
  869. }
  870. /* 待接单 */
  871. .status-assigned {
  872. background-color: #ebf5ff;
  873. color: #409eff;
  874. border-color: #d8ebff;
  875. }
  876. /* 已挂起 */
  877. .status-suspended {
  878. background-color: #fff2f0;
  879. color: #ff4d4f;
  880. border-color: #ffccc7;
  881. }
  882. .empty-tips {
  883. padding: 30rpx;
  884. justify-content: center;
  885. align-items: center;
  886. .empty-text {
  887. font-size: 26rpx;
  888. color: #999999;
  889. }
  890. }
  891. </style>