Commit eb46340fa5c95f837e4f10ee2df0030f869fbe19
1 parent
3e08a794
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> |
| ... | ... | @@ -139,6 +139,12 @@ |
| 139 | 139 | <uni-datetime-picker :start="minDeliveryDate" type="date" v-model="item.deliveryDate" @change="onDateChange(idx, $event)" /> |
| 140 | 140 | </template> |
| 141 | 141 | </uni-list-item> |
| 142 | + <uni-list-item class="select-item" :class="typeof item.sampleOrder === 'boolean' ? 'is-filled' : 'is-empty'" clickable | |
| 143 | + @click="openProductSheet(idx, 'sampleOrder')" :rightText="typeof item.sampleOrder === 'boolean' ? (item.sampleOrder ? '是' : '否') : '请选择'" showArrow> | |
| 144 | + <template v-slot:body> | |
| 145 | + <view class="item-title"><text>是否为试样订单</text></view> | |
| 146 | + </template> | |
| 147 | + </uni-list-item> | |
| 142 | 148 | </uni-list> |
| 143 | 149 | <view class="block-ops"> |
| 144 | 150 | <div class="del" @click="onRemove(idx)"> |
| ... | ... | @@ -197,6 +203,7 @@ |
| 197 | 203 | <view class="row"><text class="label">总金额</text><text class="value">{{ formatCurrency(item.totalAmount) |
| 198 | 204 | }}</text></view> |
| 199 | 205 | <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text></view> |
| 206 | + <view class="row"><text class="label">是否为试样订单</text><text class="value">{{ item.sampleOrder ? '是' : '否' }}</text></view> | |
| 200 | 207 | </view> |
| 201 | 208 | </view> |
| 202 | 209 | <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" /> |
| ... | ... | @@ -219,7 +226,7 @@ export default { |
| 219 | 226 | return { |
| 220 | 227 | items: [], |
| 221 | 228 | collapsedView: false, |
| 222 | - sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1 } | |
| 229 | + sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1, mode: 'product' } | |
| 223 | 230 | } |
| 224 | 231 | }, |
| 225 | 232 | watch: { |
| ... | ... | @@ -268,7 +275,7 @@ export default { |
| 268 | 275 | }, |
| 269 | 276 | methods: { |
| 270 | 277 | defaultItem() { |
| 271 | - return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '', status: '', quantity: '', unitPrice: '', processingFee: undefined, totalAmount: 0, deliveryDate: '' } | |
| 278 | + return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '', status: '', quantity: '', unitPrice: '', processingFee: undefined, totalAmount: 0, deliveryDate: '', sampleOrder: '' } | |
| 272 | 279 | }, |
| 273 | 280 | onNonNegativeInput(idx, field) { |
| 274 | 281 | const it = this.items[idx] |
| ... | ... | @@ -345,18 +352,38 @@ export default { |
| 345 | 352 | const l = [item.length, item.lengthTolPos, item.lengthTolNeg].filter(Boolean).join('/') |
| 346 | 353 | return [t, w, l].filter(Boolean).join(' × ') |
| 347 | 354 | }, |
| 348 | - openProductSheet(idx) { | |
| 349 | - const opts = Array.isArray(this.selectOptions) ? this.selectOptions : [] | |
| 350 | - const current = this.items[idx] && this.items[idx].productId | |
| 351 | - const match = (opts || []).find(o => String(o.value) === String(current)) | |
| 352 | - this.sheet = { ...this.sheet, visible: true, title: '请选择产品', options: opts, idx, value: match ? match.value : '' } | |
| 355 | + openProductSheet(idx, mode = 'product') { | |
| 356 | + let opts = [] | |
| 357 | + let title = '' | |
| 358 | + let value = '' | |
| 359 | + const item = this.items[idx] | |
| 360 | + | |
| 361 | + if (mode === 'product') { | |
| 362 | + opts = Array.isArray(this.selectOptions) ? this.selectOptions : [] | |
| 363 | + const current = item && item.productId | |
| 364 | + const match = (opts || []).find(o => String(o.value) === String(current)) | |
| 365 | + value = match ? match.value : '' | |
| 366 | + title = '请选择产品' | |
| 367 | + } else if (mode === 'sampleOrder') { | |
| 368 | + opts = [{ label: '是', value: true }, { label: '否', value: false }] | |
| 369 | + value = item.sampleOrder | |
| 370 | + title = '是否为试样订单' | |
| 371 | + } | |
| 372 | + | |
| 373 | + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode } | |
| 353 | 374 | }, |
| 354 | 375 | onProductConfirm({ value, label }) { |
| 355 | - const idx = this.sheet.idx | |
| 376 | + const { idx, mode } = this.sheet | |
| 356 | 377 | const it = this.items[idx] |
| 357 | 378 | if (!it) { this.sheet.visible = false; return } |
| 358 | - it.productId = value | |
| 359 | - it.productName = label || '' | |
| 379 | + | |
| 380 | + if (mode === 'product') { | |
| 381 | + it.productId = value | |
| 382 | + it.productName = label || '' | |
| 383 | + } else if (mode === 'sampleOrder') { | |
| 384 | + it.sampleOrder = value | |
| 385 | + } | |
| 386 | + | |
| 360 | 387 | this.$set(this.items, idx, it) |
| 361 | 388 | this.sheet.visible = false |
| 362 | 389 | this.emitChange() | ... | ... |