index.uvue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  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/44.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/11.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/22.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/11.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/11.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. try {
  570. // 跳转到工单详情页
  571. uni.navigateTo({
  572. url: `/pages/order/detail/acceptIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  573. })
  574. } catch (e) {
  575. console.error('处理超时工单点击事件失败:', e)
  576. }
  577. }
  578. const registerPush =() =>{
  579. console.log("获取CID")
  580. uni.getPushClientId({
  581. success: (res) => {
  582. console.log(res.cid);
  583. registerServer(res.cid).then((result:any) => {
  584. console.log("注册成功");
  585. });
  586. },
  587. fail(err) {
  588. console.log(err)
  589. }
  590. })
  591. }
  592. onShow(() => {
  593. // 重新加载所有计数
  594. loadAssignedCount()
  595. loadSelfScoreCount()
  596. loadOverdueCount()
  597. loadSuspendedCount()
  598. loadApproveCount()
  599. loadOverdueList()
  600. // 修复:使用从vue导入的nextTick,移除document操作
  601. nextTick(() => {
  602. // uts中无需手动操作DOM,nextTick已确保数据更新后DOM完成渲染
  603. console.log('数据更新完成,DOM已重新渲染')
  604. })
  605. })
  606. // 初始化
  607. //onMounted(() => {
  608. onLoad((options: any) => {
  609. // 检查权限设置tabbar
  610. tabbar[2] = checkPermi(['gxt:app:worktime']) ? 1 : 0
  611. tabbar[3] = checkPermi(['gxt:app:score']) ? 1 : 0
  612. const userInfo = getUserInfo()
  613. if (userInfo != null) {
  614. const realName = userInfo['nickName'] as string | null
  615. userName.value = realName ?? '用户'
  616. const userId = userInfo['userId']?.toString()
  617. if(userId!=null){
  618. console.log("监听:"+userId)
  619. handleKeepAlive()
  620. registerPush();
  621. }
  622. }
  623. // 加载待接单数量
  624. loadAssignedCount()
  625. // 加载待自评工单数量
  626. loadSelfScoreCount()
  627. // 加载超时工单数量
  628. loadOverdueCount()
  629. // 加载已挂起工单数量
  630. loadSuspendedCount()
  631. // 加载待审批工单数量
  632. loadApproveCount()
  633. // 加载即将超时工单列表
  634. // loadAlmostOverdueList()
  635. // 加载超时工单列表
  636. loadOverdueList()
  637. // 监听工单状态更新事件
  638. uni.$on('refreshAssignedCount', () => {
  639. loadAssignedCount()
  640. })
  641. // 监听评分工单状态更新事件
  642. uni.$on('refreshSelfScoreCount', () => {
  643. loadSelfScoreCount()
  644. })
  645. // 监听超时工单状态更新事件
  646. uni.$on('refreshOverdueCount', () => {
  647. loadOverdueCount()
  648. })
  649. // 监听接单成功的事件,刷新列表
  650. uni.$on('refreshOrderList', () => {
  651. loadOverdueList()
  652. })
  653. // 监听已挂起工单状态更新事件
  654. uni.$on('refreshSuspendedCount', () => {
  655. loadSuspendedCount()
  656. })
  657. // 监听待审批工单状态更新事件
  658. uni.$on('refreshApproveCount', () => {
  659. loadApproveCount()
  660. })
  661. })
  662. </script>
  663. <style lang="scss">
  664. .page-container {
  665. position: relative;
  666. flex: 1;
  667. // padding-top: env(safe-area-inset-top);
  668. background-color: #e8f0f9;
  669. z-index: 1; // 新增:基础层级
  670. }
  671. .bg-image {
  672. position: absolute;
  673. top: 0;
  674. left: 0;
  675. width: 100%;
  676. height: 100%;
  677. z-index: 0;
  678. }
  679. .bg-color {
  680. position: absolute;
  681. top: 0;
  682. left: 0;
  683. width: 100%;
  684. height: 100%;
  685. z-index: -1;
  686. background: #71a6e4;
  687. }
  688. .page-content {
  689. position: relative;
  690. flex: 1;
  691. margin-top: 30rpx;
  692. margin-bottom: 150rpx;
  693. // padding: 20rpx;
  694. z-index: 2;
  695. }
  696. .header {
  697. flex-direction: row;
  698. height: 40px;
  699. &-title {
  700. font-size: 40rpx;
  701. color: #ffffff;
  702. font-weight: bold;
  703. margin-bottom: 15rpx;
  704. }
  705. &-greeting {
  706. font-size: 28rpx;
  707. color: rgba(255, 255, 255, 0.9);
  708. }
  709. }
  710. .section-title {
  711. font-size: 32rpx;
  712. color: #333333;
  713. font-weight: bold;
  714. // margin-bottom: 20rpx;
  715. }
  716. .section-title-container {
  717. // margin-top: 20rpx;
  718. padding: 20rpx 30rpx;
  719. }
  720. .section-header {
  721. flex-direction: row;
  722. justify-content: space-between;
  723. align-items: center;
  724. }
  725. .view-all {
  726. font-size: 28rpx;
  727. color: #165dff;
  728. }
  729. /* 图表区域 */
  730. .chart-section {
  731. padding: 30rpx;
  732. margin-bottom: 20rpx;
  733. background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.9) 100%);
  734. box-shadow: 0 0 16rpx 0 rgba(0, 0, 0, 0.1);
  735. border-radius: 16rpx;
  736. }
  737. .db-view{
  738. display: flex;
  739. flex-direction: row;
  740. flex-wrap: wrap;
  741. justify-content: flex-start; // 或 space-around
  742. // justify-content: space-around; /* 自动分配间距,避免挤压 */
  743. align-items: center;
  744. padding: 0 20rpx; // 可选:避免贴边
  745. .db-box {
  746. background-color: #fff;
  747. width: 216rpx;
  748. display: flex;
  749. flex-direction: column; // 垂直排列:图标在上,文字在下
  750. justify-content: center;
  751. align-items: center;
  752. margin: 0 10rpx 20rpx 10rpx; // 左右间距(替代原来的 margin-left)
  753. border-radius: 5px;
  754. padding: 30rpx 10rpx; // 可选:增加内边距使内容不拥挤
  755. position: relative;
  756. .db-text {
  757. margin-top: 16rpx; // 图标与文字间距
  758. font-size: 24rpx; // 建议用 rpx,10px 太小了
  759. color: #333;
  760. }
  761. .db-image{
  762. width:100rpx;
  763. height:100rpx;
  764. }
  765. .db-block{
  766. z-index: 6;
  767. }
  768. .badge {
  769. z-index: 7;
  770. position: absolute;
  771. top: 35rpx;
  772. right: 35rpx;
  773. background-color: #ff4d4f;
  774. border-radius: 40rpx;
  775. min-width: 40rpx;
  776. height: 40rpx;
  777. display: flex; // 启用 Flexbox 布局
  778. justify-content: center; // 水平居中
  779. align-items: center; // 垂直居中
  780. box-sizing: border-box; // 确保 padding 不影响整体尺寸
  781. padding: 0 12rpx;
  782. overflow: hidden;
  783. .count {
  784. // line-height: 40rpx;
  785. font-size: 26rpx;
  786. // text-align: center;
  787. color: #ffffff;
  788. }
  789. }
  790. }
  791. }
  792. .list-item {
  793. margin: 0 30rpx 24rpx 30rpx;
  794. background-color: #ffffff;
  795. border-radius: 16rpx;
  796. }
  797. .item-container {
  798. padding: 30rpx;
  799. }
  800. .item-header {
  801. flex-direction: row;
  802. align-items: center;
  803. margin-bottom: 16rpx;
  804. .item-title {
  805. flex: 1;
  806. font-size: 32rpx;
  807. color: #333333;
  808. font-weight: bold;
  809. }
  810. .detail-link {
  811. font-size: 28rpx;
  812. color: #999999;
  813. }
  814. }
  815. .btn-primary {
  816. font-size: 14px;
  817. background-color: #165DFF;
  818. color: #ffffff;
  819. }
  820. .info-row {
  821. flex-direction: row;
  822. justify-content: space-between;
  823. align-items: center;
  824. .info-label {
  825. font-size: 26rpx;
  826. color: #666;
  827. }
  828. .info-value {
  829. font-size: 26rpx;
  830. }
  831. }
  832. .text-gray{
  833. font-size: 26rpx;
  834. color: #666;
  835. }
  836. /* 剩余时间颜色样式 */
  837. .time-critical {
  838. color: #ff4d4f; /* 红色 */
  839. }
  840. .time-warning {
  841. color: #fa8c16; /* 橙色 */
  842. }
  843. .time-notice {
  844. color: #faad14; /* 黄色 */
  845. }
  846. .status-tag {
  847. padding: 8rpx 20rpx;
  848. border-radius: 20rpx;
  849. font-size: 24rpx;
  850. white-space: nowrap;
  851. margin-left: 20rpx;
  852. border: 1rpx solid;
  853. }
  854. /* 已超时工单标题红色样式 */
  855. .overdue-title {
  856. margin-top: 16rpx;
  857. font-size: 26rpx;
  858. color: #ff4d4f;
  859. }
  860. /* 待接单 */
  861. .status-assigned {
  862. background-color: #ebf5ff;
  863. color: #409eff;
  864. border-color: #d8ebff;
  865. }
  866. /* 已挂起 */
  867. .status-suspended {
  868. background-color: #fff2f0;
  869. color: #ff4d4f;
  870. border-color: #ffccc7;
  871. }
  872. .empty-tips {
  873. padding: 30rpx;
  874. justify-content: center;
  875. align-items: center;
  876. .empty-text {
  877. font-size: 26rpx;
  878. color: #999999;
  879. }
  880. }
  881. </style>