ソースを参照

feat(融资管理):融资管理货物合并

sufan 6 ヶ月 前
コミット
cabb32b6a7

+ 67 - 7
src/components/CommTable/index.vue

@@ -6,7 +6,7 @@
       v-loading="loading"
       :data="data"
       :expand-row-keys="expandList"
-      :row-key="row => row.id"
+      :row-key="row => row[rowKey]"
       :default-sort="tableOptions && tableOptions.defaultSort"
       :max-height="tableOptions && tableOptions.maxHeight"
       :tree-props="tableOptions && tableOptions.treeProps"
@@ -21,8 +21,9 @@
       <template
         v-for="({label, prop, className, width, fixed, type, single, align, headerAlign, sortable, showTooltip, pre, suf, show, separator = '/', _renderHeader, _child, _render, ruleRequired, index: _i}, index) in tableRow"
       >
+        <!-- :show-overflow-tooltip="showTooltip || false" -->
         <el-table-column
-          v-if="!_child && !type && !pre && !suf && !Array.isArray(prop) && prop !== 'operation' && type !== 'selection' &&type !== 'index' && !_renderHeader && !_render"
+          v-if="!_child && !type && !pre && !suf && !Array.isArray(prop) && prop !== 'operation' && type !== 'selection' && type !== 'index' && type !== 'expand' && !_renderHeader && !_render"
           :key="index"
           :prop="prop"
           :class-name="className"
@@ -33,9 +34,17 @@
           :align="align || 'left'"
           :header-align="headerAlign || 'left'"
           :sortable="sortable || false"
-          :show-overflow-tooltip="showTooltip || false"
           :label-class-name="ruleRequired ? 'rule-required' : ''"
-        />
+        >
+          <template slot-scope="{row, $index}">
+            <template v-if="showTooltip">
+              <el-tooltip effect="dark" :content="handleProp(row, prop)" placement="top-start">
+                <div class="one-ellipsis">{{ handleProp(row, prop) }}</div>
+              </el-tooltip>
+            </template>
+            <span v-else>{{ _i ? $index + 1 : handleProp(row, prop) }}</span>
+          </template>
+        </el-table-column>
         <el-table-column
           v-else-if="type === 'expand'"
           :key="index"
@@ -53,8 +62,8 @@
         >
           <template slot-scope="{row, $index}">
             <template v-if="_render">
-              {{ createNode('_render_'+$index, _render(row, $index)) }}
-              <slot :name="'_render_'+$index" />
+              {{ createNode('_render_'+$index +$index, _render(row, $index)) }}
+              <slot :name="'_render_'+$index +$index" />
             </template>
           </template>
         </el-table-column>
@@ -173,6 +182,7 @@
  *    singleSelected 是否开启单选,默认false
  *    pageSlot 页码slot
  *    parentComponent 兼容dialog 寻找指定父组件赋值vm
