123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954 |
- <template>
- <div :style="{padding:type=='edit'?'10px':0}">
- <a-spin :spinning="spinning" tip="Loading...">
- <ve-table
- style="width:100%"
- border-y
- border-x
- border-around
- row-key-field-name="salesPromoSn"
- :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="promoRuleSn" @close="closeDetailModal"></detailModal>
- <!-- 导入产品 -->
- <importGuideModal
- v-if="type=='edit'"
- ref="importGuideModal"
- :openModal="openGuideModal"
- @close="closeGuideModel"
- @ok="hanldeImportOk" />
- <!-- 查看累计产品 -->
- <totalProductDetailModal ref="totalProductModal" :show="openTotalProductModal" @cancel="openTotalProductModal=false"></totalProductDetailModal>
- <!-- 查看买赠产品详情 -->
- <normalProductDetailModal ref="normalProductModal" :buyGiftsInfo="buyGiftsInfo" :openModal="openNormalProductModal" @close="openNormalProductModal=false"></normalProductDetailModal>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
- import totalProductDetailModal from './totalProductDetailModal.vue'
- import normalProductDetailModal from './normalProductDetailModal.vue'
- import ImportGuideModal from './importGuideModal.vue'
- import { salesDisablePromo, salesEnablePromoPromo, salesBatchInsert, salesDetailInsertBatchBorrow } from '@/api/salesDetailNew'
- import { salesPromoSaveSort } from '@/api/salesNew'
- export default {
- mixins: [commonMixin],
- components: { detailModal, ImportGuideModal, totalProductDetailModal, normalProductDetailModal },
- props: {
- type: {
- type: String,
- default: 'edit'
- },
- activeList: {
- type: Array,
- default: () => []
- },
- // 仓库sn
- warehouseSn: {
- type: String,
- default: ''
- },
- // 销售单sn
- salesBillSn: {
- type: String,
- default: ''
- },
- showCols: {
- type: Array,
- default: () => []
- },
- hasNormal: {
- type: Boolean,
- default: true
- }
- },
- watch: {
- activeList: {
- handler (val) {
- if (!this.hasInit) {
- this.tableData = []
- this.getDataList(val)
- }
- },
- immediate: true
- }
- },
- data () {
- return {
- hasInit: false,
- spinning: false,
- // 表格列宽拖到
- columnWidthResizeOption: {
- // default false
- enable: true,
- // column resize min width
- minWidth: 50
- },
- openTotalProductModal: false, // 查看累计产品
- openNormalProductModal: false, // 查看买赠产品详情
- // 表格复选框
- checkboxOption: {
- hideSelectAll: true,
- selectedRowKeys: [],
- // 禁用的选择(禁止勾选或者禁止取消勾选)
- disableSelectedRowKeys: [],
- // 行选择改变事件
- selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
- // 当前勾选产品
- const endSelProduct = selectedRowKeys[selectedRowKeys.length - 1]
- // 叠加多选
- if (endSelProduct && row.promotionRule && row.promotionRule.stackFlag == '1') {
- const rows = this.tableData.filter(item => selectedRowKeys.includes(item.salesPromoSn) && item.promotionRule && item.promotionRule.stackFlag == '1')
- this.checkboxOption.selectedRowKeys = rows.map(item => item.salesPromoSn)
- } else {
- // 非叠加单选
- this.checkboxOption.selectedRowKeys = isSelected ? [endSelProduct] : []
- }
- // 查询此活动下的已选产品列表
- this.$emit('selected', this.checkboxOption.selectedRowKeys)
- }
- },
- // 单元格样式
- cellStyleOption: {
- headerCellClass: ({ column, rowIndex }) => {
- if (column.key >= 4 && column.key <= 8) {
- return 'table-header-cell-blue'
- }
- if (column.key >= 9 && column.key < 12) {
- return 'table-header-cell-org'
- }
- if (column.key >= 12 && column.key <= 15) {
- return 'table-header-cell-red'
- }
- if (column.key >= 16 && column.key <= 18) {
- return 'table-header-cell-green'
- }
- if (column.key >= 19 && column.key <= 21) {
- return 'table-header-cell-zs'
- }
- },
- bodyCellClass: ({ row, column, rowIndex }) => {
- }
- },
- // 筛选
- ruleTypeList: [
- { value: 'BUY_PROD_GIVE_PROD', label: '买产品送产品', selected: true },
- { value: 'BUY_PROD_GIVE_MONEY', label: '买产品送采购额', selected: true },
- { value: 'PROMO_PROD', label: '特价活动', selected: true }
- ],
- ruleEnableList: [
- { value: '1', label: '启用', selected: true },
- { value: '0', label: '禁用', selected: true }
- ],
- searchData: {
- ruleType: [],
- enable: []
- },
- // 表格列表
- tableData: [],
- openDetailModal: false, // 规则详情弹框
- promoRuleSn: null, // 销售单sn
- disabledActiveOption: null, // 禁用规则选项
- enableActiveOption: null, // 启用规则选项
- openGuideModal: false, // 导入产品引导
- buyGiftsInfo: null // 买赠产品弹窗详情信息
- }
- },
- computed: {
- columns () {
- const _this = this
- // 格式化数字金额单元格
- const formatTd = (row, column, rowIndex, uniKey, fun) => {
- const ismktj = column.field == 'specialPriceSelected' && row.totalPromoOrigAmount
- if (column.field != 'regularBaseVal' && column.field != 'regularNextVal' ? row[column.field] : (row[column.field] || row[column.field] == 0)) {
- return (<div onClick={() => fun ? fun(row, uniKey) : false}><span class={fun ? 'table-link-btn' : (column.field == 'geteBalance' || column.field == 'regularBaseVal') ? 'table-word-color' : ''}>{row[column.field]}</span>{ismktj ? <span>({row.totalPromoOrigAmount})</span> : ''}<span style="font-size:10px;zoom:0.7;margin-left:3px;">{row[uniKey]}</span></div>)
- } else {
- return ''
- }
- }
- const cols = [
- {
- field: '',
- key: '1',
- title: '序号',
- width: 25,
- align: 'center',
- fixed: 'left',
- renderBodyCell: ({ row, column, rowIndex }, h) => {
- return ++rowIndex
- }
- },
- {
- field: 'promotionRuleType',
- key: '2',
- width: 90,
- title: '活动类型',
- align: 'center',
- fixed: 'left',
- renderBodyCell: ({ row, column, rowIndex }, h) => {
- const isTejia = row && row.promotionRule && row.promotionRule.promotionRuleType == 'PROMO_PROD' && row.promotionRule.stackFlag == 1 && _this.type == 'edit' // 是否特价叠加
- const tejiaLen = _this.tableData.filter(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD' && item.promotionRule.stackFlag == 1).length // 特价叠加活动数量
- const tjStart = _this.tableData.findIndex(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD' && item.promotionRule.stackFlag == 1) // 特价叠加活动开始索引
- // 特价活动上移下移排序
- const equalWord = <div class="table-arrow-box">
- {rowIndex > tjStart ? <span class="up" onClick={() => _this.moveTjRow(row, rowIndex, 1)} title="上移">⇡</span> : ''}
- {rowIndex < tjStart + tejiaLen - 1 ? <span class="down" onClick={() => _this.moveTjRow(row, rowIndex, 0)} title="下移">⇣</span> : <span></span>}
- </div>
- // 买产品送产品 同款产品 是累计产品才弹详情窗
- if (row.promotionRule.promotionRuleType === 'BUY_PROD_GIVE_PROD' && row.promotionRule.borrowFlag == '1' && row.promotionRule.regularSameFlag == '1') {
- return (<div style="width:100%;display:flex;justify-content: space-between;">
- <div class="table-link-text" onClick={() => _this.showBuyGifts(row)} style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title={row[column.field]}>{row[column.field]}</div>
- {isTejia && tejiaLen > 1 ? equalWord : ''}
- </div>)
- } else {
- return (<div style="width:100%;display:flex;justify-content: space-between;">
- <div style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title={row[column.field]}>{row[column.field]}</div>
- {isTejia && tejiaLen > 1 ? equalWord : ''}
- </div>)
- }
- },
- // 筛选项
- filter: {
- filterList: _this.ruleTypeList,
- isMultiple: true,
- // filter confirm
- filterConfirm: (filterList) => {
- const labels = filterList
- .filter((x) => x.selected)
- .map((x) => x.value)
- _this.searchData.ruleType = labels
- _this.filtrateList()
- },
- // filter reset
- filterReset: (filterList) => {
- filterList.map(x => { x.selected = true })
- _this.searchData.ruleType = []
- _this.filtrateList()
- }
- }
- },
- { field: 'promotionRuleDesc',
- key: '3',
- width: 110,
- title: '规则简称',
- align: 'center',
- fixed: 'left',
- renderBodyCell: ({ row, column, rowIndex }, h) => {
- let mkInfo = ''
- if (row.promotionRule.gateFlag === '1') {
- if (row.promotionRule.gateType === 'RATIO_AMOUNT') {
- mkInfo = `购买门槛产品金额 ${row.promotionRule.gateValue ? (row.promotionRule.gateValue * 100).toFixed(2) : '0.00'}% 作为配额`
- } else if (row.promotionRule.gateType === 'MIN_AMOUNT') {
- mkInfo = `购买门槛产品满最低金额 ${this.toThousands(row.promotionRule.gateValue)} 元,不限制配额`
- } else {
- if (row.promotionRule.promotionRuleType != 'PROMO_PROD') {
- mkInfo = `购买满 ${this.toThousands(row.promotionRule.gateValue)} 元门槛产品,可使用 ${this.toThousands(row.promotionRule.quotaAmount)} 元配额,采购规则中的正价商品`
- } else {
- mkInfo = `购买每满 ${row.promotionRule.gateUnit === 'YUAN' ? this.toThousands(row.promotionRule.gateValue) : row.promotionRule.gateValue} ${row.promotionRule.gateUnit === 'YUAN' ? '元' : '个'}门槛产品,可采购 ${row.promotionRule.quotaAmount} 个特价产品`
- }
- }
- }
- return (<div style="width:100%;display:flex;justify-content: space-between;" onClick={() => _this.showDesc(row)}>
- <div class="table-link-text">
- <a-popover placement="right">
- <template slot="title">
- {row.promotionTitle + '(' + row[column.field] + ')'}
- </template>
- <template slot="content">
- <div><strong>规则门槛:</strong>{row.promotionRule.gateFlag === '1' ? <div>{mkInfo}</div> : <span>无</span>}</div>
- <div><strong>规则:</strong><div domPropsInnerHTML={row.promotionRule.ruleInfo}></div></div>
- </template>
- <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{row[column.field]}</span>
- </a-popover>
- </div>
- <div style="position:absolute;right:0;">
- {row.promotionRule.stackFlag == 1 ? <a-badge count="叠" numberStyle={{ backgroundColor: '#00aa00', marginLeft: '2px', zoom: '0.7' }}/> : ''}
- {row.promotionRule.borrowFlag == 1 ? <a-badge count="累" numberStyle={{ backgroundColor: '#F5222D', marginLeft: '2px', zoom: '0.7' }} /> : ''}
- </div>
- </div>)
- }
- },
- {
- title: '门槛产品',
- children: [
- {
- field: 'gateSelected',
- key: '4',
- title: '已选',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
- },
- {
- field: 'gateTotal',
- key: '5',
- title: '累计',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
- // renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit', _this.openTotalProduct)
- },
- {
- field: 'geteBalance',
- key: '6',
- title: '差额',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
- },
- {
- field: 'gateQuota',
- key: '7',
- title: '配额',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'quotaUnit')
- },
- {
- field: 'unUseGateQuota',
- key: '8',
- title: '未用配额',
- width: 60,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'quotaUnit')
- }
- ]
- },
- {
- title: '特价',
- children: [
- {
- field: 'specialPriceSelected',
- key: '9',
- title: '已选',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
- },
- {
- field: 'discountRuleValue',
- key: '10',
- title: '基础',
- width: 60,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
- },
- {
- field: 'discountRuleNextValue',
- key: '11',
- title: '下阶差',
- width: 60,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
- }
- ]
- },
- {
- title: '正价产品',
- children: [
- {
- field: 'regularSelected',
- key: '12',
- title: '已选',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
- },
- {
- field: 'regularTotal',
- key: '13',
- title: '累计',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
- // renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit', _this.openTotalProduct)
- },
- {
- field: 'regularBaseVal',
- key: '14',
- title: '基础',
- width: 60,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
- },
- {
- field: 'regularNextVal',
- key: '15',
- title: '下阶差',
- width: 60,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
- }
- ]
- },
- {
- title: '促销品',
- children: [
- {
- field: 'promoLimit',
- key: '16',
- title: '额度',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
- },
- {
- field: 'promoSelected',
- key: '17',
- title: '已选',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
- },
- {
- field: 'promoBalance',
- key: '18',
- title: '差额',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
- }
- ]
- },
- {
- title: '采购额',
- children: [
- {
- field: 'purchaseLimit',
- key: '19',
- title: '额度',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
- },
- {
- field: 'purchaseSelected',
- key: '20',
- title: '已选',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
- },
- {
- field: 'purchaseSurplus',
- key: '21',
- title: '结余',
- width: 50,
- align: 'center',
- renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
- }
- ]
- },
- { field: 'totalCategory', key: '22', title: '款数', width: 50, align: 'center', fixed: 'right' },
- { field: 'totalQty', key: '23', title: '数量', width: 50, align: 'center', fixed: 'right' }
- ]
- // 复选框
- cols.unshift({
- field: '',
- key: '0',
- type: 'checkbox',
- title: '',
- width: 23,
- align: 'center',
- fixed: 'left'
- })
- // 销售价权限
- if (this.type == 'view' && this.$hasPermissions('B_salesDetail_salesPrice') || this.type == 'edit' && this.$hasPermissions('B_salesEdit_salesPrice')) {
- cols.push({ field: 'totalAmount', key: '24', title: '总金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } })
- cols.push({ field: 'lossAmount', key: '25', title: '优惠金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } })
- }
- // 编辑页面
- if (this.type == 'edit') {
- cols.push({
- field: '',
- key: '26',
- title: '状态',
- width: 50,
- align: 'center',
- fixed: 'right',
- renderBodyCell: ({ row, column, rowIndex }, h) => {
- return (
- <div>
- <a-switch checked-children="启" un-checked-children="禁" checked={row.enabledFlag == 1} on-change={(c, e) => this.enableRow(c, e, row)}/>
- </div>
- )
- },
- // 筛选项
- filter: {
- filterList: _this.ruleEnableList,
- isMultiple: true,
- // filter confirm
- filterConfirm: (filterList) => {
- const labels = filterList
- .filter((x) => x.selected)
- .map((x) => x.value)
- _this.searchData.enable = labels
- _this.filtrateList()
- },
- // filter reset
- filterReset: (filterList) => {
- filterList.map(x => { x.selected = true })
- _this.searchData.enable = []
- _this.filtrateList()
- }
- }
- })
- cols.push({
- field: '',
- key: '27',
- title: '操作',
- width: 100,
- align: 'center',
- fixed: 'right',
- renderBodyCell: ({ row, column, rowIndex }, h) => {
- // 导入产品按钮
- const importButton = []
- if (row && row.promotionRule && row.promotionRule.gateFlag === '1') {
- importButton.push({ key: 'GATE', name: '门槛产品' })
- }
- if (row && row.promotionRule && row.promotionRule.promotionRuleType != 'PROMO_PROD') {
- importButton.push({ key: 'REGULAR', name: '正价产品' })
- }
- if (row && row.promotionRule && (row.promotionRule.regularPromotionSameFlag === '0' || row.promotionRule.scopeFlag === '0' || (row.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_MONEY' && row.promotionRule.scopeFlag === '1'))) {
- importButton.push({ key: 'GIFT', name: '促销产品' })
- }
- if (row && row.promotionRule && row.promotionRule.promotionRuleType == 'PROMO_PROD') {
- importButton.push({ key: 'DISCOUNT', name: '特价产品' })
- }
- if (row && row.promotionRule && row.promotionRule.borrowFlag == 1 && row.promotionRule.gateFlag === '1') {
- importButton.push({ key: 'BORROW_GATE', name: '累计门槛产品' })
- }
- if (row && row.promotionRule && row.promotionRule.borrowFlag == 1 && row.promotionRule.promotionRuleType != 'PROMO_PROD') {
- importButton.push({ key: 'BORROW_REGULAR', name: '累计正价产品' })
- }
- return (
- <div>
- {row.enabledFlag == 1 ? <a-dropdown>
- <a-menu slot="overlay" on-click={(e) => this.handleImportClick(e, row, importButton)} id={'salesEdit-menu-import-' + row.id}>
- {importButton.map(item => {
- return (
- <a-menu-item id={'salesEdit-menu-import-' + item.key + '-' + row.id} key={item.key}>{item.name}</a-menu-item>
- )
- })}
- </a-menu>
- <a-button
- id={'salesEdit-menu-import-plaction-' + row.id}
- type="link"
- class="button-primary"
- size="small"
- >
- 导入∨
- </a-button>
- </a-dropdown> : ''}
- {row.enabledFlag == 1 ? <a-button
- type="link"
- size="small"
- class="button-primary"
- on-click={() => this.addProduct(row, 1)}
- >
- 添加
- </a-button> : ''}
- {row.enabledFlag == 1 && row.promotionRule.borrowFlag == 1 ? <a-button
- type="link"
- size="small"
- class="button-primary"
- on-click={() => this.addProduct(row, 2)}
- >
- 累计
- </a-button> : <span style="width:40px;display:inline-block;"></span>}
- </div>
- )
- }
- })
- }
- return cols.filter((item, index) => {
- const i = index - 1
- return this.showCols.includes(i.toString()) || index == 0 || index > 12
- })
- }
- },
- methods: {
- // 筛选
- filtrateList () {
- const { ruleType, enable } = this.searchData
- const list = this.activeList.filter(item => ruleType.length === 0 || ruleType.includes(item.promotionRule.promotionRuleType)).filter(item => enable.length == 0 || enable.includes(item.enabledFlag))
- this.tableData = []
- this.getDataList(list)
- },
- getDataList (list) {
- this.hasInit = true
- for (let i = 0; i < list.length; i++) {
- const item = list[i]
- // 门槛统计
- const isYuan = item.gateRuleUnit == 'YUAN'
- const gateUnit = isYuan ? '元' : '个' // 单位
- const gateSelected = isYuan ? (item.gateAmount || item.gateAmount == 0 ? Number(item.gateAmount).toFixed(2) : undefined) : item.gateQty // 已选
- const gateTotal = isYuan ? (item.gateBorrowAmount || item.gateBorrowAmount == 0 ? Number(item.gateBorrowAmount).toFixed(2) : undefined) : item.gateBorrowQty // 累计
- const geteBalance = item.gateShortfallValue || item.gateShortfallValue == 0 ? item.gateShortfallValue : undefined // 差额
- const quotaUnit = item.quotaRuleUnit == 'YUAN' ? '元' : '个' // 配额单位
- const gateQuota = item.gateQuotaAmount || item.gateQuotaAmount == 0 ? Number(item.gateQuotaAmount).toFixed(2) : undefined // 配额
- const unUseGateQuota = item.unUseAmount || item.unUseAmount == 0 ? Number(item.unUseAmount).toFixed(2) : undefined // 未用配额
- // 特价产品
- const isYuan2 = item.discountRuleUnit == 'YUAN'
- const discountRuleUnit = isYuan2 ? '元' : '个' // 单位
- const specialPriceSelected = isYuan2 ? (item.discountAmount || item.discountAmount == 0 ? Number(item.discountAmount).toFixed(2) : undefined) : item.discountQty || 0 // 已选
- const totalPromoOrigAmount = isYuan2 && (item.totalPromoOrigAmount || item.totalPromoOrigAmount == 0) ? Number(item.totalPromoOrigAmount).toFixed(2) : undefined
- const discountRuleValue = isYuan2 ? (item.discountRuleValue || item.discountRuleValue == 0 ? Number(item.discountRuleValue).toFixed(2) : undefined) : item.discountRuleValue // 基础
- const discountRuleNextValue = isYuan2 ? (item.discountShortfallValue || item.discountShortfallValue == 0 ? Number(item.discountShortfallValue).toFixed(2) : undefined) : item.discountShortfallValue // 下阶差
- // 正价统计
- const isYuan1 = item.regularRuleUnit == 'YUAN'
- const regularUnit = isYuan1 ? '元' : '个' // 单位
- const regularSelected = isYuan1 ? (item.regularAmount || item.regularAmount == 0 ? Number(item.regularAmount).toFixed(2) : undefined) : item.regularQty // 已选
- const regularTotal = isYuan1 ? (item.regularBorrowAmount || item.regularBorrowAmount == 0 ? Number(item.regularBorrowAmount).toFixed(2) : undefined) : item.regularBorrowQty // 累计
- const regularPromotionSameFlag = item.promotionRule.promotionRuleType === 'BUY_PROD_GIVE_PROD' && item.promotionRule.regularPromotionSameFlag == 1 // 促销品是否与正品一致
- const baseVal1 = isYuan1 ? (item.regularRuleValue || item.regularRuleValue == 0 ? Number(item.regularRuleValue).toFixed(2) : undefined) : item.regularRuleValue
- const nextVal1 = isYuan1 ? (item.regularShortfallValue || item.regularShortfallValue == 0 ? Number(item.regularShortfallValue).toFixed(2) : undefined) : item.regularShortfallValue
- const regularBaseVal = regularPromotionSameFlag ? undefined : baseVal1 // 基础差
- const regularNextVal = regularPromotionSameFlag ? undefined : nextVal1 // 下级差
- // 促销品
- const promoUnit = '个'
- const promoSelected = item.giftQty || item.giftQty == 0 ? item.giftQty : undefined// 已选
- const promoBalance = item.giftShortfallQty || item.giftShortfallQty == 0 ? item.giftShortfallQty : undefined // 差额
- const promoLimit = item.giftGiveQty || item.giftGiveQty == 0 ? item.giftGiveQty : undefined // 额度
- // 采购额
- const purchaseUnit = '元'
- const purchaseLimit = item.totalPromoGiftsAmount || item.totalPromoGiftsAmount == 0 ? Number(item.totalPromoGiftsAmount).toFixed(2) : undefined // 额度
- const purchaseSelected = item.totalUsePromoGiftsAmount || item.totalUsePromoGiftsAmount == 0 ? Number(item.totalUsePromoGiftsAmount).toFixed(2) : undefined // 已选
- const purchaseSurplus = item.surplusAmount || item.surplusAmount == 0 ? Number(item.surplusAmount).toFixed(2) : undefined // 结余
- // 促销品
- this.tableData.push({
- ...item,
- ruleType: item.promotionRule.promotionRuleType,
- promotionRuleType: item.promotionRule.promotionRuleTypeDictValue,
- promotionRuleDesc: item.promotionRule.description,
- promotionTitle: item.promotion.title,
- // 门槛
- gateUnit, // 单位
- quotaUnit, // 配额单位
- gateQuota, // 配额
- unUseGateQuota, // 未用配额
- gateSelected, // 已选
- gateTotal, // 累计
- geteBalance, // 差额
- // 特价产品
- discountRuleUnit,
- specialPriceSelected, // 已选
- totalPromoOrigAmount,
- discountRuleValue, // 基础
- discountRuleNextValue, // 下阶差
- // 正价
- regularUnit, // 单位
- regularSelected, // 已选
- regularTotal, // 累计
- regularBaseVal, // 基础差
- regularNextVal, // 下阶差
- // 促销品
- promoUnit, // 单位
- promoLimit, // 额度
- promoSelected, // 已选
- promoBalance, // 差额
- // 采购额
- purchaseUnit,
- purchaseLimit, // 额度
- purchaseSelected, // 已选
- purchaseSurplus // 结余
- })
- }
- // 获取禁用的活动规则
- this.disabledActiveIds()
- },
- // 禁用的活动规则
- disabledActiveIds () {
- this.checkboxOption.disableSelectedRowKeys = this.tableData.filter(item => item.enabledFlag == 0).map(item => item.id)
- },
- // 上下移动特价活动
- moveTjRow (item, rowIndex, type) {
- const temp = this.tableData[type == 1 ? rowIndex - 1 : rowIndex + 1]
- const tempSort = temp.sort
- temp.sort = item.sort
- item.sort = tempSort
- // 保存排序
- const tejia = this.tableData.filter(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD')
- const data = tejia.map(item => {
- return {
- id: item.id,
- sort: item.sort
- }
- })
- this.spinning = true
- salesPromoSaveSort({ salesBillSn: this.salesBillSn, salesPromoList: data }).then(res => {
- this.spinning = false
- if (res.status == 200) {
- this.$emit('refash', '', 'sort')
- } else {
- // 恢复排序
- item.sort = temp.sort
- temp.sort = tempSort
- }
- })
- },
- // 刷新当前规则
- refashRow (item, enable) {
- // 刷新产品列表
- this.$emit('refash', '', 'enable')
- const active = this.tableData.find(k => k.id == item.id)
- active.enabledFlag = enable
- // 获取禁用的活动规则
- this.disabledActiveIds()
- },
- // 查看累计产品 详情
- openTotalProduct (row, type) {
- this.openTotalProductModal = true
- this.$refs.totalProductModal.pageInit({ salesBillSn: row.salesBillSn, salesPromoSn: row.salesPromoSn, promotionFlag: type === 'gateUnit' ? 'GATE' : 'REGULAR' })
- },
- // 显示买赠产品弹窗
- showBuyGifts (rowVal) {
- rowVal.promotionRule.salesPromoSn = rowVal.salesPromoSn
- this.buyGiftsInfo = rowVal.promotionRule
- this.openNormalProductModal = true
- const _this = this
- this.$nextTick(() => {
- _this.$refs.normalProductModal.resetSearchForm()
- })
- },
- // 启用规则
- enabledActive (item) {
- const _this = this
- this.spinning = true
- salesEnablePromoPromo({
- salesBillSn: _this.salesBillSn,
- salesPromoSn: item.salesPromoSn,
- salesEnableType: _this.enableActiveOption
- }).then(res => {
- if (res.status == 200) {
- // 刷新
- _this.refashRow(item, 1)
- _this.enableActiveOption = null
- _this.$message.success('启用成功')
- }
- _this.spinning = false
- })
- },
- // 禁用规则
- disabledActive (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) {
- // 刷新
- _this.refashRow(item, 0)
- _this.disabledActiveOption = null
- _this.$message.success('禁用成功')
- }
- _this.spinning = false
- })
- },
- enableRow (c, e, item) {
- const _this = this
- // 启用
- if (item.enabledFlag == 0) {
- // 启用无正常产品直接启用
- if (!this.hasNormal) {
- _this.enableActiveOption = 'ENABLE_ONLY'
- _this.enabledActive(item)
- return
- }
- const isJiejia = item.promotionRule.stackFlag == 1 // 叠加产品
- this.$confirm({
- title: item.promotion.description + '-' + item.promotionRule.description + ',确定启用规则?',
- centered: true,
- class: 'confirm-center',
- content: <div>
- <div style="padding:10px;">
- <div style="padding:10px 0;">请选择</div>
- <aRadioGroup onChange={e => { _this.enableActiveOption = e.target.value }}>
- <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_WITH_NORMAL">
- 正常产品适配
- </aRadio>
- {isJiejia ? <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_WITH_STACK">
- 叠加规则产品适配
- </aRadio> : ''}
- {isJiejia ? <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_WITH_STACK_NORMAL">
- 所有产品适配
- </aRadio> : ''}
- <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_ONLY">
- 仅启用不适配
- </aRadio>
- </aRadioGroup>
- </div>
- </div>,
- onOk () {
- if (_this.enableActiveOption) {
- _this.enabledActive(item)
- } else {
- _this.$message.info('请选择启用方式!')
- return true
- }
- },
- onCancel () {
- _this.enableActiveOption = null
- }
- })
- return
- }
- // 禁用
- // 无产品直接禁用
- if (item.totalQty == 0) {
- _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={e => { _this.disabledActiveOption = e.target.value }}>
- <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
- }
- })
- },
- // 导入产品
- handleImportClick (e, row, importButton) {
- const title = importButton.find(item => item.key === e.key).name
- this.$refs.importGuideModal.pageInit({ promoProductClz: e.key, salesBillSn: this.salesBillSn, salesPromoSn: row.salesPromoSn }, row, title)
- this.openGuideModal = true
- },
- // 关闭导入弹框
- closeGuideModel () {
- this.openGuideModal = false
- },
- // 批量导入产品
- hanldeImportOk (salesBillDetailList, row, promoProductClz, isTotalFlag) {
- const fun = isTotalFlag ? salesDetailInsertBatchBorrow : salesBatchInsert
- const params = {
- salesBillSn: this.salesBillSn,
- salesBillDetailList: salesBillDetailList
- }
- // 活动导入
- if (row.salesPromoSn) {
- params.salesPromoSn = row.salesPromoSn
- params.promoRuleSn = row.promoRuleSn
- params.promoProductClz = promoProductClz
- }
- fun(params).then(res => {
- if (res.status == 200) {
- this.$message.success(isTotalFlag ? '累计产品导入成功' : '产品导入成功', 2.5)
- this.$emit('refash', '', 'import')
- }
- })
- },
- // 添加产品
- addProduct (row, type) {
- this.$emit('openCpModal', type, row)
- },
- // 查看活动详情
- showDesc (row) {
- if (row.promoRuleSn) {
- this.promoRuleSn = row.promoRuleSn
- this.openDetailModal = true
- }
- },
- // 关闭详情弹窗
- closeDetailModal () {
- this.promoRuleSn = null
- this.openDetailModal = false
- }
- }
- }
- </script>
- <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{
- width:100%;
- color: #409EFF;
- display:flex;
- cursor:pointer;
- &:hover{
- text-decoration: underline;
- }
- }
- .table-link-btn{
- color: #409EFF;
- cursor:pointer;
- &:hover{
- text-decoration: underline;
- }
- }
- .table-word-color{
- color:#ed1c24;
- }
- .table-arrow-box{
- display: flex;
- span{
- width:16px;
- text-align:center;
- cursor:pointer;
- border-radius: 50px;
- }
- .up{
- color:#ed1c24;
- &:hover{
- color:#fff;
- background:#ed1c24;
- }
- }
- .down{
- color:#00aaff;
- &:hover{
- color:#fff;
- background:#00aaff;
- }
- }
- }
- </style>
|