updateActiveModal.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. :title="title"
  5. centered
  6. :maskClosable="false"
  7. :width="total?'450px':'300px'"
  8. :footer="null"
  9. @cancel="cancel"
  10. >
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div style="padding: 0 30px;" v-if="total">
  13. <aRadioGroup v-model="upActiveVal">
  14. <aRadio :style="radioStyle" value="0" v-if="promoRuleSn">
  15. 不参加促销
  16. </aRadio>
  17. <!-- 非叠加 -->
  18. <div v-for="(item,idx) in activeList" :key="idx">
  19. <div>
  20. <strong>{{ item.title }}</strong>
  21. </div>
  22. <aRadio :style="radioStyle" v-for="(sitem,sindex) in item.promotionRuleList" :key="sindex" :value="item.promotionSn+'-'+sitem.promotionRuleSn+'-'+sitem.promotionProductType">
  23. {{ sindex+1 }}、{{ sitem.description }}
  24. </aRadio>
  25. </div>
  26. </aRadioGroup>
  27. </div>
  28. <div style="padding: 10px 30px;text-align:center;" v-else>
  29. 没有可参与的【启用状态】的促销规则
  30. </div>
  31. <div style="padding: 30px 0 0;text-align: center;">
  32. <a-button @click="cancel" style="margin-right: 15px" :type="total?'default':'primary'" id="chooseCustom-btn-back">{{ total?'取消':'知道了' }}</a-button>
  33. <a-button v-if="total" type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">确定</a-button>
  34. </div>
  35. </a-spin>
  36. </a-modal>
  37. </template>
  38. <script>
  39. import { commonMixin } from '@/utils/mixin'
  40. import { salesPromoMatchProduct } from '@/api/salesNew'
  41. export default {
  42. name: 'SetWarehouse',
  43. mixins: [commonMixin],
  44. props: {
  45. show: [Boolean]
  46. },
  47. data () {
  48. return {
  49. opened: this.show,
  50. spinning: false,
  51. confirmLoading: false,
  52. upActiveVal: null,
  53. radioStyle: "display:block;height: '30px';lineHeight: '30px';padding:5px 0;",
  54. activeList: [],
  55. editRow: null,
  56. promoRuleSn: null
  57. }
  58. },
  59. computed: {
  60. title () {
  61. if (this.total == 0) {
  62. return '提示'
  63. }
  64. return this.promoRuleSn ? '确定换促销活动?' : '确定参加促销活动?'
  65. },
  66. total () {
  67. return this.promoRuleSn ? 1 : this.activeList.length
  68. },
  69. // 叠加活动
  70. stackActiveList () {
  71. return this.activeList.filter(item => item.promotion.stackFlag == 1)
  72. },
  73. // 非叠加活动
  74. noStackActiveList () {
  75. return this.activeList.filter(item => item.promotion.stackFlag !== 1)
  76. }
  77. },
  78. methods: {
  79. getActiveList (data, record) {
  80. this.promoRuleSn = data.promoRuleSn
  81. this.editRow = record
  82. this.spinning = true
  83. salesPromoMatchProduct(data).then(res => {
  84. this.activeList = res.data || []
  85. this.spinning = false
  86. })
  87. },
  88. // 保存
  89. handleSubmit (e) {
  90. e.preventDefault()
  91. const _this = this
  92. if (_this.upActiveVal) {
  93. _this.confirmLoading = true
  94. _this.$emit('ok', _this.upActiveVal, _this.editRow)
  95. } else {
  96. _this.$message.info('请选择活动规则!')
  97. }
  98. },
  99. cancel () {
  100. if (!this.confirmLoading) {
  101. this.opened = false
  102. this.upActiveVal = null
  103. this.$emit('cancel')
  104. } else {
  105. this.$message.info('正在更换促销,请勿关闭!')
  106. }
  107. }
  108. },
  109. watch: {
  110. show (newValue, oldValue) {
  111. this.opened = newValue
  112. if (!newValue) {
  113. this.upActiveVal = null
  114. }
  115. }
  116. }
  117. }
  118. </script>