Commit fa27a4a2cd45ac3e08e3c64aa1942dac09958d80

Authored by 史婷婷
1 parent e190552e

feat: 草稿要车单-编辑-必填逻辑

Showing 1 changed file with 28 additions and 3 deletions
@@ -36,17 +36,26 @@ @@ -36,17 +36,26 @@
36 </uni-list-item> 36 </uni-list-item>
37 </view> 37 </view>
38 <view class="section"> 38 <view class="section">
39 - <uni-list-item title="卸货地点"> 39 + <uni-list-item>
  40 + <template v-slot:body>
  41 + <view class="item-title"><text class="required">*</text><text>卸货地点</text></view>
  42 + </template>
40 <template v-slot:footer> 43 <template v-slot:footer>
41 <uni-easyinput v-model="form.destination" placeholder="请输入卸货地点" :inputBorder="false" /> 44 <uni-easyinput v-model="form.destination" placeholder="请输入卸货地点" :inputBorder="false" />
42 </template> 45 </template>
43 </uni-list-item> 46 </uni-list-item>
44 - <uni-list-item title="接货人/联络人"> 47 + <uni-list-item>
  48 + <template v-slot:body>
  49 + <view class="item-title"><text class="required">*</text><text>接货人/联络人</text></view>
  50 + </template>
45 <template v-slot:footer> 51 <template v-slot:footer>
46 <uni-easyinput v-model="form.consignee" placeholder="请输入接货人/联络人" :inputBorder="false" /> 52 <uni-easyinput v-model="form.consignee" placeholder="请输入接货人/联络人" :inputBorder="false" />
47 </template> 53 </template>
48 </uni-list-item> 54 </uni-list-item>
49 - <uni-list-item title="联系电话"> 55 + <uni-list-item>
  56 + <template v-slot:body>
  57 + <view class="item-title"><text class="required">*</text><text>联系电话</text></view>
  58 + </template>
50 <template v-slot:footer> 59 <template v-slot:footer>
51 <uni-easyinput v-model="form.phone" placeholder="请输入联系电话" :inputBorder="false" /> 60 <uni-easyinput v-model="form.phone" placeholder="请输入联系电话" :inputBorder="false" />
52 </template> 61 </template>
@@ -121,7 +130,23 @@ export default { @@ -121,7 +130,23 @@ export default {
121 uni.showToast({ title: '加载失败', icon: 'none' }) 130 uni.showToast({ title: '加载失败', icon: 'none' })
122 } 131 }
123 }, 132 },
  133 + validateRequired() {
  134 + const checks = [
  135 + { key: 'destination', label: '卸货地点' },
  136 + { key: 'consignee', label: '接货人/联络人' },
  137 + { key: 'phone', label: '联系电话' },
  138 + ]
  139 + for (const it of checks) {
  140 + const val = this.form[it.key]
  141 + if (val === undefined || val === null || String(val).trim() === '') {
  142 + uni.showToast({ title: `请先输入${it.label}`, icon: 'none' })
  143 + return false
  144 + }
  145 + }
  146 + return true
  147 + },
124 async onSubmit() { 148 async onSubmit() {
  149 + if (!this.validateRequired()) return
125 const payload = { ...this.form } 150 const payload = { ...this.form }
126 delete payload.status 151 delete payload.status
127 console.log('onSubmit__payload', payload) 152 console.log('onSubmit__payload', payload)