Bläddra i källkod

对接促销产品统计

chenrui 4 år sedan
förälder
incheckning
2901198608

+ 7 - 3
src/views/promotionRulesManagement/orderStatistics/detailModal.vue

@@ -9,7 +9,7 @@
     @cancle="isShow=false"
     width="80%">
     <div>
-      <p>销售单号: {{ nowData.salesBillNo || '--' }}</p>
+      <p>销售单号:{{ nowData ? (nowData.salesBillNo || '--') : '--' }}</p>
       <!-- 列表 -->
       <s-table
         class="sTable"
@@ -29,6 +29,7 @@
 
 <script>
 import { STable } from '@/components'
+import { getOperationalPrecision } from '@/libs/tools.js'
 import { salesDetailList } from '@/api/salesDetail'
 export default {
   name: 'OrderStatisticsDetailModal',
@@ -61,7 +62,7 @@ export default {
         { title: '促销价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '原价小计', dataIndex: 'totalAmounts', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '原价小计', dataIndex: 'priceSubtotal', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '促销价小计', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '节省金额小计', dataIndex: 'totalEconomizeAmount', width: 130, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '促销类型', dataIndex: 'promotionRulesName', width: 150, align: 'center', customRender: function (text) { return text || '--' } }
@@ -73,7 +74,10 @@ export default {
           const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
-            // priceSubtotal
+            const origPrice = data.list[i].origPrice || 0
+            const qty = data.list[i].qty || 0
+            // 成本小计  由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
+            data.list[i].priceSubtotal = getOperationalPrecision(origPrice, qty)
           }
           return data
         })

+ 1 - 0
src/views/promotionRulesManagement/orderStatistics/list.vue

@@ -210,6 +210,7 @@ export default {
     closeModal () {
       this.openModal = false
       this.itemSn = ''
+      this.nowData = null
     }
   },
   beforeRouteEnter (to, from, next) {

+ 31 - 44
src/views/promotionRulesManagement/productStatistics/detailModal.vue

@@ -9,7 +9,9 @@
     @cancle="isShow=false"
     width="80%">
     <div>
-      <p>产品信息: 产品名称(产品编码)</p>
+      <p>产品信息:
+        {{ nowData ? (nowData.productEntity?(nowData.productEntity.name || '--') : '--') : '--' }}({{ nowData ? (nowData.productEntity?(nowData.productEntity.code || '--') : '--') : '--' }})
+      </p>
       <!-- 列表 -->
       <s-table
         class="sTable"
@@ -18,18 +20,9 @@
         :rowKey="(record) => record.id"
         :columns="columns"
         :data="loadData"
-        :scroll="{ x: 1360, y: 400 }"
+        :defaultLoadData="false"
+        :scroll="{ x: 1180, y: 400 }"
         bordered>
-        <!-- 操作 -->
-        <template slot="action" slot-scope="text, record">
-          <a-button
-            size="small"
-            type="link"
-            @click="handleDetail(record)"
-            class="button-success"
-            id="orderStatisticsDetail-edit-btn">详情</a-button>
-          <!-- <span>--</span> -->
-        </template>
       </s-table>
       <div class="btn-cont"><a-button id="orderStatisticsDetail-back" @click="isShow = false">返回列表</a-button></div>
     </div>
@@ -38,7 +31,8 @@
 
 <script>
 import { STable } from '@/components'
-// import { custFindById } from '@/api/customer'
+import { getOperationalPrecision } from '@/libs/tools.js'
+import { salesDetailList } from '@/api/salesDetail'
 export default {
   name: 'OrderStatisticsDetailModal',
   components: { STable },
@@ -47,9 +41,15 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
+    itemSn: {
       type: [Number, String],
       default: ''
+    },
+    nowData: {
+      type: Object,
+      default: () => {
+        return {}
+      }
     }
   },
   data () {
@@ -58,42 +58,29 @@ export default {
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '采购单号', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '原价', dataIndex: 'productTotalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '促销价', dataIndex: 'productTotalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '数量', dataIndex: 'psroductTotalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '单位', dataIndex: 'suppliersName', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '原价小计', dataIndex: 'productTotdalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '促销价小计', dataIndex: 'productTdotalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '节省金额小计', dataIndex: 'productTdostalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '促销类型', dataIndex: 'stateDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '采购单号', dataIndex: 'purchaseBillNo', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '原价', dataIndex: 'origPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '促销价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '原价小计', dataIndex: 'priceSubtotal', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '促销价小计', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '节省金额小计', dataIndex: 'totalEconomizeAmount', width: 130, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '促销类型', dataIndex: 'promotionRulesName', width: 150, align: 'center', customRender: function (text) { return text || '--' } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        // return sparePartsPurList(Object.assign(parameter, this.queryParam)).then(res => {
-        //   const data = res.data
-        //   const no = (data.pageNo - 1) * data.pageSize
-        //   for (var i = 0; i < data.list.length; i++) {
-        //     data.list[i].no = no + i + 1
-        //   }
-        //   return data
-        // })
-        const _this = this
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [
-              { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', inventoryNumss: '0' },
-              { id: '2', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', inventoryNumss: '0' },
-              { id: '3', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', inventoryNumss: '0' }
-            ]
-          }
+        return salesDetailList(Object.assign(parameter, { productSn: this.itemSn, promotionFlag: 1 })).then(res => {
+          const data = res.data
           const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
+            const origPrice = data.list[i].origPrice || 0
+            const qty = data.list[i].qty || 0
+            // 成本小计  由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
+            data.list[i].priceSubtotal = getOperationalPrecision(origPrice, qty)
           }
-          resolve(data)
+          return data
         })
       }
     }
@@ -112,7 +99,7 @@ export default {
         this.$emit('close')
       }
     },
-    itemId (newValue, oldValue) {
+    itemSn (newValue, oldValue) {
       if (this.isShow && newValue) {
         const _this = this
         setTimeout(() => {

+ 28 - 30
src/views/promotionRulesManagement/productStatistics/list.vue

@@ -17,12 +17,12 @@
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="产品名称">
-              <a-input id="productStatisticsList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
+              <a-input id="productStatisticsList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="产品编码">
-              <a-input id="productStatisticsList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
+              <a-input id="productStatisticsList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
             </a-form-item>
           </a-col>
           <template v-if="advanced">
@@ -58,13 +58,6 @@
           <a-col :md="6" :sm="24">
             <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productStatisticsList-refresh">查询</a-button>
             <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productStatisticsList-reset">重置</a-button>
-            <!-- <a-button
-              style="margin: 0 0 18px 8px"
-              type="danger"
-              @click="handleExport"
-              :disabled="disabled"
-              :loading="exportLoading"
-              id="inventoryQueryList-export">导出</a-button> -->
             <a @click="advanced=!advanced" style="margin-left: 8px">
               {{ advanced ? '收起' : '展开' }}
               <a-icon :type="advanced ? 'up' : 'down'"/>
@@ -75,17 +68,20 @@
     </div>
     <!-- alert -->
     <a-alert type="info" showIcon style="margin-bottom:15px">
-      <div slot="message">节省总金额: <strong>{{ dataTotalCount }}</strong> ;总数量:<strong>{{ productTotal.productTotalCost }}</strong>。 </div>
+      <div slot="message">
+        节省总金额:<strong>{{ productTotal ? ((productTotal.totalEconomizeAmount || productTotal.totalEconomizeAmount==0) ? productTotal.totalEconomizeAmount : '--') : '--' }}</strong>,
+        总数量:<strong>{{ productTotal ? ((productTotal.totalQty || productTotal.totalQty==0) ? productTotal.totalQty : '--') : '--' }}</strong>
+      </div>
     </a-alert>
     <!-- 列表 -->
     <s-table
       class="sTable"
       ref="table"
       size="default"
-      :rowKey="(record) => record.id"
+      :rowKey="(record, index) => index"
       :columns="columns"
       :data="loadData"
-      :scroll="{ x: 1610, y: tableHeight }"
+      :scroll="{ x: 1140, y: tableHeight }"
       bordered>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
@@ -98,7 +94,7 @@
       </template>
     </s-table>
     <!-- 详情 -->
-    <productStatisticsDetailModal :openModal="openModal" :itemId="itemId" @close="closeModal" />
+    <productStatisticsDetailModal :openModal="openModal" :itemSn="itemSn" :nowData="nowData" @close="closeModal" />
   </a-card>
 </template>
 
@@ -119,24 +115,23 @@ export default {
       createDate: [], //  统计时间
       dateFormat: 'YYYY-MM-DD',
       queryParam: { //  查询条件
-        code: '', //  产品编码
-        name: '', //  产品名称
+        productCode: '', //  产品编码
+        productName: '', //  产品名称
         productBrandSn: undefined, //  产品品牌
         productTypeSn1: '', //  产品一级分类
         productTypeSn2: '', //  产品二级分类
         productTypeSn3: '' //  产品三级分类
       },
       disabled: false, //  查询、重置按钮是否可操作
-      exportLoading: false, // 导出loading
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '品牌', dataIndex: 'productBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '产品编码', dataIndex: 'code', width: 220, align: 'center' },
-        { title: '数量', dataIndex: 'terminasslPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '单位', dataIndex: 'origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '节省金额', dataIndex: 'terminalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? '¥' + text : '--') } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
+        { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center' },
+        { title: '数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '节省金额', dataIndex: 'totalEconomizeAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? '¥' + text : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -159,15 +154,16 @@ export default {
             data.list[i].no = no + i + 1
           }
           this.disabled = false
+          this.getTotal(Object.assign(parameter, this.queryParam))
           return data
         })
       },
       openModal: false, //  查看客户详情  弹框
-      itemId: '', //  当前产品id
+      itemSn: '', //  当前sn
+      nowData: null,
       productBrandList: [], //  品牌下拉数据
       productTypeList: [], //  分类下拉数据
-      productTotal: null,
-      dataTotalCount: '' //  列表数据总条数
+      productTotal: null
     }
   },
   methods: {
@@ -177,8 +173,8 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.code = ''
-      this.queryParam.name = ''
+      this.queryParam.productCode = ''
+      this.queryParam.productName = ''
       this.queryParam.productBrandSn = undefined
       this.queryParam.productTypeSn1 = ''
       this.queryParam.productTypeSn2 = ''
@@ -199,12 +195,14 @@ export default {
     },
     //  详情
     handleDetail (row) {
-      this.itemId = row.id
+      this.itemSn = row.productSn
+      this.nowData = row
       this.openModal = true
     },
     //  关闭弹框
     closeModal () {
-      this.itemId = ''
+      this.itemSn = ''
+      this.nowData = null
       this.openModal = false
     },
     //  产品分类  change