Ver código fonte

添加条件修改

duy 2 meses atrás
pai
commit
db566e2813
2 arquivos alterados com 67 adições e 33 exclusões
  1. 31 17
      src/views/codeRule/ConditionsSet.vue
  2. 36 16
      src/views/codeRule/ruleManage.vue

+ 31 - 17
src/views/codeRule/ConditionsSet.vue

@@ -76,7 +76,7 @@
                 <div style="color: black;">
                     {{item.codeName}}
                 </div>
-                <i class="el-icon-close" @click.stop="handleDeleteItem(index)"></i>
+                <i class="el-icon-close" @click.stop="handleDeleteItem(item,index)"></i>
                 </div>
                 <div class="code-list">
                 <div v-for="(item1,index) in item.codeValue" :key="index" class="code-item">
@@ -93,7 +93,7 @@
     </div>
     <div slot="footer" class="dialog-footer">
    
-      <el-button type="primary" @click="handleConfirm" :style="{ background: 'rgb(37, 80, 162)', borderColor: 'rgb(37, 80, 162)' }">确认添加</el-button>
+      <el-button type="primary" @click="handleConfirm" :style="{ background: 'rgb(37, 80, 162)', borderColor: 'rgb(37, 80, 162)' }">保存</el-button>
     </div>
 
      <el-dialog
@@ -101,6 +101,7 @@
         :visible.sync="addDialogVisible"
         width="30%"
         append-to-body
+        close-on-click-modal="false"
         >
          <div slot="title" class="dialog-title">
         <div>
@@ -122,7 +123,7 @@
             </el-select>
             </el-form-item>
             <el-form-item label="基础信息">
-            <el-select v-model="addForm.codeValue" placeholder="请选择" multiple style="width: 100%;" @change="handleSelectCode">
+            <el-select v-model="addForm.codeValueList" placeholder="请选择" multiple style="width: 100%;" @change="handleSelectCode">
                 <el-option
                 v-for="item in basicOptions"
                 :key="item.value"
