delayModal.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <a-modal
  3. class="delayModal"
  4. title="套餐服务延期"
  5. width="60%"
  6. centered
  7. :footer="null"
  8. :maskClosable="false"
  9. :destroyOnClose="true"
  10. @cancel="isShow = false"
  11. v-model="isShow">
  12. <!-- 表单 -->
  13. <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
  14. <!-- 服务名称 -->
  15. <a-form-model-item label="服务名称" class="item-con"><p class="item-main">清泉洗车(VIP)</p></a-form-model-item>
  16. <!-- 到期时间 -->
  17. <a-form-model-item label="到期时间" class="item-con"><p class="item-main">2020-11-28</p></a-form-model-item>
  18. <!-- 过期次数 -->
  19. <a-form-model-item label="过期次数" class="item-con"><p class="item-main">15次</p></a-form-model-item>
  20. <!-- 新的到期时间 -->
  21. <a-form-model-item label="新的到期时间" prop="time">
  22. <a-date-picker
  23. type="date"
  24. v-model="form.time"
  25. id="delay-time"
  26. placeholder="请选择到期时间,超过该时间,用户将无法再使用套餐"
  27. :disabled-date="disabledDate"
  28. style="width: 80%;" />
  29. </a-form-model-item>
  30. <!-- 是否返还已过期服务 -->
  31. <a-form-model-item label="是否返还已过期服务" prop="timeType">
  32. <a-radio-group id="delay-timeType" v-model="form.timeType">
  33. <a-radio :value="1">是</a-radio>
  34. <a-radio :value="0">否</a-radio>
  35. </a-radio-group>
  36. </a-form-model-item>
  37. <!-- 返还次数 -->
  38. <a-form-model-item v-if="form.timeType==1" label="返还次数" prop="custMobile">
  39. <a-input-number
  40. id="delay-custMobile"
  41. v-model="form.custMobile"
  42. :precision="0"
  43. :min="0"
  44. :max="999999"
  45. placeholder="请输入返还次数"
  46. style="width: 80%;margin-right: 10px;" />次
  47. </a-form-model-item>
  48. <a-form-model-item label="" class="btn-cont" :label-col="{ span: 0 }" :wrapper-col="{ span: 24 }">
  49. <a-button id="delay-cancel" class="delay-cancel" @click="cancel">取消</a-button>
  50. <a-button type="primary" id="delay-submit" @click="onSubmit">提交</a-button>
  51. </a-form-model-item>
  52. </a-form-model>
  53. </a-modal>
  54. </template>
  55. <script>
  56. import moment from 'moment'
  57. export default {
  58. name: 'DelayModal',
  59. props: {
  60. openModal: {
  61. // 弹框是否展示
  62. type: Boolean,
  63. default: false
  64. },
  65. setmealId: {
  66. // 套餐id
  67. type: [String, Number],
  68. default: ''
  69. }
  70. },
  71. data () {
  72. return {
  73. isShow: this.openModal, // 弹框是否展示
  74. form: {
  75. time: null, // 新的到期时间
  76. timeType: 1, // 是否返还已过期服务
  77. custMobile: null // 返还次数
  78. },
  79. rules: {
  80. time: [{ required: true, message: '请选择新的到期时间', trigger: 'change' }],
  81. timeType: [{ required: true, message: '请选择是否返还已过期服务', trigger: 'change' }],
  82. custMobile: [{ required: true, message: '请输入返还次数', trigger: 'blur' }]
  83. }
  84. }
  85. },
  86. methods: {
  87. moment,
  88. disabledDate (current) {
  89. // return current && current < moment().endOf('day') // 不包含当天
  90. return current.valueOf() < moment().subtract(1, 'days').valueOf() // 包含当天
  91. },
  92. // 取消
  93. cancel () {
  94. this.resetForm() // 重置表单数据
  95. this.isShow = false
  96. },
  97. // 重置表单
  98. resetForm () {
  99. this.form.custMobile = null
  100. this.form.timeType = 1
  101. this.form.time = null
  102. },
  103. // 提交
  104. onSubmit () {
  105. this.$refs.ruleForm.validate(valid => {
  106. if (valid) {
  107. const params = {
  108. bundleId: this.setmealId,
  109. custMobile: this.form.custMobile,
  110. timeType: this.form.timeType,
  111. time: this.form.time
  112. }
  113. // bundleBuy(params).then(res => {
  114. // if (res.status == 200) {
  115. // this.cancel()
  116. // }
  117. // })
  118. } else {
  119. console.log('error submit!!')
  120. return false
  121. }
  122. })
  123. }
  124. },
  125. watch: {
  126. // 父页面传过来的弹框状态
  127. openModal (newValue, oldValue) {
  128. this.isShow = newValue
  129. },
  130. // 重定义的弹框状态
  131. isShow (val) {
  132. if (!val) {
  133. this.$emit('close')
  134. } else {
  135. this.resetForm() // 重置表单数据
  136. }
  137. },
  138. setmealId (newValue, oldValue) {
  139. if (newValue && this.isShow) {
  140. // this.setmealData = newValue
  141. } else {
  142. // this.setmealData = null
  143. }
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="less">
  149. .delayModal{
  150. .btn-cont {
  151. text-align: center;
  152. margin: 50px 0 10px;
  153. button{
  154. margin: 0 20px;
  155. }
  156. }
  157. }
  158. </style>