Showing
4 changed files
with
57 additions
and
21 deletions
| @@ -116,7 +116,7 @@ | @@ -116,7 +116,7 @@ | ||
| 116 | </uni-list-item> | 116 | </uni-list-item> |
| 117 | <uni-list-item title="发货日期"> | 117 | <uni-list-item title="发货日期"> |
| 118 | <template v-slot:footer> | 118 | <template v-slot:footer> |
| 119 | - <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" disabled /> | 119 | + <uni-datetime-picker type="date" :start="todayDate" v-model="item.deliveryDate" /> |
| 120 | </template> | 120 | </template> |
| 121 | </uni-list-item> | 121 | </uni-list-item> |
| 122 | </uni-list> | 122 | </uni-list> |
| @@ -195,6 +195,13 @@ export default { | @@ -195,6 +195,13 @@ export default { | ||
| 195 | } | 195 | } |
| 196 | }, | 196 | }, |
| 197 | computed: { | 197 | computed: { |
| 198 | + todayDate() { | ||
| 199 | + const now = new Date() | ||
| 200 | + const y = now.getFullYear() | ||
| 201 | + const m = String(now.getMonth() + 1).padStart(2, '0') | ||
| 202 | + const d = String(now.getDate()).padStart(2, '0') | ||
| 203 | + return `${y}-${m}-${d}` | ||
| 204 | + }, | ||
| 198 | totalQuantity() { | 205 | totalQuantity() { |
| 199 | const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) | 206 | const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) |
| 200 | return this.round(qty, 2) | 207 | return this.round(qty, 2) |
| @@ -228,6 +235,19 @@ export default { | @@ -228,6 +235,19 @@ export default { | ||
| 228 | this.loadDetail() | 235 | this.loadDetail() |
| 229 | }, | 236 | }, |
| 230 | methods: { | 237 | methods: { |
| 238 | + normalizeDate(val) { | ||
| 239 | + if (!val) return '' | ||
| 240 | + const s = String(val) | ||
| 241 | + if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s | ||
| 242 | + const m = s.match(/^(\d{4}-\d{2}-\d{2})/) | ||
| 243 | + return m ? m[1] : s | ||
| 244 | + }, | ||
| 245 | + isBeforeToday(dateStr) { | ||
| 246 | + const d = this.normalizeDate(dateStr) | ||
| 247 | + const t = this.todayDate | ||
| 248 | + if (!d || !t) return false | ||
| 249 | + return d < t | ||
| 250 | + }, | ||
| 231 | onLockChange(idx, e) { | 251 | onLockChange(idx, e) { |
| 232 | const it = this.items[idx] | 252 | const it = this.items[idx] |
| 233 | if (!it) return | 253 | if (!it) return |
| @@ -265,7 +285,7 @@ export default { | @@ -265,7 +285,7 @@ export default { | ||
| 265 | unitPrice: v.unitPrice || '', | 285 | unitPrice: v.unitPrice || '', |
| 266 | // amountExcludingTax: v.amountExcludingTax || 0, | 286 | // amountExcludingTax: v.amountExcludingTax || 0, |
| 267 | totalAmount: v.totalAmount || 0, | 287 | totalAmount: v.totalAmount || 0, |
| 268 | - deliveryDate: v.deliveryDate || '', | 288 | + deliveryDate: this.normalizeDate(v.deliveryDate), |
| 269 | specDisplay: '' | 289 | specDisplay: '' |
| 270 | })) | 290 | })) |
| 271 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) | 291 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) |
| @@ -359,6 +379,7 @@ export default { | @@ -359,6 +379,7 @@ export default { | ||
| 359 | raw.currentQuantity = (curQtyRaw === '' || curQtyRaw === null || curQtyRaw === undefined) ? null : this.toNumber(curQtyRaw) | 379 | raw.currentQuantity = (curQtyRaw === '' || curQtyRaw === null || curQtyRaw === undefined) ? null : this.toNumber(curQtyRaw) |
| 360 | raw.unitPrice = price | 380 | raw.unitPrice = price |
| 361 | raw.totalAmount = total | 381 | raw.totalAmount = total |
| 382 | + raw.deliveryDate = it.deliveryDate | ||
| 362 | // raw.amountExcludingTax = excl | 383 | // raw.amountExcludingTax = excl |
| 363 | return raw | 384 | return raw |
| 364 | }) | 385 | }) |
| @@ -374,12 +395,9 @@ export default { | @@ -374,12 +395,9 @@ export default { | ||
| 374 | uni.showToast({ title: '请填写单价', icon: 'none' }) | 395 | uni.showToast({ title: '请填写单价', icon: 'none' }) |
| 375 | return | 396 | return |
| 376 | } | 397 | } |
| 377 | - const invalidQty = selected.find(r => { | ||
| 378 | - const q = this.toNumber(r.currentQuantity) | ||
| 379 | - return !(q > 0) | ||
| 380 | - }) | ||
| 381 | - if (invalidQty) { | ||
| 382 | - uni.showToast({ title: '请填写本次锁价数量', icon: 'none' }) | 398 | + const invalidDeliveryDate = selected.find(r => this.isBeforeToday(r.deliveryDate)) |
| 399 | + if (invalidDeliveryDate) { | ||
| 400 | + uni.showToast({ title: '发货日期不得早于今日', icon: 'none' }) | ||
| 383 | return | 401 | return |
| 384 | } | 402 | } |
| 385 | this.selectedItems = selected | 403 | this.selectedItems = selected |
| @@ -803,4 +821,4 @@ export default { | @@ -803,4 +821,4 @@ export default { | ||
| 803 | height: 60rpx; | 821 | height: 60rpx; |
| 804 | align-items: center; | 822 | align-items: center; |
| 805 | } | 823 | } |
| 806 | -</style> | ||
| 824 | +</style> |
| @@ -90,9 +90,9 @@ | @@ -90,9 +90,9 @@ | ||
| 90 | placeholder="不可编辑" /> | 90 | placeholder="不可编辑" /> |
| 91 | </template> | 91 | </template> |
| 92 | </uni-list-item> | 92 | </uni-list-item> |
| 93 | - <uni-list-item title="本次锁价数量"> | 93 | + <uni-list-item title="拆分数量(kg)"> |
| 94 | <template v-slot:footer> | 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 | </template> | 96 | </template> |
| 97 | </uni-list-item> | 97 | </uni-list-item> |
| 98 | <uni-list-item title="单价"> | 98 | <uni-list-item title="单价"> |
| @@ -106,7 +106,7 @@ | @@ -106,7 +106,7 @@ | ||
| 106 | </uni-list-item> | 106 | </uni-list-item> |
| 107 | <uni-list-item title="发货日期"> | 107 | <uni-list-item title="发货日期"> |
| 108 | <template v-slot:footer> | 108 | <template v-slot:footer> |
| 109 | - <uni-easyinput v-model="item.deliveryDate" :inputBorder="false" disabled /> | 109 | + <uni-datetime-picker type="date" :start="todayDate" v-model="item.deliveryDate" /> |
| 110 | </template> | 110 | </template> |
| 111 | </uni-list-item> | 111 | </uni-list-item> |
| 112 | </uni-list> | 112 | </uni-list> |
| @@ -182,6 +182,13 @@ export default { | @@ -182,6 +182,13 @@ export default { | ||
| 182 | } | 182 | } |
| 183 | }, | 183 | }, |
| 184 | computed: { | 184 | computed: { |
| 185 | + todayDate() { | ||
| 186 | + const now = new Date() | ||
| 187 | + const y = now.getFullYear() | ||
| 188 | + const m = String(now.getMonth() + 1).padStart(2, '0') | ||
| 189 | + const d = String(now.getDate()).padStart(2, '0') | ||
| 190 | + return `${y}-${m}-${d}` | ||
| 191 | + }, | ||
| 185 | totalQuantity() { | 192 | totalQuantity() { |
| 186 | const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) | 193 | const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) |
| 187 | return this.round(qty, 2) | 194 | return this.round(qty, 2) |
| @@ -215,6 +222,19 @@ export default { | @@ -215,6 +222,19 @@ export default { | ||
| 215 | this.loadDetail() | 222 | this.loadDetail() |
| 216 | }, | 223 | }, |
| 217 | methods: { | 224 | methods: { |
| 225 | + normalizeDate(val) { | ||
| 226 | + if (!val) return '' | ||
| 227 | + const s = String(val) | ||
| 228 | + if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s | ||
| 229 | + const m = s.match(/^(\d{4}-\d{2}-\d{2})/) | ||
| 230 | + return m ? m[1] : s | ||
| 231 | + }, | ||
| 232 | + isBeforeToday(dateStr) { | ||
| 233 | + const d = this.normalizeDate(dateStr) | ||
| 234 | + const t = this.todayDate | ||
| 235 | + if (!d || !t) return false | ||
| 236 | + return d < t | ||
| 237 | + }, | ||
| 218 | onLockChange(idx, e) { | 238 | onLockChange(idx, e) { |
| 219 | const it = this.items[idx] | 239 | const it = this.items[idx] |
| 220 | if (!it) return | 240 | if (!it) return |
| @@ -252,7 +272,7 @@ export default { | @@ -252,7 +272,7 @@ export default { | ||
| 252 | unitPrice: v.unitPrice || '', | 272 | unitPrice: v.unitPrice || '', |
| 253 | amountExcludingTax: v.amountExcludingTax || 0, | 273 | amountExcludingTax: v.amountExcludingTax || 0, |
| 254 | totalAmount: v.totalAmount || 0, | 274 | totalAmount: v.totalAmount || 0, |
| 255 | - deliveryDate: v.deliveryDate || '', | 275 | + deliveryDate: this.normalizeDate(v.deliveryDate), |
| 256 | specDisplay: '' | 276 | specDisplay: '' |
| 257 | })) | 277 | })) |
| 258 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) | 278 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) |
| @@ -347,6 +367,7 @@ export default { | @@ -347,6 +367,7 @@ export default { | ||
| 347 | raw.unitPrice = price | 367 | raw.unitPrice = price |
| 348 | raw.totalAmount = total | 368 | raw.totalAmount = total |
| 349 | raw.amountExcludingTax = excl | 369 | raw.amountExcludingTax = excl |
| 370 | + raw.deliveryDate = it.deliveryDate | ||
| 350 | return raw | 371 | return raw |
| 351 | }) | 372 | }) |
| 352 | if (!selected.length) { | 373 | if (!selected.length) { |
| @@ -361,12 +382,9 @@ export default { | @@ -361,12 +382,9 @@ export default { | ||
| 361 | uni.showToast({ title: '请填写单价', icon: 'none' }) | 382 | uni.showToast({ title: '请填写单价', icon: 'none' }) |
| 362 | return | 383 | return |
| 363 | } | 384 | } |
| 364 | - const invalidQty = selected.find(r => { | ||
| 365 | - const q = this.toNumber(r.currentQuantity) | ||
| 366 | - return !(q > 0) | ||
| 367 | - }) | ||
| 368 | - if (invalidQty) { | ||
| 369 | - uni.showToast({ title: '请填写本次锁价数量', icon: 'none' }) | 385 | + const invalidDeliveryDate = selected.find(r => this.isBeforeToday(r.deliveryDate)) |
| 386 | + if (invalidDeliveryDate) { | ||
| 387 | + uni.showToast({ title: '发货日期不得早于今日', icon: 'none' }) | ||
| 370 | return | 388 | return |
| 371 | } | 389 | } |
| 372 | this.selectedItems = selected | 390 | this.selectedItems = selected |
| @@ -84,9 +84,9 @@ | @@ -84,9 +84,9 @@ | ||
| 84 | <uni-easyinput v-model="item.quantity" type="number" :inputBorder="false" disabled placeholder="不可编辑" /> | 84 | <uni-easyinput v-model="item.quantity" type="number" :inputBorder="false" disabled placeholder="不可编辑" /> |
| 85 | </template> | 85 | </template> |
| 86 | </uni-list-item> | 86 | </uni-list-item> |
| 87 | - <uni-list-item title="本次锁价数量"> | 87 | + <uni-list-item title="拆分数量(kg)"> |
| 88 | <template v-slot:footer> | 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 | </template> | 90 | </template> |
| 91 | </uni-list-item> | 91 | </uni-list-item> |
| 92 | <uni-list-item title="单价"> | 92 | <uni-list-item title="单价"> |