newPromoModal.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. title="新活动提醒"
  5. centered
  6. :maskClosable="false"
  7. width="30%"
  8. :footer="null"
  9. @cancel="cancel"
  10. >
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div style="padding: 0 50px;">
  13. <div style="padding:10px 0;text-align:left;">
  14. 系统发布新的促销活动,是否要参与?
  15. </div>
  16. <div style="text-align:left;color:#00aaff;">
  17. <a-checkbox-group v-model="newPromoSnList">
  18. <a-row v-for="item in newActiveList" :key="item.promotionSn">
  19. <a-col :span="24"><a-checkbox :value="item.promotionSn">{{ item.description }}</a-checkbox></a-col>
  20. </a-row>
  21. </a-checkbox-group>
  22. </div>
  23. </div>
  24. <div style="margin-top:36px;text-align:center;">
  25. <a-button @click="cancel" style="margin-right: 15px" id="chooseCustom-btn-back">取消</a-button>
  26. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">确定</a-button>
  27. </div>
  28. </a-spin>
  29. </a-modal>
  30. </template>
  31. <script>
  32. import { commonMixin } from '@/utils/mixin'
  33. import { salesDetailAddPromo } from '@/api/salesDetailNew'
  34. export default {
  35. name: 'NewPromoModal',
  36. mixins: [commonMixin],
  37. props: {
  38. show: [Boolean],
  39. newActiveList: [Array],
  40. salesBillSn: [String]
  41. },
  42. data () {
  43. return {
  44. opened: this.show,
  45. spinning: false,
  46. newPromoSnList: [], // 新活动选项sn
  47. confirmLoading: false
  48. }
  49. },
  50. methods: {
  51. // 保存
  52. handleSubmit () {
  53. const _this = this
  54. if (_this.newPromoSnList.length) {
  55. _this.confirmLoading = true
  56. salesDetailAddPromo({
  57. 'salesBillSn': _this.salesBillSn,
  58. 'promoSnList': _this.newPromoSnList
  59. }).then(res => {
  60. if (res.status == 200) {
  61. _this.$emit('ok', 1)
  62. }
  63. _this.confirmLoading = false
  64. })
  65. } else {
  66. _this.$message.info('请选择要参与的新活动')
  67. return true
  68. }
  69. },
  70. // 取消
  71. cancel () {
  72. this.opened = false
  73. this.$emit('cancel')
  74. this.$emit('ok', 0)
  75. }
  76. },
  77. watch: {
  78. show (newValue, oldValue) {
  79. this.opened = newValue
  80. if (!newValue) {
  81. this.newPromoSnList = []
  82. } else {
  83. // 默认全选
  84. this.newActiveList.map(item => {
  85. this.newPromoSnList.push(item.promotionSn)
  86. })
  87. }
  88. }
  89. }
  90. }
  91. </script>