|
@@ -162,7 +162,7 @@ import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detai
|
|
|
import toPurchaseModal from './toPurchaseModal'
|
|
|
import chooseWarehouse from '@/views/common/chooseWarehouse'
|
|
|
// 接口
|
|
|
-import { salesDetailAllList, waitDispatchDetailList, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
|
|
|
+import { queryAwaitDispatch, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
|
|
|
import { salesPromoQueryList, getCreatePurchaseFlag } from '@/api/salesNew'
|
|
|
|
|
|
export default {
|
|
@@ -181,6 +181,10 @@ export default {
|
|
|
showHeader: { // 是否显示表格头部
|
|
|
type: Boolean,
|
|
|
default: true
|
|
|
+ },
|
|
|
+ activeList: { // 参与的活动列表
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
@@ -208,7 +212,6 @@ export default {
|
|
|
convertPromoGiftsFlag: undefined // 转采购额
|
|
|
},
|
|
|
disabled: false, // 查询、重置按钮是否可操作
|
|
|
- activeList: [], // 活动列表
|
|
|
spinning: false,
|
|
|
dataSource: [], // 原始数据
|
|
|
tableData: [], // 表格数据
|
|
@@ -293,23 +296,15 @@ export default {
|
|
|
}
|
|
|
// 单号
|
|
|
const codeFormat = function (record, data, h) {
|
|
|
- let ftext = ''
|
|
|
- let fcolor = ''
|
|
|
- if (record.promotionFlag == 'GIFT') {
|
|
|
- ftext = '促'
|
|
|
- fcolor = '#52c41a'
|
|
|
- }
|
|
|
- if (record.promotionFlag == 'GATE') {
|
|
|
- ftext = '槛'
|
|
|
- fcolor = '#108ee9'
|
|
|
- }
|
|
|
-
|
|
|
return (
|
|
|
<div>
|
|
|
- <span style="padding-right: 15px;">{data}</span>
|
|
|
- {ftext ? (<a-badge count={ftext} number-style={{ backgroundColor: fcolor, zoom: '80%' }}></a-badge>) : ''}
|
|
|
- {record.bakConvertPromoGiftsQty ? (<a-badge count="转" number-style={{ backgroundColor: '#ffaa00', zoom: '80%' }}></a-badge>) : ''}
|
|
|
- { Number((_this.showLockStockQty ? record.lockStockQty : record.stockQty) || 0) < Number(record.unpushedQty || 0) ? (<a-badge count="缺" number-style={{ zoom: '80%' }}></a-badge>) : ''}
|
|
|
+ <span style="padding-right: 10px;">{data}</span>
|
|
|
+ {record.promotionFlag.indexOf('GIFT') >= 0 ? <a-badge count="促" numberStyle={{ backgroundColor: '#52c41a', zoom: '0.7' }}/> : ''}
|
|
|
+ {record.promotionFlag.indexOf('DISCOUNT') >= 0 ? <a-badge count="特" numberStyle={{ backgroundColor: '#faad14', zoom: '0.7' }}/> : ''}
|
|
|
+ {record.promotionFlag.indexOf('GATE') >= 0 ? <a-badge count="槛" numberStyle={{ backgroundColor: '#108ee9', zoom: '0.7' }}/> : ''}
|
|
|
+ {record.promotionFlag.indexOf('REGULAR') >= 0 ? <a-badge count="正" numberStyle={{ backgroundColor: '#ff5500', zoom: '0.7' }}/> : ''}
|
|
|
+ {record.bakConvertPromoGiftsQty ? (<a-badge count="转" numberStyle={{ backgroundColor: '#ffaa00', zoom: '80%' }}></a-badge>) : ''}
|
|
|
+ {Number((_this.showLockStockQty ? record.lockStockQty : record.stockQty) || 0) < Number(record.unpushedQty || 0) ? (<a-badge count="缺" numberStyle={{ zoom: '0.7' }}></a-badge>) : ''}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
@@ -377,31 +372,10 @@ export default {
|
|
|
}
|
|
|
// 编号,并且格式化活动分类行
|
|
|
const noFormat = function (record, data, h) {
|
|
|
- const isBuyPSendP = record.promo && record.promo.promotionRule.convertExpenseFlag == 1 && record.promo.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_PROD'
|
|
|
return (
|
|
|
<div>
|
|
|
- {record.id.indexOf('promo-') >= 0 ? (
|
|
|
- <div class="active-title">
|
|
|
- {record.promo ? (
|
|
|
- <div>
|
|
|
- <strong style="font-size:14px;">{record.promo.promotion.description} </strong>
|
|
|
- <span>({record.promo.promotionRule.description})</span>
|
|
|
- <span id={'dispacth-desc-' + record.promo.promoRuleSn} style="margin-left:20px;color:#00aaff;cursor: pointer;" onClick={() => _this.showDesc(record.promo)}>
|
|
|
- <a-icon title="查看活动详情" type="eye"/> 活动详情
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- ) : (<div></div>)}
|
|
|
- <div>
|
|
|
- 款数:<strong>{record.total && record.total.totalCategory || '--'}</strong>;
|
|
|
- 数量:<strong>{record.total && record.total.totalQty || '--'}</strong>;
|
|
|
- {_this.$hasPermissions('B_salesEdit_salesPrice') ? (<span>总金额:<strong>{record.total && record.total.totalAmount || '--'}</strong>;</span>) : ('')}
|
|
|
- {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.lossAmount ? (<span>优惠金额:<strong>{record.total.lossAmount}</strong>;</span>) : ('')}
|
|
|
- {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.cgejyAmount > 0 && !isBuyPSendP ? (<span>采购额结余:<strong>{_this.toThousands(record.total.cgejyAmount)}</strong>;</span>) : ('')}
|
|
|
- {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.cgejyAmount < 0 && !isBuyPSendP ? (<span>采购额超出:<strong>{_this.toThousands(record.total.cgeccAmount)}</strong>;</span>) : ('')}
|
|
|
- {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.totalPromoGiftsAmount && isBuyPSendP ? (<span>促销产品转采购额金额:<strong>{_this.toThousands(record.total && record.total.totalPromoGiftsAmount) || '--'}</strong>;</span>) : ('')}
|
|
|
- {record.expenseAccountFlag != 'WAIT' ? record.expenseAccountFlagDictValue : ''}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ {record.id.indexOf('promo-active') >= 0 ? (
|
|
|
+ <div class="active-title">参与促销的产品</div>
|
|
|
) : (<span>{data}</span>)}
|
|
|
</div>
|
|
|
)
|
|
@@ -412,9 +386,37 @@ export default {
|
|
|
{ title: '序号', field: 'no', key: 'a', width: 50, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return noFormat(row, row[column.field], h) } },
|
|
|
{ title: '产品编码', field: 'productCode', key: 'b', width: 150, align: 'left', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row, row[column.field], h) } },
|
|
|
{ title: '产品名称', field: 'productName', key: 'c', width: 220, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
|
|
|
+ {
|
|
|
+ title: '规则数量',
|
|
|
+ field: 'rulesNums',
|
|
|
+ key: '4',
|
|
|
+ width: 60,
|
|
|
+ align: 'center',
|
|
|
+ operationColumn: false,
|
|
|
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
|
|
|
+ return (
|
|
|
+ <a-popover placement="right">
|
|
|
+ <template slot="content">
|
|
|
+ {row.promoRuleSnList.map(item => {
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ id={'dispacth-ruleDetail-' + row.productSn}
|
|
|
+ title="点击查看详情"
|
|
|
+ style="padding:5px 0;cursor: pointer;"
|
|
|
+ onClick={() => _this.showRuleDetail(item)}
|
|
|
+ >{ _this.activeRuleFilter(item) }</div>
|
|
|
+ )
|
|
|
+ })}
|
|
|
+ </template>
|
|
|
+ <a-button type="link" id={'dispacth-ruleSn-' + row.productSn} size="small" class="button-info">{row.promoRuleNum}<span style="zoom:0.6;color: #666;">个∨</span></a-button>
|
|
|
+ </a-popover>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
{ title: '原厂编码', field: 'productOrigCode', key: 'd', width: 150, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
|
|
|
{ title: '出库仓库', field: 'warehouseName', key: 'e', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
|
|
|
]
|
|
|
+ // 单元格合并数量
|
|
|
this.colspanNums = this.showConvertPromoGifts ? 7 : 6
|
|
|
if (this.$hasPermissions('B_salesDispatch_salesPrice')) { // 售价权限
|
|
|
this.colspanNums = this.colspanNums + 1
|
|
@@ -459,16 +461,21 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- // 查看活动详情
|
|
|
- showDesc (row) {
|
|
|
- this.detailSn = row.promoRuleSn
|
|
|
- this.openDetailModal = true
|
|
|
- },
|
|
|
// 关闭详情弹窗
|
|
|
closeDetailModal () {
|
|
|
this.detailSn = null
|
|
|
this.openDetailModal = false
|
|
|
},
|
|
|
+ // 参与规则名称
|
|
|
+ activeRuleFilter (val) {
|
|
|
+ const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
|
|
|
+ return row ? row.promotion.description + '-' + row.promotionRule.description : ''
|
|
|
+ },
|
|
|
+ // 查看参与规则详情
|
|
|
+ showRuleDetail (promoRuleSn) {
|
|
|
+ this.detailSn = promoRuleSn
|
|
|
+ this.openDetailModal = true
|
|
|
+ },
|
|
|
// 合并活动分类单元格
|
|
|
bodyCellSpan ({ row, column, rowIndex }) {
|
|
|
if (row.id.indexOf('promo-') >= 0) {
|
|
@@ -513,17 +520,6 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- // 获取销售单参与的活动列表
|
|
|
- getActiveList () {
|
|
|
- salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- this.activeList = res.data.filter(item => item.enabledFlag == 1) || []
|
|
|
- }
|
|
|
- this.$nextTick(() => {
|
|
|
- this.searchTable()
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
// 查询列表
|
|
|
async searchTable () {
|
|
|
this.selectedRowKeys = []
|
|
@@ -534,63 +530,24 @@ export default {
|
|
|
this.queryParam.salesBillSn = this.salesBillSn
|
|
|
this.queryParam.showStock = true
|
|
|
const params = this.queryParam
|
|
|
- // 获取活动列表
|
|
|
+ // 所有活动接口
|
|
|
const active = this.activeList
|
|
|
- // 正常产品
|
|
|
+ // 是否查询正常产品
|
|
|
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
|
|
|
- // 是否有正常产品
|
|
|
- this.hasNormalProduct = proList.length > 0
|
|
|
- // 没有活动时不显示统计
|
|
|
- let listData = active.length ? (proList.length ? [{
|
|
|
- id: 'promo-normal',
|
|
|
- total: norTotal
|
|
|
- }, ...proList] : []) : proList
|
|
|
+ const proList = hasSearchNormal ? await queryAwaitDispatch({ ...params, detailPromoFlag: 0 }).then(res => res.data) : []
|
|
|
+ this.hasNormalProduct = proList.length > 0 // 是否有正常产品
|
|
|
+ // 没有活动时不显示正常产品标题行
|
|
|
+ let listData = 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) || []
|
|
|
- }
|
|
|
- }
|
|
|
+ const aclist = await queryAwaitDispatch({ ...params, detailPromoFlag: 1 }).then(res => res.data)
|
|
|
+ // 没用活动产品,不显示
|
|
|
+ const retList = aclist.length ? [{
|
|
|
+ id: 'promo-active'
|
|
|
+ }, ...aclist] : []
|
|
|
+ // 将活动产品数据拼接
|
|
|
+ listData = aclist && aclist.length ? listData.concat(retList) : listData
|
|
|
}
|
|
|
this.dataSource = listData
|
|
|
|
|
@@ -652,10 +609,9 @@ export default {
|
|
|
pageInit (salesBillSn, detailData) {
|
|
|
this.salesBillSn = salesBillSn
|
|
|
this.detailData = detailData
|
|
|
- // 获取活动列表
|
|
|
- this.getActiveList()
|
|
|
// 是否转过采购单
|
|
|
this.hasCreatePurchaseFlag()
|
|
|
+ this.searchTable()
|
|
|
},
|
|
|
// 清空选项
|
|
|
clearSelectTable () {
|