Browse Source

C2,D2,C6数据转换处理

shaun-sheep 5 years ago
parent
commit
8f5a8d368b
2 changed files with 49 additions and 41 deletions
  1. 38 34
      src/components/ready/buildfloor/addBuild.vue
  2. 11 7
      src/views/ready/buildfloor/index.vue

+ 38 - 34
src/components/ready/buildfloor/addBuild.vue

@@ -39,12 +39,11 @@
         <el-select
           placeholder="请选择"
           v-else-if="item.InputMode == 'D2'"
-          v-model="replaceForm[item.Path]"
+          v-model="form[item.Path]"
           multiple
           collapse-tags
-          @change="multipleSelect($event,item.Path)"
         >
-        
+
             <el-option :key="op.Code" :label="op.Name" :value="op.Code" v-for="op in item.options"></el-option>
           </el-select>
            <el-date-picker
@@ -54,13 +53,13 @@
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
-             end-placeholder="结束日期"/>
+             end-placeholder="结束日期"
+           />
              <el-cascader
                v-else-if="item.InputMode == 'D1L'"
                placeholder="请选择"
                :options="item.options"
-               v-model="replaceForm[item.Path]"
-              @change="multipleSelect($event,item.Path)"
+               v-model="form[item.Path]"
                :props="{ checkStrictly: true ,value: 'Code',label:'Name'}"
                clearable
              />
@@ -96,7 +95,6 @@
                @change="changeItem"
              />
           <el-input disabled title="暂不支持" v-else v-model="form[item.Path]"></el-input>
-          <span>{{item.InputMode}}</span>
         </el-form-item>
       </span>
       </template>
@@ -160,51 +158,43 @@
           ]
         },
         buildData: {},
-        replaceForm: {}
       }
     },
     components: {uploadFiles, uploadImgs},
     props: ['buildTitle', 'buildMessage', 'currentBuild'],
     computed: {
-      'item.Path':{
-        get() {
-          return this.form[item.Path].split(',')
-          },
-        set(val) {
-          this.form[item.Path] = val.join(',')
-        }
-      }
     },
     mounted() {
 
 
     },
     methods: {
-      formKey(val){
-
-        let _keyArr = []
-        return _keyArr;
-      },
       deepCopy(obj) {
         return JSON.parse(JSON.stringify(obj))
       },
-      multipleSelect(val,item) {
-        let value = val.join(',')
-        this.form[item] = value
-      },
       showDialog(data) {
         //获取信息
-        debugger
-        this.buildData = data || {};  // string =>array key 
-        this.buildData = flattenKeys(this.buildData)
-        // this.keysArr = this.buildData[]
+        let buildData = data || {};  // string =>array key
+        buildData = flattenKeys(buildData);
+        for (let key in this.buildMessage) {
+          let arr = this.buildMessage[key];
+          if (Array.isArray(arr)) {
+            let list = arr.filter(i => i.InputMode == 'D2' || i.InputMode == 'C6');
+            list.forEach(j => {
+              if (buildData.hasOwnProperty(j.Path)) {
+                if (!Array.isArray(buildData[j.Path])) {
+                  buildData[j.Path] = buildData[j.Path].split(',');
+                }
+              }
+
+            })
+          }
+        }
+        this.buildData = buildData;
         this.timeoutSetVal()
         this.buildDialogVis = true
       },
-      changeParams(data){
-        this.replaceForm = data;
-        
-      },
+
       timeoutSetVal() {
         let that = this
         setTimeout(() => {
@@ -217,12 +207,26 @@
       },
       closeDialog() {
         this.buildDialogVis = false
-        this.replaceForm = {}
       },
       submitForm(formName) {
         this.$refs[formName].validate((valid) => {
           if (valid) {
+            console.log(this.form);
+            for (let key in this.buildMessage) {
+              let arr = this.buildMessage[key];
+              if (Array.isArray(arr)) {
+                let list = arr.filter(i => i.InputMode == 'D2' || i.InputMode == 'C6');
+                list.forEach(j => {
+                  if (this.form.hasOwnProperty(j.Path)) {
+                    if (Array.isArray(this.form[j.Path])) {
+                      this.form[j.Path] = this.form[j.Path].join(',');
+                    }
+                  }
+                })
+              }
+            }
             this.$emit('handleBuild', this.form)
+
           } else {
             return false;
           }

+ 11 - 7
src/views/ready/buildfloor/index.vue

@@ -174,6 +174,7 @@
     created() {
       this.init();
       this.handleBuildQuery()
+      this.handleSearchBuildKey()
     },
     methods: {
       init() {
@@ -219,15 +220,15 @@
           type: 'Building'
         };
         getDataDictionary(params, res => {
-          let list = res.Content.map(item => {
-            if (item.InputMode === 'D1' && item.DataSource != undefined) {
-              item.options = JSON.parse(item.DataSource)
-            }
-            return item
-          })
+          // let list = res.Content.map(item => {
+          //   if (item.InputMode === 'D1' && item.DataSource != undefined) {
+          //     item.options = JSON.parse(item.DataSource)
+          //   }
+          //   return item
+          // })
           let first = {}
           //一级循环出来一级标签
-          list.map(item => {
+          res.Content.map(item => {
             if ((item.InputMode === 'D1' || item.InputMode === 'D2'  || item.InputMode === 'E2'|| item.InputMode === 'D1L') && item.DataSource != undefined) {
               item.options = JSON.parse(item.DataSource)
             }
@@ -275,6 +276,9 @@
         for (let i = 0; i < list.length; i++) {
           obj = list[i]
         }
+
+
+
         this.$refs.addBuildDialog.showDialog(obj);
 
       },