updateActiveModal.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. <!-- 非叠加活动 -->
  14. <div>
  15. <aRadioGroup v-model="upActiveVal" @change="(e)=>{upActiveValArr=[]}">
  16. <aRadio :style="radioStyle" value="-1" v-if="pageType">
  17. 不参加促销
  18. </aRadio>
  19. <div v-if="noStackActiveList&&noStackActiveList.length">
  20. <strong >非叠加活动</strong>
  21. </div>
  22. <aRadio
  23. :style="radioStyle"
  24. v-for="(item,sindex) in noStackActiveList"
  25. :key="item.id"
  26. :value="item.salesPromoSn">
  27. {{ sindex+1 }}、{{ item.description }}
  28. </aRadio>
  29. </aRadioGroup>
  30. </div>
  31. <!-- 叠加活动 -->
  32. <div v-if="stackActiveList&&stackActiveList.length">
  33. <div>
  34. <strong >叠加活动</strong>
  35. </div>
  36. <a-checkbox-group v-model="upActiveValArr" @change="(e)=>{upActiveVal=null}">
  37. <a-checkbox
  38. :style="radioStyle"
  39. v-for="(item,sindex) in stackActiveList"
  40. :value="item.salesPromoSn"
  41. :key="item.id">
  42. {{ sindex+1 }}、{{ item.description }}
  43. </a-checkbox>
  44. </a-checkbox-group>
  45. </div>
  46. </div>
  47. <div style="padding: 10px 30px;text-align:center;" v-else>
  48. 没有可参与的【启用状态】的促销规则
  49. </div>
  50. <div style="padding: 30px 0 0;text-align: center;">
  51. <a-button @click="cancel" style="margin-right: 15px" :type="total?'default':'primary'" id="chooseCustom-btn-back">{{ total?'取消':'知道了' }}</a-button>
  52. <a-button v-if="total" type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">确定</a-button>
  53. </div>
  54. </a-spin>
  55. </a-modal>
  56. </template>
  57. <script>
  58. import { commonMixin } from '@/utils/mixin'
  59. import { salesPromoMatchProduct } from '@/api/salesNew'
  60. export default {
  61. name: 'SetWarehouse',
  62. mixins: [commonMixin],
  63. props: {
  64. show: [Boolean],
  65. pageType: {// 判断是转促销弹窗
  66. type: Boolean,
  67. default: false
  68. }
  69. },
  70. data () {
  71. return {
  72. opened: this.show,
  73. spinning: false,
  74. confirmLoading: false,
  75. upActiveVal: null,
  76. upActiveValArr: [],
  77. radioStyle: "display:block;height: '30px';lineHeight: '30px';padding:5px 0;margin:0;",
  78. activeList: [],
  79. editRow: null
  80. }
  81. },
  82. computed: {
  83. title () {
  84. if (this.total == 0) {
  85. return '提示'
  86. }
  87. return this.pageType ? '确定换促销活动?' : '确定参加促销活动?'
  88. },
  89. total () {
  90. return this.pageType ? 1 : this.activeList.length
  91. },
  92. // 叠加活动
  93. stackActiveList () {
  94. return this.activeList.filter(item => item.stackFlag == 1)
  95. },
  96. // 非叠加活动
  97. noStackActiveList () {
  98. return this.activeList.filter(item => item.stackFlag == 0)
  99. }
  100. },
  101. methods: {
  102. getActiveList (data, record) {
  103. this.editRow = record
  104. this.spinning = true
  105. salesPromoMatchProduct(data).then(res => {
  106. this.activeList = res.data || []
  107. this.spinning = false
  108. })
  109. },
  110. // 保存
  111. handleSubmit (e) {
  112. e.preventDefault()
  113. const _this = this
  114. if (_this.upActiveVal || this.upActiveValArr.length) {
  115. let salesPromoSnList = []
  116. // 不参与
  117. if (this.upActiveVal == '-1') {
  118. salesPromoSnList = []
  119. } else {
  120. salesPromoSnList = this.upActiveVal ? [this.upActiveVal] : this.upActiveValArr
  121. }
  122. _this.confirmLoading = true
  123. _this.$emit('ok', salesPromoSnList, _this.editRow)
  124. } else {
  125. _this.$message.info('请选择活动规则!')
  126. }
  127. },
  128. cancel () {
  129. if (!this.confirmLoading) {
  130. this.opened = false
  131. this.upActiveVal = null
  132. this.upActiveValArr = []
  133. this.$emit('cancel')
  134. } else {
  135. this.$message.info('正在更换促销,请勿关闭!')
  136. }
  137. }
  138. },
  139. watch: {
  140. show (newValue, oldValue) {
  141. this.opened = newValue
  142. if (!newValue) {
  143. this.upActiveVal = null
  144. }
  145. }
  146. }
  147. }
  148. </script>