Commit 3321d521be8f64dcd5611e61a066418d4540b9ad

Authored by gesilong
1 parent 2532e300

commit:锁价发货日期可编辑

@@ -111,7 +111,7 @@ @@ -111,7 +111,7 @@
111 </uni-list-item> 111 </uni-list-item>
112 <uni-list-item title="发货日期"> 112 <uni-list-item title="发货日期">
113 <template v-slot:footer> 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 </template> 115 </template>
116 </uni-list-item> 116 </uni-list-item>
117 </uni-list> 117 </uni-list>
@@ -190,6 +190,13 @@ export default { @@ -190,6 +190,13 @@ export default {
190 } 190 }
191 }, 191 },
192 computed: { 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 totalQuantity() { 200 totalQuantity() {
194 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) 201 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0)
195 return this.round(qty, 2) 202 return this.round(qty, 2)
@@ -223,6 +230,19 @@ export default { @@ -223,6 +230,19 @@ export default {
223 this.loadDetail() 230 this.loadDetail()
224 }, 231 },
225 methods: { 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 onLockChange(idx, e) { 246 onLockChange(idx, e) {
227 const it = this.items[idx] 247 const it = this.items[idx]
228 if (!it) return 248 if (!it) return
@@ -259,7 +279,7 @@ export default { @@ -259,7 +279,7 @@ export default {
259 unitPrice: v.unitPrice || '', 279 unitPrice: v.unitPrice || '',
260 // amountExcludingTax: v.amountExcludingTax || 0, 280 // amountExcludingTax: v.amountExcludingTax || 0,
261 totalAmount: v.totalAmount || 0, 281 totalAmount: v.totalAmount || 0,
262 - deliveryDate: v.deliveryDate || '', 282 + deliveryDate: this.normalizeDate(v.deliveryDate),
263 specDisplay: '' 283 specDisplay: ''
264 })) 284 }))
265 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) 285 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
@@ -350,6 +370,7 @@ export default { @@ -350,6 +370,7 @@ export default {
350 else raw.quantity = qty 370 else raw.quantity = qty
351 raw.unitPrice = price 371 raw.unitPrice = price
352 raw.totalAmount = total 372 raw.totalAmount = total
  373 + raw.deliveryDate = it.deliveryDate
353 // raw.amountExcludingTax = excl 374 // raw.amountExcludingTax = excl
354 return raw 375 return raw
355 }) 376 })
@@ -365,6 +386,11 @@ export default { @@ -365,6 +386,11 @@ export default {
365 uni.showToast({ title: '请填写单价', icon: 'none' }) 386 uni.showToast({ title: '请填写单价', icon: 'none' })
366 return 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 this.selectedItems = selected 394 this.selectedItems = selected
369 const payload = { 395 const payload = {
370 id: this.id, 396 id: this.id,
@@ -786,4 +812,4 @@ export default { @@ -786,4 +812,4 @@ export default {
786 height: 60rpx; 812 height: 60rpx;
787 align-items: center; 813 align-items: center;
788 } 814 }
789 -</style>  
  815 +</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="单价">
@@ -101,7 +101,7 @@ @@ -101,7 +101,7 @@
101 </uni-list-item> 101 </uni-list-item>
102 <uni-list-item title="发货日期"> 102 <uni-list-item title="发货日期">
103 <template v-slot:footer> 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 </template> 105 </template>
106 </uni-list-item> 106 </uni-list-item>
107 </uni-list> 107 </uni-list>
@@ -177,6 +177,13 @@ export default { @@ -177,6 +177,13 @@ export default {
177 } 177 }
178 }, 178 },
179 computed: { 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 totalQuantity() { 187 totalQuantity() {
181 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0) 188 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0)
182 return this.round(qty, 2) 189 return this.round(qty, 2)
@@ -210,6 +217,19 @@ export default { @@ -210,6 +217,19 @@ export default {
210 this.loadDetail() 217 this.loadDetail()
211 }, 218 },
212 methods: { 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 onLockChange(idx, e) { 233 onLockChange(idx, e) {
214 const it = this.items[idx] 234 const it = this.items[idx]
215 if (!it) return 235 if (!it) return
@@ -246,7 +266,7 @@ export default { @@ -246,7 +266,7 @@ export default {
246 unitPrice: v.unitPrice || '', 266 unitPrice: v.unitPrice || '',
247 amountExcludingTax: v.amountExcludingTax || 0, 267 amountExcludingTax: v.amountExcludingTax || 0,
248 totalAmount: v.totalAmount || 0, 268 totalAmount: v.totalAmount || 0,
249 - deliveryDate: v.deliveryDate || '', 269 + deliveryDate: this.normalizeDate(v.deliveryDate),
250 specDisplay: '' 270 specDisplay: ''
251 })) 271 }))
252 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) 272 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
@@ -338,6 +358,7 @@ export default { @@ -338,6 +358,7 @@ export default {
338 raw.unitPrice = price 358 raw.unitPrice = price
339 raw.totalAmount = total 359 raw.totalAmount = total
340 raw.amountExcludingTax = excl 360 raw.amountExcludingTax = excl
  361 + raw.deliveryDate = it.deliveryDate
341 return raw 362 return raw
342 }) 363 })
343 if (!selected.length) { 364 if (!selected.length) {
@@ -352,6 +373,11 @@ export default { @@ -352,6 +373,11 @@ export default {
352 uni.showToast({ title: '请填写单价', icon: 'none' }) 373 uni.showToast({ title: '请填写单价', icon: 'none' })
353 return 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 this.selectedItems = selected 381 this.selectedItems = selected
356 const payload = { 382 const payload = {
357 id: this.id, 383 id: this.id,
@@ -768,4 +794,4 @@ export default { @@ -768,4 +794,4 @@ export default {
768 height: 60rpx; 794 height: 60rpx;
769 align-items: center; 795 align-items: center;
770 } 796 }
771 -</style>  
  797 +</style>
@@ -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="单价">