Browse Source

化学品类型 子类修改

dedsudiyu 2 weeks ago
parent
commit
421db9f2ac

+ 8 - 9
src/api/chemicalManage/index.js

@@ -661,13 +661,12 @@ export function chemicalStockStockCollectDetailsList(data) {
     data: data
   })
 }
-
-
-
-
-
-
-
-
-
+//根据code查询化学品类型
+export function systemDictChemicalType(query) {
+  return request({
+    url: '/system/dict/chemicalType',
+    method: 'get',
+    params: query
+  })
+}
 

+ 30 - 40
src/views/chemicalManage/basicManagement/chemicalInfo/index.vue

@@ -6,19 +6,13 @@
         <el-form :model="queryParams" class="form-box" ref="queryForm"
                  :inline="true" style="width:100%;">
           <el-form-item label="" prop="chemicalCategory">
-            <!--<el-select v-model="queryParams.chemicalCategory" clearable placeholder="请选择类别" style="width: 200px">-->
-              <!--<el-option-->
-                <!--v-for="dict in optionListA"-->
-                <!--:key="dict.value"-->
-                <!--:label="dict.label"-->
-                <!--:value="dict.value"-->
-              <!--/>-->
-            <!--</el-select>-->
             <el-cascader
+              ref="queryParamsCascader"
+              @change="handleChange"
               v-model="queryParams.chemicalCategory"
               :options="optionListA"
-              :props="{ checkStrictly: true ,emitPath:false }"
-              :show-all-levels="false"
+              :props="{ checkStrictly: true }"
+              :show-all-levels="true"
             ></el-cascader>
           </el-form-item>
           <el-form-item label="" prop="chemicalLevel">
@@ -111,7 +105,7 @@
 </template>
 <script>
   import { getDicts } from "@/api/commonality/noPermission";
-  import { chemicalChemicalList,chemicalChemicalDelete } from "@/api/chemicalManage/index";
+  import { chemicalChemicalList,chemicalChemicalDelete,systemDictChemicalType } from "@/api/chemicalManage/index";
   import addChemicals from "@/views/chemicalManage/components/addChemicals.vue";
   import importComponent from "@/components/importComponent/importComponent.vue";
   import exportComponent from "@/components/exportComponent/exportComponent.vue";
@@ -152,7 +146,7 @@
           page:1,
           pageSize:20,
           searchValue:"",
-          chemicalCategory :null,
+          chemicalCategory :[],
           chemicalLevel :null,
         },
         selectedNum:0,
