activeStatisticsList.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. <template>
  2. <div :style="{padding:type=='edit'?'10px':0}">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <ve-table
  5. style="width:100%"
  6. border-y
  7. border-x
  8. border-around
  9. row-key-field-name="salesPromoSn"
  10. :checkbox-option="checkboxOption"
  11. :column-width-resize-option="columnWidthResizeOption"
  12. :cell-style-option="cellStyleOption"
  13. :row-style-option="{clickHighlight: true}"
  14. :cellSelectionOption="{enable: false}"
  15. :virtual-scroll-option="{enable: false}"
  16. :columns="columns"
  17. :table-data="tableData" />
  18. </a-spin>
  19. <!-- 活动规则详情 -->
  20. <detailModal :openModal="openDetailModal" pageType="salesPage" :itemSn="promoRuleSn" @close="closeDetailModal"></detailModal>
  21. <!-- 导入产品 -->
  22. <importGuideModal
  23. v-if="type=='edit'"
  24. ref="importGuideModal"
  25. :openModal="openGuideModal"
  26. @close="closeGuideModel"
  27. @ok="hanldeImportOk" />
  28. <!-- 查看累计产品 -->
  29. <totalProductDetailModal ref="totalProductModal" :show="openTotalProductModal" @cancel="openTotalProductModal=false"></totalProductDetailModal>
  30. <!-- 查看买赠产品详情 -->
  31. <normalProductDetailModal ref="normalProductModal" :buyGiftsInfo="buyGiftsInfo" :openModal="openNormalProductModal" @close="openNormalProductModal=false"></normalProductDetailModal>
  32. </div>
  33. </template>
  34. <script>
  35. import { commonMixin } from '@/utils/mixin'
  36. import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
  37. import totalProductDetailModal from './totalProductDetailModal.vue'
  38. import normalProductDetailModal from './normalProductDetailModal.vue'
  39. import ImportGuideModal from './importGuideModal.vue'
  40. import { salesDisablePromo, salesEnablePromoPromo, salesBatchInsert, salesDetailInsertBatchBorrow } from '@/api/salesDetailNew'
  41. import { salesPromoSaveSort } from '@/api/salesNew'
  42. export default {
  43. mixins: [commonMixin],
  44. components: { detailModal, ImportGuideModal, totalProductDetailModal, normalProductDetailModal },
  45. props: {
  46. type: {
  47. type: String,
  48. default: 'edit'
  49. },
  50. activeList: {
  51. type: Array,
  52. default: () => []
  53. },
  54. // 仓库sn
  55. warehouseSn: {
  56. type: String,
  57. default: ''
  58. },
  59. // 销售单sn
  60. salesBillSn: {
  61. type: String,
  62. default: ''
  63. },
  64. showCols: {
  65. type: Array,
  66. default: () => []
  67. },
  68. hasNormal: {
  69. type: Boolean,
  70. default: true
  71. }
  72. },
  73. watch: {
  74. activeList: {
  75. handler (val) {
  76. if (!this.hasInit) {
  77. this.tableData = []
  78. this.getDataList(val)
  79. }
  80. },
  81. immediate: true
  82. }
  83. },
  84. data () {
  85. return {
  86. hasInit: false,
  87. spinning: false,
  88. // 表格列宽拖到
  89. columnWidthResizeOption: {
  90. // default false
  91. enable: true,
  92. // column resize min width
  93. minWidth: 50
  94. },
  95. openTotalProductModal: false, // 查看累计产品
  96. openNormalProductModal: false, // 查看买赠产品详情
  97. // 表格复选框
  98. checkboxOption: {
  99. hideSelectAll: true,
  100. selectedRowKeys: [],
  101. // 禁用的选择(禁止勾选或者禁止取消勾选)
  102. disableSelectedRowKeys: [],
  103. // 行选择改变事件
  104. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  105. // 当前勾选产品
  106. const endSelProduct = selectedRowKeys[selectedRowKeys.length - 1]
  107. // 叠加多选
  108. if (endSelProduct && row.promotionRule && row.promotionRule.stackFlag == '1') {
  109. const rows = this.tableData.filter(item => selectedRowKeys.includes(item.salesPromoSn) && item.promotionRule && item.promotionRule.stackFlag == '1')
  110. this.checkboxOption.selectedRowKeys = rows.map(item => item.salesPromoSn)
  111. } else {
  112. // 非叠加单选
  113. this.checkboxOption.selectedRowKeys = isSelected ? [endSelProduct] : []
  114. }
  115. // 查询此活动下的已选产品列表
  116. this.$emit('selected', this.checkboxOption.selectedRowKeys)
  117. }
  118. },
  119. // 单元格样式
  120. cellStyleOption: {
  121. headerCellClass: ({ column, rowIndex }) => {
  122. if (column.key >= 4 && column.key <= 8) {
  123. return 'table-header-cell-blue'
  124. }
  125. if (column.key >= 9 && column.key < 12) {
  126. return 'table-header-cell-org'
  127. }
  128. if (column.key >= 12 && column.key <= 15) {
  129. return 'table-header-cell-red'
  130. }
  131. if (column.key >= 16 && column.key <= 18) {
  132. return 'table-header-cell-green'
  133. }
  134. if (column.key >= 19 && column.key <= 21) {
  135. return 'table-header-cell-zs'
  136. }
  137. },
  138. bodyCellClass: ({ row, column, rowIndex }) => {
  139. }
  140. },
  141. // 筛选
  142. ruleTypeList: [
  143. { value: 'BUY_PROD_GIVE_PROD', label: '买产品送产品', selected: true },
  144. { value: 'BUY_PROD_GIVE_MONEY', label: '买产品送采购额', selected: true },
  145. { value: 'PROMO_PROD', label: '特价活动', selected: true }
  146. ],
  147. ruleEnableList: [
  148. { value: '1', label: '启用', selected: true },
  149. { value: '0', label: '禁用', selected: true }
  150. ],
  151. searchData: {
  152. ruleType: [],
  153. enable: []
  154. },
  155. // 表格列表
  156. tableData: [],
  157. openDetailModal: false, // 规则详情弹框
  158. promoRuleSn: null, // 销售单sn
  159. disabledActiveOption: null, // 禁用规则选项
  160. enableActiveOption: null, // 启用规则选项
  161. openGuideModal: false, // 导入产品引导
  162. buyGiftsInfo: null // 买赠产品弹窗详情信息
  163. }
  164. },
  165. computed: {
  166. columns () {
  167. const _this = this
  168. // 格式化数字金额单元格
  169. const formatTd = (row, column, rowIndex, uniKey, fun) => {
  170. const ismktj = column.field == 'specialPriceSelected' && row.totalPromoOrigAmount
  171. if (column.field != 'regularBaseVal' && column.field != 'regularNextVal' ? row[column.field] : (row[column.field] || row[column.field] == 0)) {
  172. 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>)
  173. } else {
  174. return ''
  175. }
  176. }
  177. const cols = [
  178. {
  179. field: '',
  180. key: '1',
  181. title: '序号',
  182. width: 25,
  183. align: 'center',
  184. fixed: 'left',
  185. renderBodyCell: ({ row, column, rowIndex }, h) => {
  186. return ++rowIndex
  187. }
  188. },
  189. {
  190. field: 'promotionRuleType',
  191. key: '2',
  192. width: 90,
  193. title: '活动类型',
  194. align: 'center',
  195. fixed: 'left',
  196. renderBodyCell: ({ row, column, rowIndex }, h) => {
  197. const isTejia = row && row.promotionRule && row.promotionRule.promotionRuleType == 'PROMO_PROD' && row.promotionRule.stackFlag == 1 && _this.type == 'edit' // 是否特价叠加
  198. const tejiaLen = _this.tableData.filter(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD' && item.promotionRule.stackFlag == 1).length // 特价叠加活动数量
  199. const tjStart = _this.tableData.findIndex(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD' && item.promotionRule.stackFlag == 1) // 特价叠加活动开始索引
  200. // 特价活动上移下移排序
  201. const equalWord = <div class="table-arrow-box">
  202. {rowIndex > tjStart ? <span class="up" onClick={() => _this.moveTjRow(row, rowIndex, 1)} title="上移">⇡</span> : ''}
  203. {rowIndex < tjStart + tejiaLen - 1 ? <span class="down" onClick={() => _this.moveTjRow(row, rowIndex, 0)} title="下移">⇣</span> : <span></span>}
  204. </div>
  205. // 买产品送产品 同款产品 是累计产品才弹详情窗
  206. if (row.promotionRule.promotionRuleType === 'BUY_PROD_GIVE_PROD' && row.promotionRule.borrowFlag == '1' && row.promotionRule.regularSameFlag == '1') {
  207. return (<div style="width:100%;display:flex;justify-content: space-between;">
  208. <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>
  209. {isTejia && tejiaLen > 1 ? equalWord : ''}
  210. </div>)
  211. } else {
  212. return (<div style="width:100%;display:flex;justify-content: space-between;">
  213. <div style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title={row[column.field]}>{row[column.field]}</div>
  214. {isTejia && tejiaLen > 1 ? equalWord : ''}
  215. </div>)
  216. }
  217. },
  218. // 筛选项
  219. filter: {
  220. filterList: _this.ruleTypeList,
  221. isMultiple: true,
  222. // filter confirm
  223. filterConfirm: (filterList) => {
  224. const labels = filterList
  225. .filter((x) => x.selected)
  226. .map((x) => x.value)
  227. _this.searchData.ruleType = labels
  228. _this.filtrateList()
  229. },
  230. // filter reset
  231. filterReset: (filterList) => {
  232. filterList.map(x => { x.selected = true })
  233. _this.searchData.ruleType = []
  234. _this.filtrateList()
  235. }
  236. }
  237. },
  238. { field: 'promotionRuleDesc',
  239. key: '3',
  240. width: 110,
  241. title: '规则简称',
  242. align: 'center',
  243. fixed: 'left',
  244. renderBodyCell: ({ row, column, rowIndex }, h) => {
  245. let mkInfo = ''
  246. if (row.promotionRule.gateFlag === '1') {
  247. if (row.promotionRule.gateType === 'RATIO_AMOUNT') {
  248. mkInfo = `购买门槛产品金额 ${row.promotionRule.gateValue ? (row.promotionRule.gateValue * 100).toFixed(2) : '0.00'}% 作为配额`
  249. } else if (row.promotionRule.gateType === 'MIN_AMOUNT') {
  250. mkInfo = `购买门槛产品满最低金额 ${this.toThousands(row.promotionRule.gateValue)} 元,不限制配额`
  251. } else {
  252. if (row.promotionRule.promotionRuleType != 'PROMO_PROD') {
  253. mkInfo = `购买满 ${this.toThousands(row.promotionRule.gateValue)} 元门槛产品,可使用 ${this.toThousands(row.promotionRule.quotaAmount)} 元配额,采购规则中的正价商品`
  254. } else {
  255. mkInfo = `购买每满 ${row.promotionRule.gateUnit === 'YUAN' ? this.toThousands(row.promotionRule.gateValue) : row.promotionRule.gateValue} ${row.promotionRule.gateUnit === 'YUAN' ? '元' : '个'}门槛产品,可采购 ${row.promotionRule.quotaAmount} 个特价产品`
  256. }
  257. }
  258. }
  259. return (<div style="width:100%;display:flex;justify-content: space-between;" onClick={() => _this.showDesc(row)}>
  260. <div class="table-link-text">
  261. <a-popover placement="right">
  262. <template slot="title">
  263. {row.promotionTitle + '(' + row[column.field] + ')'}
  264. </template>
  265. <template slot="content">
  266. <div><strong>规则门槛:</strong>{row.promotionRule.gateFlag === '1' ? <div>{mkInfo}</div> : <span>无</span>}</div>
  267. <div><strong>规则:</strong><div domPropsInnerHTML={row.promotionRule.ruleInfo}></div></div>
  268. </template>
  269. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{row[column.field]}</span>
  270. </a-popover>
  271. </div>
  272. <div style="position:absolute;right:0;">
  273. {row.promotionRule.stackFlag == 1 ? <a-badge count="叠" numberStyle={{ backgroundColor: '#00aa00', marginLeft: '2px', zoom: '0.7' }}/> : ''}
  274. {row.promotionRule.borrowFlag == 1 ? <a-badge count="累" numberStyle={{ backgroundColor: '#F5222D', marginLeft: '2px', zoom: '0.7' }} /> : ''}
  275. </div>
  276. </div>)
  277. }
  278. },
  279. {
  280. title: '门槛产品',
  281. children: [
  282. {
  283. field: 'gateSelected',
  284. key: '4',
  285. title: '已选',
  286. width: 50,
  287. align: 'center',
  288. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
  289. },
  290. {
  291. field: 'gateTotal',
  292. key: '5',
  293. title: '累计',
  294. width: 50,
  295. align: 'center',
  296. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
  297. // renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit', _this.openTotalProduct)
  298. },
  299. {
  300. field: 'geteBalance',
  301. key: '6',
  302. title: '差额',
  303. width: 50,
  304. align: 'center',
  305. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
  306. },
  307. {
  308. field: 'gateQuota',
  309. key: '7',
  310. title: '配额',
  311. width: 50,
  312. align: 'center',
  313. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'quotaUnit')
  314. },
  315. {
  316. field: 'unUseGateQuota',
  317. key: '8',
  318. title: '未用配额',
  319. width: 60,
  320. align: 'center',
  321. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'quotaUnit')
  322. }
  323. ]
  324. },
  325. {
  326. title: '特价',
  327. children: [
  328. {
  329. field: 'specialPriceSelected',
  330. key: '9',
  331. title: '已选',
  332. width: 50,
  333. align: 'center',
  334. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
  335. },
  336. {
  337. field: 'discountRuleValue',
  338. key: '10',
  339. title: '基础',
  340. width: 60,
  341. align: 'center',
  342. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
  343. },
  344. {
  345. field: 'discountRuleNextValue',
  346. key: '11',
  347. title: '下阶差',
  348. width: 60,
  349. align: 'center',
  350. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
  351. }
  352. ]
  353. },
  354. {
  355. title: '正价产品',
  356. children: [
  357. {
  358. field: 'regularSelected',
  359. key: '12',
  360. title: '已选',
  361. width: 50,
  362. align: 'center',
  363. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  364. },
  365. {
  366. field: 'regularTotal',
  367. key: '13',
  368. title: '累计',
  369. width: 50,
  370. align: 'center',
  371. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  372. // renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit', _this.openTotalProduct)
  373. },
  374. {
  375. field: 'regularBaseVal',
  376. key: '14',
  377. title: '基础',
  378. width: 60,
  379. align: 'center',
  380. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  381. },
  382. {
  383. field: 'regularNextVal',
  384. key: '15',
  385. title: '下阶差',
  386. width: 60,
  387. align: 'center',
  388. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  389. }
  390. ]
  391. },
  392. {
  393. title: '促销品',
  394. children: [
  395. {
  396. field: 'promoLimit',
  397. key: '16',
  398. title: '额度',
  399. width: 50,
  400. align: 'center',
  401. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
  402. },
  403. {
  404. field: 'promoSelected',
  405. key: '17',
  406. title: '已选',
  407. width: 50,
  408. align: 'center',
  409. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
  410. },
  411. {
  412. field: 'promoBalance',
  413. key: '18',
  414. title: '差额',
  415. width: 50,
  416. align: 'center',
  417. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
  418. }
  419. ]
  420. },
  421. {
  422. title: '采购额',
  423. children: [
  424. {
  425. field: 'purchaseLimit',
  426. key: '19',
  427. title: '额度',
  428. width: 50,
  429. align: 'center',
  430. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
  431. },
  432. {
  433. field: 'purchaseSelected',
  434. key: '20',
  435. title: '已选',
  436. width: 50,
  437. align: 'center',
  438. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
  439. },
  440. {
  441. field: 'purchaseSurplus',
  442. key: '21',
  443. title: '结余',
  444. width: 50,
  445. align: 'center',
  446. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
  447. }
  448. ]
  449. },
  450. { field: 'totalCategory', key: '22', title: '款数', width: 50, align: 'center', fixed: 'right' },
  451. { field: 'totalQty', key: '23', title: '数量', width: 50, align: 'center', fixed: 'right' }
  452. ]
  453. // 复选框
  454. cols.unshift({
  455. field: '',
  456. key: '0',
  457. type: 'checkbox',
  458. title: '',
  459. width: 23,
  460. align: 'center',
  461. fixed: 'left'
  462. })
  463. // 销售价权限
  464. if (this.type == 'view' && this.$hasPermissions('B_salesDetail_salesPrice') || this.type == 'edit' && this.$hasPermissions('B_salesEdit_salesPrice')) {
  465. cols.push({ field: 'totalAmount', key: '24', title: '总金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } })
  466. cols.push({ field: 'lossAmount', key: '25', title: '优惠金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } })
  467. }
  468. // 编辑页面
  469. if (this.type == 'edit') {
  470. cols.push({
  471. field: '',
  472. key: '26',
  473. title: '状态',
  474. width: 50,
  475. align: 'center',
  476. fixed: 'right',
  477. renderBodyCell: ({ row, column, rowIndex }, h) => {
  478. return (
  479. <div>
  480. <a-switch checked-children="启" un-checked-children="禁" checked={row.enabledFlag == 1} on-change={(c, e) => this.enableRow(c, e, row)}/>
  481. </div>
  482. )
  483. },
  484. // 筛选项
  485. filter: {
  486. filterList: _this.ruleEnableList,
  487. isMultiple: true,
  488. // filter confirm
  489. filterConfirm: (filterList) => {
  490. const labels = filterList
  491. .filter((x) => x.selected)
  492. .map((x) => x.value)
  493. _this.searchData.enable = labels
  494. _this.filtrateList()
  495. },
  496. // filter reset
  497. filterReset: (filterList) => {
  498. filterList.map(x => { x.selected = true })
  499. _this.searchData.enable = []
  500. _this.filtrateList()
  501. }
  502. }
  503. })
  504. cols.push({
  505. field: '',
  506. key: '27',
  507. title: '操作',
  508. width: 100,
  509. align: 'center',
  510. fixed: 'right',
  511. renderBodyCell: ({ row, column, rowIndex }, h) => {
  512. // 导入产品按钮
  513. const importButton = []
  514. if (row && row.promotionRule && row.promotionRule.gateFlag === '1') {
  515. importButton.push({ key: 'GATE', name: '门槛产品' })
  516. }
  517. if (row && row.promotionRule && row.promotionRule.promotionRuleType != 'PROMO_PROD') {
  518. importButton.push({ key: 'REGULAR', name: '正价产品' })
  519. }
  520. if (row && row.promotionRule && (row.promotionRule.regularPromotionSameFlag === '0' || row.promotionRule.scopeFlag === '0' || (row.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_MONEY' && row.promotionRule.scopeFlag === '1'))) {
  521. importButton.push({ key: 'GIFT', name: '促销产品' })
  522. }
  523. if (row && row.promotionRule && row.promotionRule.promotionRuleType == 'PROMO_PROD') {
  524. importButton.push({ key: 'DISCOUNT', name: '特价产品' })
  525. }
  526. if (row && row.promotionRule && row.promotionRule.borrowFlag == 1 && row.promotionRule.gateFlag === '1') {
  527. importButton.push({ key: 'BORROW_GATE', name: '累计门槛产品' })
  528. }
  529. if (row && row.promotionRule && row.promotionRule.borrowFlag == 1 && row.promotionRule.promotionRuleType != 'PROMO_PROD') {
  530. importButton.push({ key: 'BORROW_REGULAR', name: '累计正价产品' })
  531. }
  532. return (
  533. <div>
  534. {row.enabledFlag == 1 ? <a-dropdown>
  535. <a-menu slot="overlay" on-click={(e) => this.handleImportClick(e, row, importButton)} id={'salesEdit-menu-import-' + row.id}>
  536. {importButton.map(item => {
  537. return (
  538. <a-menu-item id={'salesEdit-menu-import-' + item.key + '-' + row.id} key={item.key}>{item.name}</a-menu-item>
  539. )
  540. })}
  541. </a-menu>
  542. <a-button
  543. id={'salesEdit-menu-import-plaction-' + row.id}
  544. type="link"
  545. class="button-primary"
  546. size="small"
  547. >
  548. 导入∨
  549. </a-button>
  550. </a-dropdown> : ''}
  551. {row.enabledFlag == 1 ? <a-button
  552. type="link"
  553. size="small"
  554. class="button-primary"
  555. on-click={() => this.addProduct(row, 1)}
  556. >
  557. 添加
  558. </a-button> : ''}
  559. {row.enabledFlag == 1 && row.promotionRule.borrowFlag == 1 ? <a-button
  560. type="link"
  561. size="small"
  562. class="button-primary"
  563. on-click={() => this.addProduct(row, 2)}
  564. >
  565. 累计
  566. </a-button> : <span style="width:40px;display:inline-block;"></span>}
  567. </div>
  568. )
  569. }
  570. })
  571. }
  572. return cols.filter((item, index) => {
  573. const i = index - 1
  574. return this.showCols.includes(i.toString()) || index == 0 || index > 12
  575. })
  576. }
  577. },
  578. methods: {
  579. // 筛选
  580. filtrateList () {
  581. const { ruleType, enable } = this.searchData
  582. const list = this.activeList.filter(item => ruleType.length === 0 || ruleType.includes(item.promotionRule.promotionRuleType)).filter(item => enable.length == 0 || enable.includes(item.enabledFlag))
  583. this.tableData = []
  584. this.getDataList(list)
  585. },
  586. getDataList (list) {
  587. this.hasInit = true
  588. for (let i = 0; i < list.length; i++) {
  589. const item = list[i]
  590. // 门槛统计
  591. const isYuan = item.gateRuleUnit == 'YUAN'
  592. const gateUnit = isYuan ? '元' : '个' // 单位
  593. const gateSelected = isYuan ? (item.gateAmount || item.gateAmount == 0 ? Number(item.gateAmount).toFixed(2) : undefined) : item.gateQty // 已选
  594. const gateTotal = isYuan ? (item.gateBorrowAmount || item.gateBorrowAmount == 0 ? Number(item.gateBorrowAmount).toFixed(2) : undefined) : item.gateBorrowQty // 累计
  595. const geteBalance = item.gateShortfallValue || item.gateShortfallValue == 0 ? item.gateShortfallValue : undefined // 差额
  596. const quotaUnit = item.quotaRuleUnit == 'YUAN' ? '元' : '个' // 配额单位
  597. const gateQuota = item.gateQuotaAmount || item.gateQuotaAmount == 0 ? Number(item.gateQuotaAmount).toFixed(2) : undefined // 配额
  598. const unUseGateQuota = item.unUseAmount || item.unUseAmount == 0 ? Number(item.unUseAmount).toFixed(2) : undefined // 未用配额
  599. // 特价产品
  600. const isYuan2 = item.discountRuleUnit == 'YUAN'
  601. const discountRuleUnit = isYuan2 ? '元' : '个' // 单位
  602. const specialPriceSelected = isYuan2 ? (item.discountAmount || item.discountAmount == 0 ? Number(item.discountAmount).toFixed(2) : undefined) : item.discountQty || 0 // 已选
  603. const totalPromoOrigAmount = isYuan2 && (item.totalPromoOrigAmount || item.totalPromoOrigAmount == 0) ? Number(item.totalPromoOrigAmount).toFixed(2) : undefined
  604. const discountRuleValue = isYuan2 ? (item.discountRuleValue || item.discountRuleValue == 0 ? Number(item.discountRuleValue).toFixed(2) : undefined) : item.discountRuleValue // 基础
  605. const discountRuleNextValue = isYuan2 ? (item.discountShortfallValue || item.discountShortfallValue == 0 ? Number(item.discountShortfallValue).toFixed(2) : undefined) : item.discountShortfallValue // 下阶差
  606. // 正价统计
  607. const isYuan1 = item.regularRuleUnit == 'YUAN'
  608. const regularUnit = isYuan1 ? '元' : '个' // 单位
  609. const regularSelected = isYuan1 ? (item.regularAmount || item.regularAmount == 0 ? Number(item.regularAmount).toFixed(2) : undefined) : item.regularQty // 已选
  610. const regularTotal = isYuan1 ? (item.regularBorrowAmount || item.regularBorrowAmount == 0 ? Number(item.regularBorrowAmount).toFixed(2) : undefined) : item.regularBorrowQty // 累计
  611. const regularPromotionSameFlag = item.promotionRule.promotionRuleType === 'BUY_PROD_GIVE_PROD' && item.promotionRule.regularPromotionSameFlag == 1 // 促销品是否与正品一致
  612. const baseVal1 = isYuan1 ? (item.regularRuleValue || item.regularRuleValue == 0 ? Number(item.regularRuleValue).toFixed(2) : undefined) : item.regularRuleValue
  613. const nextVal1 = isYuan1 ? (item.regularShortfallValue || item.regularShortfallValue == 0 ? Number(item.regularShortfallValue).toFixed(2) : undefined) : item.regularShortfallValue
  614. const regularBaseVal = regularPromotionSameFlag ? undefined : baseVal1 // 基础差
  615. const regularNextVal = regularPromotionSameFlag ? undefined : nextVal1 // 下级差
  616. // 促销品
  617. const promoUnit = '个'
  618. const promoSelected = item.giftQty || 0 // 已选
  619. const promoBalance = item.giftShortfallQty // 差额
  620. const promoLimit = item.giftGiveQty // 额度
  621. // 采购额
  622. const purchaseUnit = '元'
  623. const purchaseLimit = item.totalPromoGiftsAmount || item.totalPromoGiftsAmount == 0 ? Number(item.totalPromoGiftsAmount).toFixed(2) : undefined // 额度
  624. const purchaseSelected = item.totalUsePromoGiftsAmount || item.totalUsePromoGiftsAmount == 0 ? Number(item.totalUsePromoGiftsAmount).toFixed(2) : undefined // 已选
  625. const purchaseSurplus = item.surplusAmount || item.surplusAmount == 0 ? Number(item.surplusAmount).toFixed(2) : undefined // 结余
  626. // 促销品
  627. this.tableData.push({
  628. ...item,
  629. ruleType: item.promotionRule.promotionRuleType,
  630. promotionRuleType: item.promotionRule.promotionRuleTypeDictValue,
  631. promotionRuleDesc: item.promotionRule.description,
  632. promotionTitle: item.promotion.title,
  633. // 门槛
  634. gateUnit, // 单位
  635. quotaUnit, // 配额单位
  636. gateQuota, // 配额
  637. unUseGateQuota, // 未用配额
  638. gateSelected, // 已选
  639. gateTotal, // 累计
  640. geteBalance, // 差额
  641. // 特价产品
  642. discountRuleUnit,
  643. specialPriceSelected, // 已选
  644. totalPromoOrigAmount,
  645. discountRuleValue, // 基础
  646. discountRuleNextValue, // 下阶差
  647. // 正价
  648. regularUnit, // 单位
  649. regularSelected, // 已选
  650. regularTotal, // 累计
  651. regularBaseVal, // 基础差
  652. regularNextVal, // 下阶差
  653. // 促销品
  654. promoUnit, // 单位
  655. promoLimit, // 额度
  656. promoSelected, // 已选
  657. promoBalance, // 差额
  658. // 采购额
  659. purchaseUnit,
  660. purchaseLimit, // 额度
  661. purchaseSelected, // 已选
  662. purchaseSurplus // 结余
  663. })
  664. }
  665. // 获取禁用的活动规则
  666. this.disabledActiveIds()
  667. },
  668. // 禁用的活动规则
  669. disabledActiveIds () {
  670. this.checkboxOption.disableSelectedRowKeys = this.tableData.filter(item => item.enabledFlag == 0).map(item => item.id)
  671. },
  672. // 上下移动特价活动
  673. moveTjRow (item, rowIndex, type) {
  674. const temp = this.tableData[type == 1 ? rowIndex - 1 : rowIndex + 1]
  675. const tempSort = temp.sort
  676. temp.sort = item.sort
  677. item.sort = tempSort
  678. // 保存排序
  679. const tejia = this.tableData.filter(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD')
  680. const data = tejia.map(item => {
  681. return {
  682. id: item.id,
  683. sort: item.sort
  684. }
  685. })
  686. this.spinning = true
  687. salesPromoSaveSort({ salesBillSn: this.salesBillSn, salesPromoList: data }).then(res => {
  688. this.spinning = false
  689. if (res.status == 200) {
  690. this.$emit('refash', '', 'sort')
  691. } else {
  692. // 恢复排序
  693. item.sort = temp.sort
  694. temp.sort = tempSort
  695. }
  696. })
  697. },
  698. // 刷新当前规则
  699. refashRow (item, enable) {
  700. // 刷新产品列表
  701. this.$emit('refash', '', 'enable')
  702. const active = this.tableData.find(k => k.id == item.id)
  703. active.enabledFlag = enable
  704. // 获取禁用的活动规则
  705. this.disabledActiveIds()
  706. },
  707. // 查看累计产品 详情
  708. openTotalProduct (row, type) {
  709. this.openTotalProductModal = true
  710. this.$refs.totalProductModal.pageInit({ salesBillSn: row.salesBillSn, salesPromoSn: row.salesPromoSn, promotionFlag: type === 'gateUnit' ? 'GATE' : 'REGULAR' })
  711. },
  712. // 显示买赠产品弹窗
  713. showBuyGifts (rowVal) {
  714. rowVal.promotionRule.salesPromoSn = rowVal.salesPromoSn
  715. this.buyGiftsInfo = rowVal.promotionRule
  716. this.openNormalProductModal = true
  717. const _this = this
  718. this.$nextTick(() => {
  719. _this.$refs.normalProductModal.resetSearchForm()
  720. })
  721. },
  722. // 启用规则
  723. enabledActive (item) {
  724. const _this = this
  725. this.spinning = true
  726. salesEnablePromoPromo({
  727. salesBillSn: _this.salesBillSn,
  728. salesPromoSn: item.salesPromoSn,
  729. salesEnableType: _this.enableActiveOption
  730. }).then(res => {
  731. if (res.status == 200) {
  732. // 刷新
  733. _this.refashRow(item, 1)
  734. _this.enableActiveOption = null
  735. _this.$message.success('启用成功')
  736. }
  737. _this.spinning = false
  738. })
  739. },
  740. // 禁用规则
  741. disabledActive (item) {
  742. const _this = this
  743. _this.spinning = true
  744. salesDisablePromo({
  745. salesBillSn: _this.salesBillSn,
  746. salesPromoSn: item.salesPromoSn,
  747. promoRuleSn: item.promoRuleSn,
  748. salesDisableType: _this.disabledActiveOption
  749. }).then(res => {
  750. if (res.status == 200) {
  751. // 刷新
  752. _this.refashRow(item, 0)
  753. _this.disabledActiveOption = null
  754. _this.$message.success('禁用成功')
  755. }
  756. _this.spinning = false
  757. })
  758. },
  759. enableRow (c, e, item) {
  760. const _this = this
  761. // 启用
  762. if (item.enabledFlag == 0) {
  763. // 启用无正常产品直接启用
  764. if (!this.hasNormal) {
  765. _this.enableActiveOption = 'ENABLE_ONLY'
  766. _this.enabledActive(item)
  767. return
  768. }
  769. const isJiejia = item.promotionRule.stackFlag == 1 // 叠加产品
  770. this.$confirm({
  771. title: item.promotion.description + '-' + item.promotionRule.description + ',确定启用规则?',
  772. centered: true,
  773. class: 'confirm-center',
  774. content: <div>
  775. <div style="padding:10px;">
  776. <div style="padding:10px 0;">请选择</div>
  777. <aRadioGroup onChange={e => { _this.enableActiveOption = e.target.value }}>
  778. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_WITH_NORMAL">
  779. 正常产品适配
  780. </aRadio>
  781. {isJiejia ? <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_WITH_STACK">
  782. 叠加规则产品适配
  783. </aRadio> : ''}
  784. {isJiejia ? <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_WITH_STACK_NORMAL">
  785. 所有产品适配
  786. </aRadio> : ''}
  787. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="ENABLE_ONLY">
  788. 仅启用不适配
  789. </aRadio>
  790. </aRadioGroup>
  791. </div>
  792. </div>,
  793. onOk () {
  794. if (_this.enableActiveOption) {
  795. _this.enabledActive(item)
  796. } else {
  797. _this.$message.info('请选择启用方式!')
  798. return true
  799. }
  800. },
  801. onCancel () {
  802. _this.enableActiveOption = null
  803. }
  804. })
  805. return
  806. }
  807. // 禁用
  808. // 无产品直接禁用
  809. if (item.totalQty == 0) {
  810. _this.disabledActiveOption = 'DELETE'
  811. _this.disabledActive(item)
  812. return
  813. }
  814. this.$confirm({
  815. title: item.promotion.description + '-' + item.promotionRule.description + ',确定禁用规则?',
  816. centered: true,
  817. class: 'confirm-center',
  818. content: <div>
  819. <div style="padding:10px 0;text-align:center;">禁用规则后,将无法享受该活动规则优惠</div>
  820. <div style="padding:0 0 10px 0;text-align:center;">
  821. <aRadioGroup onChange={e => { _this.disabledActiveOption = e.target.value }}>
  822. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="DELETE">
  823. 删除产品
  824. </aRadio>
  825. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="REMOVE">
  826. 移出产品
  827. </aRadio>
  828. </aRadioGroup>
  829. </div>
  830. </div>,
  831. onOk () {
  832. if (_this.disabledActiveOption) {
  833. _this.disabledActive(item)
  834. } else {
  835. _this.$message.info('请选择禁用方式!')
  836. return true
  837. }
  838. },
  839. onCancel () {
  840. _this.disabledActiveOption = null
  841. }
  842. })
  843. },
  844. // 导入产品
  845. handleImportClick (e, row, importButton) {
  846. const title = importButton.find(item => item.key === e.key).name
  847. this.$refs.importGuideModal.pageInit({ promoProductClz: e.key, salesBillSn: this.salesBillSn, salesPromoSn: row.salesPromoSn }, row, title)
  848. this.openGuideModal = true
  849. },
  850. // 关闭导入弹框
  851. closeGuideModel () {
  852. this.openGuideModal = false
  853. },
  854. // 批量导入产品
  855. hanldeImportOk (salesBillDetailList, row, promoProductClz, isTotalFlag) {
  856. const fun = isTotalFlag ? salesDetailInsertBatchBorrow : salesBatchInsert
  857. const params = {
  858. salesBillSn: this.salesBillSn,
  859. salesBillDetailList: salesBillDetailList
  860. }
  861. // 活动导入
  862. if (row.salesPromoSn) {
  863. params.salesPromoSn = row.salesPromoSn
  864. params.promoRuleSn = row.promoRuleSn
  865. params.promoProductClz = promoProductClz
  866. }
  867. fun(params).then(res => {
  868. if (res.status == 200) {
  869. this.$message.success(isTotalFlag ? '累计产品导入成功' : '产品导入成功', 2.5)
  870. this.$emit('refash', '', 'import')
  871. }
  872. })
  873. },
  874. // 添加产品
  875. addProduct (row, type) {
  876. this.$emit('openCpModal', type, row)
  877. },
  878. // 查看活动详情
  879. showDesc (row) {
  880. if (row.promoRuleSn) {
  881. this.promoRuleSn = row.promoRuleSn
  882. this.openDetailModal = true
  883. }
  884. },
  885. // 关闭详情弹窗
  886. closeDetailModal () {
  887. this.promoRuleSn = null
  888. this.openDetailModal = false
  889. }
  890. }
  891. }
  892. </script>
  893. <style lang="less">
  894. .table-header-cell-blue {
  895. background: #c9fbff !important;
  896. }
  897. .table-header-cell-red {
  898. background: #ffdccb !important;
  899. }
  900. .table-header-cell-green {
  901. background: #deffec !important;
  902. }
  903. .table-header-cell-zs {
  904. background: #fff2ff !important;
  905. }
  906. .table-header-cell-org {
  907. background: #fff3c2 !important;
  908. }
  909. .table-link-text{
  910. width:100%;
  911. color: #409EFF;
  912. display:flex;
  913. cursor:pointer;
  914. &:hover{
  915. text-decoration: underline;
  916. }
  917. }
  918. .table-link-btn{
  919. color: #409EFF;
  920. cursor:pointer;
  921. &:hover{
  922. text-decoration: underline;
  923. }
  924. }
  925. .table-word-color{
  926. color:#ed1c24;
  927. }
  928. .table-arrow-box{
  929. display: flex;
  930. span{
  931. width:16px;
  932. text-align:center;
  933. cursor:pointer;
  934. border-radius: 50px;
  935. }
  936. .up{
  937. color:#ed1c24;
  938. &:hover{
  939. color:#fff;
  940. background:#ed1c24;
  941. }
  942. }
  943. .down{
  944. color:#00aaff;
  945. &:hover{
  946. color:#fff;
  947. background:#00aaff;
  948. }
  949. }
  950. }
  951. </style>