From 3282e95db0207ee133d1e98d9771dec9d83b0fc4 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 02 四月 2026 16:24:38 +0800
Subject: [PATCH] 2026.4.2 新增专题管理功能
---
pages/inspection/scene/info/device-status/index.js | 114 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 99 insertions(+), 15 deletions(-)
diff --git a/pages/inspection/scene/info/device-status/index.js b/pages/inspection/scene/info/device-status/index.js
index dd0ceb9..60bf3ce 100644
--- a/pages/inspection/scene/info/device-status/index.js
+++ b/pages/inspection/scene/info/device-status/index.js
@@ -8,9 +8,31 @@
Page({
data: {
+ // 璁惧鐘舵�佽〃鍗曞唴瀹�
formArray: [],
showNewStatus: false,
deviceStatusList: [],
+
+ // 鍥剧墖涓婁紶鍒楄〃
+ fileList: [],
+ // 鍥剧墖灞曠ず鏂瑰紡
+ gridConfig: {
+ column: 3,
+ width: 210,
+ height: 210,
+ },
+ // 鍥剧墖闄愬埗澶у皬
+ sizeLimit: { size: 5, unit: 'MB', message: '鍥剧墖澶у皬涓嶈秴杩�5MB' },
+
+ // 瀹氫綅淇℃伅
+ locations: {
+ // 浣嶇疆鍚嶇О
+ name: '',
+ address: '',
+ // 浣跨敤 gcj02 鍥芥祴灞�鍧愭爣绯�
+ longitude: '',
+ latitude: '',
+ },
},
onLoad(options) {
@@ -18,38 +40,100 @@
if (data) {
const { scene, type, deviceInfo } = data;
defaultForm = deviceStatusForm({
- dlDeviceId: deviceInfo.diId,
+ dlDeviceId: deviceInfo._id,
dlDeviceType: type,
dlSceneGuid: scene.guid,
dlSceneTypeId: scene.typeid,
});
- // console.log(scene);
- // console.log(type);
- // console.log(deviceInfo);
+ this.setData({
+ scene,
+ type,
+ deviceInfo,
+ });
+
+ this.fetchDeviceStatus();
}
});
},
- onAddStatus() {
- this.setData({
- showNewStatus: true,
- formArray: defaultForm
+ fetchDeviceStatus() {
+ const { scene, type, deviceInfo } = this.data;
+ fetchDeviceStatus(scene.guid, deviceInfo._id, type).then(res => {
+ this.setData({
+ deviceStatusList: res.data,
+ });
});
},
- saveNewStatus(e) {
- const { deviceStatusList } = this.data;
- const formObj = e.detail;
- deviceStatusList.push(formObj);
- uploadDeviceStatus(formObj);
+ // 鏄剧ず鏂板璁惧鐘舵�佽緭鍏ヨ〃鍗�
+ onAddStatus() {
this.setData({
- showNewStatus: false,
- deviceStatusList,
+ showNewStatus: true,
+ formArray: defaultForm,
+ fileList: [],
+ locations: {},
});
},
+
+ // 淇濆瓨鏂拌澶囩姸鎬�
+ saveNewStatus(e) {
+ const { deviceStatusList, fileList, locations } = this.data;
+ const formObj = e.detail;
+
+ formObj.dlLocation = locations.address;
+ formObj.dlLongitude = locations.longitude;
+ formObj.dlLatitude = locations.latitude;
+ const images = fileList.map(v => v.url);
+ uploadDeviceStatus(formObj, images).then(res => {
+ // if (res.success) {
+ // deviceStatusList.push(formObj);
+ // this.setData({
+ // showNewStatus: false,
+ // deviceStatusList,
+ // });
+ // }
+ this.setData({
+ showNewStatus: false,
+ });
+ this.fetchDeviceStatus();
+ });
+ },
+ // 鍙栨秷璁惧鐘舵�佽〃鍗曠紪杈�
cancelNewStatus() {
this.setData({
showNewStatus: false,
});
},
+
+ // 鎵嬪姩淇敼瀹氫綅浣嶇疆鎻忚堪
+ handleLocation(e) {},
+
+ // 浠庡湴鍥鹃�夋嫨瀹氫綅
+ chooseLocation() {
+ wx.chooseLocation({
+ success: res => {
+ console.log(res);
+ this.setData({ locations: res });
+ },
+ });
+ },
+
+ // 娣诲姞鍥剧墖
+ handleAddImg(e) {
+ const { fileList } = this.data;
+ const { files } = e.detail;
+ this.setData({
+ fileList: [...fileList, ...files],
+ });
+ },
+ // 绉婚櫎鍥剧墖
+ handleRemoveImg(e) {
+ const { index } = e.detail;
+ const { fileList } = this.data;
+
+ fileList.splice(index, 1);
+ this.setData({
+ fileList,
+ });
+ },
});
--
Gitblit v1.9.3