多租户商城-商户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.4 KiB

3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <el-dialog :close-on-click-modal="false" title="新增渠道优惠券" width="80%" :visible.sync="visible" @close="closeModal">
  3. <el-form ref="form" :model="form" size="small" label-width="120px">
  4. <coupon-select ref="couponSelect" @couponChange="couponChange($event)" />
  5. <product-select ref="productSelect" />
  6. </el-form>
  7. <div slot="footer" class="dialog-footer">
  8. <el-button @click="doCancel">{{ $t('common.cancel') }}</el-button>
  9. <el-button type="primary" @click="doSubmit">确认</el-button>
  10. </div>
  11. </el-dialog>
  12. </template>
  13. <script>
  14. import {
  15. add
  16. } from '@/api/channelCoupons'
  17. import ProductSelect from '@/views/marketing/channelCoupons/components/productSelect.vue'
  18. import CouponSelect from '@/views/marketing/channelCoupons/components/couponSelect.vue'
  19. import Cookies from 'js-cookie'
  20. import {getShopId} from "@@/utils/auth.js"
  21. export default {
  22. name: 'AdForm',
  23. components: { CouponSelect, ProductSelect },
  24. data() {
  25. return {
  26. loading: false,
  27. visible: false,
  28. channelList: [],
  29. form: {}
  30. }
  31. },
  32. methods: {
  33. // 关闭弹窗
  34. closeModal() {
  35. this.$refs.couponSelect.tableData = []
  36. this.$refs.couponSelect.params = {
  37. search: '',
  38. page: 1,
  39. pageSize: 10,
  40. shopId: undefined,
  41. shelveState: 1
  42. }
  43. this.$refs.productSelect.tableData = []
  44. this.$refs.productSelect.visible = false
  45. this.$refs.productSelect.params = {
  46. search: '',
  47. page: 1,
  48. pageSize: 10,
  49. shopId: undefined,
  50. shelveState: 1
  51. }
  52. this.$refs.couponSelect.getTableData()
  53. },
  54. // 打开弹出窗
  55. show(row) {
  56. /*this.form = {
  57. shopId: parseInt(getShopId())
  58. }*/
  59. this.visible = true
  60. },
  61. // 取消
  62. doCancel() {
  63. this.visible = false
  64. },
  65. doSubmit() {
  66. this.$refs['form'].validate((valid) => {
  67. if (valid) {
  68. this.loading = true
  69. this.doAdd()
  70. }
  71. })
  72. },
  73. doAdd() {
  74. this.$refs['form'].validate((valid) => {
  75. if (valid) {
  76. this.form.shopCouponId = this.$refs.couponSelect.tableRadio.shopCouponId
  77. this.form.productId = this.$refs.productSelect.tableRadio.productId
  78. if (!this.form.productId) {
  79. this.$message({
  80. message: '请查询并选择商品',
  81. type: 'warning'
  82. })
  83. return false
  84. }
  85. if (!this.form.shopCouponId) {
  86. this.$message({
  87. message: '请查询并选择优惠券',
  88. type: 'warning'
  89. })
  90. return false
  91. }
  92. add(this.form).then(res => {
  93. this.loading = false
  94. this.resetForm()
  95. this.$emit('reset')
  96. this.$message({
  97. message: this.$t('common.addsuccessful'),
  98. type: 'success'
  99. })
  100. }).catch(err => {
  101. console.log(err.response.data.message)
  102. this.loading = false
  103. })
  104. }
  105. })
  106. },
  107. couponChange(val) {
  108. this.$refs.productSelect.getTableData(val)
  109. },
  110. resetForm() {
  111. this.visible = false
  112. this.$refs.productSelect.params.search = ''
  113. this.$refs.productSelect.data = []
  114. this.$refs.couponSelect.params.search = ''
  115. this.$refs.couponSelect.data = []
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang='scss' scoped>
  121. //@import url(); 引入公共css类
  122. @import url("../../../styles/elDialog.scss");
  123. </style>