@@ -174,32 +168,8 @@
     methods: {
       //获取化学品类别
       getDicts(){
-        getDicts('chemicals_category').then(response => {
-          // this.$set(this,'optionListA',response.data);
-          this.$set(this,'optionListA',[
-            {
-              value: '1',
-              label: '1',
-              children:[{
-                value: '1-1',
-                label: '1-1',
-              },{
-                value: '1-2',
-                label: '1-2',
-              }],
-            },
-            {
-              value: '2',
-              label: '2',
-              children:[{
-                value: '2-1',
-                label: '2-1',
-              },{
-                value: '2-2',
-                label: '2-2',
-              }],
-            }
-          ]);
+        systemDictChemicalType({dictCode:'chemicals_category'}).then(response => {
+          this.$set(this,'optionListA',response.data);
         });
       },
       //查询按钮
@@ -217,7 +187,7 @@
           page:1,
           pageSize:20,
           searchValue:"",
-          chemicalCategory :null,
+          chemicalCategory :[],
           chemicalLevel :null,
         });
         this.$set(this.exportConfig,'ids','');
@@ -229,8 +199,25 @@
       },
       //获取数据列表
       getList(){
+        let self = this;
         this.$set(this,'loading',true);
-        chemicalChemicalList(this.queryParams).then(response => {
+        let obj = {
+          page:this.queryParams.page,
+          pageSize:this.queryParams.pageSize,
+          searchValue:this.queryParams.searchValue,
+          chemicalLevel :this.queryParams.chemicalLevel,
+        };
+        if(this.queryParams.chemicalCategory[1]){
+          obj.chemicalCategory = this.queryParams.chemicalCategory[0]
+          obj.chemicalCategoryClass = this.queryParams.chemicalCategory[1]
+        }else if(this.queryParams.chemicalCategory[0]){
+          obj.chemicalCategory = this.queryParams.chemicalCategory[0]
+          obj.chemicalCategoryClass = null
+        }else{
+          obj.chemicalCategory = null
+          obj.chemicalCategoryClass = null
+        }
+        chemicalChemicalList(obj).then(response => {
           this.$set(this,'loading',false);
           this.$set(this,'dataList',response.data.records);
           this.$set(this,'total',response.data.total);
@@ -281,6 +268,9 @@
       getRowKeys(row) {
         return row.chemicalId
       },
+      handleChange(value, selectedData) {
+        this.$refs.queryParamsCascader.dropDownVisible = false;
+      },
     },
   }
 </script>

+ 28 - 42
src/views/chemicalManage/components/addChemicals.vue

@@ -36,15 +36,9 @@
         </el-form-item>
         <div>
           <el-form-item label="类别:" prop="chemicalCategory" label-width="130px">
-            <!--<el-select v-model="dialogForm.chemicalCategory" placeholder="请选择类别" style="width: 245px">-->
-              <!--<el-option-->
-                <!--v-for="dict in categoryOptions"-->
-                <!--:key="dict.value"-->
-                <!--:label="dict.label"-->
-                <!--:value="dict.value"-->
-              <!--/>-->
-            <!--</el-select>-->
             <el-cascader
+              ref="addCascader"
+              @change="addHandleChange"
               style="width:245px;"
               v-model="dialogForm.chemicalCategory"
               :options="categoryOptions"
@@ -126,7 +120,7 @@
 </template>
 <script>
   import { getDicts } from "@/api/commonality/noPermission";
-  import { chemicalChemicalAdd,chemicalChemicalUpdate,chemicalChemicalDetail } from "@/api/chemicalManage/index";
+  import { chemicalChemicalAdd,chemicalChemicalUpdate,chemicalChemicalDetail,systemDictChemicalType } from "@/api/chemicalManage/index";
   export default {
     name: 'addChemicals',
     data () {
@@ -141,7 +135,7 @@
         stateOfMatter:[],
         dialogForm:{
           chemicalName:null,
-          chemicalCategory:"1",
+          chemicalCategory:[],
           chemicalLevel:1,
           casNum:null,
           anotherName:null,
@@ -184,7 +178,7 @@
           this.initialize();
           this.$set(this,'dialogForm',{
             chemicalName:null,
-            chemicalCategory:'1',
+            chemicalCategory:[],
             chemicalLevel:1,
             casNum:null,
             anotherName:null,
@@ -197,10 +191,9 @@
           this.$set(this,'lookImgDialogType',true);
         }else if(type == 2){
           chemicalChemicalDetail({chemicalId:row.chemicalId}).then(response => {
-            this.$set(this,'dialogForm',{
+            let obj = {
               chemicalId:row.chemicalId,
               chemicalName:response.data.chemicalName,
-              chemicalCategory:response.data.chemicalCategory,
               chemicalLevel:response.data.chemicalLevel,
               casNum:response.data.casNum,
               anotherName:response.data.anotherName,
@@ -209,7 +202,13 @@
               depositRequire:response.data.depositRequire+'',
               depositUnit:response.data.depositUnit,
               relativeDensity:response.data.relativeDensity,
-            });
+            };
+            if(response.data.chemicalCategoryClass){
+              obj.chemicalCategory = [response.data.chemicalCategory,response.data.chemicalCategoryClass]
+            }else{
+              obj.chemicalCategory = [response.data.chemicalCategory]
+            }
+            this.$set(this,'dialogForm',obj);
             this.$set(this,'lookImgDialogTitle','编辑');
             this.$set(this,'lookImgDialogType',true);
           });
@@ -222,32 +221,8 @@
       //初始化
       initialize(){
         //化学品类别字典
-        getDicts('chemicals_category').then(response => {
-          // this.$set(this,'categoryOptions',response.data);
-          this.$set(this,'categoryOptions',[
-            {
-              value: '1',
-              label: '1',
-              children:[{
-                value: '1-1',
-                label: '1-1',
-              },{
-                value: '1-2',
-                label: '1-2',
-              }],
-            },
-            {
-              value: '2',
-              label: '2',
-              children:[{
-                value: '2-1',
-                label: '2-1',
-              },{
-                value: '2-2',
-                label: '2-2',
-              }],
-            }
-          ]);
+        systemDictChemicalType({dictCode:'chemicals_category'}).then(response => {
+          this.$set(this,'categoryOptions',response.data);
         });
         //存放单位
         getDicts('storage_unit').then(response => {
@@ -265,14 +240,22 @@
                 return
               }
             }
+            let obj = JSON.parse(JSON.stringify(this.dialogForm))
+            if(obj.chemicalCategory[1]){
+              obj.chemicalCategoryClass = obj.chemicalCategory[1]
+              obj.chemicalCategory = obj.chemicalCategory[0]
+            }else{
+              obj.chemicalCategoryClass = null;
+              obj.chemicalCategory = obj.chemicalCategory[0]
+            }
             if(this.dialogForm.chemicalId){
-              chemicalChemicalUpdate(this.dialogForm).then(response => {
+              chemicalChemicalUpdate(obj).then(response => {
                 this.msgSuccess(response.message)
                 this.$parent.submitSuccessful();
                 this.addChemicalsOpen(3);
               });
             }else{
-              chemicalChemicalAdd(this.dialogForm).then(response => {
+              chemicalChemicalAdd(obj).then(response => {
                 this.msgSuccess(response.message)
                 this.$parent.submitSuccessful();
                 this.addChemicalsOpen(3);
@@ -280,6 +263,9 @@
             }
           }
         })
+      },
+      addHandleChange(value, selectedData) {
+        this.$refs.addCascader.dropDownVisible = false;
       }
     },
   }