+ *    selectData 选中的数据
  * }
  * columns: {
  *    label 表头显示名称
@@ -253,6 +263,14 @@ export default {
     name: {
       type:String,
       default: 'commTable'
+    },
+    rowKey: {
+      type: String,
+      default: 'id'
+    },
+    selectData: {
+      type: Array,
+      default: () => []
     }
   },
   filters: {
@@ -314,12 +332,32 @@ export default {
       },
       deep: true,
       immediate: true
+    },
+    selectData: {
+      handler(val) {
+        if (val === undefined) return
+        if (val && val.length) {
+          setTimeout(() => {
+            this.toggleRowSelection(val)
+          }, 300);
+        }
+      },
+      immediate: true
     }
   },
   mounted() {
     if (this.$refs.tableRef) this.$refs.tableRef.columns.map(item => (item.className = item.className ? item.className + ' ' + item.property : item.property))
   },
   methods: {
+    // 处理prop多项
+    handleProp(row, prop) {
+      let keys = prop.split('.');
+      let value = row;
+      for (let key of keys) {
+          value = value[key];
+      }
+      return value
+    },
     // 创建节点
     createNode(key, vnode) {
       this.$slots[key] = vnode
@@ -343,7 +381,7 @@ export default {
     // 单选
     handleSelectionSingleChange(selection, row) {
       if(!this.tableRow[0].single) return
-      if (this.multipleSelection.length && this.multipleSelection[0].id === row.id) {
+      if (this.multipleSelection.length && this.multipleSelection[0][this.rowKey] === row[[this.rowKey]]) {
         this.$refs.tableRef.clearSelection()
         this.multipleSelection = []
       } else {
@@ -366,9 +404,23 @@ export default {
         return true
       }
     },
+    // 回显勾选数据
     toggleRowSelection(list) {
       this.$nextTick(() => {
+        this.$refs.tableRef.clearSelection()
+        let selectArr = []
         list.forEach(row => {
+          this.data.forEach(item => {
+            if(row[this.rowKey]) {
+              if (row[this.rowKey] === item[this.rowKey]) {
+                selectArr.push(item)
+              }
+            }else {
+              selectArr = list
+            }
+          })
+        })
+        selectArr.forEach(row => {
           this.$refs.tableRef.toggleRowSelection(row, true)
         })
         this.multipleSelection = list
@@ -461,3 +513,11 @@ export default {
   }
 }
 </style>
+<style scoped>
+.one-ellipsis {
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+
+</style>

+ 13 - 0
src/utils/index.js

@@ -414,3 +414,16 @@ export function throttle(func, delay) {
     }
   }
 }
+
+// 生成uuid
+export function getUuid() {
+  var s = []
+  var hexDigits = '0123456789abcdef'
+  for (var i = 0; i < 32; i++) {
+    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
+  }
+  s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010
+  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01
+  var uuid = s.join('')
+  return uuid
+}

+ 70 - 16
src/views/myFinancing/applyFinancing/index.vue

@@ -59,6 +59,7 @@
           :columns="columns"
           :data="tableData"
           :count="0"
+          row-key="fid"
         />
       </div>
       <cy-info-title style="margin-top: 20px;">网价附件</cy-info-title>
@@ -88,6 +89,7 @@
           :columns="columnsInfo"
           :data="tableDataInfo"
           :count="0"
+          row-key="fid"
         />
       </div>
       <cy-info-title style="margin-top: 20px;">联系信息</cy-info-title>
@@ -136,7 +138,7 @@
 <script>
 import { getProjectInfo, getFinishProCon, getApplicantInfo, chooseToAcceptTheGoods, generateReceivable, applySubmit, getDetailsInfo } from '@/api/myFinancing'
 import { validMail } from '@/utils/validate'
-import { deduplicateArray } from '@/utils'
+import { deduplicateArray, getUuid } from '@/utils'
 export default {
   name: 'ApplyFinancing',
   props: {
@@ -209,9 +211,25 @@ export default {
       },
       tableData: [],
       columns: [
+        {
+          type: 'expand',
+          render: (h, row, index) => {
+            const columnsDeep = this.columns.toSpliced(0, 2)
+            columnsDeep.unshift({
+              label: '序号',
+              prop: 'tOrder'
+            })
+            return <cy-comm-table
+              columns={ columnsDeep }
+              data={row.children}
+              count={0}
+              rowKey='tid'
+            />
+          }
+        },
         {
           label: '序号',
-          index: true
+          prop: 'fOrder'
         },
         {
           label: '验收单货物编号',
@@ -298,9 +316,25 @@ export default {
       },
       tableDataInfo: [],
       columnsInfo: [
+        {
+          type: 'expand',
+          render: (h, row, index) => {
+            const columnsDeep = this.columnsInfo.toSpliced(0, 2)
+            columnsDeep.unshift({
+              label: '序号',
+              prop: 'tOrder'
+            })
+            return <cy-comm-table
+              columns={ columnsDeep }
+              data={row.children}
+              count={0}
+              rowKey='tid'
+            />
+          }
+        },
         {
           label: '序号',
-          index: true
+          prop: 'fOrder'
         },
         {
           label: '验收单货物编号',
@@ -425,7 +459,7 @@ export default {
   methods: {
     initData(data) {
       const { financingBasicInfo, financingGoodsInfoList, financingAccountsReceivableInfoList, financingApplicantInfo, fileStorageDOList } = data
-      this.tableData = financingGoodsInfoList
+      this.tableData = this.handlerGoodsFormat(financingGoodsInfoList)
       const { applicantContact,
         applicantContactNumber,
         applicantContactEmail,
@@ -442,9 +476,9 @@ export default {
         applicantDesignatedBank
       }
       this.fileStorageList = fileStorageDOList
-      this.tableDataInfo = financingAccountsReceivableInfoList
+      this.tableDataInfo = this.handlerGoodsFormat(financingAccountsReceivableInfoList)
       this.getGoodsCalc(financingGoodsInfoList)
-      this.getReceivableCalc()
+      this.getReceivableCalc(financingAccountsReceivableInfoList)
     },
     getDetails() {
       const { id } = this.$route.params
@@ -500,10 +534,15 @@ export default {
       chooseToAcceptTheGoods(params).then(({ data }) => {
         this.goodsTableData = data.rows
         var selectRow = []
+        const tableList = []
         this.tableData.forEach(item => {
-          selectRow = this.goodsTableData.filter(row => row.acceptanceNumber === item.acceptanceNumber)
-          this.$refs.goodsTable.toggleRowSelection(selectRow)
+          tableList.push(...item.children)
         })
+        tableList.forEach(item => {
+          selectRow.push(this.goodsTableData.find(row => row.acceptanceNumber === item.acceptanceGoodsNumber))
+        })
+
+        this.$refs.goodsTable.toggleRowSelection(selectRow)
         this.goodsLoading = false
       })
     },
@@ -523,7 +562,7 @@ export default {
         return
       }
       this.getMultipleList(multipleList)
-      this.getReceivable()
+
       this.$refs.dialog.show = false
     },
     // 底层货物
@@ -540,7 +579,8 @@ export default {
         listData.push(...list)
       })
       this.getGoodsCalc(listData)
-      this.tableData = listData
+      this.getReceivable(listData)
+      this.tableData = this.handlerGoodsFormat(listData)
     },
     // 底层货物计算
     getGoodsCalc(list) {
@@ -559,20 +599,20 @@ export default {
       })
     },
     // 生成底层
-    getReceivable() {
-      generateReceivable(this.tableData).then(({ data }) => {
-        this.tableDataInfo = data
-        this.getReceivableCalc()
+    getReceivable(list) {
+      generateReceivable(list).then(({ data }) => {
+        this.tableDataInfo = this.handlerGoodsFormat(data)
+        this.getReceivableCalc(data)
       })
     },
     // 底层信息计算
-    getReceivableCalc() {
+    getReceivableCalc(list) {
       this.bottomInfoCalc = {
         numTotal: 0,
         accountsTotal: 0,
         netAccounts: 0
       }
-      this.tableDataInfo.forEach(item => {
+      list.forEach(item => {
         const { numTotal, accountsTotal, netAccounts } = this.bottomInfoCalc
         this.bottomInfoCalc = {
           numTotal: (Number(numTotal) + Number(item.goodsQuantity)).toFixed(4),
@@ -622,6 +662,20 @@ export default {
           }
         })
       }
+    },
+    handlerGoodsFormat(arr) {
+      let fOrder = 0
+      let tOrder = 0
+      return Object.values(arr.reduce((acc, cur) => {
+        if (!acc[cur.acceptanceGoodsNumber]) {
+          fOrder += 1
+          tOrder = 0
+          acc[cur.acceptanceGoodsNumber] = { ...cur, fid: getUuid(), tid: getUuid(), fOrder, children: [] }
+        }
+        tOrder += 1
+        acc[cur.acceptanceGoodsNumber].children.push({ ...cur, fid: getUuid(), tid: getUuid(), tOrder })
+        return acc
+      }, {}))
     }
   }
 }

+ 2 - 2
src/views/myTrade/acceptanceManagement/acceptanceAdd.vue

@@ -87,7 +87,7 @@
       <!-- 合作平台 -->
       <cy-info-title style="margin: 25px -15px 10px;">合作平台</cy-info-title>
       <el-form-item
-        label="是否为钢小二"
+        label="是否有合作平台"
         prop="steelWaiter"
         class="industry"
       >
@@ -261,7 +261,7 @@ export default {
         checkOperatorSupplierContact: [{ required: true, trigger: 'blur', message: '请输入联系方式' }, { validator: validateMobile, trigger: 'blur' }],
         checkOperatorEnterprise: [{ required: true, trigger: 'change', message: '请选择验收经办人(核心企业)' }],
         checkOperatorEnterpriseContact: [{ required: true, trigger: 'blur', message: '请输入联系方式' }, { validator: validateMobile, trigger: 'blur' }],
-        steelWaiter: [{ required: true, trigger: 'change', message: '请选择是否为钢小二' }],
+        steelWaiter: [{ required: true, trigger: 'change', message: '请选择是否有合作平台' }],
         approval: [{ required: true, trigger: 'change', message: '请选择是否申请审核' }]
       },
       countTotal: 0,

+ 1 - 1
src/views/myTrade/acceptanceManagement/acceptanceViewTemp.vue

@@ -67,7 +67,7 @@
       <!-- 合作平台 -->
       <cy-info-title style="margin: 25px -15px 10px;">合作平台</cy-info-title>
       <el-form-item
-        label="是否为钢小二"
+        label="是否有合作平台"
         prop="steelWaiter"
         class="industry"
       >

+ 1 - 1
src/views/myTrade/acceptanceManagement/components/historyViewContent/add.vue

@@ -66,7 +66,7 @@
       <!-- 合作平台 -->
       <cy-info-title style="margin: 25px -15px 10px;">合作平台</cy-info-title>
       <el-form-item
-        label="是否为钢小二"
+        label="是否有合作平台"
         prop="steelWaiter"
         class="industry"
       >