rule.vue 5.4 KB

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