activeStatisticsList.vue 31 KB

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