rule.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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-success"
  37. @click="handleDetail(record)"
  38. id="promotionRulesList-rule-detail-btn">详情</a-button>
  39. <a-button
  40. size="small"
  41. type="link"
  42. class="button-error"
  43. @click="handleDel(record)"
  44. id="promotionRulesList-rule-del-btn">删除</a-button>
  45. </template>
  46. </s-table>
  47. <!-- 新增/编辑 -->
  48. <edit-rule-modal :openModal="openModal" :itemSn="itemSn" @ok="handleOk" @close="openModal=false" />
  49. </a-card>
  50. </div>
  51. </template>
  52. <script>
  53. import { STable, VSelect } from '@/components'
  54. import editRuleModal from './editRuleModal.vue'
  55. import { promoRuleQueryList } from '@/api/promoRule'
  56. export default {
  57. components: { STable, VSelect, editRuleModal },
  58. data () {
  59. return {
  60. tableHeight: 0,
  61. disabled: false, // 查询、重置按钮是否可操作
  62. columns: [
  63. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  64. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  65. { title: '促销类型', dataIndex: 'promoRuleTypeDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  66. { title: '促销规则', dataIndex: 'promoRule', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  67. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  68. ],
  69. // 加载数据方法 必须为 Promise 对象
  70. loadData: parameter => {
  71. this.disabled = true
  72. if (this.tableHeight == 0) {
  73. this.tableHeight = window.innerHeight - 502
  74. }
  75. return promoRuleQueryList({ promoActiveSn: this.$route.params.sn }).then(res => {
  76. const data = res.data
  77. for (var i = 0; i < data.length; i++) {
  78. data[i].no = i + 1
  79. if (data[i].promoRuleType == 'BUY_PROD_GIVE_PROD') { // 买产品送产品
  80. data[i].promoRule = '购买满' + data[i].orderGoodsQty + '正价产品,送' + data[i].promoQty + '促销品'
  81. } else if (data[i].promoRuleType == 'BUY_PROD_GIVE_MONEY') { // 买产品送采购额
  82. if (data[i].orderRuleType == 'prod_qty') {
  83. data[i].promoRule = '购买满' + data[i].orderAmount + '元正价产品,送' + data[i].promoAmount + '元采购额可用于购买促销品'
  84. } else if (data[i].orderRuleType == 'order_amount') {
  85. data[i].promoRule = '购买满' + data[i].orderAmount + '元正价产品可以返正价产品采购额的' + data[i].promoAmountPer * 100 + '%用于购买促销品'
  86. }
  87. } else if (data[i].promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  88. data[i].promoRule = '购买满' + data[i].orderGoodsQty + '个正价产品,可以以换购价购买任意1个换购产品'
  89. }
  90. }
  91. this.disabled = false
  92. return data
  93. })
  94. },
  95. openModal: false, // 弹框
  96. itemSn: '' // 当前sn
  97. }
  98. },
  99. methods: {
  100. // 编辑
  101. handleEdit (row) {
  102. this.itemSn = row.promoRuleSn
  103. this.openModal = true
  104. },
  105. handleOk (data) {
  106. this.$refs.table.refresh(true)
  107. },
  108. // 详情
  109. handleDetail (row) {
  110. this.itemId = row.id
  111. this.openModal = true
  112. },
  113. // 返回列表
  114. handleBack () {
  115. this.$router.push({ path: '/promotionRulesManagement/promotionRules/list' })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="less" scoped>
  121. .promotionRulesList-rule-wrap{
  122. .promotionRulesList-rule-back{
  123. margin-bottom: 15px;
  124. }
  125. }
  126. </style>