From b09c7e7aefd41a62326ea56460092aa0db54c083 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 21 四月 2026 17:30:52 +0800
Subject: [PATCH] 现场监管模块
---
package_supervision/pages/inspection/index.js | 302 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 259 insertions(+), 43 deletions(-)
diff --git a/package_supervision/pages/inspection/index.js b/package_supervision/pages/inspection/index.js
index b8e8be3..7664b8a 100644
--- a/package_supervision/pages/inspection/index.js
+++ b/package_supervision/pages/inspection/index.js
@@ -1,66 +1,282 @@
-// package_supervision/pages/inspection/index.js
-Page({
+import { inspectPicUrl } from '../../../config/index';
+import taskApi from '../../api/taskApi';
+import { fetchScene } from '../../../services/inspection/fetchScene';
+import Message from 'tdesign-miniprogram/message/index';
+/**
+ * status: 鏈墽琛� | 姝e湪鎵ц | 宸茬粨鏉�
+ * action: 寮�濮嬩换鍔� | 缁撴潫浠诲姟 | 宸茬粨鏉�
+ * theme: primary | danger | default
+ * icon: play-circle-stroke | pause-circle-stroke | stop-circle
+ */
+const TASK_STATUS = {
+ 鏈墽琛�: {
+ status: '鏈墽琛�',
+ action: '寮�濮嬩换鍔�',
+ theme: 'primary',
+ icon: 'play-circle-stroke',
+ },
+ 姝e湪鎵ц: {
+ status: '姝e湪鎵ц',
+ action: '缁撴潫浠诲姟',
+ theme: 'danger',
+ icon: 'pause-circle-stroke',
+ },
+ 宸茬粨鏉�: {
+ status: '宸茬粨鏉�',
+ action: '宸茬粨鏉�',
+ theme: 'default',
+ icon: 'stop-circle-stroke',
+ },
+};
+
+Page({
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
+ title: '鐜板満鐩戠',
+ // 宸℃煡瀛愪换鍔�
+ subtask: {},
+ // 鍦烘櫙淇℃伅
+ scene: {},
+ inspeciton: {},
+ //
+ mapMarkers: [],
+ // 鍔熻兘鑿滃崟
+ menu1: [
+ {
+ name: '闂澶嶆牳',
+ icon: `${inspectPicUrl}icons/icon_patrol_check.png`,
+ disabled: true,
+ },
+ {
+ name: '闂鍙栬瘉',
+ icon: `${inspectPicUrl}icons/icon_patrol_new_question.png`,
+ disabled: true,
+ url: '/package_supervision/pages/menu_evidence/index'
+ },
+ {
+ name: '闂娓呭崟',
+ icon: `${inspectPicUrl}icons/icon_patrol_question_list.png`,
+ disabled: true,
+ },
+ {
+ name: '鐜板満鏁存敼',
+ icon: `${inspectPicUrl}icons/icon_patrol_change.png`,
+ disabled: true,
+ },
+ {
+ name: '浠绘剰鎷嶇収',
+ icon: `${inspectPicUrl}icons/icon_patrol_camera.png`,
+ disabled: true,
+ },
+ {
+ name: '瀵艰埅',
+ icon: `${inspectPicUrl}icons/icon_patrol_navi.png`,
+ disabled: false,
+ },
+ {
+ name: '閲嶆柊瀹氫綅',
+ icon: `${inspectPicUrl}icons/icon_patrol_latlng.png`,
+ disabled: false,
+ },
+ {
+ name: '淇敼淇℃伅',
+ icon: `${inspectPicUrl}icons/icon_patrol_edit.png`,
+ disabled: false,
+ },
+ {
+ name: '闂瀹℃牳',
+ icon: `${inspectPicUrl}icons/icon_patrol_online.png`,
+ disabled: true,
+ },
+ {
+ name: '鏁存敼瀹℃牳',
+ icon: `${inspectPicUrl}icons/icon_patrol_promiss.png`,
+ disabled: true,
+ },
+ ],
+ menu2: [
+ {
+ name: '鍥剧墖鍙栬瘉',
+ icon: `${inspectPicUrl}icons/icon_patrol_new_question.png`,
+ disabled: true,
+ },
+ {
+ name: '鏁存敼鎵胯',
+ icon: `${inspectPicUrl}icons/icon_patrol_promiss.png`,
+ disabled: true,
+ },
+ {
+ name: '缁煎悎璇勫垎',
+ icon: `${inspectPicUrl}icons/icon_patrol_rate.png`,
+ disabled: true,
+ },
+ {
+ name: '涓�閿垎浜�',
+ icon: `${inspectPicUrl}icons/icon_patrol_submit.png`,
+ disabled: true,
+ },
+ {
+ name: '鎶�闃叉帾鏂�',
+ icon: `${inspectPicUrl}icons/icon_patrol_newgit.png`,
+ disabled: true,
+ },
+ ],
+ // 浠诲姟鐘舵��
+ taskStatus: {
+ loading: false,
+ ...TASK_STATUS.宸茬粨鏉�,
+ },
+ // 浠诲姟鐘舵�佹寜閽姞杞芥牱寮�
+ loadProps: {
+ theme: 'spinner',
+ tClass: 'ins-buttons__loading',
+ },
+ // 浠诲姟鐘舵�佹洿鏀圭‘璁ゅ脊鍑烘
+ taskStatusDialog: {
+ show: false,
+ title: '瑕佸紑濮嬩换鍔″悧锛�',
+ content: '',
+ },
},
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
- */
onLoad(options) {
-
+ // 鑾峰彇宸℃煡浠诲姟鍙傛暟 subtask锛屽苟鏇存柊浠诲姟鐘舵�� taskStatus
+ this.getOpenerEventChannel().on('acceptSubTaskData', data => {
+ if (data) {
+ this.setData({
+ subtask: data.subtask,
+ taskStatus: {
+ loading: false,
+ ...TASK_STATUS[data.subtask.status],
+ },
+ });
+ this.fetchInspectionData();
+ }
+ });
},
/**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
+ * 鏍规嵁浠诲姟鐘舵�侊紝鏇存柊鎸夐挳鏄惁鍙偣鍑�
+ * @param {string} status 浠诲姟鐘舵�侊細 鏈墽琛� | 姝e湪鎵ц | 宸茬粨鏉�
*/
- onReady() {
-
+ refreshMenuStatus(status) {
+ const { menu1, menu2 } = this.data;
+ if (status == '姝e湪鎵ц') {
+ menu1.forEach(m => {
+ m.disabled = false;
+ });
+ menu2.forEach(m => {
+ m.disabled = false;
+ });
+ } else if (status == '宸茬粨鏉�') {
+ menu1[1].disabled = true;
+ menu2[0].disabled = true;
+ } else {
+ menu1.forEach(m => {
+ m.disabled = true;
+ });
+ menu2.forEach(m => {
+ m.disabled = true;
+ });
+ [5, 6, 7].forEach(i => {
+ menu1[i].disabled = false;
+ });
+ }
+ this.setData({ menu1, menu2 });
},
/**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+ * 鑾峰彇宸℃煡淇℃伅鍜屽満鏅俊鎭�
*/
- onShow() {
+ fetchInspectionData() {
+ const { subtask } = this.data;
+ taskApi.fetchInspectionData(subtask.stguid).then(res => {
+ this.setData({
+ inspeciton: res,
+ });
+ });
+ fetchScene(subtask.scenseid).then(res => {
+ const { mapMarkers } = this.data;
+ mapMarkers.push({
+ id: 1,
+ longitude: res.longitude,
+ latitude: res.latitude,
+ title: res.name,
+ callout: res.name,
+ width: 16,
+ height: 24,
+ });
+ this.setData({
+ scene: res,
+ mapMarkers,
+ title: res.name,
+ });
+ });
+ },
+ showTaskStatusChangeDialog() {
+ let { taskStatusDialog, taskStatus } = this.data;
+ if (taskStatus.status == '鏈墽琛�') {
+ taskStatusDialog = {
+ show: true,
+ title: '瑕佸紑濮嬩换鍔″悧锛�',
+ content: '',
+ };
+ } else if (taskStatus.status == '姝e湪鎵ц') {
+ taskStatusDialog = {
+ show: true,
+ title: '瑕佺粨鏉熶换鍔″悧锛�',
+ content: '缁撴潫浠诲姟鍚庝笉鑳藉啀鏂板闂',
+ };
+ }
+ this.setData({ taskStatusDialog });
+ },
+
+ closeDialog() {
+ this.setData({ 'taskStatusDialog.show': false });
},
/**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
+ * 浠诲姟鐘舵�佸彉鏇翠簨浠跺鐞嗗嚱鏁�
*/
- onHide() {
-
+ handleTaskStatusChange() {
+ this.closeDialog();
+ let { taskStatus, subtask } = this.data;
+ this.setData({ 'taskStatus.loading': true });
+ if (taskStatus.status == '宸茬粨鏉�') {
+ return;
+ }
+ if (taskStatus.status == '鏈墽琛�') {
+ taskStatus = {
+ loading: true,
+ ...TASK_STATUS.姝e湪鎵ц,
+ };
+ } else if (taskStatus.status == '姝e湪鎵ц') {
+ taskStatus = {
+ loading: true,
+ ...TASK_STATUS.宸茬粨鏉�,
+ };
+ }
+ taskApi
+ .changeSubTaskStatus(subtask.stguid)
+ .then(res => {
+ if (res.success) {
+ this.setData({ taskStatus });
+ this.getOpenerEventChannel().emit('changeStatusEvent', { subtask: res.data });
+ this.refreshMenuStatus(taskStatus.status)
+ } else {
+ Message.error({
+ context: this,
+ offset: [90, 32],
+ duration: 2000,
+ content: res.message,
+ });
+ }
+ })
+ .finally(() => this.setData({ 'taskStatus.loading': false }));
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
- */
- onUnload() {
-
- },
-
- /**
- * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
- */
- onReachBottom() {
-
- },
-
- /**
- * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
- */
- onShareAppMessage() {
-
- }
-})
\ No newline at end of file
+});
--
Gitblit v1.9.3