zouyu
2023-09-06 154d53ca0f4c9a3f1a8433ae4d458f65a81341dc
src/views/standardLibrary/index.vue
@@ -65,22 +65,22 @@
      <el-dialog class="addTree" title="添加标准指标" width="28%" :visible.sync="addTreeFormVisible">
         <el-form v-model="addTreeForm" label-position="top">
            <el-form-item label="标准类型">
               <el-cascader v-model="addTreeForm.addTypeArr" :options="formTypeOptions"
               <el-cascader  v-model="addTreeForm.addTypeArr" :options="formTypeOptions"
                  :props="{ ...defaultProps, checkStrictly: true }" clearable @change="changeCascader"/>
            </el-form-item>
            <el-form-item v-show="addTreeForm.addTypeArr.length < 2" label="物料名称">
               <el-input v-model="addTreeForm.materialName" />
               <el-input @change="changeSample" v-model="addTreeForm.materialName" />
            </el-form-item>
            <el-form-item v-show="addTreeForm.addTypeArr.length < 3" label="执行标准">
               <el-input v-model="addTreeForm.standardName" />
               <el-input  v-model="addTreeForm.standardName" />
            </el-form-item>
            <el-form-item v-show="addTreeForm.addTypeArr.length < 4" label="规格型号">
               <el-input v-model="addTreeForm.specificationsName" />
               <el-input  v-model="addTreeForm.specificationsName" />
            </el-form-item>
         </el-form>
         <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="subAddTreeForm">确 定</el-button>
            <el-button @click="addTreeFormVisible = false">取 消</el-button>
            <el-button @click="clear">取 消</el-button>
         </div>
      </el-dialog>
   </div>
@@ -139,6 +139,11 @@
      watch: {
         filterText(val) {
            this.$refs.tree.filter(val);
         },
         addTreeFormVisible(newVal){
            if(newVal === false){
               this.clear();
            }
         }
      },
      created() {
@@ -146,6 +151,41 @@
      },
      mounted() {},
      methods: {
         clear(){
            this.addTreeFormVisible = false;
            this.addTreeForm.addTypeArr=[];
            this.addTreeForm.specificationsName='';
            this.addTreeForm.materialName=''
            this.addTreeForm.standardName=''
         },
         changeSample(){
            // console.log(this.standardTree);
            // console.log(this.addTreeForm);
            // console.log(this.addTreeForm.addTypeArr.length);
            let selectType=this.standardTree.filter(item=>{
               return item.id===this.addTreeForm.addTypeArr[0]
            })[0];
            if(this.addTreeForm.addTypeArr.length==1){
               let samples=selectType.children.filter(item=>{
                  return item.name===this.addTreeForm.materialName
               })[0]
               if(samples===undefined||samples===[]){
                  this.$message({
                            message: '请先在基础数据中添加该【'+this.addTreeForm.materialName+'】样品',
                            type: 'warning'
                       });
                   return false;
               }
            }
            return true
         },
         oneSize(){},
         twoSize(){
            return true;
         },
         threeSize(){
            return true;
         },
         async initSelect() {
            this.options = [];
            this.versionValue = "";
@@ -318,7 +358,17 @@
            );
         },
         async subAddTreeForm() {
            console.log(this.addTreeForm);
            if(this.addTreeForm.addTypeArr.length==0){
               this.$message({
                            message: '请先选择标准类型!',
                            type: 'warning'
                       });
               return
            }
            let handelerSample=this.changeSample()
            if(!handelerSample){
               return;
            }
            let res = null;
            try {
               switch (this.addTreeForm.addTypeArr.length) {
@@ -348,8 +398,11 @@
            this.addTreeFormVisible = false;
            this.getStandardTree();
            this.getTableByClick(this.selectData, this.versionValue);
            this.addTreeForm=null
            this.addTreeForm.addTypeArr=[]
            this.addTreeForm.addTypeArr=[];
            this.addTreeForm.specificationsName=''
            this.addTreeForm.materialName=''
            this.addTreeForm.standardName=''
            // console.log(this.addTreeForm);
         },
         changeCascader(data) {
            this.addTreeForm.addTypeArr = data;
@@ -381,7 +434,6 @@
                  });
               }
            });
            console.log(this.tableData);
         },
         // 表格树全部选中配置
         // 全选/取消选操作