index.uvue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996
  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 v-if="overdueCount > 0" class="badge"><text class="count">{{ overdueCount }}</text></view>
  11. <view class="db-block">
  12. <view class="db-center-3">
  13. <image class="db-image" src="/static/images/map/2.png"></image>
  14. </view>
  15. </view>
  16. <text class="db-text">超时工单</text>
  17. </view>
  18. <view class="db-box" @click="navigateToAssignedOrders">
  19. <view v-if="assignedCount > 0" class="badge"><text class="count">{{ assignedCount }}</text></view>
  20. <view class="db-block">
  21. <view class="db-center-1">
  22. <image class="db-image" src="/static/images/map/1.png"></image>
  23. </view>
  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 v-if="selfScoreCount > 0" class="badge"><text class="count">{{ selfScoreCount }}</text></view>
  29. <view class="db-block">
  30. <view class="db-center-2">
  31. <image class="db-image" src="/static/images/map/2.png"></image>
  32. </view>
  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 v-if="suspendedCount > 0" class="badge"><text class="count">{{ suspendedCount }}</text></view>
  38. <view class="db-block">
  39. <view class="db-center-1">
  40. <image class="db-image" src="/static/images/map/2.png"></image>
  41. </view>
  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 v-if="approveCount > 0" class="badge"><text class="count">{{ approveCount }}</text></view>
  47. <view class="db-block">
  48. <view class="db-center-2">
  49. <image class="db-image" src="/static/images/map/1.png"></image>
  50. </view>
  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 } 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") // 只需要获取总数,不需要具体数据
  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. console.log("onStartCSystemTimer ");
  465. getNofiyMes();
  466. // 加载待接单数量
  467. loadAssignedCount()
  468. // 加载待自评工单数量
  469. loadSelfScoreCount()
  470. // 加载超时工单数量
  471. loadOverdueCount()
  472. // 加载已挂起工单数量
  473. loadSuspendedCount()
  474. // 加载待审批工单数量
  475. loadApproveCount()
  476. // 超时工单列表
  477. loadOverdueList()
  478. keep.acquire(1000);// 唤醒一秒钟
  479. });
  480. uni.setStorageSync("notify_key", "1")
  481. }
  482. }
  483. // 辅助函数:从 any 类型提取属性
  484. const getWorkOrderProjectNo = (item: any | null): string | null => {
  485. if (item == null) return ''
  486. const orderInfoItem = item as UTSJSONObject
  487. return orderInfoItem['workOrderProjectNo'] as string != null ? orderInfoItem['workOrderProjectNo'] as string : ''
  488. }
  489. const getPcsDeviceName = (item: any | null): string | null=> {
  490. if (item == null) return ''
  491. const orderInfoItem = item as UTSJSONObject
  492. return orderInfoItem['pcsDeviceName'] as string != null ? orderInfoItem['pcsDeviceName'] as string : ''
  493. }
  494. const getStationName = (item: any | null): string | null=> {
  495. if (item == null) return ''
  496. const orderInfoItem = item as UTSJSONObject
  497. return orderInfoItem['pcsStationName'] as string != null ? orderInfoItem['pcsStationName'] as string : ''
  498. }
  499. const getCreateTime = (item: any | null): string|null => {
  500. if (item == null) return null
  501. const orderInfoItem = item as UTSJSONObject
  502. return orderInfoItem['createTime'] as string != null ? orderInfoItem['createTime'] as string : ''
  503. }
  504. const getRemark = (item: any | null): string|null => {
  505. if (item == null) return null
  506. const orderInfoItem = item as UTSJSONObject
  507. return orderInfoItem['remark'] as string != null ? orderInfoItem['remark'] as string : ''
  508. }
  509. // 根据剩余时间获取颜色类名
  510. const getRemarkClass = (item: any | null): string => {
  511. if (item == null) return ''
  512. const orderInfoItem = item as UTSJSONObject
  513. const remark = orderInfoItem['remark'] as string
  514. if (remark == null || remark.length === 0) return ''
  515. // 解析备注中的剩余时间(假设格式为包含数字和小时的字符串)
  516. // 例如:"剩余时间:5小时" 或 "还剩10小时"
  517. const timeMatch = remark.match(/(\d+(\.\d+)?)\s*(小时|时)/)
  518. if (timeMatch != null && timeMatch.length > 1 && timeMatch[1] != null) {
  519. const hours = parseFloat(timeMatch[1] as string)
  520. if (hours < 6) {
  521. return 'time-critical' // 红色
  522. } else if (hours < 12) {
  523. return 'time-warning' // 橙色
  524. } else if (hours < 24) {
  525. return 'time-notice' // 黄色
  526. }
  527. }
  528. return ''
  529. }
  530. // 辅助函数:从 any 类型提取属性
  531. const getOrderType = (item: any | null): string => {
  532. if (item == null) return ''
  533. const orderInfoItem = item as UTSJSONObject
  534. return orderInfoItem['orderType'] == 1?"维修工单":"维保工单";
  535. }
  536. const getInspectionType = (item: any | null): string | null => {
  537. if (item == null) return ''
  538. const orderInfoItem = item as UTSJSONObject
  539. const rawStatus = orderInfoItem['inspectionType']
  540. if (rawStatus==null) return ''
  541. // 如果字典尚未加载,返回原始值
  542. if (!dictLoaded.value) {
  543. return rawStatus
  544. }
  545. // 查找字典中对应的标签
  546. const dictItem = inspectionTypeList.value.find(dict => dict.dictValue == rawStatus)
  547. return dictItem!=null ? dictItem.dictLabel : rawStatus
  548. }
  549. // 即将超时工单点击事件
  550. const handleAlmostOverdueItemClick = (item: any, index: number): void => {
  551. if (item == null) return
  552. const orderItem = item as UTSJSONObject
  553. try {
  554. // 跳转到工单详情页
  555. uni.navigateTo({
  556. url: `/pages/order/detail/index?id=${orderItem['id']}&orderType=${orderItem['orderType']}`
  557. })
  558. } catch (e) {
  559. console.error('处理即将超时工单点击事件失败:', e)
  560. }
  561. }
  562. // 超时工单点击事件
  563. const handleOverdueItemClick = (item: any, index: number): void => {
  564. if (item == null) return
  565. const orderItem = item as UTSJSONObject
  566. try {
  567. // 跳转到工单详情页
  568. uni.navigateTo({
  569. url: `/pages/order/detail/acceptIndex?id=${orderItem.id}&orderType=${orderItem.orderType}`
  570. })
  571. } catch (e) {
  572. console.error('处理超时工单点击事件失败:', e)
  573. }
  574. }
  575. const registerPush =() =>{
  576. console.log("获取CID")
  577. uni.getPushClientId({
  578. success: (res) => {
  579. console.log(res.cid);
  580. registerServer(res.cid).then((result:any) => {
  581. console.log("注册成功");
  582. });
  583. },
  584. fail(err) {
  585. console.log(err)
  586. }
  587. })
  588. }
  589. // 初始化
  590. //onMounted(() => {
  591. onLoad((options: any) => {
  592. // 检查权限设置tabbar
  593. tabbar[2] = checkPermi(['gxt:app:worktime']) ? 1 : 0
  594. tabbar[3] = checkPermi(['gxt:app:score']) ? 1 : 0
  595. const userInfo = getUserInfo()
  596. if (userInfo != null) {
  597. const realName = userInfo['nickName'] as string | null
  598. userName.value = realName ?? '用户'
  599. const userId = userInfo['userId']?.toString()
  600. if(userId!=null){
  601. console.log("监听:"+userId)
  602. handleKeepAlive()
  603. registerPush();
  604. }
  605. }
  606. // 加载待接单数量
  607. loadAssignedCount()
  608. // 加载待自评工单数量
  609. loadSelfScoreCount()
  610. // 加载超时工单数量
  611. loadOverdueCount()
  612. // 加载已挂起工单数量
  613. loadSuspendedCount()
  614. // 加载待审批工单数量
  615. loadApproveCount()
  616. // 加载即将超时工单列表
  617. // loadAlmostOverdueList()
  618. // 加载超时工单列表
  619. loadOverdueList()
  620. // 监听工单状态更新事件
  621. uni.$on('refreshAssignedCount', () => {
  622. loadAssignedCount()
  623. })
  624. // 监听评分工单状态更新事件
  625. uni.$on('refreshSelfScoreCount', () => {
  626. loadSelfScoreCount()
  627. })
  628. // 监听超时工单状态更新事件
  629. uni.$on('refreshOverdueCount', () => {
  630. loadOverdueCount()
  631. })
  632. // 监听接单成功的事件,刷新列表
  633. uni.$on('refreshOrderList', () => {
  634. loadOverdueList()
  635. })
  636. // 监听已挂起工单状态更新事件
  637. uni.$on('refreshSuspendedCount', () => {
  638. loadSuspendedCount()
  639. })
  640. // 监听待审批工单状态更新事件
  641. uni.$on('refreshApproveCount', () => {
  642. loadApproveCount()
  643. })
  644. })
  645. </script>
  646. <style lang="scss">
  647. .page-container {
  648. position: relative;
  649. flex: 1;
  650. // padding-top: env(safe-area-inset-top);
  651. background-color: #e8f0f9;
  652. }
  653. .bg-image {
  654. position: absolute;
  655. top: 0;
  656. left: 0;
  657. width: 100%;
  658. height: 100%;
  659. z-index: 0;
  660. }
  661. .bg-color {
  662. position: absolute;
  663. top: 0;
  664. left: 0;
  665. width: 100%;
  666. height: 100%;
  667. z-index: -1;
  668. background: #71a6e4;
  669. }
  670. .page-content {
  671. position: relative;
  672. flex: 1;
  673. margin-top: 30rpx;
  674. margin-bottom: 150rpx;
  675. // padding: 20rpx;
  676. z-index: 10;
  677. }
  678. .header {
  679. flex-direction: row;
  680. height: 40px;
  681. &-title {
  682. font-size: 40rpx;
  683. color: #ffffff;
  684. font-weight: bold;
  685. margin-bottom: 15rpx;
  686. }
  687. &-greeting {
  688. font-size: 28rpx;
  689. color: rgba(255, 255, 255, 0.9);
  690. }
  691. }
  692. .section-title {
  693. font-size: 32rpx;
  694. color: #333333;
  695. font-weight: bold;
  696. // margin-bottom: 20rpx;
  697. }
  698. .section-title-container {
  699. // margin-top: 20rpx;
  700. padding: 20rpx 30rpx;
  701. }
  702. .section-header {
  703. flex-direction: row;
  704. justify-content: space-between;
  705. align-items: center;
  706. }
  707. .view-all {
  708. font-size: 28rpx;
  709. color: #165dff;
  710. }
  711. /* 图表区域 */
  712. .chart-section {
  713. padding: 30rpx;
  714. margin-bottom: 20rpx;
  715. background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.9) 100%);
  716. box-shadow: 0 0 16rpx 0 rgba(0, 0, 0, 0.1);
  717. border-radius: 16rpx;
  718. }
  719. .db-view{
  720. display: flex;
  721. flex-direction: row;
  722. flex-wrap: wrap;
  723. justify-content: flex-start; // 或 space-around
  724. // justify-content: space-around; /* 自动分配间距,避免挤压 */
  725. align-items: center;
  726. padding: 0 20rpx; // 可选:避免贴边
  727. .db-box {
  728. background-color: #fff;
  729. width: 216rpx;
  730. // 删除固定宽高 ↓
  731. // max-width: 300rpx;
  732. // height: 200rpx;
  733. // flex: 1; // ✅ 关键:平均分空间
  734. display: flex;
  735. flex-direction: column; // 垂直排列:图标在上,文字在下
  736. justify-content: center;
  737. align-items: center;
  738. margin: 0 10rpx 20rpx 10rpx; // 左右间距(替代原来的 margin-left)
  739. border-radius: 5px;
  740. padding: 30rpx 10rpx; // 可选:增加内边距使内容不拥挤
  741. .db-text {
  742. margin-top: 16rpx; // 图标与文字间距
  743. font-size: 24rpx; // 建议用 rpx,10px 太小了
  744. color: #333;
  745. }
  746. .db-center-1,
  747. .db-center-2,
  748. .db-center-3 {
  749. display: flex;
  750. justify-content: center;
  751. align-items: center;
  752. width: 100rpx;
  753. height: 100rpx;
  754. border-radius: 50rpx;
  755. position: relative;
  756. }
  757. .db-center-1 { background-color: #DBEAFE; }
  758. .db-center-2 { background-color: #DCFCE7; }
  759. .db-center-3 { background-color: #F3E8FF; }
  760. }
  761. .db-image{
  762. width:50rpx;
  763. height:50rpx;
  764. }
  765. }
  766. .badge {
  767. z-index: 999;
  768. position: absolute;
  769. top: 35rpx;
  770. right: 35rpx;
  771. background-color: #ff4d4f;
  772. border-radius: 40rpx;
  773. min-width: 40rpx;
  774. height: 40rpx;
  775. display: flex; // 启用 Flexbox 布局
  776. justify-content: center; // 水平居中
  777. align-items: center; // 垂直居中
  778. box-sizing: border-box; // 确保 padding 不影响整体尺寸
  779. padding: 0 12rpx;
  780. .count {
  781. // line-height: 40rpx;
  782. font-size: 26rpx;
  783. // text-align: center;
  784. color: #ffffff;
  785. }
  786. }
  787. .list-item {
  788. margin: 0 30rpx 24rpx 30rpx;
  789. background-color: #ffffff;
  790. border-radius: 16rpx;
  791. }
  792. .item-container {
  793. padding: 30rpx;
  794. }
  795. .item-header {
  796. flex-direction: row;
  797. align-items: center;
  798. margin-bottom: 16rpx;
  799. .item-title {
  800. flex: 1;
  801. font-size: 32rpx;
  802. color: #333333;
  803. font-weight: bold;
  804. }
  805. .detail-link {
  806. font-size: 28rpx;
  807. color: #999999;
  808. }
  809. }
  810. .btn-primary {
  811. font-size: 14px;
  812. background-color: #165DFF;
  813. color: #ffffff;
  814. }
  815. .info-row {
  816. flex-direction: row;
  817. justify-content: space-between;
  818. align-items: center;
  819. .info-label {
  820. font-size: 26rpx;
  821. color: #666;
  822. }
  823. .info-value {
  824. font-size: 26rpx;
  825. }
  826. }
  827. .text-gray{
  828. font-size: 26rpx;
  829. color: #666;
  830. }
  831. /* 剩余时间颜色样式 */
  832. .time-critical {
  833. color: #ff4d4f; /* 红色 */
  834. }
  835. .time-warning {
  836. color: #fa8c16; /* 橙色 */
  837. }
  838. .time-notice {
  839. color: #faad14; /* 黄色 */
  840. }
  841. .status-tag {
  842. padding: 8rpx 20rpx;
  843. border-radius: 20rpx;
  844. font-size: 24rpx;
  845. white-space: nowrap;
  846. margin-left: 20rpx;
  847. border: 1rpx solid;
  848. }
  849. /* 已超时工单标题红色样式 */
  850. .overdue-title {
  851. margin-top: 16rpx;
  852. font-size: 26rpx;
  853. color: #ff4d4f;
  854. }
  855. /* 待接单 */
  856. .status-assigned {
  857. background-color: #ebf5ff;
  858. color: #409eff;
  859. border-color: #d8ebff;
  860. }
  861. /* 已挂起 */
  862. .status-suspended {
  863. background-color: #fff2f0;
  864. color: #ff4d4f;
  865. border-color: #ffccc7;
  866. }
  867. .empty-tips {
  868. padding: 30rpx;
  869. justify-content: center;
  870. align-items: center;
  871. .empty-text {
  872. font-size: 26rpx;
  873. color: #999999;
  874. }
  875. }
  876. </style>