Commit eb46340fa5c95f837e4f10ee2df0030f869fbe19
1 parent
3e08a794
feat: 外贸库存合同-新增&编辑&查看-产品- 是否为试样订单 逻辑
Showing
1 changed file
with
39 additions
and
12 deletions
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | <view v-if="mode === 'add'" class="add-list"> | 16 | <view v-if="mode === 'add'" class="add-list"> |
| 17 | <view v-for="(item, idx) in items" :key="idx" class="block"> | 17 | <view v-for="(item, idx) in items" :key="idx" class="block"> |
| 18 | <uni-list v-show="item.collapsed"> | 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 | <template v-slot:body> | 20 | <template v-slot:body> |
| 21 | <view class="item-title"><text>产品名称</text></view> | 21 | <view class="item-title"><text>产品名称</text></view> |
| 22 | </template> | 22 | </template> |
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | </uni-list-item> | 33 | </uni-list-item> |
| 34 | </uni-list> | 34 | </uni-list> |
| 35 | <uni-list v-show="!item.collapsed"> | 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 | <template v-slot:body> | 37 | <template v-slot:body> |
| 38 | <view class="item-title"><text>产品名称</text></view> | 38 | <view class="item-title"><text>产品名称</text></view> |
| 39 | </template> | 39 | </template> |
| @@ -139,6 +139,12 @@ | @@ -139,6 +139,12 @@ | ||
| 139 | <uni-datetime-picker :start="minDeliveryDate" type="date" v-model="item.deliveryDate" @change="onDateChange(idx, $event)" /> | 139 | <uni-datetime-picker :start="minDeliveryDate" type="date" v-model="item.deliveryDate" @change="onDateChange(idx, $event)" /> |
| 140 | </template> | 140 | </template> |
| 141 | </uni-list-item> | 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 | </uni-list> | 148 | </uni-list> |
| 143 | <view class="block-ops"> | 149 | <view class="block-ops"> |
| 144 | <div class="del" @click="onRemove(idx)"> | 150 | <div class="del" @click="onRemove(idx)"> |
| @@ -197,6 +203,7 @@ | @@ -197,6 +203,7 @@ | ||
| 197 | <view class="row"><text class="label">总金额</text><text class="value">{{ formatCurrency(item.totalAmount) | 203 | <view class="row"><text class="label">总金额</text><text class="value">{{ formatCurrency(item.totalAmount) |
| 198 | }}</text></view> | 204 | }}</text></view> |
| 199 | <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text></view> | 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 | </view> | 207 | </view> |
| 201 | </view> | 208 | </view> |
| 202 | <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" /> | 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,7 +226,7 @@ export default { | ||
| 219 | return { | 226 | return { |
| 220 | items: [], | 227 | items: [], |
| 221 | collapsedView: false, | 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 | watch: { | 232 | watch: { |
| @@ -268,7 +275,7 @@ export default { | @@ -268,7 +275,7 @@ export default { | ||
| 268 | }, | 275 | }, |
| 269 | methods: { | 276 | methods: { |
| 270 | defaultItem() { | 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 | onNonNegativeInput(idx, field) { | 280 | onNonNegativeInput(idx, field) { |
| 274 | const it = this.items[idx] | 281 | const it = this.items[idx] |
| @@ -345,18 +352,38 @@ export default { | @@ -345,18 +352,38 @@ export default { | ||
| 345 | const l = [item.length, item.lengthTolPos, item.lengthTolNeg].filter(Boolean).join('/') | 352 | const l = [item.length, item.lengthTolPos, item.lengthTolNeg].filter(Boolean).join('/') |
| 346 | return [t, w, l].filter(Boolean).join(' × ') | 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 | onProductConfirm({ value, label }) { | 375 | onProductConfirm({ value, label }) { |
| 355 | - const idx = this.sheet.idx | 376 | + const { idx, mode } = this.sheet |
| 356 | const it = this.items[idx] | 377 | const it = this.items[idx] |
| 357 | if (!it) { this.sheet.visible = false; return } | 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 | this.$set(this.items, idx, it) | 387 | this.$set(this.items, idx, it) |
| 361 | this.sheet.visible = false | 388 | this.sheet.visible = false |
| 362 | this.emitChange() | 389 | this.emitChange() |