Ver Fonte

准入申请服务类-缺少资质合并表格

baichengfei há 5 anos atrás
pai
commit
53a3ecb7b7

+ 37 - 2
src/dashoo.cn/frontend_web/src/components/oilsupplier/techlist.vue

@@ -60,6 +60,7 @@
             row-class-name="warning-row"
             highlight-current-row
             :data="lostTableData"
+            :span-method="objectSpanMethod"
             border
             size="mini"
             style="width: 100%; margin-top:20px">
@@ -258,13 +259,47 @@
           return
         }
         _this.$axios.post('/suppliercertsub/tech-cert-lost', params).then(res => {
-          _this.lostTableData = res.data
+          _this.lostTableData = _this.mergeTableRow(res.data, ['Code'])
           this.loading = false
         }).catch(err => {
           this.loading = false
           console.error(err)
         })
-
+      },
+      objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
+        const span = column['property'] + '-span'
+        if (row[span]) {
+          return row[span]
+        }
+      },
+      /**
+       *  table合并行通用 */
+      mergeTableRow (data, merge) {
+        if (!data || data.length === 0 || !merge || merge.length === 0) {
+          return data
+        }
+        merge.forEach((m) => {
+          const mList = {}
+          data = data.map((v, index) => {
+            const rowVal = v[m]
+            if (mList[rowVal]) {
+              mList[rowVal]++
+              data[index - (mList[rowVal] - 1)][m + '-span'].rowspan++
+              v[m + '-span'] = {
+                rowspan: 0,
+                colspan: 0
+              }
+            } else {
+              mList[rowVal] = 1
+              v[m + '-span'] = {
+                rowspan: 1,
+                colspan: 1
+              }
+            }
+            return v
+          })
+        })
+        return data
       },
       getChecklist () {
         let val = this.$refs.orgmanagetree.getCheckedNodes()