소스 검색

样品多选 依据多选bug + 设置store

yuhan 1 년 전
부모
커밋
d10775079d

+ 7 - 0
itdmWeb/src/store/getters.js

@@ -19,6 +19,13 @@ const getters = {
   },
   sysSafeMode: state => state.user.sysSafeMode,
 
+  //
+  baseInfos: state => state.weituoInfo.baseInfos,
+  yangpinInfos: state => state.weituoInfo.yangpinInfos,
+  shiyanInfos: state => state.weituoInfo.shiyanInfos,
+  countYp: state => state.weituoInfo.countYp,
+  countSy: state => state.weituoInfo.countSy,
+
 }
 
 export default getters

+ 2 - 0
itdmWeb/src/store/index.js

@@ -7,6 +7,7 @@ import permission from './modules/permission'
 import enhance from './modules/enhance'
 import online from './modules/online'
 import getters from './getters'
+import weituoInfo from './modules/weituoInfo'
 
 Vue.use(Vuex)
 
@@ -17,6 +18,7 @@ export default new Vuex.Store({
     permission,
     enhance,
     online,
+    weituoInfo
   },
   state: {
 

+ 50 - 0
itdmWeb/src/store/modules/weituoInfo.js

@@ -0,0 +1,50 @@
+import Vue from 'vue'
+// import { ONL_AUTH_FIELDS } from "@/store/mutation-types"
+// import { getAction } from '@/api/manage'
+
+
+const weituoInfo = {
+  state: {
+    //存储当前委托登记新增的数据,用于步骤之间的数据传输
+    baseInfos: {},
+    yangpinInfos: [],
+    shiyanInfos: [],
+    countYp: 1,
+    countSy: 1,
+  },
+  // (大概)区别:mutations用来修改state数据 同步
+  mutations: {
+    SET_BASEINFO: (state, infos) => {
+      // console.log('fields',fields)
+      // Vue.set(state, 'baseInfos', fields)
+      state.baseInfos = infos
+    },
+    SET_YANGPININFO: (state, infos) => {
+      state.yangpinInfos = infos
+    },
+    SET_SHIYANINFO: (state, infos) => {
+      state.shiyanInfos = infos
+    },
+    SET_COUNTYP: (state, infos) => {
+      // console.log('fields',fields)
+      // Vue.set(state, 'baseInfos', fields)
+      state.countYp = infos
+    },
+    SET_COUNTSY: (state, infos) => {
+      // console.log('fields',fields)
+      // Vue.set(state, 'baseInfos', fields)
+      state.countSy = infos
+    },
+  },
+  // (大概)区别:actions用来设计复杂逻辑 异步
+  actions: {
+    setWeituoBaseInfos({ commit }, record) {
+      commit('SET_BASEINFO', record)
+    }
+    // this.$store.state.weituoInfo.baseInfos
+    // this.$store.dispatch('setWeituoBaseInfos', data)
+
+  }
+}
+
+export default weituoInfo

+ 25 - 9
itdmWeb/src/views/module-iTDM/weituo/modules/ItdmWeituoInfoForm.vue

@@ -65,7 +65,16 @@ export default {
   computed: {
     formDisabled() {
       return this.disabled
-    }
+    },
+    baseInfos() {
+      return this.$store.getters.baseInfos
+    },
+    yangpinInfos() {
+      return this.$store.getters.yangpinInfos
+    },
+    shiyanInfos() {
+      return this.$store.getters.shiyanInfos
+    },
   },
   created() {
     //备份model原始值
@@ -97,9 +106,14 @@ export default {
         if (res.success) {
           this.model.id = res.result.id
 
-          sessionStorage.setItem('data', JSON.stringify(res.result.data))
-          sessionStorage.setItem('yangpin', JSON.stringify(res.result.yangpins))
-          sessionStorage.setItem('yangpinkz', JSON.stringify(res.result.pinShiYans))
+          // sessionStorage.setItem('data', JSON.stringify(res.result.data))
+          // sessionStorage.setItem('yangpin', JSON.stringify(res.result.yangpins))
+          // sessionStorage.setItem('yangpinkz', JSON.stringify(res.result.pinShiYans))
+          this.$store.commit('SET_BASEINFO', res.result.data);
+          this.$store.commit('SET_YANGPININFO', res.result.yangpins);
+          this.$store.commit('SET_SHIYANINFO', res.result.pinShiYans);
+          this.$store.commit('SET_COUNTYP', res.result.yangpins.length>0?res.result.yangpins.length>0:1);
+          this.$store.commit('SET_COUNTSY', res.result.pinShiYans.length>0?res.result.pinShiYans.length>0:1);
           this.$refs.data001.init()
 
         } else {
@@ -112,13 +126,15 @@ export default {
     submitForm() {
       const that = this
       // 触发表单验证
-      this.weituomodel = JSON.parse(sessionStorage.getItem('data'))
-      this.weituomodel.yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
+      // this.weituomodel = JSON.parse(sessionStorage.getItem('data'))
+      // this.weituomodel.yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
       // this.weituomodel.pinShiYans = JSON.parse(sessionStorage.getItem('yangpinkz'))
       // console.log(JSON.parse(sessionStorage.getItem('yangpinkz')))
-      var pinShiYans = JSON.parse(sessionStorage.getItem('yangpinkz'))
-      this.weituomodel.pinShiYans = pinShiYans.map(item => {
-        item.standardRequirement = item.standardRequirement.toString()
+      // var pinShiYans = JSON.parse(sessionStorage.getItem('yangpinkz'))
+      this.weituomodel = this.baseInfos
+      this.weituomodel.yangpins = this.yangpinInfos
+      this.weituomodel.yangpins = this.shiyanInfos.map(item => {
+        item.standardRequirement = item.standardRequirementQ.toString()
         return item
       })
       

+ 40 - 9
itdmWeb/src/views/module-iTDM/weituo/modules/ItdmWeituoInfoModal.vue

@@ -30,6 +30,17 @@ import { postAction  } from '@api/manage'
         disableSubmit: false
       }
     },
+    computed: {
+      baseInfos() {
+        return this.$store.getters.baseInfos
+      },
+      yangpinInfos() {
+        return this.$store.getters.yangpinInfos
+      },
+      shiyanInfos() {
+        return this.$store.getters.shiyanInfos
+      },
+    },
     methods: {
       add () {
 
@@ -40,6 +51,10 @@ import { postAction  } from '@api/manage'
         sessionStorage.removeItem("count")
         sessionStorage.removeItem("count1")
 
+        this.$store.commit('SET_BASEINFO', {});
+            this.$store.commit('SET_YANGPININFO', []);
+            this.$store.commit('SET_SHIYANINFO', []);
+
 
         this.visible=true
         this.$nextTick(()=>{
@@ -52,17 +67,23 @@ import { postAction  } from '@api/manage'
         sessionStorage.removeItem("yangpinkz")
         sessionStorage.removeItem("count")
         sessionStorage.removeItem("count1")
+        this.$store.commit('SET_BASEINFO', {});
+            this.$store.commit('SET_YANGPININFO', []);
+            this.$store.commit('SET_SHIYANINFO', []);
         this.visible=true
         this.$nextTick(()=>{
           this.$refs.realForm.edit(record);
         })
       },
       close () {
-        sessionStorage.removeItem("data")
-        sessionStorage.removeItem("yangpin")
-        sessionStorage.removeItem("yangpinkz")
-        sessionStorage.removeItem("count")
-        sessionStorage.removeItem("count1")
+        // sessionStorage.removeItem("data")
+        // sessionStorage.removeItem("yangpin")
+        // sessionStorage.removeItem("yangpinkz")
+        // sessionStorage.removeItem("count")
+        // sessionStorage.removeItem("count1")
+        this.$store.commit('SET_BASEINFO', {});
+        this.$store.commit('SET_YANGPININFO', []);
+        this.$store.commit('SET_SHIYANINFO', []);
         this.$emit('close');
         this.visible = false;
       },
@@ -71,6 +92,9 @@ import { postAction  } from '@api/manage'
         var weituoInfo = {}
         // console.log(this.$refs.realForm.model.id)
         var weituoId = this.$refs.realForm.model.id
+
+        // this.weituomodel.yangpins = this.shiyanInfos
+
         switch (this.$refs.realForm.currentTab) {
           case 0:
             // console.log(this.$refs.realForm.$refs.data001.model)
@@ -78,14 +102,21 @@ import { postAction  } from '@api/manage'
             break;
           case 1:
             // console.log(this.$refs.realForm.$refs.ypxx.model)
-            weituoInfo = JSON.parse(sessionStorage.getItem('data'))
+            // weituoInfo = JSON.parse(sessionStorage.getItem('data'))
+            weituoInfo = this.baseInfos
             weituoInfo.yangpins = this.$refs.realForm.$refs.ypxx.model.data
             break;
           case 2:
             // console.log(this.$refs.realForm.$refs.syxx.model)
-            weituoInfo = JSON.parse(sessionStorage.getItem('data'))
-            weituoInfo.yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
-            weituoInfo.pinShiYans = this.$refs.realForm.$refs.syxx.model
+            // weituoInfo = JSON.parse(sessionStorage.getItem('data'))
+            // weituoInfo.yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
+            weituoInfo = this.baseInfos
+            weituoInfo.yangpins = this.yangpinInfos
+            var pinShiYans = this.$refs.realForm.$refs.syxx.model.list
+            weituoInfo.pinShiYans = pinShiYans.map(item => {
+              item.standardRequirement = item.standardRequirementQ.toString()
+              return item
+            })
             break;
         
           default:

+ 10 - 6
itdmWeb/src/views/module-iTDM/weituo/modules/step/Step1.vue

@@ -105,7 +105,7 @@ export default {
     return {
       restaurants: [], // 获取的所有客户信息
       weituoClients: [], // 搜索用的客户下拉列表
-      model: {},
+      // model: {},
       labelCol: {
         xs: { span: 24 },
         sm: { span: 5 }
@@ -151,6 +151,9 @@ export default {
   computed: {
     formDisabled() {
       return this.disabled
+    },
+    model() {
+      return this.$store.getters.baseInfos
     }
   },
 
@@ -194,12 +197,12 @@ export default {
     },
 
     init() {
-      const data = JSON.parse(sessionStorage.getItem('data'))
+      // const data = JSON.parse(sessionStorage.getItem('data'))
 
-      if (data != null) {
-        this.model = data
+      // if (data != null) {
+      //   this.model = data
 
-      }
+      // }
     },
     handleAsyncChange(value) {
       console.log(value)
@@ -217,7 +220,8 @@ export default {
         tiaojianFile: this.model.tiaojianFile
       }
 
-      sessionStorage.setItem('data', JSON.stringify(data))
+      // sessionStorage.setItem('data', JSON.stringify(data))
+      this.$store.commit('SET_BASEINFO', data);
 
       this.$refs.form.validate(valid => {
 

+ 67 - 14
itdmWeb/src/views/module-iTDM/weituo/modules/step/Step2.vue

@@ -5,6 +5,8 @@
       :dataSource="model.data"
       :pagination="false"
       :rowKey="(record, index) => { return index }"
+      bordered
+      class="u-edit-table"
     >
       <!-- <template
         v-for="(col, i) in ['sampleName', 'sampleModelSpecification', 'sampleQuantities','sampleManufacturer']"
@@ -167,38 +169,59 @@ export default {
   computed: {
     formDisabled() {
       return this.disabled
-    }
+    },
+    baseInfos() {
+      return this.$store.getters.baseInfos
+    },
+    yangpinInfos() {
+      return this.$store.getters.yangpinInfos
+    },
+    countYp() {
+      return this.$store.getters.countYp
+    },
   },
   created() {
-    const data = JSON.parse(sessionStorage.getItem('yangpin'))
-    if (data != null) {
-      this.model.data = data
-
+    // this.count = this.countYp
+    // console.log(this.count)
+    // const data = JSON.parse(sessionStorage.getItem('yangpin'))
+    if (this.yangpinInfos.length > 0) {
+      this.model.data = this.yangpinInfos.map((item, index) => {
+        item.key = (index+1) + ''
+        item.editable = true
+        return item
+      })
+      // this.count++
+      this.count = this.yangpinInfos.length + 1
+      console.log(this.model.data)
     } else {
-      this.model.data=[]
+      this.model.data = []
       this.newMember()
     }
-    this.count = sessionStorage.getItem('count') != null ? Number(sessionStorage.getItem('count')) : 1
+    // this.count = sessionStorage.getItem('count') != null ? Number(sessionStorage.getItem('count')) : 1
 
   },
   methods: {
     // 新增样品
     newMember() {
+      console.log(this.count)
       this.model.data.push({
         key: this.count + '',
-        sampleQuantities: 0,
+        sampleQuantities: 1,
         sampleModelSpecification: '',
         sampleName: '',
-        sampleManufacturer: sessionStorage.getItem('data') ? JSON.parse(sessionStorage.getItem('data')).weituoClient : '',
+        sampleManufacturer: this.baseInfos ? this.baseInfos.weituoClient : '',
         editable: true,
         isNew: true
       })
       this.count++
-      sessionStorage.setItem('count', this.count)
+      // sessionStorage.setItem('count', this.count)
+      
+      
 
     },
     // 删除
     remove(key) {
+      console.log(key)
       const newData = this.model.data.filter(item => item.key !== key)
       this.model.data = newData
     },
@@ -223,15 +246,18 @@ export default {
       console.log(11111,this.model.data)
       this.$refs.form.validate(valid => {
         if (valid) {
-          sessionStorage.setItem('yangpin', JSON.stringify(this.model.data))
+          // sessionStorage.setItem('yangpin', JSON.stringify(this.model.data))
+          this.$store.commit('SET_YANGPININFO', this.model.data);
+          // this.$store.commit('SET_COUNTYP', this.count);
           this.$emit('nextStep')
         }
       })
-
+      
     },
     prevStep() {
-      sessionStorage.setItem('yangpin', JSON.stringify(this.model.data))
-
+      // sessionStorage.setItem('yangpin', JSON.stringify(this.model.data))
+      this.$store.commit('SET_YANGPININFO', this.model.data);
+      // this.$store.commit('SET_COUNTYP', this.count);
       this.$emit('prevStep')
     },
 
@@ -240,6 +266,33 @@ export default {
 </script>
 
 <style lang="less" scoped>
+.u-edit-table{
+  margin-top: 12px;
+  .ant-form-item{
+    margin-bottom: 0;
+  }
+  /deep/.ant-table-tbody .ant-table-row td {
+    padding-top: 2px !important;
+    padding-bottom: 2px !important;
+  }
+  // .ant-table-tbody > tr > td{
+    
+  //   padding-top: 0 !important;
+  // }
+  .ant-input{
+    // padding: 0;
+    border: none;
+  }
+  .ant-table-tbody > tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) .ant-input{
+    background: #e6f7ff;
+  }
+  // .ant-input:hover{
+  //   background: #e6f7ff;
+  // }
+  .ant-input:focus{
+    box-shadow: none;
+  }
+}
 .card {
   margin-bottom: 24px;
 }

+ 93 - 34
itdmWeb/src/views/module-iTDM/weituo/modules/step/Step3.vue

@@ -5,6 +5,9 @@
       :dataSource="model.list"
       :pagination="false"
       :customRow="clickThenCheck"
+      ref="table"
+      bordered
+      class="u-edit-table"
     >
 
 
@@ -43,7 +46,7 @@
           <!-- 为了解决下拉框显示不全的问题,原来的没有对应参数配置 -->
           <a-select
             :disabled="formDisabled"
-            v-model="record.standardRequirement"
+            v-model="record.standardRequirementQ"
             allowClear
             optionFilterProp="label"
             :dropdownMatchSelectWidth="false"
@@ -151,7 +154,7 @@ export default {
           dataIndex: 'yangpinKeyId',
           key: 'yangpinKeyId',
           align: 'center',
-          width: '15%',
+          width: '12%',
           scopedSlots: { customRender: 'yangpinKeyId' }
         },
         {
@@ -159,7 +162,7 @@ export default {
           dataIndex: 'sampleModelSpecification',
           key: 'sampleModelSpecification',
           align: 'center',
-          width: '15%',
+          width: '12%',
           scopedSlots: { customRender: 'sampleModelSpecification' }
         },
         {
@@ -167,7 +170,7 @@ export default {
           dataIndex: 'testItems',
           key: 'testItems',
           align: 'center',
-          width: '15%',
+          width: '12%',
           scopedSlots: { customRender: 'testItems' }
         },
         {
@@ -175,7 +178,7 @@ export default {
           dataIndex: 'standardRequirement',
           key: 'standardRequirement',
           align: 'center',
-          width: '20%',
+          width: '15%',
           scopedSlots: { customRender: 'standardRequirement' }
         },
         {
@@ -183,14 +186,14 @@ export default {
           dataIndex: 'judgementBasis',
           key: 'judgementBasis',
           align: 'center',
-          width: '25%',
+          width: '15%',
           scopedSlots: { customRender: 'judgementBasis' }
         },
         {
           title: '检测依据文件',
           dataIndex: 'yijufile',
           key: 'yijufile',
-          width: '15%',
+          width: '12%',
           align: 'center',
           scopedSlots: { customRender: 'yijufile' }
         },
@@ -199,7 +202,7 @@ export default {
           title: '备注',
           dataIndex: 'beizhu',
           key: 'beizhu',
-          width: '15%',
+          width: '7%',
           align: 'center',
           scopedSlots: { customRender: 'beizhu' }
         },
@@ -207,6 +210,7 @@ export default {
           title: '操作',
           key: 'action',
           align: 'center',
+          width: '5%',
           scopedSlots: { customRender: 'operation' }
         }
       ],
@@ -216,29 +220,48 @@ export default {
   computed: {
     formDisabled() {
       return this.disabled
-    }
+    },
+    yangpinInfos() {
+      return this.$store.getters.yangpinInfos
+    },
+    shiyanInfos() {
+      return this.$store.getters.shiyanInfos
+    },
+    // count() {
+    //   return this.$store.getters.countSy
+    // },
   },
   created() {
     this.getYijuLists()
-    console.log(JSON.parse(sessionStorage.getItem('yangpin')))
-    console.log(JSON.parse(sessionStorage.getItem('yangpinkz')))
-    const data = JSON.parse(sessionStorage.getItem('yangpinkz'))
-    if (data != null) {
-      this.model.list=data
-
+    // console.log(JSON.parse(sessionStorage.getItem('yangpin')))
+    // console.log(JSON.parse(sessionStorage.getItem('yangpinkz')))
+    // const data = JSON.parse(sessionStorage.getItem('yangpinkz'))
+    if (this.shiyanInfos.length > 0) {
+      this.model.list = this.shiyanInfos.map((item, index) => {
+        // console.log(!item.standardRequirement)
+        // console.log(item.standardRequirement)
+        if(!item.standardRequirement){
+          item.standardRequirementQ = []
+        } else {
+          item.standardRequirementQ = item.standardRequirement.split(',')
+        }
+        item.key = (index+1) + ''
+        item.editable = true
+        return item
+      })
+      this.count = this.shiyanInfos.length + 1
+      console.log(this.model.list)
+      
     }else{
       this.newMember()
     }
 
-    console.log(2323,sessionStorage.getItem('yangpin'))
-    const yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
+    // console.log(2323,sessionStorage.getItem('yangpin'))
+    // const yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
 
-    if (yangpins != null) {
-      this.yangpins = yangpins
-      console.log(this.yangpins)
-    }
+    this.yangpins = this.yangpinInfos
 
-    this.count = sessionStorage.getItem('count1') != null ? Number(sessionStorage.getItem('count1')) : 1
+    // this.count = sessionStorage.getItem('count1') != null ? Number(sessionStorage.getItem('count1')) : 1
 
   },
   methods: {
@@ -264,10 +287,12 @@ export default {
     // 获得选中项信息
     handleChange2(value,optipn) {
       console.log(777,value,optipn);
-      const a = optipn.data.attrs.channel
-      console.log(a)
-      this.model.list[this.clickIndex].sampleModelSpecification = a.sampleModelSpecification
-      console.log(this.model)
+      if(value){
+        const a = optipn.data.attrs.channel
+        // console.log(a)
+        this.$set(this.model.list[this.clickIndex], 'sampleModelSpecification', a.sampleModelSpecification )
+        this.$set(this.model.list[this.clickIndex], 'yangpinKeyId', a.sampleName )
+      }
     },
 
     // 多选依据
@@ -280,7 +305,8 @@ export default {
         key: this.count + '',
         yangpinKeyId: '',
         testItems: '',
-        standardRequirement: [],
+        standardRequirementQ: [], // 前端用来下拉选择的,直接standardRequirement赋值standardRequirement会有问题
+        standardRequirement: '',
         judgementBasis: '',
         yijufile: '',
         beizhu: '',
@@ -289,7 +315,7 @@ export default {
       })
 
       this.count++
-      sessionStorage.setItem('count1', this.count)
+      // sessionStorage.setItem('count1', this.count)
 
     },
     remove(key) {
@@ -312,19 +338,20 @@ export default {
       }
     },
     submitForm() {
-      sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
-      // sessionStorage.setItem('yangpin', JSON.stringify(this.model.list))
-
+      // sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
+      this.$store.commit('SET_SHIYANINFO', this.model.list);
+      
       this.$refs.form.validate(valid => {
         if (valid) {
-
+          
           this.$emit('submitForm')
         }
       })
-
+      
     },
     prevStep() {
-      sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
+      // sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
+      this.$store.commit('SET_SHIYANINFO', this.model.list);
 
       this.$emit('prevStep')
     },
@@ -333,6 +360,38 @@ export default {
 </script>
 
 <style lang="less" scoped>
+.u-edit-table{
+  margin-top: 12px;
+  .ant-form-item{
+    margin-bottom: 0;
+  }
+  /deep/.ant-table-tbody .ant-table-row td {
+    padding-top: 2px !important;
+    padding-bottom: 2px !important;
+  }
+  .ant-input{
+    // padding: 0;
+    border: none;
+  }
+  .ant-table-tbody > tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) .ant-input{
+    background: #e6f7ff;
+  }
+  // .ant-input:hover{
+  //   background: #e6f7ff;
+  // }
+  .ant-input:focus{
+    box-shadow: none;
+  }
+  /deep/.ant-select-selection{
+    border: none;
+  }
+  /deep/.ant-select-selection:focus{
+    box-shadow: none;
+  }
+  .ant-table-tbody > tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) .ant-select-selection{
+    background: #e6f7ff;
+  }
+}
 .card {
   margin-bottom: 24px;
 }