scorpio 2 years ago
parent
commit
80eff77ccb
1 changed files with 26 additions and 14 deletions
  1. 26 14
      src/views/home/component/form_dialog.vue

+ 26 - 14
src/views/home/component/form_dialog.vue

@@ -155,7 +155,21 @@
         </div>
         <div style="height: 320px;overflow-x: scroll" v-if='selectIndex !== -1'>
           <div class="flex flex-wrap ">
-            <div v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
+
+            <div v-if='selectIndex ===2' class=' full-width'>
+              <div v-for='item in fieldType[selectIndex].groupList' :key='item.id' class='mt-10  full-width border'>
+                <div class='flex flex-wrap'>
+                  <div v-for='sub in item' :key='sub.id' class='pointer item'>
+                    <el-checkbox v-model='sub.checked' :label="sub.code" size="large"
+                                 @change='change(selectIndex,index)'>
+                      {{ sub.dictValue }}
+                    </el-checkbox>
+                  </div>
+                </div>
+              </div>
+            </div>
+
+            <div v-else v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
                  class="pointer item" style='height: 30px'>
               <el-checkbox v-model='item.checked' :label="item.code" size="large" @change='change(selectIndex,index)'>
                 {{ item.dictValue }}
@@ -422,22 +436,20 @@ export default {
         this.fieldType[index].params = tmps
       }
       // list to params
-      const keys = unique(this.fieldType[index].params.map(sub => sub.type))
-      console.log(keys)
-      for (const key in keys) {
-        const tmp = this.fieldType[index].params = this.groupBy(this.fieldType[index].params, key)
-        console.log(tmp)
-      }
-
+      // 排序 ,去重,返回type 关键词数组 list
+      const keys = unique(this.fieldType[index].params.sort((val1, val2) => {
+        if (val1.frontSort < val2.frontSort) return -1
+        if (val1.frontSort > val2.frontSort) return 0
+        return 0
+      }).map(sub => sub.type))
+      // 分组数据
+      this.fieldType[index].groupList = []
+      keys.forEach(sub => {
+        this.fieldType[index].groupList.push(this.fieldType[index].params.filter(item => item.type === sub))
+      })
       this.fieldType[index].count = this.fieldType[index].params.filter(e => e.checked).length
       this.fieldType[index].checkAll = this.fieldType[index].count === this.fieldType[index].params.length
     },
-    groupBy (xs, key) {
-      return xs.reduce(function (rv, x) {
-        (rv[x[key]] = rv[x[key]] || []).push(x)
-        return rv
-      }, {})
-    },
     importExcel () {
       if (this.attaches && this.attaches.length === 0) {
         this.$message.error('请选择要上传的文件')