lilei 2 tygodni temu
rodzic
commit
1dadf928a4

+ 54 - 13
src/views/financialManagement/accountStatement/confrontModal.vue

@@ -65,6 +65,25 @@
         </div>
       </a-card>
       <a-card size="small" :bordered="false" class="conFrontModal-wrap">
+        <div class="action-bar">
+          列显示
+          <a-popover title="勾选显示列" trigger="click">
+            <template slot="content">
+              <div style="width:150px;">
+                <a-checkbox-group v-model="showCols">
+                  <a-row>
+                    <a-col :span="24" v-for="item in showColsOptions" :key="item.value">
+                      <a-checkbox v-show="item.show" :value="item.value">{{ item.label }}</a-checkbox>
+                    </a-col>
+                  </a-row>
+                </a-checkbox-group>
+              </div>
+            </template>
+            <a-button type="link" size="small">
+              设置 <a-icon type="setting" />
+            </a-button>
+          </a-popover>
+        </div>
         <!-- 列表 -->
         <s-table
           class="sTable"
@@ -170,12 +189,29 @@ export default {
       detailData: null,
       dealear: null,
       verifyAccountBillSn: undefined,
-      orderType: 0
+      orderType: 0,
+      showCols: []
     }
   },
   computed: {
+    showColsOptions () {
+      return [
+        { label: '序号', value: 'no', show: false },
+        { label: '年', value: 'year', show: false },
+        { label: '月', value: 'month', show: false },
+        { label: '日', value: 'day', show: false },
+        { label: '业务单号', value: 'bizNo', show: false },
+        { label: '业务类型', value: 'bizTypeDictValue', show: false },
+        { label: '费用/调拨类型', value: 'expenseAllocateType', show: true },
+        { label: '摘要', value: 'digestInfo', show: true },
+        { label: '客诉索赔编码', value: 'productCode', show: true },
+        { label: '借方金额', value: 'debitAmount', show: false },
+        { label: '贷方金额', value: 'creditorAmount', show: false },
+        { label: '余额', value: 'totalAmount', show: true },
+        { label: '备注', value: 'remarks', show: true }
+      ]
+    },
     columns () {
-      const _this = this
       const renderContent = (value, row, index) => {
         const obj = {
           children: value || '--',
@@ -200,7 +236,7 @@ export default {
                 { title: '月', dataIndex: 'month', width: '4%', align: 'center', customRender: renderContent },
                 { title: '日', dataIndex: 'day', width: '4%', align: 'center', customRender: renderContent },
                 { title: '业务单号', dataIndex: 'bizNo', width: '8%', align: 'center', customRender: renderContent }
-              ]
+              ].filter(item => this.showCols.includes(item.dataIndex))
             },
             {
               title: this.dealear ? this.dealear.dealerAlias : '--',
@@ -212,7 +248,7 @@ export default {
                   align: 'center',
                   customRender: renderContent
                 }
-              ]
+              ].filter(item => this.showCols.includes(item.dataIndex))
             },
             {
               title: '系统名称',
@@ -220,7 +256,7 @@ export default {
                 { title: '摘要', dataIndex: 'digestInfo', width: '10%', align: 'center', customRender: renderContent },
                 { title: '客诉索赔编码', dataIndex: 'productCode', width: '8%', align: 'center', customRender: renderContent },
                 { title: '借方', dataIndex: 'debitAmount', width: '6%', align: 'right', customRender: renderContent }
-              ]
+              ].filter(item => this.showCols.includes(item.dataIndex))
             },
             {
               title: this.dealear ? this.dealear.dealerName : '--',
@@ -228,7 +264,7 @@ export default {
                 { title: '贷方', dataIndex: 'creditorAmount', width: '6%', align: 'right', customRender: renderContent },
                 { title: '余额', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: renderContent },
                 { title: '备注', dataIndex: 'remarks', width: '15%', align: 'center', customRender: renderContent }
-              ]
+              ].filter(item => this.showCols.includes(item.dataIndex))
             }
           ]
         }
