|
@@ -0,0 +1,248 @@
|
|
|
+<template>
|
|
|
+ <div class="veTableCon">
|
|
|
+ <ve-table
|
|
|
+ border-y
|
|
|
+ v-show="!showEmpty"
|
|
|
+ :scroll-width="0"
|
|
|
+ :max-height="(tableHeight)"
|
|
|
+ :show-header="showTableHead"
|
|
|
+ :row-style-option="{clickHighlight: true}"
|
|
|
+ :cellSelectionOption="{enable: false}"
|
|
|
+ :virtual-scroll-option="{enable: true}"
|
|
|
+ :columns="columns"
|
|
|
+ :table-data="dataSource"
|
|
|
+ />
|
|
|
+ <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
+import { Empty } from 'ant-design-vue'
|
|
|
+export default {
|
|
|
+ name: 'DetailProductList',
|
|
|
+ mixins: [commonMixin],
|
|
|
+ props: {
|
|
|
+ newLoading: Boolean, // loadin
|
|
|
+ // 最大高度
|
|
|
+ maxHeight: {
|
|
|
+ type: [String, Number],
|
|
|
+ default: '300'
|
|
|
+ },
|
|
|
+ // 是否显示表格头部
|
|
|
+ showHeader: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ spinning: false,
|
|
|
+ openDetailModal: false, // 活动规则详情弹框
|
|
|
+ detailSn: null, // 活动规则详情sn
|
|
|
+ activeList: [], // 活动列表
|
|
|
+ dataSource: [], // 列表原始数据
|
|
|
+ tableHeight: this.maxHeight, // 表格高度
|
|
|
+ // 自定义单元格样式
|
|
|
+ cellStyleOption: {
|
|
|
+ bodyCellClass: ({ row, column, rowIndex }) => {
|
|
|
+ if (row.id.indexOf('promo-') >= 0 && column.field === 'no') {
|
|
|
+ return 'table-body-cell-no'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 表格列可拖曳
|
|
|
+ columnWidthResizeOption: {
|
|
|
+ // default false
|
|
|
+ enable: true,
|
|
|
+ // column resize min width
|
|
|
+ minWidth: 50
|
|
|
+ },
|
|
|
+ // 自定义单元格内容
|
|
|
+ cellSpanOption: {
|
|
|
+ bodyCellSpan: this.bodyCellSpan
|
|
|
+ },
|
|
|
+ isCityPrice: false, // 是否显示市级价
|
|
|
+ outStockStr: '', // 产品库存不足提示信息
|
|
|
+ showEmpty: true, // 是否显示空数据图片
|
|
|
+ showTableHead: true, // 是否显示表格头部
|
|
|
+ colspanNums: 13, // 单元格合并列数
|
|
|
+ hasOutStockOfActive: false,
|
|
|
+ simpleImage: Empty.PRESENTED_IMAGE_SIMPLE // 空图片
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ columns () {
|
|
|
+ const _this = this
|
|
|
+ // 终端价格变价
|
|
|
+ const priceEdit = function (record, data) {
|
|
|
+ return (
|
|
|
+ <a-input placeholder="请输入"/>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ // 操作按钮
|
|
|
+ const actionFormat = function (record, data) {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <a-button size="small" type="link" class="button-info" onClick={() => _this.handleDel(record)}>删除</a-button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ const arr = [
|
|
|
+ { title: '序号', field: 'no', key: 'a', width: 40, align: 'center' },
|
|
|
+ { title: '产品编码', field: 'productBrandName', key: 'a', align: 'center', width: 80, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '全品类' } },
|
|
|
+ { title: '产品名称', field: 'productTypeName1', key: 'b', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
|
|
|
+ { title: '原厂编码', field: 'productTypeName2', key: 'c', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
|
|
|
+ { title: '活动价', field: 'productTypeName3', key: 'd', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return priceEdit(row, row[column.field]) } },
|
|
|
+ { title: '参考终端价', field: 'priceLevelDictValue', key: 'e', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
|
|
|
+ { title: '操作', field: 'action', width: 80, key: 'f', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column }) => { return actionFormat(row, row[column.field]) } }
|
|
|
+ ]
|
|
|
+ return arr
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 关闭详情弹窗
|
|
|
+ closeDetailModal () {
|
|
|
+ this.detailSn = null
|
|
|
+ this.openDetailModal = false
|
|
|
+ },
|
|
|
+ // 合并活动分类单元格
|
|
|
+ bodyCellSpan ({ row, column, rowIndex }) {
|
|
|
+ if (row.id.indexOf('promo-') >= 0) {
|
|
|
+ if (column.field == 'no') {
|
|
|
+ return {
|
|
|
+ rowspan: 1,
|
|
|
+ colspan: this.colspanNums
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ rowspan: 0,
|
|
|
+ colspan: 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 查看活动详情
|
|
|
+ showDesc (row) {
|
|
|
+ this.detailSn = row.promoRuleSn
|
|
|
+ this.openDetailModal = true
|
|
|
+ },
|
|
|
+ // 获取销售单参与的活动列表
|
|
|
+ pageInit () {
|
|
|
+ salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.activeList = res.data || []
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.searchTable()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 查询表格数据
|
|
|
+ async searchTable () {
|
|
|
+ this.dataSource = []
|
|
|
+ this.disabled = true
|
|
|
+ this.spinning = true
|
|
|
+ // 参数
|
|
|
+ const params = {
|
|
|
+ salesBillSn: this.salesBillSn,
|
|
|
+ showStock: this.showStock,
|
|
|
+ warehouseSn: this.warehouseSn,
|
|
|
+ promotionFlag: this.promoFlag == '' ? undefined : this.promoFlag
|
|
|
+ }
|
|
|
+ // 参与活动数据
|
|
|
+ const active = this.activeList.filter(item => item.enabledFlag == 1)
|
|
|
+
|
|
|
+ // 正常产品
|
|
|
+ const hasSearchNormal = !params.promotionFlag || params.promotionFlag == 0
|
|
|
+ const proList = hasSearchNormal ? await salesDetailAllList(params).then(res => res.data) : []
|
|
|
+ const norTotal = hasSearchNormal ? await salesDetaiCount(params).then(res => res.data) : null
|
|
|
+
|
|
|
+ // 没有活动时,表格不显示统计数据
|
|
|
+ let listData = active.length ? (proList.length ? [{
|
|
|
+ id: 'promo-normal',
|
|
|
+ total: norTotal
|
|
|
+ }, ...proList] : []) : proList
|
|
|
+
|
|
|
+ // 有促销活动产品
|
|
|
+ if (params.promotionFlag != 0) {
|
|
|
+ // 循环获取活动产品
|
|
|
+ for (let i = 0; i < active.length; i++) {
|
|
|
+ const promo = active[i]
|
|
|
+ const activeParams = {
|
|
|
+ promoRuleSn: promo.promoRuleSn,
|
|
|
+ promoSn: promo.promoSn,
|
|
|
+ salesPromoSn: promo.salesPromoSn,
|
|
|
+ ...params
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取活动产品统计
|
|
|
+ const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
|
|
|
+ if (acTotal) {
|
|
|
+ // 采购额结余
|
|
|
+ acTotal.cgejyAmount = (Number(acTotal.totalPromoGiftsAmount || 0) - Number(acTotal.totalUsePromoGiftsAmount || 0)).toFixed(2)
|
|
|
+ // 采购额超出
|
|
|
+ acTotal.cgeccAmount = (Number(acTotal.totalUsePromoGiftsAmount || 0) - Number(acTotal.totalPromoGiftsAmount || 0)).toFixed(2)
|
|
|
+ }
|
|
|
+ // 有数据时才调用接口,避免做无用的调用
|
|
|
+ if (acTotal && acTotal.totalQty) {
|
|
|
+ // 获取活动产品列表
|
|
|
+ const aclist = await salesDetailAllList(activeParams).then(res => res.data)
|
|
|
+ // 合并结果数据
|
|
|
+ const retList = aclist.length ? [{
|
|
|
+ id: 'promo-' + i,
|
|
|
+ promo: promo,
|
|
|
+ total: acTotal
|
|
|
+ }, ...aclist] : []
|
|
|
+ // 将活动产品数据拼接
|
|
|
+ listData = aclist && aclist.length ? listData.concat(retList) : listData
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果活动没有任何产品,不显示统计一行
|
|
|
+ if (active.length) {
|
|
|
+ const hasAcp = listData.filter(item => item.id != 'promo-normal').filter(item => item.id.indexOf('promo-') >= 0)
|
|
|
+ if (hasAcp && hasAcp.length == 0) {
|
|
|
+ listData = listData.filter(item => item.id.indexOf('promo-') < 0) || []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 赋值
|
|
|
+ this.dataSource = listData
|
|
|
+ // 格式化数据
|
|
|
+ let f = 0
|
|
|
+ let str = ''
|
|
|
+ this.outStockStr = ''
|
|
|
+ this.dataSource.map((item, i) => {
|
|
|
+ if (item.id.indexOf('promo-') >= 0) { f = f - 1 }
|
|
|
+ item.no = i + 1 + f
|
|
|
+ // 格式化数据
|
|
|
+ const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
|
|
|
+ const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
|
|
|
+ const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
|
|
|
+ const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
|
|
|
+ item.productCode = productCode || '--'
|
|
|
+ item.productName = productName || '--'
|
|
|
+ item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
|
|
|
+ item.productOrigUnit = productOrigUnit || '--'
|
|
|
+ item.epushedQty = Number(item.pushedQty) - Number(item.pushQty)
|
|
|
+ if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
|
|
|
+ str += item.productCode + '、'
|
|
|
+ if (item.promotionFlag != 0) {
|
|
|
+ this.hasOutStockOfActive = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (str.length > 0) {
|
|
|
+ str = str.substr(0, str.length - 1)
|
|
|
+ this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
|
|
|
+ }
|
|
|
+ this.showEmpty = this.dataSource.length <= 0
|
|
|
+ this.tableHeight = (this.showEmpty ? 200 : this.maxHeight) + 'px'
|
|
|
+ this.spinning = false
|
|
|
+ this.disabled = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+</style>
|