activeStatisticsList.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  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" :title="promoRuleTitle" :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. promoRuleTitle: '',
  160. disabledActiveOption: null, // 禁用规则选项
  161. enableActiveOption: null, // 启用规则选项
  162. openGuideModal: false, // 导入产品引导
  163. buyGiftsInfo: null // 买赠产品弹窗详情信息
  164. }
  165. },
  166. computed: {
  167. columns () {
  168. const _this = this
  169. // 格式化数字金额单元格
  170. const formatTd = (row, column, rowIndex, uniKey, fun) => {
  171. const ismktj = column.field == 'specialPriceSelected' && row.totalPromoOrigAmount
  172. console.log(row[column.field], row[column.field] != undefined, column.field)
  173. if (row[column.field] != undefined) {
  174. const isred = column.field == 'regularNextVal' && row[column.field] > 0
  175. return (<div onClick={() => fun ? fun(row, uniKey) : false}><span class={fun ? 'table-link-btn' : (column.field == 'geteBalance' || isred) ? '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>)
  176. } else {
  177. return ''
  178. }
  179. }
  180. const cols = [
  181. {
  182. field: '',
  183. key: '1',
  184. title: '序号',
  185. width: 25,
  186. align: 'center',
  187. fixed: 'left',
  188. renderBodyCell: ({ row, column, rowIndex }, h) => {
  189. return ++rowIndex
  190. }
  191. },
  192. {
  193. field: 'promotionRuleType',
  194. key: '2',
  195. width: 90,
  196. title: '活动类型',
  197. align: 'center',
  198. fixed: 'left',
  199. renderBodyCell: ({ row, column, rowIndex }, h) => {
  200. const isTejia = row && row.promotionRule && row.promotionRule.promotionRuleType == 'PROMO_PROD' && row.promotionRule.stackFlag == 1 && _this.type == 'edit' // 是否特价叠加
  201. const tejiaLen = _this.tableData.filter(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD' && item.promotionRule.stackFlag == 1).length // 特价叠加活动数量
  202. const tjStart = _this.tableData.findIndex(item => item.promotionRule && item.promotionRule.promotionRuleType == 'PROMO_PROD' && item.promotionRule.stackFlag == 1) // 特价叠加活动开始索引
  203. // 特价活动上移下移排序
  204. const equalWord = <div class="table-arrow-box">
  205. {rowIndex > tjStart ? <span class="up" onClick={() => _this.moveTjRow(row, rowIndex, 1)} title="上移">⇡</span> : ''}
  206. {rowIndex < tjStart + tejiaLen - 1 ? <span class="down" onClick={() => _this.moveTjRow(row, rowIndex, 0)} title="下移">⇣</span> : <span></span>}
  207. </div>
  208. // 买产品送产品 同款产品 是累计产品才弹详情窗
  209. if (row.promotionRule.promotionRuleType === 'BUY_PROD_GIVE_PROD' && row.promotionRule.borrowFlag == '1' && row.promotionRule.regularSameFlag == '1') {
  210. return (<div style="width:100%;display:flex;justify-content: space-between;">
  211. <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>
  212. {isTejia && tejiaLen > 1 ? equalWord : ''}
  213. </div>)
  214. } else {
  215. return (<div style="width:100%;display:flex;justify-content: space-between;">
  216. <div style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title={row[column.field]}>{row[column.field]}</div>
  217. {isTejia && tejiaLen > 1 ? equalWord : ''}
  218. </div>)
  219. }
  220. },
  221. // 筛选项
  222. filter: {
  223. filterList: _this.ruleTypeList,
  224. isMultiple: true,
  225. // filter confirm
  226. filterConfirm: (filterList) => {
  227. const labels = filterList
  228. .filter((x) => x.selected)
  229. .map((x) => x.value)
  230. _this.searchData.ruleType = labels
  231. _this.filtrateList()
  232. },
  233. // filter reset
  234. filterReset: (filterList) => {
  235. filterList.map(x => { x.selected = true })
  236. _this.searchData.ruleType = []
  237. _this.filtrateList()
  238. }
  239. }
  240. },
  241. { field: 'promotionRuleDesc',
  242. key: '3',
  243. width: 110,
  244. title: '规则简称',
  245. align: 'center',
  246. fixed: 'left',
  247. renderBodyCell: ({ row, column, rowIndex }, h) => {
  248. let mkInfo = ''
  249. if (row.promotionRule.gateFlag === '1') {
  250. if (row.promotionRule.gateType === 'RATIO_AMOUNT') {
  251. mkInfo = `购买门槛产品金额 ${row.promotionRule.gateValue ? (row.promotionRule.gateValue * 100).toFixed(2) : '0.00'}% 作为配额`
  252. } else if (row.promotionRule.gateType === 'MIN_AMOUNT') {
  253. mkInfo = `购买门槛产品满最低金额 ${this.toThousands(row.promotionRule.gateValue)} 元,不限制配额`
  254. } else {
  255. if (row.promotionRule.promotionRuleType != 'PROMO_PROD') {
  256. mkInfo = `购买满 ${this.toThousands(row.promotionRule.gateValue)} 元门槛产品,可使用 ${this.toThousands(row.promotionRule.quotaAmount)} 元配额,采购规则中的正价商品`
  257. } else {
  258. mkInfo = `购买每满 ${row.promotionRule.gateUnit === 'YUAN' ? this.toThousands(row.promotionRule.gateValue) : row.promotionRule.gateValue} ${row.promotionRule.gateUnit === 'YUAN' ? '元' : '个'}门槛产品,可采购 ${row.promotionRule.quotaAmount} 个特价产品`
  259. }
  260. }
  261. }
  262. return (<div style="width:100%;display:flex;justify-content: space-between;" onClick={() => _this.showDesc(row)}>
  263. <div class="table-link-text">
  264. <a-popover placement="right">
  265. <template slot="title">
  266. {row.promotionTitle + '(' + row[column.field] + ')'}
  267. </template>
  268. <template slot="content">
  269. <div><strong>规则门槛:</strong>{row.promotionRule.gateFlag === '1' ? <div>{mkInfo}</div> : <span>无</span>}</div>
  270. <div><strong>规则:</strong><div domPropsInnerHTML={row.promotionRule.ruleInfo}></div></div>
  271. </template>
  272. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{row[column.field]}</span>
  273. </a-popover>
  274. </div>
  275. <div style="position:absolute;right:0;">
  276. {row.promotionRule.stackFlag == 1 ? <a-badge count="叠" numberStyle={{ backgroundColor: '#00aa00', marginLeft: '2px', zoom: '0.7' }}/> : ''}
  277. {row.promotionRule.borrowFlag == 1 ? <a-badge count="累" numberStyle={{ backgroundColor: '#F5222D', marginLeft: '2px', zoom: '0.7' }} /> : ''}
  278. </div>
  279. </div>)
  280. }
  281. },
  282. {
  283. title: '门槛产品',
  284. children: [
  285. {
  286. field: 'gateSelected',
  287. key: '4',
  288. title: '已选',
  289. width: 50,
  290. align: 'center',
  291. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
  292. },
  293. {
  294. field: 'gateTotal',
  295. key: '5',
  296. title: '累计',
  297. width: 50,
  298. align: 'center',
  299. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
  300. // renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit', _this.openTotalProduct)
  301. },
  302. {
  303. field: 'geteBalance',
  304. key: '6',
  305. title: '差额',
  306. width: 50,
  307. align: 'center',
  308. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
  309. },
  310. {
  311. field: 'gateQuota',
  312. key: '7',
  313. title: '配额',
  314. width: 50,
  315. align: 'center',
  316. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'quotaUnit')
  317. },
  318. {
  319. field: 'unUseGateQuota',
  320. key: '8',
  321. title: '未用配额',
  322. width: 60,
  323. align: 'center',
  324. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'quotaUnit')
  325. }
  326. ]
  327. },
  328. {
  329. title: '特价',
  330. children: [
  331. {
  332. field: 'specialPriceSelected',
  333. key: '9',
  334. title: '已选',
  335. width: 50,
  336. align: 'center',
  337. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
  338. },
  339. {
  340. field: 'discountRuleValue',
  341. key: '10',
  342. title: '基础',
  343. width: 60,
  344. align: 'center',
  345. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
  346. },
  347. {
  348. field: 'discountRuleNextValue',
  349. key: '11',
  350. title: '下阶差',
  351. width: 60,
  352. align: 'center',
  353. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'discountRuleUnit')
  354. }
  355. ]
  356. },
  357. {
  358. title: '正价产品',
  359. children: [
  360. {
  361. field: 'regularSelected',
  362. key: '12',
  363. title: '已选',
  364. width: 50,
  365. align: 'center',
  366. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  367. },
  368. {
  369. field: 'regularTotal',
  370. key: '13',
  371. title: '累计',
  372. width: 50,
  373. align: 'center',
  374. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  375. // renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit', _this.openTotalProduct)
  376. },
  377. {
  378. field: 'regularBaseVal',
  379. key: '14',
  380. title: '基础',
  381. width: 60,
  382. align: 'center',
  383. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  384. },
  385. {
  386. field: 'regularNextVal',
  387. key: '15',
  388. title: '下阶差',
  389. width: 60,
  390. align: 'center',
  391. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
  392. }
  393. ]
  394. },
  395. {
  396. title: '促销品',
  397. children: [
  398. {
  399. field: 'promoLimit',
  400. key: '16',
  401. title: '额度',
  402. width: 50,
  403. align: 'center',
  404. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
  405. },
  406. {
  407. field: 'promoSelected',
  408. key: '17',
  409. title: '已选',
  410. width: 50,
  411. align: 'center',
  412. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
  413. },
  414. {
  415. field: 'promoBalance',
  416. key: '18',
  417. title: '差额',
  418. width: 50,
  419. align: 'center',
  420. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
  421. }
  422. ]
  423. },
  424. {
  425. title: '采购额',
  426. children: [
  427. {
  428. field: 'purchaseLimit',
  429. key: '19',
  430. title: '额度',
  431. width: 50,
  432. align: 'center',
  433. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
  434. },
  435. {
  436. field: 'purchaseSelected',
  437. key: '20',
  438. title: '已选',
  439. width: 50,
  440. align: 'center',
  441. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
  442. },
  443. {
  444. field: 'purchaseSurplus',
  445. key: '21',
  446. title: '结余',
  447. width: 50,
  448. align: 'center',
  449. renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
  450. }
  451. ]
  452. },
  453. { field: 'totalCategory', key: '22', title: '款数', width: 50, align: 'center', fixed: 'right' },
  454. { field: 'totalQty', key: '23', title: '数量', width: 50, align: 'center', fixed: 'right' }
  455. ]
  456. // 复选框
  457. cols.unshift({
  458. field: '',
  459. key: '0',
  460. type: 'checkbox',
  461. title: '',
  462. width: 23,
  463. align: 'center',
  464. fixed: 'left'
  465. })
  466. // 销售价权限
  467. if (this.type == 'view' && this.$hasPermissions('B_salesDetail_salesPrice') || this.type == 'edit' && this.$hasPermissions('B_salesEdit_salesPrice')) {
  468. cols.push({ field: 'totalAmount', key: '24', title: '总金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } })
  469. cols.push({ field: 'lossAmount', key: '25', title: '优惠金额', width: 60, align: 'center', fixed: 'right', renderBodyCell: ({ row, column, rowIndex }, h) => { return this.toThousands(row[column.field]) } })
  470. }
  471. // 编辑页面
  472. if (this.type == 'edit') {
  473. cols.push({
  474. field: '',
  475. key: '26',
  476. title: '状态',
  477. width: 50,
  478. align: 'center',
  479. fixed: 'right',
  480. renderBodyCell: ({ row, column, rowIndex }, h) => {
  481. return (
  482. <div>
  483. <a-switch checked-children="启" un-checked-children="禁" checked={row.enabledFlag == 1} on-change={(c, e) => this.enableRow(c, e, row)}/>
  484. </div>
  485. )
  486. },
  487. // 筛选项
  488. filter: {
  489. filterList: _this.ruleEnableList,
  490. isMultiple: true,
  491. // filter confirm
  492. filterConfirm: (filterList) => {
  493. const labels = filterList
  494. .filter((x) => x.selected)
  495. .map((x) => x.value)
  496. _this.searchData.enable = labels
  497. _this.filtrateList()
  498. },
  499. // filter reset
  500. filterReset: (filterList) => {
  501. filterList.map(x => { x.selected = true })
  502. _this.searchData.enable = []
  503. _this.filtrateList()
  504. }
  505. }
  506. })
  507. cols.push({
  508. field: '',
  509. key: '27',
  510. title: '操作',
  511. width: 100,
  512. align: 'center',
  513. fixed: 'right',
  514. renderBodyCell: ({ row, column, rowIndex }, h) => {
  515. // 导入产品按钮
  516. const importButton = []
  517. if (row && row.promotionRule && row.promotionRule.gateFlag === '1') {
  518. importButton.push({ key: 'GATE', name: '门槛产品' })
  519. }
  520. if (row && row.promotionRule && row.promotionRule.promotionRuleType != 'PROMO_PROD') {
  521. importButton.push({ key: 'REGULAR', name: '正价产品' })
  522. }
  523. if (row && row.promotionRule && (row.promotionRule.regularPromotionSameFlag === '0' || row.promotionRule.scopeFlag === '0' || (row.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_MONEY' && row.promotionRule.scopeFlag === '1'))) {
  524. importButton.push({ key: 'GIFT', name: '促销产品' })
  525. }
  526. if (row && row.promotionRule && row.promotionRule.promotionRuleType == 'PROMO_PROD') {
  527. importButton.push({ key: 'DISCOUNT', name: '特价产品' })
  528. }
  529. if (row && row.promotionRule && row.promotionRule.borrowFlag == 1 && row.promotionRule.gateFlag === '1') {
  530. importButton.push({ key: 'BORROW_GATE', name: '累计门槛产品' })
  531. }
  532. if (row && row.promotionRule && row.promotionRule.borrowFlag == 1 && row.promotionRule.promotionRuleType != 'PROMO_PROD') {
  533. importButton.push({ key: 'BORROW_REGULAR', name: '累计正价产品' })
  534. }
  535. return (
  536. <div>
  537. {row.enabledFlag == 1 ? <a-dropdown>
  538. <a-menu slot="overlay" on-click={(e) => this.handleImportClick(e, row, importButton)} id={'salesEdit-menu-import-' + row.id}>
  539. {importButton.map(item => {
  540. return (
  541. <a-menu-item id={'salesEdit-menu-import-' + item.key + '-' + row.id} key={item.key}>{item.name}</a-menu-item>
  542. )
  543. })}
  544. </a-menu>
  545. <a-button
  546. id={'salesEdit-menu-import-plaction-' + row.id}
  547. type="link"
  548. class="button-primary"
  549. size="small"
  550. >
  551. 导入∨
  552. </a-button>
  553. </a-dropdown> : ''}
  554. {row.enabledFlag == 1 ? <a-button
  555. type="link"
  556. size="small"
  557. class="button-primary"
  558. on-click={() => this.addProduct(row, 1)}
  559. >
  560. 添加
  561. </a-button> : ''}
  562. {row.enabledFlag == 1 && row.promotionRule.borrowFlag == 1 ? <a-button
  563. type="link"
  564. size="small"
  565. class="button-primary"
  566. on-click={() => this.addProduct(row, 2)}
  567. >
  568. 累计
  569. </a-button> : <span style="width:40px;display:inline-block;"></span>}
  570. </div>
  571. )
  572. }
  573. })
  574. }
  575. return cols.filter((item, index) => {
  576. const i = index - 1
  577. return this.showCols.includes(i.toString()) || index == 0 || index > 12
  578. })
  579. }
  580. },
  581. methods: {
  582. // 筛选
  583. filtrateList () {
  584. const { ruleType, enable } = this.searchData
  585. const list = this.activeList.filter(item => ruleType.length === 0 || ruleType.includes(item.promotionRule.promotionRuleType)).filter(item => enable.length == 0 || enable.includes(item.enabledFlag))
  586. this.tableData = []
  587. this.getDataList(list)
  588. },
  589. getDataList (list) {
  590. this.hasInit = true
  591. for (let i = 0; i < list.length; i++) {
  592. const item = list[i]
  593. // 门槛统计
  594. const isYuan = item.gateRuleUnit == 'YUAN'
  595. const gateUnit = isYuan ? '元' : '个' // 单位
  596. const gateSelected = isYuan ? (item.gateAmount || item.gateAmount == 0 ? Number(item.gateAmount).toFixed(2) : undefined) : (item.gateQty || item.gateQty == 0 ? item.gateQty : undefined) // 已选
  597. const gateTotal = isYuan ? (item.gateBorrowAmount || item.gateBorrowAmount == 0 ? Number(item.gateBorrowAmount).toFixed(2) : undefined) : (item.gateBorrowQty || item.gateBorrowQty == 0 ? item.gateBorrowQty : undefined) // 累计
  598. const geteBalance = item.gateShortfallValue || item.gateShortfallValue == 0 ? item.gateShortfallValue : undefined // 差额
  599. const quotaUnit = item.quotaRuleUnit == 'YUAN' ? '元' : '个' // 配额单位
  600. const gateQuota = item.gateQuotaAmount || item.gateQuotaAmount == 0 ? (item.quotaRuleUnit == 'YUAN' ? Number(item.gateQuotaAmount).toFixed(2) : item.gateQuotaAmount) : undefined // 配额
  601. const unUseGateQuota = item.unUseAmount || item.unUseAmount == 0 ? (item.quotaRuleUnit == 'YUAN' ? Number(item.unUseAmount).toFixed(2) : item.unUseAmount) : undefined // 未用配额
  602. // 特价产品
  603. const isYuan2 = item.discountRuleUnit == 'YUAN'
  604. const discountRuleUnit = isYuan2 ? '元' : '个' // 单位
  605. const specialPriceSelected = isYuan2 ? (item.discountAmount || item.discountAmount == 0 ? Number(item.discountAmount).toFixed(2) : undefined) : (item.discountQty || item.discountQty == 0 ? item.discountQty : undefined) // 已选
  606. const totalPromoOrigAmount = isYuan2 && (item.totalPromoOrigAmount || item.totalPromoOrigAmount == 0) ? Number(item.totalPromoOrigAmount).toFixed(2) : undefined // 原价
  607. const discountRuleValue = item.discountRuleValue || item.discountRuleValue == 0 ? (isYuan2 ? Number(item.discountRuleValue).toFixed(2) : item.discountRuleValue) : undefined// 基础
  608. const discountRuleNextValue = item.discountShortfallValue || item.discountShortfallValue == 0 ? (isYuan2 ? Number(item.discountShortfallValue).toFixed(2) : item.discountShortfallValue) : undefined// 下阶差
  609. // 正价统计
  610. const isYuan1 = item.regularRuleUnit == 'YUAN'
  611. const regularUnit = isYuan1 ? '元' : '个' // 单位
  612. const regularSelected = isYuan1 ? (item.regularAmount || item.regularAmount == 0 ? Number(item.regularAmount).toFixed(2) : undefined) : (item.regularQty || item.regularQty == 0 ? item.regularQty : undefined)// 已选
  613. const regularTotal = isYuan1 ? (item.regularBorrowAmount || item.regularBorrowAmount == 0 ? Number(item.regularBorrowAmount).toFixed(2) : undefined) : (item.regularBorrowQty || item.regularBorrowQty == 0 ? item.regularBorrowQty : undefined) // 累计
  614. const regularBaseVal = item.regularRuleValue || item.regularRuleValue == 0 ? (isYuan1 ? Number(item.regularRuleValue).toFixed(2) : item.regularRuleValue) : undefined
  615. const regularNextVal = item.regularShortfallValue || item.regularShortfallValue == 0 ? (isYuan1 ? Number(item.regularShortfallValue).toFixed(2) : item.regularShortfallValue) : undefined
  616. // 促销品
  617. const promoUnit = '个'
  618. const promoSelected = item.giftQty || item.giftQty == 0 ? item.giftQty : undefined// 已选
  619. const promoBalance = item.giftShortfallQty || item.giftShortfallQty == 0 ? item.giftShortfallQty : undefined // 差额
  620. const promoLimit = item.giftGiveQty || item.giftGiveQty == 0 ? item.giftGiveQty : undefined // 额度
  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.promoRuleTitle = '详情 — ' + row.promotionTitle + '(' + row.promotionRuleDesc + ')'
  883. this.openDetailModal = true
  884. }
  885. },
  886. // 关闭详情弹窗
  887. closeDetailModal () {
  888. this.promoRuleSn = null
  889. this.promoRuleTitle = ''
  890. this.openDetailModal = false
  891. }
  892. }
  893. }
  894. </script>
  895. <style lang="less">
  896. .table-header-cell-blue {
  897. background: #c9fbff !important;
  898. }
  899. .table-header-cell-red {
  900. background: #ffdccb !important;
  901. }
  902. .table-header-cell-green {
  903. background: #deffec !important;
  904. }
  905. .table-header-cell-zs {
  906. background: #fff2ff !important;
  907. }
  908. .table-header-cell-org {
  909. background: #fff3c2 !important;
  910. }
  911. .table-link-text{
  912. width:100%;
  913. color: #409EFF;
  914. display:flex;
  915. cursor:pointer;
  916. &:hover{
  917. text-decoration: underline;
  918. }
  919. }
  920. .table-link-btn{
  921. color: #409EFF;
  922. cursor:pointer;
  923. &:hover{
  924. text-decoration: underline;
  925. }
  926. }
  927. .table-word-color{
  928. color:#ed1c24;
  929. }
  930. .table-arrow-box{
  931. display: flex;
  932. span{
  933. width:16px;
  934. text-align:center;
  935. cursor:pointer;
  936. border-radius: 50px;
  937. }
  938. .up{
  939. color:#ed1c24;
  940. &:hover{
  941. color:#fff;
  942. background:#ed1c24;
  943. }
  944. }
  945. .down{
  946. color:#00aaff;
  947. &:hover{
  948. color:#fff;
  949. background:#00aaff;
  950. }
  951. }
  952. }
  953. </style>