From 7c3c82d429f86358142adceb080e8922f6a18aa0 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期一, 12 八月 2024 22:43:33 +0800
Subject: [PATCH] 设备信息管理模块

---
 components/form/index.js |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

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 += '/';
           }

--
Gitblit v1.9.3