addBatchPublish.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  4. <el-form-item label="优惠券数量" >
  5. {{ids.length}}个
  6. </el-form-item>
  7. <el-form-item label="优惠券开始时间" prop="startTime">
  8. <el-date-picker clearable size="small" style="width: 200px"
  9. v-model="form.startTime"
  10. type="date"
  11. value-format="yyyy-MM-dd"
  12. placeholder="选择开始时间">
  13. </el-date-picker>
  14. </el-form-item>
  15. <el-form-item label="优惠券结束时间" prop="limitTime">
  16. <el-date-picker clearable size="small" style="width: 200px"
  17. v-model="form.limitTime"
  18. type="date"
  19. value-format="yyyy-MM-dd"
  20. placeholder="选择结束时间">
  21. </el-date-picker>
  22. </el-form-item>
  23. <el-form-item label="优惠券领取数量" prop="totalCount">
  24. <el-input-number v-model="form.totalCount" :min="0" placeholder="请输入优惠券领取数量" />
  25. </el-form-item>
  26. </el-form>
  27. <div class="footer">
  28. <el-button type="primary" @click="submitForm">确 定</el-button>
  29. <el-button @click="cancel">取 消</el-button>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import { batchPublishCoupon } from "@/api/store/storeCoupon";
  35. export default {
  36. name: "batchPublish",
  37. data() {
  38. return {
  39. statusOptions:[],
  40. ids:[],
  41. // 表单参数
  42. form: {},
  43. // 表单校验
  44. rules: {
  45. totalCount: [
  46. { required: true, message: "数量不能为空", trigger: "blur" }
  47. ],
  48. startTime: [
  49. { required: true, message: "开始时间不能为空", trigger: "blur" }
  50. ],
  51. limitTime: [
  52. { required: true, message: "结束时间不能为空", trigger: "blur" }
  53. ],
  54. }
  55. };
  56. },
  57. created() {
  58. },
  59. methods: {
  60. cancel(){
  61. this.$emit('close');
  62. },
  63. handleBatch(ids) {
  64. console.log(ids)
  65. this.ids=ids;
  66. },
  67. /** 提交按钮 */
  68. submitForm() {
  69. this.$refs["form"].validate(valid => {
  70. if (valid) {
  71. this.myloading = this.$loading({
  72. lock: true,
  73. text: '处理中...',
  74. spinner: 'el-icon-loading',
  75. background: 'rgba(0, 0, 0, 0.7)'
  76. });
  77. this.form.ids=this.ids.toString();
  78. batchPublishCoupon(this.form).then(response => {
  79. this.myloading.close()
  80. if (response.code === 200) {
  81. this.msgSuccess("发布成功");
  82. this.$emit('close');
  83. }
  84. });
  85. }
  86. });
  87. },
  88. }
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .contents{
  93. height: 100%;
  94. background-color: #fff;
  95. padding: 20px;
  96. }
  97. .footer{
  98. display: flex;
  99. align-items: center;
  100. justify-content: flex-end;
  101. }
  102. </style>