updateActiveModal.vue 3.1 KB

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