Commit 46f6440f1df0c072508f12e3466e6b01d635be13
1 parent
904236b3
feat: 规格变更单-新增&编辑-产品-发货日期 控制选择范围 得大于 订货日期
Showing
3 changed files
with
44 additions
and
5 deletions
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | |
| 45 | 45 | <!-- 产品 --> |
| 46 | 46 | <view class="section2"> |
| 47 | - <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange" /> | |
| 47 | + <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange" :orderDate="form.orderDate" /> | |
| 48 | 48 | </view> |
| 49 | 49 | |
| 50 | 50 | <view class="section"> | ... | ... |
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | |
| 44 | 44 | <!-- 产品 --> |
| 45 | 45 | <view class="section2"> |
| 46 | - <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange" /> | |
| 46 | + <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange" :orderDate="form.orderDate" /> | |
| 47 | 47 | </view> |
| 48 | 48 | |
| 49 | 49 | <view class="section"> | ... | ... |
| ... | ... | @@ -127,7 +127,7 @@ |
| 127 | 127 | </uni-list-item> |
| 128 | 128 | <uni-list-item title="发货日期"> |
| 129 | 129 | <template v-slot:footer> |
| 130 | - <uni-datetime-picker type="date" v-model="item.deliveryDate" /> | |
| 130 | + <uni-datetime-picker type="date" v-model="item.deliveryDate" :start="minDeliveryDate" @change="onDeliveryChange($event, item, idx)" /> | |
| 131 | 131 | </template> |
| 132 | 132 | </uni-list-item> |
| 133 | 133 | <uni-list-item title="考核超协"> |
| ... | ... | @@ -211,7 +211,8 @@ export default { |
| 211 | 211 | mode: { type: String, default: 'add' }, |
| 212 | 212 | list: { type: Array, default: () => [] }, |
| 213 | 213 | max: { type: Number, default: 8 }, |
| 214 | - totalQuantity: { type: Number, default: 0 } | |
| 214 | + totalQuantity: { type: Number, default: 0 }, | |
| 215 | + orderDate: { type: String, default: '' } | |
| 215 | 216 | }, |
| 216 | 217 | data() { |
| 217 | 218 | return { |
| ... | ... | @@ -219,7 +220,22 @@ export default { |
| 219 | 220 | collapsedView: false, |
| 220 | 221 | } |
| 221 | 222 | }, |
| 222 | - computed: { | |
| 223 | + computed: { | |
| 224 | + minDeliveryDate() { | |
| 225 | + const s = this.orderDate | |
| 226 | + if (!s) return '' | |
| 227 | + const parts = String(s).split('-') | |
| 228 | + const y = Number(parts[0]) | |
| 229 | + const m = Number(parts[1]) | |
| 230 | + const d = Number(parts[2]) | |
| 231 | + if (!y || !m || !d) return '' | |
| 232 | + const dt = new Date(y, m - 1, d) | |
| 233 | + dt.setDate(dt.getDate() + 1) | |
| 234 | + const yy = dt.getFullYear() | |
| 235 | + const mm = String(dt.getMonth() + 1).padStart(2, '0') | |
| 236 | + const dd = String(dt.getDate()).padStart(2, '0') | |
| 237 | + return `${yy}/${mm}/${dd}` | |
| 238 | + } | |
| 223 | 239 | }, |
| 224 | 240 | watch: { |
| 225 | 241 | items: { |
| ... | ... | @@ -327,6 +343,29 @@ export default { |
| 327 | 343 | }, |
| 328 | 344 | toggleViewCollapse() { |
| 329 | 345 | this.collapsedView = !this.collapsedView |
| 346 | + }, | |
| 347 | + onDeliveryChange(e, item, idx) { | |
| 348 | + const getStr = (x) => { | |
| 349 | + if (x && x.detail && x.detail.value !== undefined) return x.detail.value | |
| 350 | + if (typeof x === 'string') return x | |
| 351 | + return item && item.deliveryDate ? item.deliveryDate : '' | |
| 352 | + } | |
| 353 | + const val = getStr(e) | |
| 354 | + if (!val || !this.orderDate) return | |
| 355 | + const parse = (s) => { | |
| 356 | + const p = String(s).replace(/\//g, '-').split('-') | |
| 357 | + const y = Number(p[0]) | |
| 358 | + const m = Number(p[1]) | |
| 359 | + const d = Number(p[2]) | |
| 360 | + return new Date(y, m - 1, d) | |
| 361 | + } | |
| 362 | + const sel = parse(val) | |
| 363 | + const ord = parse(this.orderDate) | |
| 364 | + if (!(sel > ord)) { | |
| 365 | + item.deliveryDate = '' | |
| 366 | + this.$set(this.items, idx, { ...item }) | |
| 367 | + uni.showToast({ title: '发货日期必须大于订货日期', icon: 'none' }) | |
| 368 | + } | |
| 330 | 369 | } |
| 331 | 370 | } |
| 332 | 371 | } | ... | ... |