Commit 3e08a79477354475e5fc72fae330b930c45d8799
1 parent
bb240e75
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> |
| ... | ... | @@ -137,6 +137,12 @@ |
| 137 | 137 | <uni-datetime-picker :start="minDeliveryDate" type="date" v-model="item.deliveryDate" @change="onDateChange(idx, $event)" /> |
| 138 | 138 | </template> |
| 139 | 139 | </uni-list-item> |
| 140 | + <uni-list-item class="select-item" :class="typeof item.sampleOrder === 'boolean' ? 'is-filled' : 'is-empty'" clickable | |
| 141 | + @click="openProductSheet(idx, 'sampleOrder')" :rightText="typeof item.sampleOrder === 'boolean' ? (item.sampleOrder ? '是' : '否') : '请选择'" showArrow> | |
| 142 | + <template v-slot:body> | |
| 143 | + <view class="item-title"><text>是否为试样订单</text></view> | |
| 144 | + </template> | |
| 145 | + </uni-list-item> | |
| 140 | 146 | </uni-list> |
| 141 | 147 | <view class="block-ops"> |
| 142 | 148 | <div class="del" @click="onRemove(idx)"> |
| ... | ... | @@ -195,6 +201,7 @@ |
| 195 | 201 | <view class="row"><text class="label">总金额</text><text class="value">{{ formatCurrency(item.totalAmount) |
| 196 | 202 | }}</text></view> |
| 197 | 203 | <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text></view> |
| 204 | + <view class="row"><text class="label">是否为试样订单</text><text class="value">{{ item.sampleOrder ? '是' : '否' }}</text></view> | |
| 198 | 205 | </view> |
| 199 | 206 | </view> |
| 200 | 207 | <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" /> |
| ... | ... | @@ -217,7 +224,7 @@ export default { |
| 217 | 224 | return { |
| 218 | 225 | items: [], |
| 219 | 226 | collapsedView: false, |
| 220 | - sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1 } | |
| 227 | + sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1, mode: 'product' } | |
| 221 | 228 | } |
| 222 | 229 | }, |
| 223 | 230 | computed: { |
| ... | ... | @@ -266,7 +273,7 @@ export default { |
| 266 | 273 | }, |
| 267 | 274 | methods: { |
| 268 | 275 | defaultItem() { |
| 269 | - return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '',processingFee: undefined, status: '', quantity: '', unitPrice: '', totalAmount: 0, deliveryDate: '' } | |
| 276 | + return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '',processingFee: undefined, status: '', quantity: '', unitPrice: '', totalAmount: 0, deliveryDate: '', sampleOrder: '' } | |
| 270 | 277 | }, |
| 271 | 278 | onNonNegativeInput(idx, field) { |
| 272 | 279 | const it = this.items[idx] |
| ... | ... | @@ -375,18 +382,38 @@ export default { |
| 375 | 382 | const l = [item.length, item.lengthTolPos, item.lengthTolNeg].filter(Boolean).join('/') |
| 376 | 383 | return [t, w, l].filter(Boolean).join(' × ') |
| 377 | 384 | }, |
| 378 | - openProductSheet(idx) { | |
| 379 | - const opts = this.selectOptions | |
| 380 | - const current = this.items[idx] && this.items[idx].productId | |
| 381 | - const match = opts.find(o => o.value === current) | |
| 382 | - this.sheet = { ...this.sheet, visible: true, title: '请选择产品', options: opts, idx, value: match ? match.value : '' } | |
| 385 | + openProductSheet(idx, mode = 'product') { | |
| 386 | + let opts = [] | |
| 387 | + let title = '' | |
| 388 | + let value = '' | |
| 389 | + const item = this.items[idx] | |
| 390 | + | |
| 391 | + if (mode === 'product') { | |
| 392 | + opts = this.selectOptions | |
| 393 | + const current = item && item.productId | |
| 394 | + const match = opts.find(o => o.value === current) | |
| 395 | + value = match ? match.value : '' | |
| 396 | + title = '请选择产品' | |
| 397 | + } else if (mode === 'sampleOrder') { | |
| 398 | + opts = [{ label: '是', value: true }, { label: '否', value: false }] | |
| 399 | + value = item.sampleOrder | |
| 400 | + title = '是否为试样订单' | |
| 401 | + } | |
| 402 | + | |
| 403 | + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode } | |
| 383 | 404 | }, |
| 384 | 405 | onProductConfirm({ value, label }) { |
| 385 | - const idx = this.sheet.idx | |
| 406 | + const { idx, mode } = this.sheet | |
| 386 | 407 | const it = this.items[idx] |
| 387 | 408 | if (!it) { this.sheet.visible = false; return } |
| 388 | - it.productId = value | |
| 389 | - it.productName = label || '' | |
| 409 | + | |
| 410 | + if (mode === 'product') { | |
| 411 | + it.productId = value | |
| 412 | + it.productName = label || '' | |
| 413 | + } else if (mode === 'sampleOrder') { | |
| 414 | + it.sampleOrder = value | |
| 415 | + } | |
| 416 | + | |
| 390 | 417 | this.$set(this.items, idx, it) |
| 391 | 418 | this.sheet.visible = false |
| 392 | 419 | this.emitChange() | ... | ... |