Prechádzať zdrojové kódy

Finish Hotfix-mo-15

莫绍宝 3 rokov pred
rodič
commit
8aea08a870

+ 11 - 0
src/filters/index.js

@@ -68,6 +68,17 @@ export function uppercaseFirst(string) {
   return string.charAt(0).toUpperCase() + string.slice(1)
 }
 
+/**
+ * 保留2位小数点
+ * @param {number} num 
+ * @returns 
+ */
+export function numToFixed(num) {
+	if(!num) return '0.00';
+	num = Number(num);
+	return num.toFixed(2);
+}
+
 
 /**
  * 截取到“日”的日期

+ 3 - 1
src/main.js

@@ -21,12 +21,14 @@ import '@/permission' // permission control
 import * as filters from './filters' // global filters
 
 // 成功/错误提示
-import {successMsg, errorMsg, warningNotify, checkBtnRole} from '@/utils/common.js'
+import {successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed} from '@/utils/common.js'
 Vue.prototype.$successMsg = successMsg;
 Vue.prototype.$errorMsg = errorMsg;
 Vue.prototype.$warningNotify = warningNotify;
 
 Vue.prototype.$checkBtnRole = checkBtnRole;
+Vue.prototype.$getSummaries = getSummaries;
+Vue.prototype.$numToFixed = numToFixed;
 
 // 自定义组件
 import ExportButton from '@/components/Common/export-button.vue'

+ 62 - 1
src/utils/common.js

@@ -40,9 +40,70 @@ export const checkBtnRole = (value, btnRole) => {
   return index >= 0;
 };
 
+/**
+ * table合计方法
+ * 注意:sums1,sums2: 需要在获取列表数据时遍历传入需要合计的字段名
+ * 其中:sums1: 数量,不需要toFixed
+ *      sums2: 金额,需要toFixed
+ * 例如:res.data.items.forEach(item => {
+          item.sums1 = ['number'];
+          item.sums2 = ['totalAmount', 'payAmount'];
+        })
+ * @param {*} param 
+ * @returns 
+ */
+export const getSummaries = (param) => {
+  const { columns, data } = param;
+  const sums = [];
+  columns.forEach((column, index) => {
+    if (index === 0) {
+      sums[index] = '合计';
+      return;
+    }
+    const values = data.map(item => Number(item[column.property]));
+    if (data[0] && data[0].sums1.includes(column.property)) {
+      sums[index] = values.reduce((prev, curr) => {
+        const value = Number(curr);
+        if (!isNaN(value)) {
+          return prev + curr;
+        } else {
+          return prev;
+        }
+      }, 0);
+      sums[index];
+    }
+    if (data[0] && data[0].sums2.includes(column.property)) {
+      sums[index] = values.reduce((prev, curr) => {
+        const value = Number(curr);
+        if (!isNaN(value)) {
+          return prev + curr;
+        } else {
+          return prev;
+        }
+      }, 0).toFixed(2);
+      sums[index];
+    }
+  });
+  return sums;
+}
+
+/**
+ * 保留2位小数点
+ * @param {number} num 
+ * @returns 
+ */
+ export const numToFixed = (num) => {
+	if(!num) return '0.00';
+	num = Number(num);
+	return num.toFixed(2);
+}
+
+
 export default {
   successMsg,
   errorMsg,
   warningNotify,
-  checkBtnRole
+  checkBtnRole,
+  getSummaries,
+  numToFixed
 }

+ 40 - 8
src/views/supply/engin/components/home_detail.vue

@@ -133,7 +133,16 @@
       </div>
 
       <div class="table" style="margin-top: 20px">
-        <el-table :data="detailData.items" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+        <el-table 
+          :data="detailData.items" 
+          element-loading-text="Loading" 
+          border 
+          fit 
+          highlight-current-row 
+          stripe 
+          max-height="400" 
+          show-summary
+          :summary-method="$getSummaries">
           <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
           <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
@@ -141,19 +150,35 @@
           <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{ scope.row.price | numToFixed }}
+            </template>
+          </el-table-column>
           <el-table-column align="center" label="工程登录数量" prop="enginNum" min-width="120" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
+          <el-table-column align="center" label="数量" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="订单金额" prop="totalAmount" min-width="100" show-overflow-tooltip>
             <template slot-scope="scope">
-              {{ (scope.row.qty*100 - scope.row.directTransferQty*100 - scope.row.retiredQty*100) / 100 }}
+              {{ scope.row.totalAmount | numToFixed }}
             </template>
           </el-table-column>
