Przeglądaj źródła

Merge branch 'test' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

yusheng 6 miesięcy temu
rodzic
commit
df84be595d

+ 26 - 15
src/views/rulesManagement/releaseRules/components/experimentationProcess.vue

@@ -104,6 +104,7 @@
               disabled
             ></el-input>
             <el-button type="primary" @click="setEquation">配置公式</el-button>
+            <el-button type="primary" @click="delEquation">重置</el-button>
           </el-form-item>
         </el-form>
       </el-card>
@@ -261,27 +262,16 @@
       // 计算
       calculation() {
         this.getValue();
-        let data = {};
         let equation = [];
         this.list.forEach((item) => {
-          if (item.type == 'customText') {
-            data = { ...item.valueObj, ...data };
-          } else {
-            item.valueObj.rows.forEach((row) => {
-              row.cells.forEach((cell) => {
-                data[cell.id] = cell.value;
-              });
-            });
-          }
           equation.push({
             id: item.id,
             equation: item.equation
           });
         });
         equation.forEach((item) => {
-          console.log(item.equation);
-
           for (const key in item.equation) {
+            let data=this.getObjValue() //每次计算都获取最新的值
             let value = '';
             if (item.equation[key].length) {
               item.equation[key].forEach((equationItem) => {
@@ -303,6 +293,23 @@
           }
         });
       },
+      getObjValue() {
+        this.getValue();
+        let data = {};
+        this.list.forEach((item) => {
+          if (item.type == 'customText') {
+            data = { ...item.valueObj, ...data };
+          } else {
+            item.valueObj.rows.forEach((row) => {
+              row.cells.forEach((cell) => {
+                data[cell.id] = cell.value;
+              });
+            });
+          }
+        });
+        return data || {};
+      },
+
       setEquation() {
         this.getValue();
         this.idList = [];
@@ -311,8 +318,9 @@
             JSON.stringify(this.domObj.equation)
           );
           this.equationUnit.activeIndex = this.domObj.equation.length;
+        } else {
+          this.equationUnit.equation = [];
         }
-
         this.list.forEach((item) => {
           if (item.type == 'customText') {
             for (let key in item.valueObj) {
@@ -328,6 +336,10 @@
         });
         this.visible = true;
       },
+      delEquation() {
+        this.equationUnit.equation = [];
+        this.editInputChange('equation');
+      },
       tagItemDelete(index) {
         this.equationUnit.equation.splice(index, 1);
       },
@@ -393,6 +405,7 @@
       init(list) {
         this.list = JSON.parse(list);
         if (this.list.length) {
+          // this.list[0].id="ozFSPs"
           this.$nextTick(() => {
             this.list.forEach((item) => {
               this.$refs['customTextRef' + item.id][0].init({
@@ -406,7 +419,6 @@
       },
       editShowFn({ templateDivRef, domObj }) {
         this.templateDivRef = templateDivRef;
-        console.log(domObj, 'domObj');
         this.$set(this, 'domObj', domObj);
         this.editShow = true;
       },
@@ -434,7 +446,6 @@
       },
       getValue() {
         this.list.forEach((item, index) => {
-          console.log(item);
           let { form, valueObj, equation } =
             this.$refs['customTextRef' + item.id][0].getValue();
           this.$set(this.list[index], 'value', form);

+ 20 - 9
src/views/rulesManagement/releaseRules/components/templateDiv/customTable.vue

@@ -7,7 +7,11 @@
     <table style="margin-top: 10px" :id="id">
       <thead>
         <tr>
-          <th v-for="(item, index) in columns" class="tableTh">
+          <th
+            v-for="(item, index) in columns"
+            class="tableTh"
+            :style="{ width: item.width + 'px' }"
+          >
             <i
               class="el-icon-delete delete"
               style="display: none"
@@ -20,7 +24,7 @@
               class="templateInput"
               :id="item.id"
               :readonly="item.readonly == 2 || !edit"
-              @click="inputClick(item)"
+              @click="inputClick(item, 'columns')"
             />
           </th>
           <th v-if="edit"></th>
@@ -76,6 +80,7 @@
         equation: {}
       };
     },
+    created() {},
     methods: {
       // 方法:添加新列
       addColumn() {
@@ -131,11 +136,14 @@
       },
       calculation() {
         this.$emit('calculation');
+
       },
       equationValue({ domId, value }) {
         this.rows.forEach((item, index) => {
           let cellIndex = item.cells.findIndex((cell) => cell.id == domId);
-          this.$set(this.rows[index].cells[cellIndex], 'value', value);
+          if (cellIndex != '-1') {
+            this.$set(this.rows[index].cells[cellIndex], 'value', value);
+          }
         });
       },
       getValue() {
@@ -176,15 +184,18 @@
         });
       },
 
-      inputClick(item) {
+      inputClick(item, type) {
         if (!this.edit) {
           return;
         }
+        let dom = document.getElementById(item.id);
+
         this.domId = item.id;
         this.$emit('editShow', {
           templateDivRef: 'customTextRef' + this.id,
           domObj: {
-            isNoWidth: true,
+            width: dom.parentElement.offsetWidth,
+            isNoWidth: type == 'columns' ? false : true,
             id: item.id,
             readonly: item.readonly,
             value: item.value,
@@ -198,10 +209,9 @@
 <style lang="scss" scoped>
   :deep(.templateInput) {
     width: 100%;
-    border: solid 1px #bfbfbf;
-    padding: 1px;
-    margin: 1px;
-    margin-left: 3px;
+    height: 100%;
+    border: none;
+
     text-align: center;
     background-color: #fff;
   }
@@ -214,6 +224,7 @@
     border: 1px solid #ddd;
     padding: 0;
     text-align: center;
+    height: 30px;
   }
   th {
     background-color: #f2f2f2;

+ 9 - 7
src/views/rulesManagement/releaseRules/components/templateDiv/customText.vue

@@ -104,7 +104,6 @@
           '#' + this.id + ' .templateInput'
         );
         let data = {};
-        console.log(inputs, 'inputs');
         if (inputs.length) {
           inputs.forEach((item) => {
             data[item.id] = item.value;
@@ -117,14 +116,18 @@
         };
       },
       equationValue({ domId, value }) {
-        let dom = document.getElementById(domId);
-        this.valueObj[domId] = value;
-        dom.value = value;
+        if (domId) {
+          let dom = document.getElementById(domId);
+          if (dom) {
+            this.valueObj[domId] = value;
+            dom.value = value;
+          }
+        }
       },
       init({ form, valueObj, equation }) {
         this.form = form;
         this.valueObj = valueObj;
-        this.equation = equation||{};
+        this.equation = equation || {};
         this.$nextTick(() => {
           if (!this.edit) {
             let inputs = document.querySelectorAll('.templateInput');
@@ -190,10 +193,9 @@
 
     mounted() {
       this.$nextTick(() => {
-        console.log(document.getElementById(this.id), 'dsd');
         document
           .getElementById(this.id)
-          .addEventListener('change', this.inputChange);
+          .addEventListener('input', this.inputChange);
 
         document
           .getElementById(this.id)