WashingForm.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="business-form">
  3. <div style="margin-bottom: 20px;">
  4. <div class="section-label">上门服务地址</div>
  5. <el-row :gutter="10">
  6. <el-col :span="8">
  7. <el-cascader v-model="washingData.region" :options="pcaOptions" placeholder="省/市/区" style="width: 100%" />
  8. </el-col>
  9. <el-col :span="16">
  10. <el-input v-model="washingData.addressDetail" placeholder="详细地址 (街道/门牌号)" prefix-icon="Location" />
  11. </el-col>
  12. </el-row>
  13. </div>
  14. <div style="margin-bottom: 20px;">
  15. <div class="section-label" style="display:flex; align-items:center; margin-bottom:10px;">
  16. 预约服务时间
  17. <el-tag type="info" size="small" style="margin-left:10px;">共 {{ washingData.appointments.length }} 次</el-tag>
  18. </div>
  19. <div v-for="(item, index) in washingData.appointments" :key="index" style="display:flex; align-items:center; margin-bottom:10px;">
  20. <span style="width:30px; color:#999; font-size:12px; font-weight:bold;">{{ index + 1 }}.</span>
  21. <el-date-picker
  22. v-model="item.startTime"
  23. type="datetime"
  24. placeholder="开始时间"
  25. style="width: 200px; margin-right: 5px;"
  26. format="YYYY-MM-DD HH:mm"
  27. value-format="YYYY-MM-DD HH:mm"
  28. />
  29. <span style="margin:0 5px; color:#999;">~</span>
  30. <el-date-picker
  31. v-model="item.endTime"
  32. type="datetime"
  33. placeholder="结束时间 (可选)"
  34. style="width: 200px; margin-right: 15px;"
  35. format="YYYY-MM-DD HH:mm"
  36. value-format="YYYY-MM-DD HH:mm"
  37. />
  38. <div style="display:flex; gap:8px; margin-left:5px;">
  39. <el-button v-if="index === washingData.appointments.length - 1" type="primary" circle size="small" icon="Plus" @click="addAppointment" />
  40. <el-button v-if="washingData.appointments.length > 1" type="danger" circle size="small" icon="Minus" @click="removeAppointment(index)" plain />
  41. </div>
  42. </div>
  43. </div>
  44. <div class="remark-section">
  45. <el-input v-model="washingData.other" type="textarea" :rows="4" placeholder="请添加服务备注和宠物状态等" />
  46. </div>
  47. </div>
  48. </template>
  49. <script setup>
  50. import { defineProps, defineEmits } from 'vue'
  51. const props = defineProps({
  52. washingData: { type: Object, required: true },
  53. pcaOptions: { type: Array, default: () => [] }
  54. })
  55. const emit = defineEmits(['change'])
  56. const addAppointment = () => {
  57. props.washingData.appointments.push({ startTime: '', endTime: '' })
  58. emit('change', 'washing')
  59. }
  60. const removeAppointment = (index) => {
  61. if (props.washingData.appointments.length <= 1) return
  62. props.washingData.appointments.splice(index, 1)
  63. emit('change', 'washing')
  64. }
  65. </script>
  66. <style scoped>
  67. .business-form { padding-top: 5px; }
  68. .remark-section { background: #fdfdfd; border: 1px dashed #dcdfe6; padding: 15px; border-radius: 6px; margin-top: 20px; }
  69. .section-label { font-size: 13px; font-weight: bold; color: #606266; margin-bottom: 12px; }
  70. </style>