From 1a0e4972f80278bfa9e53283374b745b6c968341 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 13 八月 2024 17:30:57 +0800
Subject: [PATCH] 设备信息管理模块
---
pages/inspection/scene/info/device-info/index.js | 43 +-
pages/inspection/scene/info/index.js | 6
pages/inspection/scene/info/index.wxml | 3
pages/inspection/scene/info/device-status/index.json | 11
pages/inspection/scene/info/index.wxss | 4
pages/inspection/scene/info/device-info/index.wxml | 7
common/dataTreatmentDeviceType.js | 17 +
pages/inspection/scene/info/devicelist.wxss | 70 ++++
pages/inspection/scene/info/devicelist.wxml | 58 +++
pages/inspection/scene/info/devicelist-proxy.js | 47 +++
services/inspection/fetchDevice.js | 2
common/dataProductionDeviceType.js | 17 +
config/index.js | 4
model/device.js | 59 +++
pages/inspection/scene/util.wxs | 30 ++
pages/inspection/scene/info/device-status/index.wxss | 1
pages/inspection/scene/info/device-status/index.wxml | 30 ++
pages/inspection/scene/info/device-status/index.js | 55 +++
app.json | 3
/dev/null | 12
pages/inspection/scene/info/device-info-items.js | 80 +++-
components/form/index.js | 31 +
components/form/form-util.js | 119 +++++++
components/form/index.wxml | 135 +++++----
common/dataMonitorDeviceType.js | 33 +
25 files changed, 725 insertions(+), 152 deletions(-)
diff --git a/app.json b/app.json
index 7bd1298..47b86b1 100644
--- a/app.json
+++ b/app.json
@@ -34,7 +34,8 @@
"pages/inspection/scene/index",
"pages/inspection/scene/search/index",
"pages/inspection/scene/info/index",
- "pages/inspection/scene/info/device-info/index"
+ "pages/inspection/scene/info/device-info/index",
+ "pages/inspection/scene/info/device-status/index"
],
"tabBar": {
"custom": true,
diff --git a/common/dataMonitorDeviceType.js b/common/dataMonitorDeviceType.js
index 5f122fb..6558bfa 100644
--- a/common/dataMonitorDeviceType.js
+++ b/common/dataMonitorDeviceType.js
@@ -39,23 +39,38 @@
// 鐩戞祴璁惧绫诲瀷
function monitorDevices(sceneType) {
- switch (sceneType) {
+ switch (parseInt(sceneType)) {
// 宸ュ湴,鐮佸ご,鎼呮媽绔�,鍫嗗満
- case '1':
- case '2':
- case '3':
- case '14':
+ case 1:
+ case 2:
+ case 3:
+ case 14:
return dustDeviceType;
// 椁愰ギ
- case '5':
+ case 5:
return fumeDeviceType;
// 宸ヤ笟浼佷笟,姹戒慨
- case '4':
- case '6':
+ case 4:
+ case 6:
return vocDeviceType;
default:
return dustDeviceType;
}
}
-export { monitorDevices };
+function toLabel(sceneType, valueArr) {
+ const labelArr = [];
+ let options = monitorDevices(sceneType);
+ valueArr.forEach(v => {
+ if (options) {
+ const op = options.find(o => {
+ return o.value == v;
+ });
+ labelArr.push(op.label);
+ options = options[0].children;
+ }
+ });
+ return labelArr;
+}
+
+export { monitorDevices, toLabel };
diff --git a/common/dataProductionDeviceType.js b/common/dataProductionDeviceType.js
index 916109e..abaac5b 100644
--- a/common/dataProductionDeviceType.js
+++ b/common/dataProductionDeviceType.js
@@ -58,4 +58,19 @@
}
}
-export { productionDevices };
+function toLabel(sceneType, valueArr) {
+ const labelArr = [];
+ let options = productionDevices(sceneType);
+ valueArr.forEach(v => {
+ if (options) {
+ const op = options.find(o => {
+ return o.value == v;
+ });
+ labelArr.push(op.label);
+ options = options.children;
+ }
+ });
+ return labelArr;
+}
+
+export { productionDevices, toLabel };
diff --git a/common/dataTreatmentDeviceType.js b/common/dataTreatmentDeviceType.js
index 734bc25..c518f8f 100644
--- a/common/dataTreatmentDeviceType.js
+++ b/common/dataTreatmentDeviceType.js
@@ -58,4 +58,19 @@
}
}
-export { treatmentDevices };
+function toLabel(sceneType, valueArr) {
+ const labelArr = [];
+ let options = treatmentDevices(sceneType);
+ valueArr.forEach(v => {
+ if (options) {
+ const op = options.find(o => {
+ return o.value == v;
+ });
+ labelArr.push(op.label);
+ options = options.children;
+ }
+ });
+ return labelArr;
+}
+
+export { treatmentDevices, toLabel };
diff --git a/components/form/form-util.js b/components/form/form-util.js
new file mode 100644
index 0000000..9286ddf
--- /dev/null
+++ b/components/form/form-util.js
@@ -0,0 +1,119 @@
+/**
+ * 鐢熸垚涓�鏉¤〃鍗曟潯鐩�
+ * @param {String} _label 鏍囩鍚嶇О
+ * @param {String} _name 瀛楁鍚嶇О
+ * @param {String} _type 杈撳叆绫诲瀷 锛坱ext: 杈撳叆妗�; switch: 鍒囨崲鎸夐挳; picker: 涓嬫媺妗嗛�夐」; cascader: 绾ц仈閫夋嫨锛�
+ * @param {Boolean} _required 鏄惁涓哄繀濉」
+ * @param {Array} _options 褰撹緭鍏ョ被鍨嬩负picker鎴朿ascader鏃讹紝鎻愪緵鍙�夐」
+ * @param {Array} cascaderTitles 褰撹緭鍏ョ被鍨嬩负cascader鏃讹紝鎻愪緵姣忓眰閫夐」鐨勬爣棰�
+ * @param {Array} referItems 褰撹緭鍏ョ被鍨嬩负cascader鏃讹紝鎻愪緵鍏宠仈鐨勫睘鎬ame
+ */
+function baseInputItem(
+ _label,
+ _name,
+ _required,
+ _type = 'text',
+ _options = [],
+ cascaderTitles,
+ referItems,
+) {
+ return {
+ required: _required,
+ label: _label,
+ placeholder: (_type == 'text' ? '璇疯緭鍏�' : '璇烽�夋嫨') + _label,
+ name: _name,
+ value: null,
+ status: 'success',
+ tips: _label + '涓嶈兘涓虹┖',
+ inputType: _type,
+ options: _options,
+ cascaderTitles: cascaderTitles,
+ referItems: referItems,
+ visible: false,
+ };
+}
+
+/**
+ * 闅愯棌鏉$洰锛屼竴鑸槸涓婁紶鏃剁殑蹇呰鏉$洰淇℃伅锛屼絾鏄笉闇�瑕佸睍绀虹粰鐢ㄦ埛鍋氫慨鏀�
+ * @param {String} _label
+ * @param {String} _name
+ */
+function hideInputItem(_label, _name) {
+ const item = baseInputItem(_label, _name);
+ item.hide = true;
+ return item;
+}
+
+/**
+ * 濉厖鍒濆鏁版嵁
+ * @param {Array} items 琛ㄥ崟鏉$洰鏁扮粍
+ * @param {Object} defaultValue 鍒濆鏁版嵁
+ */
+function setDefaultValue(items, defaultValue) {
+ if (typeof defaultValue === 'object') {
+ items.forEach(e => {
+ // 鏂囨湰鍜屽紑鍏崇被鍨嬬洿鎺ヨ祴鍊�
+ if (e.inputType == 'text' || e.inputType == 'switch') {
+ if (defaultValue.hasOwnProperty(e.name)) {
+ e.value = defaultValue[e.name];
+ }
+ }
+ // 涓嬫媺妗嗛櫎浜嗚祴鍊硷紝闇�瑕侀澶栬祴鍊煎睘鎬value(鏁扮粍绫诲瀷锛岀粍浠秚-picker鐨勭壒鎬�)
+ else if (e.inputType == 'picker') {
+ if (defaultValue.hasOwnProperty(e.name)) {
+ e.value = defaultValue[e.name] + '';
+ e._value = [e.value];
+ const op = e.options.find(o=>{
+ return o.value == e.value
+ })
+ e._label = op.label
+ }
+ }
+ // 绾ц仈閫夋嫨鍣紝鏍规嵁灞炴�eferItems鎵惧埌瀵瑰簲鐨勫垵濮嬫暟鎹�
+ else if (e.inputType == 'cascader') {
+ const selectedOptions = [];
+ let value,
+ note,
+ options = e.options;
+ e.referItems.forEach(r => {
+ if (defaultValue.hasOwnProperty(r)) {
+ const o = options.find(v => {
+ return v.value == defaultValue[r];
+ });
+ selectedOptions.push(o);
+ options = options[0].children;
+ }
+ });
+ if (selectedOptions.length > 0) {
+ value = selectedOptions[selectedOptions.length - 1].value;
+ note = cascaderNote(selectedOptions);
+ const v = selectedOptions.map(v => {
+ return v.value;
+ });
+ e.value = v;
+ e._value = value;
+ e.note = note;
+ }
+ }
+ });
+ }
+}
+
+/**
+ * 绾ц仈閫夋嫨鍣ㄩ�夋嫨缁撴灉鏍煎紡鍖�
+ * @param {Array} v
+ */
+function cascaderNote(v) {
+ let note = '';
+ v.forEach(o => {
+ if (note != o.label) {
+ if (note != '') {
+ note += '/';
+ }
+ note += o.label;
+ }
+ });
+ return note;
+}
+
+export { baseInputItem, hideInputItem, setDefaultValue, cascaderNote };
diff --git a/components/form/index.js b/components/form/index.js
index 0429870..ef2114e 100644
--- a/components/form/index.js
+++ b/components/form/index.js
@@ -1,4 +1,9 @@
+import { cascaderNote } from './form-util.js';
+
Component({
+ options: {
+ multipleSlots: true, // 鍦ㄧ粍浠跺畾涔夋椂鐨勯�夐」涓惎鐢ㄥslot鏀寔
+ },
properties: {
/**
* 琛ㄥ崟杈撳叆妗嗛噰鐢═-design妗嗘灦涓嬬殑Input缁勪欢
@@ -10,7 +15,7 @@
* value: 鐪熷疄鍊�,
* status: 杈撳叆妗嗙姸鎬併�傚彲閫夐」锛歴uccess/warning/error,
* tips: 杈撳叆妗嗕笅鏂规彁绀烘枃鏈紝浼氭牴鎹笉鍚岀殑 status 鍛堢幇涓嶅悓鐨勬牱寮�,
- * inputType: 杈撳叆绫诲瀷 锛坱ext: 杈撳叆妗嗭紱switch锛氬垏鎹㈡寜閽�; picker: 涓嬫媺妗嗛�夐」; cascader: 绾ц仈閫夋嫨锛�,
+ * inputType: 杈撳叆绫诲瀷 (text: 杈撳叆妗�; switch: 鍒囨崲鎸夐挳; picker: 涓嬫媺妗嗛�夐」; cascader: 绾ц仈閫夋嫨),
* options: 褰撹緭鍏ョ被鍨嬩负picker鎴朿ascader鏃讹紝鎻愪緵鍙�夐」,
* cascaderTitles: 褰撹緭鍏ョ被鍨嬩负cascader鏃讹紝鎻愪緵姣忎釜閫夐」鐨勬爣棰�,
*/
@@ -20,6 +25,14 @@
observer(v) {
this.setData({ formArray: v });
},
+ },
+ submitText: {
+ type: String,
+ value: '淇濆瓨',
+ },
+ cancelText: {
+ type: String,
+ value: '鍙栨秷',
},
},
@@ -55,10 +68,8 @@
this.setData({
[`formArray[${index}].visible`]: false,
[`formArray[${index}]._value`]: value,
- [`formArray[${index}].value`]: {
- label: label[0],
- value: value[0],
- },
+ [`formArray[${index}]._label`]: label[0],
+ [`formArray[${index}].value`]: value[0],
});
},
onPickerCancel(e) {
@@ -75,9 +86,9 @@
onCascaderChange(e) {
const { index } = e.currentTarget.dataset;
const { selectedOptions, value } = e.detail;
- const note = this._note(selectedOptions);
+ const note = cascaderNote(selectedOptions);
const v = selectedOptions.map(v => {
- return { label: v.label, value: v.value };
+ return v.value;
});
this.setData({
[`formArray[${index}].visible`]: false,
@@ -92,7 +103,11 @@
const formObj = {};
this.data.formArray.forEach(e => {
if (e.inputType == 'picker') {
- formObj[e.name] = e.value ? e.value.value : e.value;
+ formObj[e.name] = e.value;
+ } else if (e.inputType == 'cascader') {
+ e.referItems.forEach((r, i) => {
+ formObj[r] = e.value[i];
+ });
} else {
formObj[e.name] = e.value;
}
diff --git a/components/form/index.wxml b/components/form/index.wxml
index aa1c372..cf20497 100644
--- a/components/form/index.wxml
+++ b/components/form/index.wxml
@@ -1,67 +1,82 @@
<block wx:for="{{formArray}}" wx:key="index">
- <block wx:if="{{item.inputType == 'text'}}">
- <t-input
- label="{{item.label}}"
- placeholder="{{item.placeholder}}"
- value="{{item.value}}"
- data-index="{{index}}"
- bind:change="onInputChange"
- />
- </block>
- <block wx:elif="{{item.inputType == 'switch'}}">
- <t-cell title="{{item.label}}">
- <t-switch
- label="{{['鏄�', '鍚�']}}"
- slot="note"
+ <block wx:if="{{!item.hide}}">
+ <block wx:if="{{item.inputType == 'text'}}">
+ <t-input
+ label="{{item.label}}"
+ placeholder="{{item.placeholder}}"
+ value="{{item.value}}"
data-index="{{index}}"
- bind:change="onSwitchChange"
+ bind:change="onInputChange"
/>
- </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}}"
- data-index="{{index}}"
- title="{{'閫夋嫨' + item.label}}"
- cancelBtn="鍙栨秷"
- confirmBtn="纭"
- bindchange="onPickerChange"
- bindcancel="onPickerCancel"
- >
- <t-picker-item options="{{item.options}}"></t-picker-item>
- </t-picker>
- </block>
- <block wx:elif="{{item.inputType == 'cascader'}}">
- <t-cell
- title="{{item.label}}"
- arrow
- hover
- note="{{item.note || item.placeholder}}"
- data-index="{{index}}"
- bind:click="showCascader"
- ></t-cell>
- <t-cascader
- visible="{{item.visible}}"
- value="{{item._value}}"
- options="{{item.options}}"
- sub-titles="{{item.cascaderTitles}}"
- title="{{'閫夋嫨' + item.label}}"
- data-index="{{index}}"
- bind:change="onCascaderChange"
- />
+ </block>
+ <block wx:elif="{{item.inputType == 'switch'}}">
+ <t-cell title="{{item.label}}">
+ <t-switch
+ defaultValue="{{item.value}}"
+ label="{{['鏄�', '鍚�']}}"
+ slot="note"
+ data-index="{{index}}"
+ bind:change="onSwitchChange"
+ />
+ </t-cell>
+ </block>
+ <block wx:elif="{{item.inputType == 'picker'}}">
+ <t-cell
+ title="{{item.label}}"
+ arrow
+ hover
+ note="{{item._label || item.placeholder}}"
+ data-index="{{index}}"
+ bind:click="showPicker"
+ ></t-cell>
+ <t-picker
+ visible="{{item.visible}}"
+ value="{{item._value}}"
+ data-index="{{index}}"
+ title="{{'閫夋嫨' + item.label}}"
+ cancelBtn="鍙栨秷"
+ confirmBtn="纭"
+ bindchange="onPickerChange"
+ bindcancel="onPickerCancel"
+ >
+ <t-picker-item options="{{item.options}}"></t-picker-item>
+ </t-picker>
+ </block>
+ <block wx:elif="{{item.inputType == 'cascader'}}">
+ <t-cell
+ title="{{item.label}}"
+ arrow
+ hover
+ note="{{item.note || item.placeholder}}"
+ data-index="{{index}}"
+ bind:click="showCascader"
+ ></t-cell>
+ <t-cascader
+ visible="{{item.visible}}"
+ value="{{item._value}}"
+ options="{{item.options}}"
+ sub-titles="{{item.cascaderTitles}}"
+ title="{{'閫夋嫨' + item.label}}"
+ data-index="{{index}}"
+ bind:change="onCascaderChange"
+ />
+ </block>
</block>
</block>
-
+<slot></slot>
<view class="btn-group">
- <t-button block theme="light" content="鍙栨秷" size="small" bind:tap="onCancel"></t-button>
- <t-button block theme="primary" content="淇濆瓨" size="small" bind:tap="onSubmit"></t-button>
+ <t-button
+ block
+ theme="light"
+ content="{{cancelText}}"
+ size="small"
+ bind:tap="onCancel"
+ ></t-button>
+ <t-button
+ block
+ theme="primary"
+ content="{{submitText}}"
+ size="small"
+ bind:tap="onSubmit"
+ ></t-button>
</view>
diff --git a/config/index.js b/config/index.js
index 439c3e7..c04e5c0 100644
--- a/config/index.js
+++ b/config/index.js
@@ -8,8 +8,8 @@
const baseFileUrl = `${bu}/meeting/file/`;
// 绾夸笂鐩戠
-const inspectUrl = 'https://fyami.com.cn:447';
-// const inspectUrl = 'http://192.168.0.138:8082';
+// const inspectUrl = 'https://fyami.com.cn:447';
+const inspectUrl = 'http://192.168.0.138:8082';
const iu = 'https://fyami.com.cn:447';
const inspectPicUrl = `${iu}/images/`;
diff --git a/model/device.js b/model/device.js
new file mode 100644
index 0000000..506b788
--- /dev/null
+++ b/model/device.js
@@ -0,0 +1,59 @@
+import dayjs from 'dayjs';
+import { toLabel as toLabelFreq } from '../common/dataMaintainFrequency';
+import { toLabel as toLabelOwner } from '../common/dataOwnership';
+import { toLabel as toLabelStatus } from '../common/dataRunningStatus';
+import { toLabel as toLabelMonitor } from '../common/dataMonitorDeviceType';
+import { toLabel as toLabelTreatment } from '../common/dataTreatmentDeviceType';
+import { toLabel as toLabelProduction } from '../common/dataProductionDeviceType';
+
+// 鐩戞祴璁惧
+export function getMonitorDevice(data) {
+ data._updateTime = dayjs(data.diUpdateTime).format('YYYY骞碝M鏈圖D鏃�');
+ data._maintainFrequency = toLabelFreq(data.diMaintainFrequency);
+ data._ownership = toLabelOwner(data.diOwnership);
+ data._runningStatus = toLabelStatus(data.diRunningStatus);
+ const labelArr = toLabelMonitor(data.diSceneTypeId, [data.diTypeId, data.diSubtypeId]);
+ data._type = labelArr[0];
+ data._subType = labelArr[1];
+ return data
+}
+
+// 娌荤悊璁惧
+export function getTreatmentDevice(data) {
+ data._updateTime = dayjs(data.piUpdateTime).format('YYYY骞碝M鏈圖D鏃�');
+ data._maintainFrequency = toLabelFreq(data.piMaintainFrequency);
+ data._ownership = toLabelOwner(data.piOwnership);
+ data._runningStatus = toLabelStatus(data.piRunningStatus);
+ const labelArr = toLabelTreatment(data.piSceneTypeId, [data.piTypeId, data.piSubtypeId]);
+ data._type = labelArr[0];
+ data._subType = labelArr[1];
+ return data
+}
+
+// 鐢熶骇璁惧
+export function getProductionDevice(data) {
+ data._updateTime = dayjs(data.wiUpdateTime).format('YYYY骞碝M鏈圖D鏃�');
+ data._ownership = toLabelOwner(data.wiOwnership);
+ data._runningStatus = toLabelStatus(data.wiRunningStatus);
+ const labelArr = toLabelProduction(data.wiSceneTypeId, [data.wiTypeId, data.wiSubtypeId]);
+ data._type = labelArr[0];
+ data._subType = labelArr[1];
+ return data
+}
+
+export function getDeviceList(dataList, deviceType) {
+ return dataList.map(item => {
+ // 鐩戞祴璁惧
+ if (deviceType == 0) {
+ return getMonitorDevice(item);
+ }
+ // 娌荤悊璁惧
+ else if (deviceType == 1) {
+ return getTreatmentDevice(item);
+ }
+ // 鐢熶骇璁惧
+ else if (deviceType == 2) {
+ return getProductionDevice(item);
+ }
+ });
+}
diff --git a/pages/inspection/scene/info/device-info-items.js b/pages/inspection/scene/info/device-info-items.js
index f293483..e3b9907 100644
--- a/pages/inspection/scene/info/device-info-items.js
+++ b/pages/inspection/scene/info/device-info-items.js
@@ -1,3 +1,4 @@
+import { baseInputItem, hideInputItem, setDefaultValue } from "../../../../components/form/form-util.js";
import { monitorDevices } from '../../../../common/dataMonitorDeviceType';
import { treatmentDevices } from '../../../../common/dataTreatmentDeviceType';
import { productionDevices } from '../../../../common/dataProductionDeviceType';
@@ -6,38 +7,30 @@
import { ownership } from '../../../../common/dataOwnership';
/**
- * 鐢熸垚涓�鏉¤〃鍗曟潯鐩�
- * @param {String} _label 鏍囩鍚嶇О
- * @param {String} _name 瀛楁鍚嶇О
- * @param {String} _type 杈撳叆绫诲瀷 锛坱ext: 杈撳叆妗�; switch: 鍒囨崲鎸夐挳; picker: 涓嬫媺妗嗛�夐」; cascader: 绾ц仈閫夋嫨锛�
- * @param {Boolean} _required 鏄惁涓哄繀濉」
- * @param {Array} _options 褰撹緭鍏ョ被鍨嬩负picker鏃讹紝鎻愪緵鍙�夐」
- */
-function baseInputItem(_label, _name, _required, _type = 'text', _options = []) {
- return {
- required: _required,
- label: _label,
- placeholder: (_type == 'text' ? '璇疯緭鍏�' : '璇烽�夋嫨') + _label,
- name: _name,
- value: null,
- status: 'success',
- tips: _label + '涓嶈兘涓虹┖',
- inputType: _type,
- options: _options,
- cascaderTitles: ['1', '2'],
- visible: false,
- };
-}
-
-/**
* 鐩戞祴璁惧琛ㄥ崟
+ * @param {Number} sceneType 鍦烘櫙绫诲瀷锛堥缇界洃绠$郴缁燂級
+ * @param {Object} defaultValue 琛ㄥ崟榛樿鍊�
*/
-export function monitorDeviceForm(sceneType) {
- return [
+export function monitorDeviceForm(sceneType, defaultValue) {
+ const items = [
+ hideInputItem('id', 'diId'),
+ hideInputItem('鍒涘缓鏃堕棿', 'diCreateTime'),
+ hideInputItem('鏇存柊鏃堕棿', 'diUpdateTime'),
+ hideInputItem('鍦烘櫙id', 'diSceneGuid'),
+ hideInputItem('鍦烘櫙绫诲瀷', 'diSceneTypeId'),
+
baseInputItem('绔欑偣鍚嶇О', 'diName', true),
baseInputItem('璁惧缂栧彿', 'diDeviceCode'),
// 璁惧绫诲瀷鍜岃澶囧瓙绫诲悎骞剁敤绾ц仈閫夋嫨鍣ㄥ睍绀�
- baseInputItem('璁惧绫诲瀷', '_type', true, 'cascader', monitorDevices(sceneType)),
+ baseInputItem(
+ '璁惧绫诲瀷',
+ '_type',
+ true,
+ 'cascader',
+ monitorDevices(sceneType),
+ ['閫夋嫨璁惧绫诲瀷', '閫夋嫨璁惧瀛愮被'],
+ ['diTypeId', 'diSubtypeId'],
+ ),
// baseInputItem('璁惧绫诲瀷', 'diTypeId', true, 'picker'),
// baseInputItem('璁惧瀛愮被', 'diSubtypeId', true, 'picker'),
baseInputItem('渚涘簲鍟�', 'diSupplier'),
@@ -54,12 +47,17 @@
// baseInputItem('鏍囪瘑浜岀淮鐮�', 'DI_QR_Code'),
// baseInputItem('鍏朵粬绗笁鏂规垨璁惧鑷甫浜岀淮鐮�', 'DI_Other_QR_Code'),
];
+
+ // 濉厖榛樿鏁版嵁
+ setDefaultValue(items, defaultValue);
+
+ return items;
}
/**
* 娌荤悊璁惧琛ㄥ崟
*/
-export function treatmentDeviceForm(sceneType) {
+export function treatmentDeviceForm(sceneType, defaultValue) {
return [
baseInputItem('绔欑偣鍚嶇О', 'diName', true),
baseInputItem('璁惧缂栧彿', 'diDeviceCode'),
@@ -74,7 +72,7 @@
/**
* 鐢熶骇璁惧琛ㄥ崟
*/
-export function productionDeviceForm(sceneType) {
+export function productionDeviceForm(sceneType, defaultValue) {
return [
baseInputItem('绔欑偣鍚嶇О', 'diName', true),
baseInputItem('璁惧缂栧彿', 'diDeviceCode'),
@@ -85,3 +83,27 @@
baseInputItem('鏄惁鎷嗛櫎', 'diRemoved', true, 'switch'),
];
}
+
+/**
+ * 璁惧鐘舵�佽〃鍗�
+ */
+export function deviceStatusForm(defaultValue) {
+ return [
+ hideInputItem('id', 'dlId'),
+ hideInputItem('璁惧id', 'dlDeviceId'),
+ hideInputItem('璁惧绫诲瀷', 'dlDeviceType'),
+ hideInputItem('鍦烘櫙id', 'dlSceneGuid'),
+ hideInputItem('鍦烘櫙绫诲瀷', 'dlSceneTypeId'),
+ hideInputItem('鐜板満鍥剧墖', 'dlPicUrl'),
+ hideInputItem('鐜板満瑙嗛', 'dlVideoUrl'),
+ hideInputItem('鍒涘缓鏃堕棿', 'dlCreateTime'),
+ hideInputItem('鏇存柊鏃堕棿', 'dlUpdateTime'),
+
+ baseInputItem('璁惧浣嶇疆', 'DL_Location', true),
+ baseInputItem('缁忓害', 'DL_Longitude'),
+ baseInputItem('缁村害', 'DL_Latitude', true),
+ baseInputItem('鏄惁瑙勮寖', 'DL_Standard', true, 'switch'),
+ baseInputItem('涓嶈鑼冨師鍥�', 'DL_UnStandard_Reason'),
+ baseInputItem('杩愯鐘舵��', 'DL_Real_Time_Status', true, 'picker', status),
+ ];
+}
\ No newline at end of file
diff --git a/pages/inspection/scene/info/device-info/index.js b/pages/inspection/scene/info/device-info/index.js
index 1a18400..dcb8b4d 100644
--- a/pages/inspection/scene/info/device-info/index.js
+++ b/pages/inspection/scene/info/device-info/index.js
@@ -11,29 +11,39 @@
deviceType: 0,
// 妯″紡锛宎dd: 鏂板璁惧锛泆pdate锛氭洿鏂拌澶�
mode: 'add',
+ submitText: '淇濆瓨',
},
onLoad(options) {
this.getOpenerEventChannel().on('acceptDeviceData', data => {
if (data) {
- const { scene, type, mode } = data;
- let barTitle, _formArr;
+ const { scene, type, mode, deviceInfo } = data;
+ let barTitle = mode == 'add' ? '鏂板':'淇敼', _formArr;
switch (type) {
- case 0:
- barTitle = '鏂板鐩戞祴璁惧';
- _formArr = monitorDeviceForm(scene.typeid);
- break;
case 1:
- barTitle = '鏂板娌荤悊璁惧';
- _formArr = treatmentDeviceForm(scene.typeid);
+ barTitle += '娌荤悊璁惧';
+ let defaultValue1 = mode == 'update' ? deviceInfo : {
+ piSceneGuid: scene.guid,
+ piSceneTypeId: scene.typeid,
+ }
+ _formArr = treatmentDeviceForm(scene.typeid, defaultValue1);
break;
case 2:
- barTitle = '鏂板鐢熶骇璁惧';
- _formArr = productionDeviceForm(scene.typeid);
+ barTitle += '鐢熶骇璁惧';
+ let defaultValue2 = mode == 'update' ? deviceInfo : {
+ wiSceneGuid: scene.guid,
+ wiSceneTypeId: scene.typeid,
+ }
+ _formArr = productionDeviceForm(scene.typeid, defaultValue2);
break;
+ case 0:
default:
- barTitle = '璁惧淇℃伅';
- _formArr = monitorDeviceForm(scene.typeid);
+ barTitle += '鐩戞祴璁惧';
+ let defaultValue0 = mode == 'update' ? deviceInfo : {
+ diSceneGuid: scene.guid,
+ diSceneTypeId: scene.typeid,
+ }
+ _formArr = monitorDeviceForm(scene.typeid, defaultValue0);
break;
}
wx.setNavigationBarTitle({
@@ -44,6 +54,7 @@
scene,
deviceType: type,
mode,
+ submitText: mode == 'add' ? '淇濆瓨' : '鏇存柊',
});
}
});
@@ -52,11 +63,7 @@
// 鎻愪氦琛ㄥ崟
submit(e) {
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;
+ const { mode } = this.data;
if (mode == 'add') {
this.addDevice(formObj);
} else {
@@ -80,7 +87,7 @@
},
// 鏇存柊璁惧淇℃伅
- updateDevice() {
+ updateDevice(formObj) {
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 ab483a3..41d5bd2 100644
--- a/pages/inspection/scene/info/device-info/index.wxml
+++ b/pages/inspection/scene/info/device-info/index.wxml
@@ -1,7 +1,12 @@
<view class="page">
<view class="page-header"> </view>
<view class="page-container">
- <t-form formArr="{{formArray}}" bind:submit="submit" bind:cancel="cancel"></t-form>
+ <t-form
+ formArr="{{formArray}}"
+ submit-text="{{submitText}}"
+ bind:submit="submit"
+ bind:cancel="cancel"
+ ></t-form>
</view>
<view class="page-footer"></view>
</view>
diff --git a/pages/inspection/scene/info/device-location-proxy.js b/pages/inspection/scene/info/device-location-proxy.js
deleted file mode 100644
index 8293cac..0000000
--- a/pages/inspection/scene/info/device-location-proxy.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 璁惧瀹夎浣嶇疆淇℃伅绠$悊
- */
-export const useDeviceLocation = Behavior({
- data: {
- showNewLocation: false,
- newLocation: {},
- deviceLocationList: [],
- },
- methods: {
- onAddLocation() {
- this.setData({
- showNewLocation: true,
- newLocation: {},
- });
- },
-
- saveNewLocation(e) {
- const { deviceLocationList } = this.data;
- deviceLocationList.push(e.detail);
- debugger
- this.setData({
- showNewLocation: false,
- deviceLocationList,
- });
- },
- cancelNewLocation() {
- this.setData({
- showNewLocation: false,
- });
- },
- },
-});
diff --git a/pages/inspection/scene/info/device-location.wxml b/pages/inspection/scene/info/device-location.wxml
deleted file mode 100644
index 57d090d..0000000
--- a/pages/inspection/scene/info/device-location.wxml
+++ /dev/null
@@ -1,12 +0,0 @@
-<block wx:for="{{deviceLocationList}}">
- <device-location index="{{index + 1}}" read-only="{{true}}" location="{{item}}"></device-location>
-</block>
-<t-button wx:if="{{!showNewLocation}}" theme="light" size="small" bind:tap="onAddLocation"
- >鏂板浣嶇疆鍙樻洿淇℃伅</t-button
->
-<device-location
- wx:if="{{showNewLocation}}"
- location="{{newLocation}}"
- bind:cancel="cancelNewLocation"
- bind:confirm="saveNewLocation"
-></device-location>
diff --git a/pages/inspection/scene/info/device-status/index.js b/pages/inspection/scene/info/device-status/index.js
new file mode 100644
index 0000000..dd0ceb9
--- /dev/null
+++ b/pages/inspection/scene/info/device-status/index.js
@@ -0,0 +1,55 @@
+import { deviceStatusForm } from '../device-info-items.js';
+import {
+ fetchDeviceStatus,
+ uploadDeviceStatus,
+} from '../../../../../services/inspection/fetchDevice';
+
+var defaultForm = deviceStatusForm();
+
+Page({
+ data: {
+ formArray: [],
+ showNewStatus: false,
+ deviceStatusList: [],
+ },
+
+ onLoad(options) {
+ this.getOpenerEventChannel().on('acceptDeviceStatusData', data => {
+ if (data) {
+ const { scene, type, deviceInfo } = data;
+ defaultForm = deviceStatusForm({
+ dlDeviceId: deviceInfo.diId,
+ dlDeviceType: type,
+ dlSceneGuid: scene.guid,
+ dlSceneTypeId: scene.typeid,
+ });
+ // console.log(scene);
+ // console.log(type);
+ // console.log(deviceInfo);
+ }
+ });
+ },
+
+ onAddStatus() {
+ this.setData({
+ showNewStatus: true,
+ formArray: defaultForm
+ });
+ },
+
+ saveNewStatus(e) {
+ const { deviceStatusList } = this.data;
+ const formObj = e.detail;
+ deviceStatusList.push(formObj);
+ uploadDeviceStatus(formObj);
+ this.setData({
+ showNewStatus: false,
+ deviceStatusList,
+ });
+ },
+ cancelNewStatus() {
+ this.setData({
+ showNewStatus: false,
+ });
+ },
+});
diff --git a/pages/inspection/scene/info/device-status/index.json b/pages/inspection/scene/info/device-status/index.json
new file mode 100644
index 0000000..dbb95aa
--- /dev/null
+++ b/pages/inspection/scene/info/device-status/index.json
@@ -0,0 +1,11 @@
+{
+ "navigationBarTitleText": "璁惧鐘舵��",
+ "onReachBottomDistance": 10,
+ "backgroundTextStyle": "light",
+ "navigationBarTextStyle": "white",
+ "navigationBarBackgroundColor": "#389AFF",
+ "usingComponents": {
+ "device-location": "../components/device-location/index",
+ "t-form": "/components/form/index"
+ }
+}
\ No newline at end of file
diff --git a/pages/inspection/scene/info/device-status/index.wxml b/pages/inspection/scene/info/device-status/index.wxml
new file mode 100644
index 0000000..1908ff0
--- /dev/null
+++ b/pages/inspection/scene/info/device-status/index.wxml
@@ -0,0 +1,30 @@
+<view class="page">
+ <view class="page-header">
+ <t-button
+ wx:if="{{!showNewStatus}}"
+ icon="add"
+ theme="primary"
+ size="small"
+ bind:tap="onAddStatus"
+ >娣诲姞璁惧鐘舵��</t-button
+ >
+ <t-form
+ wx:if="{{showNewStatus}}"
+ formArr="{{formArray}}"
+ bind:submit="saveNewStatus"
+ bind:cancel="cancelNewStatus"
+ >
+ <view>sssss</view>
+ </t-form>
+ </view>
+ <view class="page-container">
+ <block wx:for="{{deviceStatusList}}">
+ <device-location
+ index="{{index + 1}}"
+ read-only="{{true}}"
+ location="{{item}}"
+ ></device-location>
+ </block>
+ </view>
+ <view class="page-footer"></view>
+</view>
diff --git a/pages/inspection/scene/info/device-status/index.wxss b/pages/inspection/scene/info/device-status/index.wxss
new file mode 100644
index 0000000..b682203
--- /dev/null
+++ b/pages/inspection/scene/info/device-status/index.wxss
@@ -0,0 +1 @@
+/* pages/inspection/scene/info/device-status/index.wxss */
\ 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 0a259f4..3039815 100644
--- a/pages/inspection/scene/info/devicelist-proxy.js
+++ b/pages/inspection/scene/info/devicelist-proxy.js
@@ -1,3 +1,5 @@
+import { fetchDevices, fetchDeviceStatus } from '../../../../services/inspection/fetchDevice';
+
/**
* 璁惧淇℃伅绠$悊
*/
@@ -26,8 +28,17 @@
],
},
methods: {
+ fetchDeviceInfo(deviceTypeId) {
+ const { scene } = this.data;
+ fetchDevices(scene.guid, deviceTypeId).then(res => {
+ this.setData({
+ [`categories[${deviceTypeId}].items`]: res.data,
+ });
+ });
+ },
onSideBarChange(e) {
const { value } = e.detail;
+ this.fetchDeviceInfo(this.data.categories[value].type)
this.setData({ sideBarIndex: value });
},
addNewDevice(e) {
@@ -45,5 +56,41 @@
},
});
},
+ updateDevice(e) {
+ const { type, index } = e.currentTarget.dataset;
+ const { scene, categories } = this.data;
+ const [i0, i1] = index;
+ const deviceInfo = categories[i0].items[i1];
+ wx.navigateTo({
+ url: `/pages/inspection/scene/info/device-info/index`,
+ success: function (res) {
+ // 閫氳繃 eventChannel 鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+ res.eventChannel.emit('acceptDeviceData', {
+ type,
+ scene,
+ mode: 'update',
+ deviceInfo,
+ });
+ },
+ });
+ },
+
+ updateStatus(e) {
+ const { type, index } = e.currentTarget.dataset;
+ const { scene, categories } = this.data;
+ const [i0, i1] = index;
+ const deviceInfo = categories[i0].items[i1];
+ wx.navigateTo({
+ url: `/pages/inspection/scene/info/device-status/index`,
+ success: function (res) {
+ // 閫氳繃 eventChannel 鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+ res.eventChannel.emit('acceptDeviceStatusData', {
+ type,
+ scene,
+ deviceInfo,
+ });
+ },
+ });
+ }
},
});
diff --git a/pages/inspection/scene/info/devicelist.wxml b/pages/inspection/scene/info/devicelist.wxml
index 76cd924..0a98617 100644
--- a/pages/inspection/scene/info/devicelist.wxml
+++ b/pages/inspection/scene/info/devicelist.wxml
@@ -20,13 +20,65 @@
show-scrollbar="{{false}}"
>
<block wx:if="{{item.items.length > 0}}">
- <view class="title">
- <view>{{item.title || item.label}}</view>
+ <view class="title flex-h">
+ <span>{{item.title || item.label}}</span>
+ <t-button
+ t-class="side-btn"
+ theme="primary"
+ icon="add"
+ content="娣诲姞"
+ size="extra-small"
+ data-type="{{item.type}}"
+ bind:tap="addNewDevice"
+ ></t-button>
</view>
+ <block wx:for="{{item.items}}" wx:key="index1" wx:for-item="device" wx:for-index="index1">
+ <view class="scene__item" >
+ <view class="flex-h" style="align-items: flex-start">
+ <view class="scene__item-name">{{device.diName}} </view>
+ <view>
+ <t-tag
+ max-width="{{130}}"
+ shape="square"
+ size="small"
+ theme="success"
+ variant="light-outline"
+ >{{device._type}}</t-tag
+ >
+ </view>
+ </view>
+ <view class="flex-h">
+ <view class="scene__item-abstract">缂栧彿锛歿{device.diDeviceCode}} </view>
+ <view class="scene__item-abstract">{{device._runningStatus}} </view>
+ </view>
+ <view class="scene__item-abstract">鏇存柊鏃堕棿锛歿{device._updateTime}} </view>
+ <t-divider />
+ <view class="scene__item-tag__wrap flex-h">
+ <t-button
+ block
+ theme="light"
+ content="璁惧淇℃伅"
+ size="extra-small"
+ data-type="{{item.type}}"
+ data-index="{{[index, index1]}}"
+ bind:tap="updateDevice"
+ ></t-button>
+ <t-button
+ block
+ theme="light"
+ content="鐘舵�佸彉鏇�"
+ size="extra-small"
+ data-type="{{item.type}}"
+ data-index="{{[index, index1]}}"
+ bind:tap="updateStatus"
+ ></t-button>
+ </view>
+ </view>
+ </block>
</block>
<block wx:else>
<t-empty-page description="{{'鏆傛棤' + item.label + '淇℃伅'}}" />
- <view style="display: flex; justify-content: space-between">
+ <view class="flex-h">
<t-button
theme="primary"
icon="add"
diff --git a/pages/inspection/scene/info/devicelist.wxss b/pages/inspection/scene/info/devicelist.wxss
index 52d4b05..4c4a23a 100644
--- a/pages/inspection/scene/info/devicelist.wxss
+++ b/pages/inspection/scene/info/devicelist.wxss
@@ -1,6 +1,6 @@
.side-bar-wrapper {
display: flex;
- height: 90vh;
+ height: 80vh;
overflow: hidden;
}
@@ -16,7 +16,7 @@
}
.side-bar-wrapper .title {
- padding-left: 40rpx;
+ padding: 0 10rpx;
margin-bottom: 8rpx;
}
@@ -25,3 +25,69 @@
height: 96rpx;
border: 2rpx solid #e7e7e7;
}
+
+.flex-h {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.flex-v {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+}
+
+.scene__item-tag__wrap {
+ position: relative;
+ display: flex;
+ align-items: center;
+ gap: 2px;
+}
+
+.scene__item {
+ margin: 0 10rpx;
+ background-color: var(--td-bg-color-fade);
+ border-radius: var(--td-border-radius);
+ box-shadow: var(--td-shadow-1);
+ padding: var(--td-spacer);
+ margin-top: var(--td-spacer);
+ color: var(--td-text-color-primary);
+}
+
+/* .scene__item:active {
+ background-color: var(--td-gray-color-1);
+} */
+
+.scene__item .scene__item-name {
+ --ei-font-size: var(--td-font-size-base);
+ --ei-line-height: calc(var(--td-text-line-height) * var(--ei-font-size));
+ font-size: var(--ei-font-size);
+ line-height: var(--ei-line-height);
+ height: calc(var(--ei-line-height) * 2);
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.scene__item-abstract {
+ font-size: var(--td-font-size-s);
+ color: var(--td-text-color-secondary);
+}
+
+.scene__nav-icon {
+ position: relative;
+ bottom: 0px;
+ right: 0px;
+ display: flex;
+ justify-content: flex-end;
+ /* margin-top: var(--td-spacer); */
+ /* background-color: blanchedalmond; */
+}
+
+.side-btn {
+ margin: initial !important;
+}
\ No newline at end of file
diff --git a/pages/inspection/scene/info/index.js b/pages/inspection/scene/info/index.js
index afaca46..b80d78d 100644
--- a/pages/inspection/scene/info/index.js
+++ b/pages/inspection/scene/info/index.js
@@ -1,8 +1,7 @@
import { useDeviceList } from './devicelist-proxy.js';
-import { useDeviceLocation } from './device-location-proxy.js';
Page({
- behaviors: [useDeviceList, useDeviceLocation],
+ behaviors: [useDeviceList],
data: {
// 鍦烘櫙鍩烘湰淇℃伅
scene:{},
@@ -20,6 +19,9 @@
this.setData({
scene: data.scene,
});
+ [0, 1, 2].forEach(e => {
+ this.fetchDeviceInfo(e);
+ });
}
});
},
diff --git a/pages/inspection/scene/info/index.wxml b/pages/inspection/scene/info/index.wxml
index 30fc202..6f7bd61 100644
--- a/pages/inspection/scene/info/index.wxml
+++ b/pages/inspection/scene/info/index.wxml
@@ -14,9 +14,6 @@
<t-tab-panel label="璁惧淇℃伅" value="{{1}}" class="custom-tab-panel">
<include src="./devicelist.wxml" />
</t-tab-panel>
- <!-- <t-tab-panel label="璁惧浣嶇疆" value="{{3}}" class="custom-tab-panel">
- <include src="./device-location.wxml" />
- </t-tab-panel> -->
</t-tabs>
</view>
<view class="page-footer"></view>
diff --git a/pages/inspection/scene/info/index.wxss b/pages/inspection/scene/info/index.wxss
index d9066a3..4833483 100644
--- a/pages/inspection/scene/info/index.wxss
+++ b/pages/inspection/scene/info/index.wxss
@@ -1,5 +1,9 @@
@import './devicelist.wxss';
+.page {
+ /* background-color: white; */
+}
+
.page .page-container {
padding: 0;
}
diff --git a/pages/inspection/scene/util.wxs b/pages/inspection/scene/util.wxs
new file mode 100644
index 0000000..e426fab
--- /dev/null
+++ b/pages/inspection/scene/util.wxs
@@ -0,0 +1,30 @@
+module.exports = {
+ // 璁惧杩愯鐘舵��
+ runningStatus: function (s) {
+ switch (parseInt(s)) {
+ case 0:
+ return '鏈仈缃�';
+ case 1:
+ return '涓婄嚎涓�';
+ case 2:
+ return '宸蹭笅绾�';
+ case 3:
+ default:
+ return '宸叉媶闄�';
+ }
+ },
+ // 璁惧绫诲瀷
+ runningStatus: function (s) {
+ switch (parseInt(s)) {
+ case 0:
+ return '鏈仈缃�';
+ case 1:
+ return '涓婄嚎涓�';
+ case 2:
+ return '宸蹭笅绾�';
+ case 3:
+ default:
+ return '宸叉媶闄�';
+ }
+ },
+};
diff --git a/services/inspection/fetchDevice.js b/services/inspection/fetchDevice.js
index 6962897..8fbd1ad 100644
--- a/services/inspection/fetchDevice.js
+++ b/services/inspection/fetchDevice.js
@@ -5,6 +5,7 @@
import { get, post, put } from '../baseRequset';
import { inspectUrl, inspectPicUrl } from '../../config/index';
import { transSceneType } from '../../model/sceneType';
+import { getDeviceList } from '../../model/device';
/**
* 鑾峰彇鍦烘櫙璁惧鍩烘湰淇℃伅
@@ -22,6 +23,7 @@
},
inspectUrl,
).then(res => {
+ res.data.data = getDeviceList(res.data.data, deviceTypeId);
return res.data;
});
}
--
Gitblit v1.9.3