Commit 3b823a8775427ddd2eff3892e1f2b0eb02ce4488

Authored by gesilong
2 parents 29f6d426 3321d521

Merge branch 'cjerp-contract-1.0' into test_cjerp

... ... @@ -116,7 +116,7 @@
116 116 </uni-list-item>
117 117 <uni-list-item title="发货日期">
118 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 120 </template>
121 121 </uni-list-item>
122 122 </uni-list>
... ... @@ -195,6 +195,13 @@ export default {
195 195 }
196 196 },
197 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 205 totalQuantity() {
199 206 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0)
200 207 return this.round(qty, 2)
... ... @@ -228,6 +235,19 @@ export default {
228 235 this.loadDetail()
229 236 },
230 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 251 onLockChange(idx, e) {
232 252 const it = this.items[idx]
233 253 if (!it) return
... ... @@ -265,7 +285,7 @@ export default {
265 285 unitPrice: v.unitPrice || '',
266 286 // amountExcludingTax: v.amountExcludingTax || 0,
267 287 totalAmount: v.totalAmount || 0,
268   - deliveryDate: v.deliveryDate || '',
  288 + deliveryDate: this.normalizeDate(v.deliveryDate),
269 289 specDisplay: ''
270 290 }))
271 291 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
... ... @@ -359,6 +379,7 @@ export default {
359 379 raw.currentQuantity = (curQtyRaw === '' || curQtyRaw === null || curQtyRaw === undefined) ? null : this.toNumber(curQtyRaw)
360 380 raw.unitPrice = price
361 381 raw.totalAmount = total
  382 + raw.deliveryDate = it.deliveryDate
362 383 // raw.amountExcludingTax = excl
363 384 return raw
364 385 })
... ... @@ -374,12 +395,9 @@ export default {
374 395 uni.showToast({ title: '请填写单价', icon: 'none' })
375 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 401 return
384 402 }
385 403 this.selectedItems = selected
... ... @@ -803,4 +821,4 @@ export default {
803 821 height: 60rpx;
804 822 align-items: center;
805 823 }
806   -</style>
\ No newline at end of file
  824 +</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="单价">
... ...
... ... @@ -106,7 +106,7 @@
106 106 </uni-list-item>
107 107 <uni-list-item title="发货日期">
108 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 110 </template>
111 111 </uni-list-item>
112 112 </uni-list>
... ... @@ -182,6 +182,13 @@ export default {
182 182 }
183 183 },
184 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 192 totalQuantity() {
186 193 const qty = this.items.filter(it => it.locked).reduce((p, c) => p + this.toNumber(c.quantity), 0)
187 194 return this.round(qty, 2)
... ... @@ -215,6 +222,19 @@ export default {
215 222 this.loadDetail()
216 223 },
217 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 238 onLockChange(idx, e) {
219 239 const it = this.items[idx]
220 240 if (!it) return
... ... @@ -252,7 +272,7 @@ export default {
252 272 unitPrice: v.unitPrice || '',
253 273 amountExcludingTax: v.amountExcludingTax || 0,
254 274 totalAmount: v.totalAmount || 0,
255   - deliveryDate: v.deliveryDate || '',
  275 + deliveryDate: this.normalizeDate(v.deliveryDate),
256 276 specDisplay: ''
257 277 }))
258 278 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
... ... @@ -347,6 +367,7 @@ export default {
347 367 raw.unitPrice = price
348 368 raw.totalAmount = total
349 369 raw.amountExcludingTax = excl
  370 + raw.deliveryDate = it.deliveryDate
350 371 return raw
351 372 })
352 373 if (!selected.length) {
... ... @@ -361,12 +382,9 @@ export default {
361 382 uni.showToast({ title: '请填写单价', icon: 'none' })
362 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 388 return
371 389 }
372 390 this.selectedItems = selected
... ...
... ... @@ -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="单价">
... ...