Showing
4 changed files
with
62 additions
and
10 deletions
| ... | ... | @@ -111,7 +111,7 @@ |
| 111 | 111 | </uni-list-item> |
| 112 | 112 | <uni-list-item title="发货日期"> |
| 113 | 113 | <template v-slot:footer> |
| 114 | - <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" disabled /> | |
| 114 | + <uni-datetime-picker type="date" :start="todayDate" v-model="item.deliveryDate" /> | |
| 115 | 115 | </template> |
| 116 | 116 | </uni-list-item> |
| 117 | 117 | </uni-list> |
| ... | ... | @@ -190,6 +190,13 @@ export default { |
| 190 | 190 | } |
| 191 | 191 | }, |
| 192 | 192 | computed: { |
| 193 | + todayDate() { | |
| 194 | + const now = new Date() | |
| 195 | + const y = now.getFullYear() | |
| 196 | + const m = String(now.getMonth() + 1).padStart(2, '0') | |
| 197 | + const d = String(now.getDate()).padStart(2, '0') | |
| 198 | + return `${y}-${m}-${d}` | |
| 199 | + }, | |
| 193 | 200 | totalQuantity() { |
| 194 | 201 | const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) |
| 195 | 202 | return this.round(qty, 2) |
| ... | ... | @@ -223,6 +230,19 @@ export default { |
| 223 | 230 | this.loadDetail() |
| 224 | 231 | }, |
| 225 | 232 | methods: { |
| 233 | + normalizeDate(val) { | |
| 234 | + if (!val) return '' | |
| 235 | + const s = String(val) | |
| 236 | + if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s | |
| 237 | + const m = s.match(/^(\d{4}-\d{2}-\d{2})/) | |
| 238 | + return m ? m[1] : s | |
| 239 | + }, | |
| 240 | + isBeforeToday(dateStr) { | |
| 241 | + const d = this.normalizeDate(dateStr) | |
| 242 | + const t = this.todayDate | |
| 243 | + if (!d || !t) return false | |
| 244 | + return d < t | |
| 245 | + }, | |
| 226 | 246 | onLockChange(idx, e) { |
| 227 | 247 | const it = this.items[idx] |
| 228 | 248 | if (!it) return |
| ... | ... | @@ -259,7 +279,7 @@ export default { |
| 259 | 279 | unitPrice: v.unitPrice || '', |
| 260 | 280 | // amountExcludingTax: v.amountExcludingTax || 0, |
| 261 | 281 | totalAmount: v.totalAmount || 0, |
| 262 | - deliveryDate: v.deliveryDate || '', | |
| 282 | + deliveryDate: this.normalizeDate(v.deliveryDate), | |
| 263 | 283 | specDisplay: '' |
| 264 | 284 | })) |
| 265 | 285 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) |
| ... | ... | @@ -350,6 +370,7 @@ export default { |
| 350 | 370 | else raw.quantity = qty |
| 351 | 371 | raw.unitPrice = price |
| 352 | 372 | raw.totalAmount = total |
| 373 | + raw.deliveryDate = it.deliveryDate | |
| 353 | 374 | // raw.amountExcludingTax = excl |
| 354 | 375 | return raw |
| 355 | 376 | }) |
| ... | ... | @@ -365,6 +386,11 @@ export default { |
| 365 | 386 | uni.showToast({ title: '请填写单价', icon: 'none' }) |
| 366 | 387 | return |
| 367 | 388 | } |
| 389 | + const invalidDeliveryDate = selected.find(r => this.isBeforeToday(r.deliveryDate)) | |
| 390 | + if (invalidDeliveryDate) { | |
| 391 | + uni.showToast({ title: '发货日期不得早于今日', icon: 'none' }) | |
| 392 | + return | |
| 393 | + } | |
| 368 | 394 | this.selectedItems = selected |
| 369 | 395 | const payload = { |
| 370 | 396 | id: this.id, |
| ... | ... | @@ -786,4 +812,4 @@ export default { |
| 786 | 812 | height: 60rpx; |
| 787 | 813 | align-items: center; |
| 788 | 814 | } |
| 789 | -</style> | |
| \ No newline at end of file | ||
| 815 | +</style> | ... | ... |
| ... | ... | @@ -90,9 +90,9 @@ |
| 90 | 90 | placeholder="不可编辑" /> |
| 91 | 91 | </template> |
| 92 | 92 | </uni-list-item> |
| 93 | - <uni-list-item title="本次锁价数量"> | |
| 93 | + <uni-list-item title="拆分数量(kg)"> | |
| 94 | 94 | <template v-slot:footer> |
| 95 | - <uni-easyinput v-model="item.currentQuantity" type="number" :inputBorder="false" placeholder="请输入本次锁价数量" @input="onImmediateChange(idx)" @blur="onNumberBlur(idx, 'currentQuantity', 3)" /> | |
| 95 | + <uni-easyinput v-model="item.currentQuantity" type="number" :inputBorder="false" placeholder="请输入拆分数量" @input="onImmediateChange(idx)" @blur="onNumberBlur(idx, 'currentQuantity', 3)" /> | |
| 96 | 96 | </template> |
| 97 | 97 | </uni-list-item> |
| 98 | 98 | <uni-list-item title="单价"> | ... | ... |
| ... | ... | @@ -101,7 +101,7 @@ |
| 101 | 101 | </uni-list-item> |
| 102 | 102 | <uni-list-item title="发货日期"> |
| 103 | 103 | <template v-slot:footer> |
| 104 | - <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" disabled /> | |
| 104 | + <uni-datetime-picker type="date" :start="todayDate" v-model="item.deliveryDate" /> | |
| 105 | 105 | </template> |
| 106 | 106 | </uni-list-item> |
| 107 | 107 | </uni-list> |
| ... | ... | @@ -177,6 +177,13 @@ export default { |
| 177 | 177 | } |
| 178 | 178 | }, |
| 179 | 179 | computed: { |
| 180 | + todayDate() { | |
| 181 | + const now = new Date() | |
| 182 | + const y = now.getFullYear() | |
| 183 | + const m = String(now.getMonth() + 1).padStart(2, '0') | |
| 184 | + const d = String(now.getDate()).padStart(2, '0') | |
| 185 | + return `${y}-${m}-${d}` | |
| 186 | + }, | |
| 180 | 187 | totalQuantity() { |
| 181 | 188 | const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) |
| 182 | 189 | return this.round(qty, 2) |
| ... | ... | @@ -210,6 +217,19 @@ export default { |
| 210 | 217 | this.loadDetail() |
| 211 | 218 | }, |
| 212 | 219 | methods: { |
| 220 | + normalizeDate(val) { | |
| 221 | + if (!val) return '' | |
| 222 | + const s = String(val) | |
| 223 | + if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s | |
| 224 | + const m = s.match(/^(\d{4}-\d{2}-\d{2})/) | |
| 225 | + return m ? m[1] : s | |
| 226 | + }, | |
| 227 | + isBeforeToday(dateStr) { | |
| 228 | + const d = this.normalizeDate(dateStr) | |
| 229 | + const t = this.todayDate | |
| 230 | + if (!d || !t) return false | |
| 231 | + return d < t | |
| 232 | + }, | |
| 213 | 233 | onLockChange(idx, e) { |
| 214 | 234 | const it = this.items[idx] |
| 215 | 235 | if (!it) return |
| ... | ... | @@ -246,7 +266,7 @@ export default { |
| 246 | 266 | unitPrice: v.unitPrice || '', |
| 247 | 267 | amountExcludingTax: v.amountExcludingTax || 0, |
| 248 | 268 | totalAmount: v.totalAmount || 0, |
| 249 | - deliveryDate: v.deliveryDate || '', | |
| 269 | + deliveryDate: this.normalizeDate(v.deliveryDate), | |
| 250 | 270 | specDisplay: '' |
| 251 | 271 | })) |
| 252 | 272 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) |
| ... | ... | @@ -338,6 +358,7 @@ export default { |
| 338 | 358 | raw.unitPrice = price |
| 339 | 359 | raw.totalAmount = total |
| 340 | 360 | raw.amountExcludingTax = excl |
| 361 | + raw.deliveryDate = it.deliveryDate | |
| 341 | 362 | return raw |
| 342 | 363 | }) |
| 343 | 364 | if (!selected.length) { |
| ... | ... | @@ -352,6 +373,11 @@ export default { |
| 352 | 373 | uni.showToast({ title: '请填写单价', icon: 'none' }) |
| 353 | 374 | return |
| 354 | 375 | } |
| 376 | + const invalidDeliveryDate = selected.find(r => this.isBeforeToday(r.deliveryDate)) | |
| 377 | + if (invalidDeliveryDate) { | |
| 378 | + uni.showToast({ title: '发货日期不得早于今日', icon: 'none' }) | |
| 379 | + return | |
| 380 | + } | |
| 355 | 381 | this.selectedItems = selected |
| 356 | 382 | const payload = { |
| 357 | 383 | id: this.id, |
| ... | ... | @@ -768,4 +794,4 @@ export default { |
| 768 | 794 | height: 60rpx; |
| 769 | 795 | align-items: center; |
| 770 | 796 | } |
| 771 | -</style> | |
| \ No newline at end of file | ||
| 797 | +</style> | ... | ... |
| ... | ... | @@ -84,9 +84,9 @@ |
| 84 | 84 | <uni-easyinput v-model="item.quantity" type="number" :inputBorder="false" disabled placeholder="不可编辑" /> |
| 85 | 85 | </template> |
| 86 | 86 | </uni-list-item> |
| 87 | - <uni-list-item title="本次锁价数量"> | |
| 87 | + <uni-list-item title="拆分数量(kg)"> | |
| 88 | 88 | <template v-slot:footer> |
| 89 | - <uni-easyinput v-model="item.currentQuantity" type="number" :inputBorder="false" placeholder="请输入本次拆分数量" @input="onImmediateChange(idx)" @blur="onNumberBlur(idx, 'currentQuantity', 3)" /> | |
| 89 | + <uni-easyinput v-model="item.currentQuantity" type="number" :inputBorder="false" placeholder="请输入拆分数量" @input="onImmediateChange(idx)" @blur="onNumberBlur(idx, 'currentQuantity', 3)" /> | |
| 90 | 90 | </template> |
| 91 | 91 | </uni-list-item> |
| 92 | 92 | <uni-list-item title="单价"> | ... | ... |