@@ -148,7 +149,7 @@ export default {
   name: 'ConditionsSet',
   data() {
     return {
-      visible: true,
+      visible: false,
        paramList: [
         {
           paramName: '<0.75',
@@ -169,7 +170,7 @@ export default {
        addDialogVisible: false,
         addForm: {
             codeName: '',
-            codeValue: [],
+            codeValueList: [],
             codeValueName: '',
             codeNameId: ''
         },
@@ -180,15 +181,27 @@ export default {
         basicOptions: [
             { value: '1', label: '矿渣硅酸盐水泥' },
             { value: '2', label: '普通酸盐水泥' },
-                 { value: '3', label: '普通酸盐水泥' },
+              { value: '3', label: '普通酸盐水泥' },
             // 添加更多选项...
         ],
 
     }
   },
   methods: {
-    show() {
+    show(val) {
       this.visible = true
+      if(val.length > 0&&val[0].name) {
+        console.log(val,'val');
+        this.paramList = val.map(item => {
+          return {
+            paramName: item.select + item.name,
+            codeList: []
+          }
+        })
+       
+      }else{
+        this.paramList = []
+      }
     },
     hide() {
       this.visible = false  
@@ -211,11 +224,7 @@ export default {
    handleSelect(index) {
       this.activeIndex = index
     },
-    handleSelectCode(value) {
-        if( !value || value.length === 0) {
-          this.addForm.codeValueName = '';
-          return;
-        }
+    handleSelectCode(values) {
       if (!values || values.length === 0) {
         this.addForm.codeValueName = '';
         return;
@@ -227,7 +236,8 @@ export default {
         return option ? option.label : '';
       });
 
-      this.addForm.codeValueName = selectedLabels.join(', ');
+      this.addForm.codeValueName = selectedLabels.join('/');
+         this.addForm.codeValue = values
     },
     handleSelectCodeName(value) {
       if (!value) {
@@ -235,15 +245,18 @@ export default {
         return;
       }
       this.sampleOptions.forEach(option => {
-        if (option.label === value) {
+        if (option.value === value) {
           this.addForm.codeName = option.label;
+       
         }
       });
     },
-    handleDeleteItem(){
-
+    handleDeleteItem(item, index) {
+      this.paramList[this.activeIndex].codeList.splice(index, 1)
+      this.$message.success('删除成功')
     },
     confirmAdd() {
+      if (!this.addForm.codeName || !this.addForm.codeValue) return this.$message.error('请选择样品信息和基础信息')
       this.paramList[this.activeIndex].codeList.push(
         {codeName: this.addForm.codeName,
          codeValue: [
@@ -256,7 +269,8 @@ export default {
         codeValue: []
       }
       this.$message.success('添加成功')
-    }
+    },
+    //保存条件
     
   }
 }

+ 36 - 16
src/views/codeRule/ruleManage.vue

@@ -256,7 +256,7 @@
                   <span>新增</span>
                   <div>
                      <el-button  size="small" style="background: rgb(168, 86, 248);color: white;" icon="el-icon-office-building" @click="conditionsSet">条件设置</el-button>
-                         <el-button  size="small" style="background:rgb(37, 80, 162);;color: white;" icon="el-icon-connection">关联元素</el-button>
+                         <el-button  size="small" style="background:rgb(37, 80, 162);;color: white;" icon="el-icon-connection" @click="linkEle">关联元素</el-button>
                   </div>
                 </div>
                 <div class="add-yp-detail">
@@ -267,8 +267,8 @@
                     <el-form-item label="技术指标">
                       <div class="input-with-icon"  v-for="(item, index) in jsDetail.basic" :key="index">
                         <el-input placeholder="请输入内容" v-model="item.name" class="input-with-select">
-                          <el-select v-model="item.select" slot="prepend" placeholder="符号" style="width: 150px;">
-                            <el-option  v-for="(item1,index) in fqOptions" :key="index" :label="item1.label" :value="item1.label"></el-option>
+                          <el-select v-model="item.select" slot="prepend" placeholder="请选择符号" style="width: 150px;">
+                            <el-option  v-for="(item1,index) in fqOptions" :key="index" :label="item1.label" :value="item1.value"></el-option>
                           </el-select>
                           
                         </el-input>
@@ -368,15 +368,19 @@
       </el-dialog>
 
       <!-- 条件设置 -->
-        <ConditionsSet ref="conditionsSetRef" @confirm="handleConditionsConfirm" @cancel="handleConditionsCancel" />
+        <ConditionsSet ref="conditionsSetRef" @confirm="handleConditionsConfirm" />
+        <!-- 关联元素 -->
+        <LinkEle ref="linkEleRef" @confirm="confirmLinkEle" />
    </div>
 </template>
 <script>
 import {getLazytree} from "@/api/manager/wbsprivate";
 import ConditionsSet from './ConditionsSet.vue'
+import LinkEle from "./LinkEle.vue";
   export default {
   components: {
-    ConditionsSet
+    ConditionsSet,
+    LinkEle
   },
     data() {
       return {
@@ -445,7 +449,7 @@ import ConditionsSet from './ConditionsSet.vue'
         isShowJsList:false,
         jsDetail: {
           name: '',
-          basic: [{ name: '',select:"" }, ]
+          basic: [{ name: '',select:[] }, ]
         },
         jsRuleForm: {
           name: [
@@ -453,12 +457,12 @@ import ConditionsSet from './ConditionsSet.vue'
           ],
         },
         fqOptions: [
-          { label: '大于', value: '大于' },
-          { label: '等于', value: '等于' },
-          { label: '小于', value: '小于' },
-          { label: '大于等于', value: '大于等于' },
-          { label: '小于等于', value: '小于等于' },
-          { label: '不等于', value: '不等于' },
+          { label: '>', value: '>', },
+          { label: '=', value: '=', },
+          { label: '<', value: '<' },
+          { label: '>=', value: '>=' },
+          { label: '<=', value: '<=' },
+          { label: '!=', value: '!=' },
         ],
         conditionsSetVisible:false//条件设置弹窗是否显示
 
@@ -611,7 +615,11 @@ import ConditionsSet from './ConditionsSet.vue'
     },
     //条件设置
     conditionsSet(){
-      this.$refs.conditionsSetRef.show()
+      if(this.jsDetail.basic[0].name === ''|| this.jsDetail.basic[0].select.length === 0) {
+        this.$message.error('请先添加技术指标内容');
+        return;
+      }
+      this.$refs.conditionsSetRef.show(this.jsDetail.basic)
 
     },
     // 添加确认取消处理方法
@@ -620,10 +628,22 @@ import ConditionsSet from './ConditionsSet.vue'
     },
     handleConditionsCancel() {
       console.log('取消条件设置') 
-    }
+    },
+    //关联元素
+    linkEle() {
+      if(!this.jsDetail.basic || this.jsDetail.basic.length === 0) {
+        this.$message.error('请先添加技术指标内容');
+        return;
+      }
+        this.$refs.linkEleRef.show(this.jsDetail.basic)
+    },
+    confirmLinkEle() {
+      console.log('确认关联元素')
+
     
-    }
-  };
+    },
+  }
+  }
 </script>
 
 <style scoped lang="scss">