Commit d77880eb12bac62c3c7907e8a3e19055005cc7ec
1 parent
88ca471c
feat: 经销库存合同-新增&编辑&查看-产品 是否为试样订单逻辑
Showing
1 changed file
with
39 additions
and
12 deletions
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | <view v-if="mode === 'add'" class="add-list"> |
| 17 | 17 | <view v-for="(item, idx) in items" :key="idx" class="block"> |
| 18 | 18 | <uni-list v-show="item.collapsed"> |
| 19 | - <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx)" :rightText="item.productName || '请选择产品名称'" showArrow> | |
| 19 | + <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx, 'product')" :rightText="item.productName || '请选择产品名称'" showArrow> | |
| 20 | 20 | <template v-slot:body> |
| 21 | 21 | <view class="item-title"><text>产品名称</text></view> |
| 22 | 22 | </template> |
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | </uni-list-item> |
| 34 | 34 | </uni-list> |
| 35 | 35 | <uni-list v-show="!item.collapsed"> |
| 36 | - <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx)" :rightText="item.productName || '请选择产品名称'" showArrow> | |
| 36 | + <uni-list-item class="select-item" :class="item.productName ? 'is-filled' : 'is-empty'" clickable @click="openProductSheet(idx, 'product')" :rightText="item.productName || '请选择产品名称'" showArrow> | |
| 37 | 37 | <template v-slot:body> |
| 38 | 38 | <view class="item-title"><text>产品名称</text></view> |
| 39 | 39 | </template> |
| ... | ... | @@ -132,6 +132,12 @@ |
| 132 | 132 | <uni-datetime-picker :start="minDeliveryDate" type="date" v-model="item.deliveryDate" @change="onDateChange(idx, $event)" /> |
| 133 | 133 | </template> |
| 134 | 134 | </uni-list-item> |
| 135 | + <uni-list-item class="select-item" :class="typeof item.sampleOrder === 'boolean' ? 'is-filled' : 'is-empty'" clickable | |
| 136 | + @click="openProductSheet(idx, 'sampleOrder')" :rightText="typeof item.sampleOrder === 'boolean' ? (item.sampleOrder ? '是' : '否') : '请选择'" showArrow> | |
| 137 | + <template v-slot:body> | |
| 138 | + <view class="item-title"><text>是否为试样订单</text></view> | |
| 139 | + </template> | |
| 140 | + </uni-list-item> | |
| 135 | 141 | </uni-list> |
| 136 | 142 | <view class="block-ops"> |
| 137 | 143 | <div class="del" @click="onRemove(idx)"> |
| ... | ... | @@ -190,6 +196,7 @@ |
| 190 | 196 | <view class="row"><text class="label">总金额</text><text class="value">{{ formatCurrency(item.totalAmount) |
| 191 | 197 | }}</text></view> |
| 192 | 198 | <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text></view> |
| 199 | + <view class="row"><text class="label">是否为试样订单</text><text class="value">{{ item.sampleOrder ? '是' : '否' }}</text></view> | |
| 193 | 200 | </view> |
| 194 | 201 | </view> |
| 195 | 202 | <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" /> |
| ... | ... | @@ -212,7 +219,7 @@ export default { |
| 212 | 219 | return { |
| 213 | 220 | items: [], |
| 214 | 221 | collapsedView: false, |
| 215 | - sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1 } | |
| 222 | + sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1, mode: 'product' } | |
| 216 | 223 | } |
| 217 | 224 | }, |
| 218 | 225 | computed: { |
| ... | ... | @@ -366,7 +373,7 @@ export default { |
| 366 | 373 | return true |
| 367 | 374 | }, |
| 368 | 375 | defaultItem() { |
| 369 | - return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '', status: '', quantity: '', unitPrice: '', amountExcludingTax: 0, totalAmount: 0, deliveryDate: '' } | |
| 376 | + return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '', status: '', quantity: '', unitPrice: '', amountExcludingTax: 0, totalAmount: 0, deliveryDate: '', sampleOrder: '' } | |
| 370 | 377 | }, |
| 371 | 378 | onNonNegativeInput(idx, field) { |
| 372 | 379 | const it = this.items[idx] |
| ... | ... | @@ -419,18 +426,38 @@ export default { |
| 419 | 426 | const l = [item.length, item.lengthTolPos, item.lengthTolNeg].filter(Boolean).join('/') |
| 420 | 427 | return [t, w, l].filter(Boolean).join(' × ') |
| 421 | 428 | }, |
| 422 | - openProductSheet(idx) { | |
| 423 | - const opts = this.selectOptions | |
| 424 | - const current = this.items[idx] && this.items[idx].productId | |
| 425 | - const match = opts.find(o => o.value === current) | |
| 426 | - this.sheet = { ...this.sheet, visible: true, title: '请选择产品', options: opts, idx, value: match ? match.value : '' } | |
| 429 | + openProductSheet(idx, mode = 'product') { | |
| 430 | + let opts = [] | |
| 431 | + let title = '' | |
| 432 | + let value = '' | |
| 433 | + const item = this.items[idx] | |
| 434 | + | |
| 435 | + if (mode === 'product') { | |
| 436 | + opts = this.selectOptions | |
| 437 | + const current = item && item.productId | |
| 438 | + const match = opts.find(o => o.value === current) | |
| 439 | + value = match ? match.value : '' | |
| 440 | + title = '请选择产品' | |
| 441 | + } else if (mode === 'sampleOrder') { | |
| 442 | + opts = [{ label: '是', value: true }, { label: '否', value: false }] | |
| 443 | + value = item.sampleOrder | |
| 444 | + title = '是否为试样订单' | |
| 445 | + } | |
| 446 | + | |
| 447 | + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode } | |
| 427 | 448 | }, |
| 428 | 449 | onProductConfirm({ value, label }) { |
| 429 | - const idx = this.sheet.idx | |
| 450 | + const { idx, mode } = this.sheet | |
| 430 | 451 | const it = this.items[idx] |
| 431 | 452 | if (!it) { this.sheet.visible = false; return } |
| 432 | - it.productId = value | |
| 433 | - it.productName = label || '' | |
| 453 | + | |
| 454 | + if (mode === 'product') { | |
| 455 | + it.productId = value | |
| 456 | + it.productName = label || '' | |
| 457 | + } else if (mode === 'sampleOrder') { | |
| 458 | + it.sampleOrder = value | |
| 459 | + } | |
| 460 | + | |
| 434 | 461 | this.$set(this.items, idx, it) |
| 435 | 462 | this.sheet.visible = false |
| 436 | 463 | this.emitChange() | ... | ... |