index.uvue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  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, 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. position: relative; // 新增
  746. z-index: 3; // 新增
  747. .db-box {
  748. background-color: #fff;
  749. width: 216rpx;
  750. // 删除固定宽高 ↓
  751. // max-width: 300rpx;
  752. // height: 200rpx;
  753. // flex: 1; // ✅ 关键:平均分空间
  754. display: flex;
  755. flex-direction: column; // 垂直排列:图标在上,文字在下
  756. justify-content: center;
  757. align-items: center;
  758. margin: 0 10rpx 20rpx 10rpx; // 左右间距(替代原来的 margin-left)
  759. border-radius: 5px;
  760. padding: 30rpx 10rpx; // 可选:增加内边距使内容不拥挤
  761. position: relative;
  762. // z-index: 10 !important;
  763. z-index: 4; // 提升卡片层级
  764. .db-text {
  765. margin-top: 16rpx; // 图标与文字间距
  766. font-size: 24rpx; // 建议用 rpx,10px 太小了
  767. color: #333;
  768. }
  769. .db-center-1,
  770. .db-center-2,
  771. .db-center-3 {
  772. display: flex;
  773. justify-content: center;
  774. align-items: center;
  775. width: 100rpx;
  776. height: 100rpx;
  777. border-radius: 50rpx;
  778. // position: relative;
  779. }
  780. .db-center-1 { background-color: #DBEAFE; }
  781. .db-center-2 { background-color: #DCFCE7; }
  782. .db-center-3 { background-color: #F3E8FF; }
  783. }
  784. .db-image{
  785. width:50rpx;
  786. height:50rpx;
  787. }
  788. }
  789. .badge {
  790. z-index: 9999 !important;
  791. position: absolute;
  792. top: 35rpx;
  793. right: 35rpx;
  794. background-color: #ff4d4f;
  795. border-radius: 40rpx !important;
  796. min-width: 40rpx;
  797. height: 40rpx;
  798. display: flex; // 启用 Flexbox 布局
  799. justify-content: center; // 水平居中
  800. align-items: center; // 垂直居中
  801. box-sizing: border-box; // 确保 padding 不影响整体尺寸
  802. padding: 0 12rpx;
  803. overflow: hidden;
  804. .count {
  805. // line-height: 40rpx;
  806. font-size: 26rpx;
  807. // text-align: center;
  808. color: #ffffff;
  809. }
  810. }
  811. .list-item {
  812. margin: 0 30rpx 24rpx 30rpx;
  813. background-color: #ffffff;
  814. border-radius: 16rpx;
  815. }
  816. .item-container {
  817. padding: 30rpx;
  818. }
  819. .item-header {
  820. flex-direction: row;
  821. align-items: center;
  822. margin-bottom: 16rpx;
  823. .item-title {
  824. flex: 1;
  825. font-size: 32rpx;
  826. color: #333333;
  827. font-weight: bold;
  828. }
  829. .detail-link {
  830. font-size: 28rpx;
  831. color: #999999;
  832. }
  833. }
  834. .btn-primary {
  835. font-size: 14px;
  836. background-color: #165DFF;
  837. color: #ffffff;
  838. }
  839. .info-row {
  840. flex-direction: row;
  841. justify-content: space-between;
  842. align-items: center;
  843. .info-label {
  844. font-size: 26rpx;
  845. color: #666;
  846. }
  847. .info-value {
  848. font-size: 26rpx;
  849. }
  850. }
  851. .text-gray{
  852. font-size: 26rpx;
  853. color: #666;
  854. }
  855. /* 剩余时间颜色样式 */
  856. .time-critical {
  857. color: #ff4d4f; /* 红色 */
  858. }
  859. .time-warning {
  860. color: #fa8c16; /* 橙色 */
  861. }
  862. .time-notice {
  863. color: #faad14; /* 黄色 */
  864. }
  865. .status-tag {
  866. padding: 8rpx 20rpx;
  867. border-radius: 20rpx;
  868. font-size: 24rpx;
  869. white-space: nowrap;
  870. margin-left: 20rpx;
  871. border: 1rpx solid;
  872. }
  873. /* 已超时工单标题红色样式 */
  874. .overdue-title {
  875. margin-top: 16rpx;
  876. font-size: 26rpx;
  877. color: #ff4d4f;
  878. }
  879. /* 待接单 */
  880. .status-assigned {
  881. background-color: #ebf5ff;
  882. color: #409eff;
  883. border-color: #d8ebff;
  884. }
  885. /* 已挂起 */
  886. .status-suspended {
  887. background-color: #fff2f0;
  888. color: #ff4d4f;
  889. border-color: #ffccc7;
  890. }
  891. .empty-tips {
  892. padding: 30rpx;
  893. justify-content: center;
  894. align-items: center;
  895. .empty-text {
  896. font-size: 26rpx;
  897. color: #999999;
  898. }
  899. }
  900. </style>