-          <el-table-column align="center" label="订单金额" prop="totalAmount" min-width="100" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="返利类型" prop="customerWalletName2" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="使用返利金额" prop="payRebateAmount" min-width="120" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="格力折扣" prop="discAmount" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="使用返利金额" prop="payRebateAmount" min-width="120" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{ scope.row.payRebateAmount | numToFixed }}
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="格力折扣" prop="discAmount" min-width="100" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{ scope.row.payRebateAmount | numToFixed }}
+            </template>
+          </el-table-column>
           <el-table-column align="center" label="现金钱包" prop="customerWalletName" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{ scope.row.payAmount | numToFixed }}
+            </template>
+          </el-table-column>
           <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100" show-overflow-tooltip>
             <template slot-scope="scope">
               {{ scope.row.isDirectTransfer ? '是' : '否' }}
@@ -412,6 +437,13 @@ export default {
     // 获取详情
     getDetail() {
       getOrderDetail({id: this.listItem.parentId}).then(res => {
+        if(res.data.items) {
+          res.data.items.forEach(item => {
+            item.number = (item.qty*100 - item.directTransferQty*100 - item.retiredQty*100) / 100;
+            item.sums1 = ['number', 'directTransferQty', 'qty', 'enginNum'];
+            item.sums2 = ['totalAmount', 'payAmount', 'price', 'payRebateAmount', 'discAmount'];
+          })
+        }
         this.detailData = res.data;
       })
     },

+ 14 - 7
src/views/supply/reserve/components/reserve_form.vue

@@ -269,7 +269,7 @@ export default {
   props: ['listItem'],
   filters: {
     orderTypeFilter(val) {
-      let obj = that.orderTypeList.find(o => o.value == val);
+      let obj = that.orderTypeFilterList.find(o => o.value == val);
       return obj ? obj.label : ''
     }
   },
@@ -287,14 +287,21 @@ export default {
 
       typeList: [],
       orderTypeList: [
-        { label: '商用单', value: 'TRADE' },
-        { label: '家用单', value: 'HOME' },
+        { label: '商用工程单', value: 'TRADE' },
+        { label: '家用工程单', value: 'HOME' },
         { label: '零售单', value: 'RETAIL' },
         { label: '销售政策单', value: 'RETAIL_POLICY' },
-        { label: '置换家用单', value: 'PERMU_HOME' },
-        { label: '置换商用单', value: 'PERMU_TRADE' },
-        { label: '置换零售单', value: 'PERMU_RETAIL' },
-        { label: '置换销售政策单', value: 'PERMU_RETAIL_POLICY' },
+        { label: '置换单', value: 'PERMU' },
+      ],
+      orderTypeFilterList: [
+        { label: '商用工程单', value: 'TRADE' },
+        { label: '家用工程单', value: 'HOME' },
+        { label: '零售单', value: 'RETAIL' },
+        { label: '销售政策单', value: 'RETAIL_POLICY' },
+        { label: '置换单', value: 'PERMU_HOME' },
+        { label: '置换单', value: 'PERMU_TRADE' },
+        { label: '置换单', value: 'PERMU_RETAIL' },
+        { label: '置换单', value: 'PERMU_RETAIL_POLICY' },
       ],
       isShowDialog: false,
       screenForm: {

+ 1 - 0
src/views/supply/sales/components/sales_detail.vue

@@ -45,6 +45,7 @@
       <div class="table">
         <el-table :data="detailData.saleOrderData" element-loading-text="Loading" border fit highlight-current-row stripe>
           <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
+          <el-table-column align="center" label="金蝶出库单号" prop="kingBillNo" min-width="180" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="产品编号" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
           <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>

+ 1 - 0
src/views/supply/sales/components/sales_examine.vue

@@ -44,6 +44,7 @@
     <div class="table">
       <el-table :data="detailData.saleOrderData" element-loading-text="Loading" border fit highlight-current-row stripe>
         <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
+        <el-table-column align="center" label="金蝶出库单号" prop="kingBillNo" min-width="180" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="产品编号" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
         <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>

+ 1 - 0
src/views/supply/sales/sales_list.vue

@@ -96,6 +96,7 @@
             </el-table-column>
             <el-table-column align="center" label="出库单号" prop="id" min-width="180" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="发货单号" prop="orderNo" min-width="180" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="金蝶出库单号" prop="kingBillNo" min-width="180" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="仓库" prop="correspondName" min-width="120" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="经销商" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>