scorpio 2 năm trước cách đây
mục cha
commit
801ec32465
3 tập tin đã thay đổi với 21 bổ sung2 xóa
  1. 4 0
      src/utils/tools.js
  2. 15 0
      src/views/home/component/form_dialog.vue
  3. 2 2
      vite.config.js

+ 4 - 0
src/utils/tools.js

@@ -64,3 +64,7 @@ export const deepClone = data => {
   }
   return obj
 }
+
+export const unique = (arr) => {
+  return arr.filter((item, index) => arr.indexOf(item) === index)
+}

+ 15 - 0
src/views/home/component/form_dialog.vue

@@ -178,6 +178,7 @@
 import BaseButton from '@/components/base-button.vue'
 import uploads from '@/components/uploads.vue'
 import { useStore } from '@/store/user.js'
+import { unique } from '@/utils/tools.js'
 
 export default {
   name: 'form_dialog',
@@ -420,9 +421,23 @@ export default {
       } else {
         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)
+      }
+
       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('请选择要上传的文件')

+ 2 - 2
vite.config.js

@@ -50,8 +50,8 @@ export default defineConfig({
     proxy: {
       '/api': {
         // 正式环境地址
-        // target: 'https://dev.wutongresearch.club/api',
-        target: 'https://prod.wutongshucloud.com/api',
+        target: 'https://dev.wutongresearch.club/api',
+        // target: 'https://prod.wutongshucloud.com/api',
         // target: 'http://192.168.31.181:8110',
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/api/, '')