Commit 88ca471c1b5f88eb9d7a2a137f2b0e076e2e5dbf

Authored by 史婷婷
1 parent c064cef3

feat: 经销库存合同-新增&编辑&查看-产品 是否为试样订单 逻辑

... ... @@ -475,7 +475,8 @@ export default {
475 475 }
476 476
477 477 .label {
478   - width: 310rpx;
  478 + max-width: 400rpx;
  479 + margin-right: 20rpx;
479 480 color: rgba(0, 0, 0, 0.6);
480 481 font-size: 28rpx;
481 482 }
... ...
... ... @@ -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: {
... ... @@ -261,7 +268,7 @@ export default {
261 268 },
262 269 methods: {
263 270 defaultItem() {
264   - return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '', status: '', quantity: '', unitPrice: '', amountExcludingTax: 0, totalAmount: 0, deliveryDate: '' }
  271 + return { productId: '', productName: '', industry: '', brand: '', quality: '', thickness: '', thicknessTolPos: '', thicknessTolNeg: '', width: '', widthTolPos: '', widthTolNeg: '', length: '', lengthTolPos: '', lengthTolNeg: '', status: '', quantity: '', unitPrice: '', amountExcludingTax: 0, totalAmount: 0, deliveryDate: '', sampleOrder: '' }
265 272 },
266 273 onNumberInput(idx, field) {
267 274 const it = this.items[idx]
... ... @@ -369,18 +376,38 @@ export default {
369 376 const l = [item.length, item.lengthTolPos, item.lengthTolNeg].filter(Boolean).join('/')
370 377 return [t, w, l].filter(Boolean).join(' × ')
371 378 },
372   - openProductSheet(idx) {
373   - const opts = this.selectOptions
374   - const current = this.items[idx] && this.items[idx].productId
375   - const match = opts.find(o => o.value === current)
376   - this.sheet = { ...this.sheet, visible: true, title: '请选择产品', options: opts, idx, value: match ? match.value : '' }
  379 + openProductSheet(idx, mode = 'product') {
  380 + let opts = []
  381 + let title = ''
  382 + let value = ''
  383 + const item = this.items[idx]
  384 +
  385 + if (mode === 'product') {
  386 + opts = this.selectOptions
  387 + const current = item && item.productId
  388 + const match = opts.find(o => o.value === current)
  389 + value = match ? match.value : ''
  390 + title = '请选择产品'
  391 + } else if (mode === 'sampleOrder') {
  392 + opts = [{ label: '是', value: true }, { label: '否', value: false }]
  393 + value = item.sampleOrder
  394 + title = '是否为试样订单'
  395 + }
  396 +
  397 + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode }
377 398 },
378 399 onProductConfirm({ value, label }) {
379   - const idx = this.sheet.idx
  400 + const { idx, mode } = this.sheet
380 401 const it = this.items[idx]
381 402 if (!it) { this.sheet.visible = false; return }
382   - it.productId = value
383   - it.productName = label || ''
  403 +
  404 + if (mode === 'product') {
  405 + it.productId = value
  406 + it.productName = label || ''
  407 + } else if (mode === 'sampleOrder') {
  408 + it.sampleOrder = value
  409 + }
  410 +
384 411 this.$set(this.items, idx, it)
385 412 this.sheet.visible = false
386 413 this.emitChange()
... ...