receive.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div>
  3. <RadioGroup
  4. v-model="send_type"
  5. @on-change="e => onChange(e, 'receive_type')">
  6. <Radio class="radio" :label="0">
  7. 次日达
  8. </Radio>
  9. <Radio class="radio" :label="1">
  10. 下单
  11. <InputNumber
  12. v-model="send_days"
  13. :min="2"
  14. :precision="0"
  15. @on-change="e => onChange(e, 'receive_days')"></InputNumber> 日送达
  16. </Radio>
  17. <Radio class="radio" :label="2">
  18. 自定义配送时间
  19. <Input
  20. :maxlength="18"
  21. v-model="send_time"
  22. @input="e => onChange(e, 'receive_time')"></Input>
  23. </Radio>
  24. </RadioGroup>
  25. <error :text="error[data.keyword]" />
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. props: ['data', 'value', 'option', 'error'],
  31. data () {
  32. return {
  33. send_type: null,
  34. send_days: null,
  35. send_time: '',
  36. receive_time: '',
  37. }
  38. },
  39. methods: {
  40. onChange (e, keyword) {
  41. if (this.send_type === 1) this.receive_time = this.send_days
  42. if (this.send_type === 2) this.receive_time = this.send_time
  43. this.$hub.$emit(this.data.hub, {
  44. type: 'value',
  45. payload: Object.assign(this.value, {
  46. receive_type: this.send_type,
  47. receive_time: this.receive_time,
  48. }),
  49. })
  50. },
  51. },
  52. mounted () {
  53. this.send_type = this.value[this.data.keyword]
  54. if (!this.value[this.data.keyword]) return
  55. if (this.value[this.data.keyword] === 1) {
  56. this.send_days = Number(this.value.receive_time)
  57. } else {
  58. this.send_time = this.value.receive_time
  59. }
  60. },
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .radiogroup {
  65. display: flex;
  66. flex-direction: column;
  67. padding: 10px 0;
  68. }
  69. .radio {
  70. display: block;
  71. margin-bottom: 4px;
  72. }
  73. </style>