activeStatisticsList.vue 27 KB

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