|
@@ -1,26 +1,42 @@
|
|
|
<template>
|
|
|
<div style="padding:10px;">
|
|
|
- <ve-table
|
|
|
- style="width:100%"
|
|
|
- :max-height="300"
|
|
|
- :scroll-width="0"
|
|
|
- border-y
|
|
|
- border-x
|
|
|
- border-around
|
|
|
- row-key-field-name="id"
|
|
|
- :checkbox-option="checkboxOption"
|
|
|
- :column-width-resize-option="columnWidthResizeOption"
|
|
|
- :row-style-option="{clickHighlight: true}"
|
|
|
- :cellSelectionOption="{enable: false}"
|
|
|
- :virtual-scroll-option="{enable: false}"
|
|
|
- :columns="columns"
|
|
|
- :table-data="tableData" />
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <ve-table
|
|
|
+ style="width:100%"
|
|
|
+ :max-height="300"
|
|
|
+ :scroll-width="0"
|
|
|
+ border-y
|
|
|
+ border-x
|
|
|
+ border-around
|
|
|
+ row-key-field-name="id"
|
|
|
+ :checkbox-option="checkboxOption"
|
|
|
+ :column-width-resize-option="columnWidthResizeOption"
|
|
|
+ :cell-style-option="cellStyleOption"
|
|
|
+ :row-style-option="{clickHighlight: true}"
|
|
|
+ :cellSelectionOption="{enable: false}"
|
|
|
+ :virtual-scroll-option="{enable: false}"
|
|
|
+ :columns="columns"
|
|
|
+ :table-data="tableData" />
|
|
|
+ </a-spin>
|
|
|
+ <!-- 活动规则详情 -->
|
|
|
+ <detailModal :openModal="openDetailModal" pageType="salesPage" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
|
|
|
+ <!-- 导入产品 -->
|
|
|
+ <importGuideModal
|
|
|
+ ref="importGuideModal"
|
|
|
+ :openModal="openGuideModal"
|
|
|
+ @close="closeGuideModel"
|
|
|
+ @ok="hanldeImportOk" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { salesPromoDetailCount } from '@/api/salesDetailNew'
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
+import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
|
|
|
+import ImportGuideModal from './importGuideModal.vue'
|
|
|
+import { salesPromoDetailCount, salesDisablePromo, salesEnablePromoPromo, salesBatchInsert } from '@/api/salesDetailNew'
|
|
|
export default {
|
|
|
+ mixins: [commonMixin],
|
|
|
+ components: { detailModal, ImportGuideModal },
|
|
|
props: {
|
|
|
activeList: {
|
|
|
type: Array,
|
|
@@ -40,13 +56,18 @@ export default {
|
|
|
watch: {
|
|
|
activeList: {
|
|
|
handler (val) {
|
|
|
- this.getDataList()
|
|
|
+ if (!this.hasInit) {
|
|
|
+ this.getDataList()
|
|
|
+ }
|
|
|
},
|
|
|
immediate: true
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
+ const _this = this
|
|
|
return {
|
|
|
+ hasInit: false,
|
|
|
+ spinning: false,
|
|
|
columnWidthResizeOption: {
|
|
|
// default false
|
|
|
enable: true,
|
|
@@ -63,6 +84,28 @@ export default {
|
|
|
console.log(isSelected, selectedRowKeys)
|
|
|
}
|
|
|
},
|
|
|
+ // 单元格样式
|
|
|
+ cellStyleOption: {
|
|
|
+ headerCellClass: ({ column, rowIndex }) => {
|
|
|
+ if (column.field == 'col2' || column.field == 'col3' || column.field == 'col4') {
|
|
|
+ return 'table-header-cell-blue'
|
|
|
+ }
|
|
|
+ if (column.field == 'col6' || column.field == 'col7' || column.field == 'col8' || column.field == 'col9') {
|
|
|
+ return 'table-header-cell-red'
|
|
|
+ }
|
|
|
+ if (column.field == 'col11' || column.field == 'col12' || column.field == 'col13') {
|
|
|
+ return 'table-header-cell-green'
|
|
|
+ }
|
|
|
+ if (column.field == 'col14' || column.field == 'col15' || column.field == 'col16' || column.field == 'col17') {
|
|
|
+ return 'table-header-cell-org'
|
|
|
+ }
|
|
|
+ if (column.field == 'col18' || column.field == 'col19' || column.field == 'col20') {
|
|
|
+ return 'table-header-cell-zs'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ bodyCellClass: ({ row, column, rowIndex }) => {
|
|
|
+ }
|
|
|
+ },
|
|
|
columns: [
|
|
|
{
|
|
|
field: '',
|
|
@@ -84,8 +127,8 @@ export default {
|
|
|
return ++rowIndex
|
|
|
}
|
|
|
},
|
|
|
- { field: 'promotionRuleType', key: 'ruletype', width: 100, title: '活动类型', align: 'center', fixed: 'left' },
|
|
|
- { field: 'promotionRuleDesc', key: 'ruledesc', width: 100, title: '规则简称', align: 'center', fixed: 'left' },
|
|
|
+ { field: 'promotionRuleType', key: 'ruletype', width: 100, title: '活动类型', align: 'center', fixed: 'left', ellipsis: { showTitle: true } },
|
|
|
+ { field: 'promotionRuleDesc', key: 'ruledesc', width: 100, title: '规则简称', align: 'center', fixed: 'left', renderBodyCell: ({ row, column, rowIndex }, h) => { return (<div class="table-link-text" onClick={() => _this.showDesc(row)}>{row[column.field]}</div>) } },
|
|
|
{
|
|
|
title: '门槛产品(数量/金额)',
|
|
|
children: [
|
|
@@ -104,7 +147,7 @@ export default {
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- field: 'col5',
|
|
|
+ field: 'col4',
|
|
|
key: 'e',
|
|
|
title: '差额',
|
|
|
width: 50,
|
|
@@ -137,7 +180,7 @@ export default {
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- field: 'col10',
|
|
|
+ field: 'col9',
|
|
|
key: 'l',
|
|
|
title: '差额',
|
|
|
width: 50,
|
|
@@ -175,28 +218,28 @@ export default {
|
|
|
title: '采购额(金额)',
|
|
|
children: [
|
|
|
{
|
|
|
- field: 'col14',
|
|
|
+ field: 'totalUsePromoGiftsAmount',
|
|
|
key: 'm',
|
|
|
title: '额度',
|
|
|
width: 50,
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- field: 'col15',
|
|
|
+ field: 'totalPromoGiftsAmount',
|
|
|
key: 'n',
|
|
|
title: '已选',
|
|
|
width: 50,
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- field: 'col16',
|
|
|
+ field: 'cgejyAmount',
|
|
|
key: 'kq',
|
|
|
title: '结余',
|
|
|
width: 50,
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- field: 'col17',
|
|
|
+ field: 'cgeccAmount',
|
|
|
key: 'jw',
|
|
|
title: '超支',
|
|
|
width: 50,
|
|
@@ -232,8 +275,8 @@ export default {
|
|
|
},
|
|
|
{ field: 'totalCategory', key: 'ks', title: '款数', width: 50, align: 'center', fixed: 'right' },
|
|
|
{ field: 'totalQty', key: 'dsl', title: '数量', width: 50, align: 'center', fixed: 'right' },
|
|
|
- { field: 'totalAmount', key: 'dje', title: '总金额', width: 60, align: 'center', fixed: 'right' },
|
|
|
- { field: 'lossAmount', key: 'dyhje', title: '优惠金额', width: 60, align: 'center', fixed: 'right' },
|
|
|
+ { field: 'totalAmount', key: 'dje', title: '总金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } },
|
|
|
+ { field: 'lossAmount', key: 'dyhje', title: '优惠金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } },
|
|
|
{
|
|
|
field: '',
|
|
|
key: 'action',
|
|
@@ -296,11 +339,16 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
- tableData: []
|
|
|
+ tableData: [],
|
|
|
+ openDetailModal: false, // 规则详情弹框
|
|
|
+ detailSn: null,
|
|
|
+ disabledActiveOption: null,
|
|
|
+ openGuideModal: false // 导入产品引导
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
async getDataList () {
|
|
|
+ this.hasInit = true
|
|
|
for (let i = 0; i < this.activeList.length; i++) {
|
|
|
const item = this.activeList[i]
|
|
|
// 参数
|
|
@@ -310,7 +358,7 @@ export default {
|
|
|
promotionFlag: undefined
|
|
|
}
|
|
|
let acTotal = {}
|
|
|
- // 参与活动数据获取统计信息
|
|
|
+ // 启用的活动数据获取统计信息
|
|
|
if (item.enabledFlag == 1) {
|
|
|
// 参数
|
|
|
const activeParams = {
|
|
@@ -321,36 +369,228 @@ export default {
|
|
|
}
|
|
|
// 获取活动产品统计
|
|
|
acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
|
|
|
+ console.log(acTotal, 'acTotal')
|
|
|
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)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 禁用活动不显示
|
|
|
+ delete item.totalPromoGiftsAmount
|
|
|
+ delete item.totalUsePromoGiftsAmount
|
|
|
}
|
|
|
this.tableData.push({
|
|
|
...item,
|
|
|
promotionRuleType: item.promotionRule.promotionRuleTypeDictValue,
|
|
|
promotionRuleDesc: item.promotionRule.description,
|
|
|
- ...acTotal
|
|
|
+ ...acTotal,
|
|
|
+ countData: acTotal
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- // 禁用启用
|
|
|
- enableRow (row) {
|
|
|
-
|
|
|
+ // 禁用启用活动规则
|
|
|
+ // 启用规则
|
|
|
+ enabledActive (item) {
|
|
|
+ const _this = this
|
|
|
+ this.spinning = true
|
|
|
+ salesEnablePromoPromo({
|
|
|
+ salesBillSn: _this.salesBillSn,
|
|
|
+ salesPromoSn: item.salesPromoSn
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ item.disabled = false
|
|
|
+ _this.activeList.splice()
|
|
|
+ // 刷新产品表格
|
|
|
+ _this.$emit('refashProduct')
|
|
|
+ _this.$message.success('启用成功')
|
|
|
+ }
|
|
|
+ _this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 禁用规则
|
|
|
+ disabledActive (e, item) {
|
|
|
+ const _this = this
|
|
|
+ _this.spinning = true
|
|
|
+ salesDisablePromo({
|
|
|
+ salesBillSn: _this.salesBillSn,
|
|
|
+ salesPromoSn: item.salesPromoSn,
|
|
|
+ promoRuleSn: item.promoRuleSn,
|
|
|
+ salesDisableType: _this.disabledActiveOption
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ item.disabled = true
|
|
|
+ _this.activeList.splice()
|
|
|
+ // 刷新产品表格
|
|
|
+ _this.$emit('refashProduct')
|
|
|
+ _this.disabledActiveOption = null
|
|
|
+ _this.$message.success('禁用成功')
|
|
|
+ }
|
|
|
+ _this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ enableRow (item) {
|
|
|
+ const _this = this
|
|
|
+ // 禁用的直接启用
|
|
|
+ if (item.disabled) {
|
|
|
+ this.enabledActive(item)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 如果没有活动产品,直接禁用无需弹框提示
|
|
|
+ // const table = _this.$refs['productList-' + item.promoRuleSn][0]
|
|
|
+ // if (!table.countData || table.countData && !table.countData.totalQty) {
|
|
|
+ // _this.disabledActiveOption = 'DELETE'
|
|
|
+ // _this.disabledActive(item)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // 弹框提示禁用方式
|
|
|
+ this.$confirm({
|
|
|
+ title: item.promotion.description + '-' + item.promotionRule.description + ',确定禁用规则?',
|
|
|
+ centered: true,
|
|
|
+ class: 'confirm-center',
|
|
|
+ content: <div>
|
|
|
+ <div style="padding:10px 0;text-align:center;">禁用规则后,将无法享受该活动规则优惠</div>
|
|
|
+ <div style="padding:0 0 10px 0;text-align:center;">
|
|
|
+ <aRadioGroup onChange={_this.changeDaOpt}>
|
|
|
+ <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="DELETE">
|
|
|
+ 删除规则中相关产品
|
|
|
+ </aRadio>
|
|
|
+ <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="REMOVE">
|
|
|
+ 移出规则中相关产品
|
|
|
+ </aRadio>
|
|
|
+ </aRadioGroup>
|
|
|
+ </div>
|
|
|
+ </div>,
|
|
|
+ onOk () {
|
|
|
+ if (_this.disabledActiveOption) {
|
|
|
+ _this.disabledActive(item)
|
|
|
+ } else {
|
|
|
+ _this.$message.info('请选择禁用方式!')
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCancel () {
|
|
|
+ _this.disabledActiveOption = null
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 选择禁用活动选项
|
|
|
+ changeDaOpt (e) {
|
|
|
+ this.disabledActiveOption = e.target.value
|
|
|
},
|
|
|
// 导入产品
|
|
|
- handleImportClick (key, row) {
|
|
|
-
|
|
|
+ handleImportClick (e, row) {
|
|
|
+ this.$refs.importGuideModal.pageInit({ promoProductClz: e.key, salesBillSn: this.salesBillSn, salesPromoSn: row.salesPromoSn }, row)
|
|
|
+ this.openGuideModal = true
|
|
|
+ },
|
|
|
+ // 关闭导入弹框
|
|
|
+ closeGuideModel () {
|
|
|
+ this.openGuideModal = false
|
|
|
+ },
|
|
|
+ // 批量导入产品
|
|
|
+ hanldeImportOk (salesBillDetailList, row, promoProductClz) {
|
|
|
+ const params = {
|
|
|
+ salesBillSn: this.salesBillSn,
|
|
|
+ salesBillDetailList: salesBillDetailList
|
|
|
+ }
|
|
|
+ // 活动导入
|
|
|
+ if (row.salesPromoSn) {
|
|
|
+ params.salesPromoSn = row.salesPromoSn
|
|
|
+ params.promoRuleSn = row.promoRuleSn
|
|
|
+ params.promoProductClz = promoProductClz
|
|
|
+ }
|
|
|
+ salesBatchInsert(params).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.$message.success('产品导入成功', 2.5)
|
|
|
+ this.$emit('insterOk', 'promo')
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
// 添加产品
|
|
|
addProduct (row) {
|
|
|
-
|
|
|
+ this.$emit('openCpModal', 1, row)
|
|
|
+ },
|
|
|
+ // 保存添加的产品到销售列表
|
|
|
+ saveNewProduct (row, promotionFlag, promoProductClz) {
|
|
|
+ // 防止多次添加产品
|
|
|
+ if (this.isInster) { return }
|
|
|
+ this.$message.loading('正在添加产品...', 1)
|
|
|
+ this.isInster = true
|
|
|
+ this.spinning = true
|
|
|
+ const params = {
|
|
|
+ salesPromoSn: this.promo.salesPromoSn,
|
|
|
+ promoRuleSn: this.promo.promoRuleSn,
|
|
|
+ promoSn: this.promo.promoSn,
|
|
|
+ promoProductClz: promoProductClz,
|
|
|
+ packQty: row.productPackQty,
|
|
|
+ productSn: row.productSn,
|
|
|
+ showCost: row.lastStockCost,
|
|
|
+ price: row.productPrice,
|
|
|
+ origPrice: row.origPrice,
|
|
|
+ promotionGiftsAmount: 0,
|
|
|
+ usePromotionGiftsAmount: 0,
|
|
|
+ qty: row.salesNums,
|
|
|
+ salesBillSn: this.detailData.salesBillSn,
|
|
|
+ salesBillNo: this.detailData.salesBillNo,
|
|
|
+ purchaseBillSn: this.detailData.purchaseBillSn,
|
|
|
+ purchaseBillNo: this.detailData.purchaseBillNo,
|
|
|
+ priceLevel: row.priceLevel,
|
|
|
+ stockSn: row.stockSn,
|
|
|
+ promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
|
|
|
+ promotionFlag: promotionFlag, // 促销标记 正品传0,促销品传1
|
|
|
+ warehouseSn: row.warehouseSn
|
|
|
+ }
|
|
|
+ salesDetailInsert(params).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.$message.success('产品添加成功', 2.5)
|
|
|
+ this.resetSearchForm(true)
|
|
|
+ this.$emit('insterOk', 'promo')
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ this.isInster = false
|
|
|
+ }).catch(err => {
|
|
|
+ this.isInster = false
|
|
|
+ this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 查看活动详情
|
|
|
+ showDesc (row) {
|
|
|
+ if (row.promoRuleSn) {
|
|
|
+ this.detailSn = row.promoRuleSn
|
|
|
+ this.openDetailModal = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 关闭详情弹窗
|
|
|
+ closeDetailModal () {
|
|
|
+ this.detailSn = null
|
|
|
+ this.openDetailModal = false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style>
|
|
|
+<style lang="less">
|
|
|
+ .table-header-cell-blue {
|
|
|
+ background: #c9fbff !important;
|
|
|
+ }
|
|
|
+ .table-header-cell-red {
|
|
|
+ background: #ffdccb !important;
|
|
|
+ }
|
|
|
+ .table-header-cell-green {
|
|
|
+ background: #deffec !important;
|
|
|
+ }
|
|
|
+ .table-header-cell-zs {
|
|
|
+ background: #fff2ff !important;
|
|
|
+ }
|
|
|
+ .table-header-cell-org {
|
|
|
+ background: #fff3c2 !important;
|
|
|
+ }
|
|
|
+ .table-link-text{
|
|
|
+ color: #409EFF;
|
|
|
+ cursor: pointer;
|
|
|
+ &:hover{
|
|
|
+ text-decoration: underline;
|
|
|
+ }
|
|
|
+ }
|
|
|
</style>
|