rule.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div class="promotionRulesList-rule-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="promotionRulesList-rule-back" >
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="promotionRulesList-rule-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. </template>
  8. </a-page-header>
  9. <a-card size="small" :bordered="false" class="promotionRulesList-rule-wrap">
  10. <!-- 操作按钮 -->
  11. <div class="table-operator">
  12. <a-button id="promotionRulesList-rule-add" type="primary" class="button-error" @click="openModal=true">新增</a-button>
  13. </div>
  14. <!-- 列表 -->
  15. <s-table
  16. class="sTable"
  17. ref="table"
  18. size="default"
  19. :rowKey="(record) => record.id"
  20. :columns="columns"
  21. :data="loadData"
  22. :showPagination="false"
  23. :scroll="{ y: tableHeight }"
  24. bordered>
  25. <!-- 操作 -->
  26. <template slot="action" slot-scope="text, record">
  27. <a-button
  28. size="small"
  29. type="link"
  30. class="button-info"
  31. @click="handleEdit(record)"
  32. id="promotionRulesList-rule-edit-btn">编辑</a-button>
  33. <a-button
  34. size="small"
  35. type="link"
  36. class="button-error"
  37. @click="handleDel(record)"
  38. id="promotionRulesList-rule-del-btn">删除</a-button>
  39. </template>
  40. </s-table>
  41. <!-- 新增/编辑 -->
  42. <edit-rule-modal :openModal="openModal" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
  43. </a-card>
  44. </div>
  45. </template>
  46. <script>
  47. import { STable, VSelect } from '@/components'
  48. import editRuleModal from './editRuleModal.vue'
  49. import { promoRuleQueryList, promoRuleDel } from '@/api/promoRule'
  50. export default {
  51. components: { STable, VSelect, editRuleModal },
  52. data () {
  53. return {
  54. tableHeight: 0,
  55. disabled: false, // 查询、重置按钮是否可操作
  56. columns: [
  57. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  58. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  59. { title: '促销类型', dataIndex: 'promoRuleTypeDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  60. { title: '促销规则', dataIndex: 'promoRule', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  61. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  62. ],
  63. // 加载数据方法 必须为 Promise 对象
  64. loadData: parameter => {
  65. this.disabled = true
  66. if (this.tableHeight == 0) {
  67. this.tableHeight = window.innerHeight - 502
  68. }
  69. return promoRuleQueryList({ promoActiveSn: this.$route.params.sn }).then(res => {
  70. const data = res.data
  71. for (var i = 0; i < data.length; i++) {
  72. data[i].no = i + 1
  73. if (data[i].promoRuleType == 'BUY_PROD_GIVE_PROD') { // 买产品送产品
  74. data[i].promoRule = '购买满' + data[i].orderGoodsQty + '个正价产品,送' + data[i].promoQty + '个促销品'
  75. } else if (data[i].promoRuleType == 'BUY_PROD_GIVE_MONEY') { // 买产品送采购额
  76. if (data[i].orderRuleType == 'PROD_QTY') {
  77. data[i].promoRule = '购买满' + data[i].orderAmount + '元正价产品,送' + data[i].promoAmount + '元采购额可用于购买促销品'
  78. } else if (data[i].orderRuleType == 'ORDER_AMOUNT') {
  79. data[i].promoRule = '购买满' + data[i].orderAmount + '元正价产品可以返正价产品采购额的' + data[i].promoAmountPer * 100 + '%用于购买促销品'
  80. }
  81. } else if (data[i].promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  82. data[i].promoRule = '购买满' + data[i].orderGoodsQty + '个正价产品,可以以换购价购买任意1个换购产品'
  83. }
  84. }
  85. this.disabled = false
  86. return data
  87. })
  88. },
  89. openModal: false, // 弹框
  90. itemSn: '' // 当前sn
  91. }
  92. },
  93. methods: {
  94. // 编辑
  95. handleEdit (row) {
  96. this.itemSn = row.promoRuleSn
  97. this.openModal = true
  98. },
  99. handleOk (data) {
  100. this.$refs.table.refresh(true)
  101. },
  102. // 详情
  103. handleDetail (row) {
  104. this.itemId = row.id
  105. this.openModal = true
  106. },
  107. // 删除
  108. handleDel (row) {
  109. const _this = this
  110. this.$confirm({
  111. title: '提示',
  112. content: '确认要删除吗?',
  113. centered: true,
  114. onOk () {
  115. promoRuleDel({ sn: row.promoRuleSn }).then(res => {
  116. if (res.status == 200) {
  117. _this.$message.success(res.message)
  118. _this.$refs.table.refresh()
  119. }
  120. })
  121. }
  122. })
  123. },
  124. // 关闭弹框
  125. closeModal () {
  126. this.itemSn = ''
  127. this.openModal = false
  128. },
  129. // 返回列表
  130. handleBack () {
  131. this.$router.push({ path: '/promotionRulesManagement/promotionRules/list' })
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="less" scoped>
  137. .promotionRulesList-rule-wrap{
  138. .promotionRulesList-rule-back{
  139. margin-bottom: 15px;
  140. }
  141. }
  142. </style>