From 7c3c82d429f86358142adceb080e8922f6a18aa0 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期一, 12 八月 2024 22:43:33 +0800
Subject: [PATCH] 设备信息管理模块
---
common/dataProductionDeviceType.js | 2
pages/inspection/scene/info/device-info/index.js | 83 ++++++++++++--------
components/picker/location-picker/index.json | 1
project.private.config.json | 2
pages/inspection/scene/info/index.js | 2
app.json | 1
pages/inspection/scene/info/device-info-items.js | 8 +
pages/inspection/scene/info/device-info/index.wxss | 4
pages/inspection/scene/info/device-info/index.wxml | 29 +-----
components/form/index.js | 21 +++-
components/form/index.wxml | 17 +++-
common/dataTreatmentDeviceType.js | 2
pages/inspection/scene/info/devicelist-proxy.js | 13 ++
common/dataMonitorDeviceType.js | 2
14 files changed, 108 insertions(+), 79 deletions(-)
diff --git a/app.json b/app.json
index 7629f21..7bd1298 100644
--- a/app.json
+++ b/app.json
@@ -71,6 +71,7 @@
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-collapse": "tdesign-miniprogram/collapse/collapse",
"t-collapse-panel": "tdesign-miniprogram/collapse-panel/collapse-panel",
+ "t-cascader": "tdesign-miniprogram/cascader/cascader",
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-tabs": "tdesign-miniprogram/tabs/tabs",
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
diff --git a/common/dataMonitorDeviceType.js b/common/dataMonitorDeviceType.js
index aee97bd..5f122fb 100644
--- a/common/dataMonitorDeviceType.js
+++ b/common/dataMonitorDeviceType.js
@@ -54,7 +54,7 @@
case '6':
return vocDeviceType;
default:
- return dustDeviceTypebreak;
+ return dustDeviceType;
}
}
diff --git a/common/dataProductionDeviceType.js b/common/dataProductionDeviceType.js
index 208e785..916109e 100644
--- a/common/dataProductionDeviceType.js
+++ b/common/dataProductionDeviceType.js
@@ -54,7 +54,7 @@
case '6':
return vocDeviceType;
default:
- return dustDeviceTypebreak;
+ return dustDeviceType;
}
}
diff --git a/common/dataTreatmentDeviceType.js b/common/dataTreatmentDeviceType.js
index e9ba1ec..734bc25 100644
--- a/common/dataTreatmentDeviceType.js
+++ b/common/dataTreatmentDeviceType.js
@@ -54,7 +54,7 @@
case '6':
return vocDeviceType;
default:
- return dustDeviceTypebreak;
+ return dustDeviceType;
}
}
diff --git a/components/form/index.js b/components/form/index.js
index c699b42..0429870 100644
--- a/components/form/index.js
+++ b/components/form/index.js
@@ -40,9 +40,6 @@
onSwitchChange(e) {
const { index } = e.currentTarget.dataset;
const { value } = e.detail;
- // const { formArray } = this.data;
- // formArray[index].value = value;
- // this.setData({ formArray });
this.setData({
[`formArray[${index}].value`]: value,
});
@@ -57,6 +54,7 @@
const { label, value } = e.detail;
this.setData({
[`formArray[${index}].visible`]: false,
+ [`formArray[${index}]._value`]: value,
[`formArray[${index}].value`]: {
label: label[0],
value: value[0],
@@ -75,9 +73,18 @@
this.setData({ [`formArray[${index}].visible`]: true });
},
onCascaderChange(e) {
+ const { index } = e.currentTarget.dataset;
const { selectedOptions, value } = e.detail;
- console.log(selectedOptions);
- console.log(value);
+ const note = this._note(selectedOptions);
+ const v = selectedOptions.map(v => {
+ return { label: v.label, value: v.value };
+ });
+ this.setData({
+ [`formArray[${index}].visible`]: false,
+ [`formArray[${index}]._value`]: value,
+ [`formArray[${index}].note`]: note,
+ [`formArray[${index}].value`]: v,
+ });
},
// 淇濆瓨
@@ -85,7 +92,7 @@
const formObj = {};
this.data.formArray.forEach(e => {
if (e.inputType == 'picker') {
- formObj[e.name] = e.value.value;
+ formObj[e.name] = e.value ? e.value.value : e.value;
} else {
formObj[e.name] = e.value;
}
@@ -100,7 +107,7 @@
_note(v) {
let note = '';
v.forEach(o => {
- if (note != o.label && o.value > 0) {
+ if (note != o.label) {
if (note != '') {
note += '/';
}
diff --git a/components/form/index.wxml b/components/form/index.wxml
index b1ab81e..aa1c372 100644
--- a/components/form/index.wxml
+++ b/components/form/index.wxml
@@ -1,4 +1,4 @@
-<block wx:for="{{formArr}}" wx:key="index">
+<block wx:for="{{formArray}}" wx:key="index">
<block wx:if="{{item.inputType == 'text'}}">
<t-input
label="{{item.label}}"
@@ -19,9 +19,17 @@
</t-cell>
</block>
<block wx:elif="{{item.inputType == 'picker'}}">
+ <t-cell
+ title="{{item.label}}"
+ arrow
+ hover
+ note="{{item.value.label || item.placeholder}}"
+ data-index="{{index}}"
+ bind:click="showPicker"
+ ></t-cell>
<t-picker
visible="{{item.visible}}"
- value="{{item.value}}"
+ value="{{item._value}}"
data-index="{{index}}"
title="{{'閫夋嫨' + item.label}}"
cancelBtn="鍙栨秷"
@@ -34,17 +42,16 @@
</block>
<block wx:elif="{{item.inputType == 'cascader'}}">
<t-cell
- bordered="{{false}}"
title="{{item.label}}"
arrow
hover
- note="{{item.note}}"
+ note="{{item.note || item.placeholder}}"
data-index="{{index}}"
bind:click="showCascader"
></t-cell>
<t-cascader
visible="{{item.visible}}"
- value="{{item.value}}"
+ value="{{item._value}}"
options="{{item.options}}"
sub-titles="{{item.cascaderTitles}}"
title="{{'閫夋嫨' + item.label}}"
diff --git a/components/picker/location-picker/index.json b/components/picker/location-picker/index.json
index f29aed3..78013bd 100644
--- a/components/picker/location-picker/index.json
+++ b/components/picker/location-picker/index.json
@@ -1,6 +1,5 @@
{
"component": true,
"usingComponents": {
- "t-cascader": "tdesign-miniprogram/cascader/cascader"
}
}
\ No newline at end of file
diff --git a/pages/inspection/scene/info/device-info-items.js b/pages/inspection/scene/info/device-info-items.js
index e34449c..f293483 100644
--- a/pages/inspection/scene/info/device-info-items.js
+++ b/pages/inspection/scene/info/device-info-items.js
@@ -9,7 +9,7 @@
* 鐢熸垚涓�鏉¤〃鍗曟潯鐩�
* @param {String} _label 鏍囩鍚嶇О
* @param {String} _name 瀛楁鍚嶇О
- * @param {String} _type 杈撳叆绫诲瀷 锛坱ext: 杈撳叆妗�; switch: 鍒囨崲鎸夐挳; picker: 涓嬫媺妗嗛�夐」锛�
+ * @param {String} _type 杈撳叆绫诲瀷 锛坱ext: 杈撳叆妗�; switch: 鍒囨崲鎸夐挳; picker: 涓嬫媺妗嗛�夐」; cascader: 绾ц仈閫夋嫨锛�
* @param {Boolean} _required 鏄惁涓哄繀濉」
* @param {Array} _options 褰撹緭鍏ョ被鍨嬩负picker鏃讹紝鎻愪緵鍙�夐」
*/
@@ -17,13 +17,15 @@
return {
required: _required,
label: _label,
- placeholder: '璇疯緭鍏�' + _label,
+ placeholder: (_type == 'text' ? '璇疯緭鍏�' : '璇烽�夋嫨') + _label,
name: _name,
- value: _type == 'switch' ? false : null,
+ value: null,
status: 'success',
tips: _label + '涓嶈兘涓虹┖',
inputType: _type,
options: _options,
+ cascaderTitles: ['1', '2'],
+ visible: false,
};
}
diff --git a/pages/inspection/scene/info/device-info/index.js b/pages/inspection/scene/info/device-info/index.js
index b850077..1a18400 100644
--- a/pages/inspection/scene/info/device-info/index.js
+++ b/pages/inspection/scene/info/device-info/index.js
@@ -14,42 +14,56 @@
},
onLoad(options) {
- if (options.type) {
- this.setData({ deviceType: parseInt(options.type) });
- let barTitle, _formArr;
- switch (options.type) {
- case '0':
- barTitle = '鏂板鐩戞祴璁惧';
- _formArr = monitorDeviceForm;
- break;
- case '1':
- barTitle = '鏂板娌荤悊璁惧';
- _formArr = treatmentDeviceForm;
- break;
- case '2':
- barTitle = '鏂板鐢熶骇璁惧';
- _formArr = productionDeviceForm;
- break;
- default:
- barTitle = '璁惧淇℃伅';
- _formArr = monitorDeviceForm;
- break;
+ this.getOpenerEventChannel().on('acceptDeviceData', data => {
+ if (data) {
+ const { scene, type, mode } = data;
+ let barTitle, _formArr;
+ switch (type) {
+ case 0:
+ barTitle = '鏂板鐩戞祴璁惧';
+ _formArr = monitorDeviceForm(scene.typeid);
+ break;
+ case 1:
+ barTitle = '鏂板娌荤悊璁惧';
+ _formArr = treatmentDeviceForm(scene.typeid);
+ break;
+ case 2:
+ barTitle = '鏂板鐢熶骇璁惧';
+ _formArr = productionDeviceForm(scene.typeid);
+ break;
+ default:
+ barTitle = '璁惧淇℃伅';
+ _formArr = monitorDeviceForm(scene.typeid);
+ break;
+ }
+ wx.setNavigationBarTitle({
+ title: barTitle,
+ });
+ this.setData({
+ formArray: _formArr,
+ scene,
+ deviceType: type,
+ mode,
+ });
}
- wx.setNavigationBarTitle({
- title: barTitle,
- });
- this.setData({ formArray: _formArr });
- }
- if (options.mode == 'add' || options.mode == 'update') {
- this.setData({ mode: options.mode });
- }
+ });
},
// 鎻愪氦琛ㄥ崟
submit(e) {
- const formArr = e.detail;
+ const formObj = e.detail;
+ const { mode, scene } = this.data;
+ formObj.diSceneGuid = scene.guid;
+ formObj.diSceneTypeId = scene.typeid;
+ formObj.diTypeId = formObj._type[0].value;
+ formObj.diSubtypeId = formObj._type[1].value;
+ if (mode == 'add') {
+ this.addDevice(formObj);
+ } else {
+ this.updateDevice(formObj);
+ }
console.log('submit');
- console.log(formArr);
+ console.log(formObj);
},
// 鍙栨秷琛ㄥ崟
@@ -60,13 +74,16 @@
// 鏂板璁惧淇℃伅
addDevice(formObj) {
const { deviceType } = this.data;
- formObj.diSceneGuid
- formObj.diSceneTypeId
uploadDevice(formObj, deviceType).then(res => {
console.log(res);
});
},
// 鏇存柊璁惧淇℃伅
- updateDevice() {},
+ updateDevice() {
+ const { deviceType } = this.data;
+ updateDevice(formObj, deviceType).then(res => {
+ console.log(res);
+ });
+ },
});
diff --git a/pages/inspection/scene/info/device-info/index.wxml b/pages/inspection/scene/info/device-info/index.wxml
index b77403b..ab483a3 100644
--- a/pages/inspection/scene/info/device-info/index.wxml
+++ b/pages/inspection/scene/info/device-info/index.wxml
@@ -1,22 +1,7 @@
-<!-- <t-input label="绔欑偣鍚嶇О" placeholder="璇疯緭鍏ョ珯鐐瑰悕绉�" model:value="{{diName}}" />
-<t-input label="MN缂栧彿" placeholder="璇疯緭鍏N缂栧彿" model:value="{{diMnCode}}" />
-<t-input label="璁惧绫诲瀷" placeholder="璇疯緭鍏ヨ澶囩被鍨�" model:value="{{diType}}" />
-<t-input label="渚涘簲鍟�" placeholder="璇疯緭鍏ヤ緵搴斿晢" model:value="{{diSupplier}}" />
-<t-input label="杩愮淮鍟�" placeholder="璇疯緭鍏ヨ繍缁村晢" model:value="{{diMaintainer}}" />
-<t-cell title="鏄惁涓婄嚎">
- <t-switch
- model:value="{{diRunningStatus}}"
- defaultValue="{{true}}"
- label="{{['鏄�', '鍚�']}}"
- slot="note"
- />
-</t-cell>
-<t-cell title="鏄惁鎷嗛櫎">
- <t-switch
- model:value="{{diRemoved}}"
- defaultValue="{{false}}"
- label="{{['鏄�', '鍚�']}}"
- slot="note"
- />
-</t-cell> -->
-<t-form formArr="{{formArray}}" bind:submit="submit" bind:cancel="cancel"></t-form>
+<view class="page">
+ <view class="page-header"> </view>
+ <view class="page-container">
+ <t-form formArr="{{formArray}}" bind:submit="submit" bind:cancel="cancel"></t-form>
+ </view>
+ <view class="page-footer"></view>
+</view>
diff --git a/pages/inspection/scene/info/device-info/index.wxss b/pages/inspection/scene/info/device-info/index.wxss
index 6733d32..4d754fc 100644
--- a/pages/inspection/scene/info/device-info/index.wxss
+++ b/pages/inspection/scene/info/device-info/index.wxss
@@ -1 +1,3 @@
-/* pages/inspection/scene/info/device-info/index.wxss */
\ No newline at end of file
+.page .page-container {
+ padding: 0;
+}
\ No newline at end of file
diff --git a/pages/inspection/scene/info/devicelist-proxy.js b/pages/inspection/scene/info/devicelist-proxy.js
index ef5fe3b..0a259f4 100644
--- a/pages/inspection/scene/info/devicelist-proxy.js
+++ b/pages/inspection/scene/info/devicelist-proxy.js
@@ -32,9 +32,18 @@
},
addNewDevice(e) {
const { type } = e.currentTarget.dataset;
+ const { scene } = this.data;
wx.navigateTo({
- url: `/pages/inspection/scene/info/device-info/index?type=${type}`,
- })
+ url: `/pages/inspection/scene/info/device-info/index`,
+ success: function (res) {
+ // 閫氳繃 eventChannel 鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+ res.eventChannel.emit('acceptDeviceData', {
+ type,
+ scene,
+ mode: 'add',
+ });
+ },
+ });
},
},
});
diff --git a/pages/inspection/scene/info/index.js b/pages/inspection/scene/info/index.js
index 660b5db..afaca46 100644
--- a/pages/inspection/scene/info/index.js
+++ b/pages/inspection/scene/info/index.js
@@ -5,7 +5,7 @@
behaviors: [useDeviceList, useDeviceLocation],
data: {
// 鍦烘櫙鍩烘湰淇℃伅
- sceneInfo:{},
+ scene:{},
// 鐩戞祴璁惧淇℃伅
monitorDevices:[],
// 娌荤悊璁惧淇℃伅
diff --git a/project.private.config.json b/project.private.config.json
index 0fb58ef..93cc1f6 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -1,6 +1,6 @@
{
"description": "椤圭洰绉佹湁閰嶇疆鏂囦欢銆傛鏂囦欢涓殑鍐呭灏嗚鐩� project.config.json 涓殑鐩稿悓瀛楁銆傞」鐩殑鏀瑰姩浼樺厛鍚屾鍒版鏂囦欢涓�傝瑙佹枃妗o細https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
- "projectname": "ep-law-abiding-manage",
+ "projectname": "ep-law-abiding-manage-weixin",
"setting": {
"compileHotReLoad": true,
"urlCheck": false
--
Gitblit v1.9.3