@@ -269,23 +305,25 @@ export default {
       this.$emit('cancel')
     },
     appendSplitMergedRow (ws, firstValue, secondValue) {
+      const colsLen = this.showCols.length
+      const s = Math.floor((colsLen % 2 == 0) ? (colsLen / 2) : ((colsLen - 1) / 2))
       // 1. 获取当前数据范围
       const range = XLSX.utils.decode_range(ws['!ref'])
       const newRowNum = range.e.r + 1
 
       // 2. 填充基础数据(仅设置有效单元格)
       ws[XLSX.utils.encode_cell({ r: newRowNum, c: 0 })] = { v: firstValue, t: 's' } // 前7列合并值
-      ws[XLSX.utils.encode_cell({ r: newRowNum, c: 7 })] = { v: secondValue, t: 's' } // 后6列合并值
+      ws[XLSX.utils.encode_cell({ r: newRowNum, c: s + 1 })] = { v: secondValue, t: 's' } // 后6列合并值
 
       // 3. 设置合并区域
       if (!ws['!merges']) ws['!merges'] = []
       // 前7列合并(0-6列)
       ws['!merges'].push(XLSX.utils.decode_range(
-        `${XLSX.utils.encode_cell({ r: newRowNum, c: 0 })}:${XLSX.utils.encode_cell({ r: newRowNum, c: 6 })}`
+        `${XLSX.utils.encode_cell({ r: newRowNum, c: 0 })}:${XLSX.utils.encode_cell({ r: newRowNum, c: s })}`
       ))
       // 后6列合并(7-12列)
       ws['!merges'].push(XLSX.utils.decode_range(
-        `${XLSX.utils.encode_cell({ r: newRowNum, c: 7 })}:${XLSX.utils.encode_cell({ r: newRowNum, c: 12 })}`
+        `${XLSX.utils.encode_cell({ r: newRowNum, c: s + 1 })}:${XLSX.utils.encode_cell({ r: newRowNum, c: colsLen - 1 })}`
       ))
 
       // 4. 更新数据范围
@@ -297,9 +335,9 @@ export default {
     exportTable (dom, title) {
       var ws = XLSX.utils.table_to_sheet(dom)
       // console.log(ws)
-
+      const colsLen = this.showCols.length
       // 4. 设置列宽
-      ws['!cols'] = Array(13).fill().map((item, index) => ({ wch: index < 4 ? 6 : 20 }))
+      ws['!cols'] = Array(colsLen).fill().map((item, index) => ({ wch: index < 4 ? 6 : 20 }))
 
       // 追加备注
       const range = XLSX.utils.decode_range(ws['!ref'])
@@ -307,7 +345,7 @@ export default {
 
       // 填充数据(首列填值,其余留空)
       const mergedValue = '备注:' + this.detailData.remarks
-      for (let col = 0; col < 13; col++) {
+      for (let col = 0; col < colsLen; col++) {
         const cellRef = XLSX.utils.encode_cell({ r: newRowNum, c: col })
         ws[cellRef] = { v: col === 0 ? mergedValue : '', t: 's' }
       }
@@ -315,7 +353,7 @@ export default {
       // 设置全列合并(0-12列)
       if (!ws['!merges']) ws['!merges'] = []
       ws['!merges'].push(XLSX.utils.decode_range(
-        `${XLSX.utils.encode_cell({ r: newRowNum, c: 0 })}:${XLSX.utils.encode_cell({ r: newRowNum, c: 12 })}`
+        `${XLSX.utils.encode_cell({ r: newRowNum, c: 0 })}:${XLSX.utils.encode_cell({ r: newRowNum, c: colsLen - 1 })}`
       ))
 
       // 4. 更新数据范围
@@ -380,6 +418,9 @@ export default {
     text-align: center;
     margin-bottom: 10px;
   }
+  .action-bar{
+    text-align: right;
+  }
   .conFrontModal-flex{
     display: flex;
     justify-content: space-between;