Commit a566f00ba56a4e8f18ce83dd2a14060e9941cd18

Authored by 史婷婷
1 parent 8f71e713

feat: 产品试样确认单-编辑

... ... @@ -41,7 +41,7 @@
41 41 <view class="section2">
42 42 <!-- mode="add" 允许编辑 -->
43 43 <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange"
44   - :orderDate="form.orderDate" />
  44 + :provideSamplesOptions="provideSamplesOptions" :clearParametersOptions="clearParametersOptions" />
45 45 </view>
46 46
47 47 <view class="section">
... ... @@ -131,9 +131,13 @@ export default {
131 131 dicOptions: {
132 132 ENTERPRISE_TYPE: [], // 客户类型
133 133 SAMPLE_TYPE: [], // 试样种类
  134 + CLEAR_PARAMETERS: [], // 是否提供明确参数
  135 + PROVIDE_SAMPLES: [], // 是否提供样品
134 136 },
135 137 enterpriseTypeLocal: [], // 客户类型
136 138 sampleTypeLocal: [], // 试样种类
  139 + provideSamplesOptions: [], // 是否提供样品
  140 + clearParametersOptions: [], // 是否提供明确参数
137 141 }
138 142 },
139 143 onLoad(query) {
... ... @@ -173,10 +177,13 @@ export default {
173 177 }
174 178 },
175 179 loadAllDicData() {
176   - const dicCodes = ['ENTERPRISE_TYPE', 'SAMPLE_TYPE']
  180 + const dicCodes = ['ENTERPRISE_TYPE', 'SAMPLE_TYPE', 'CLEAR_PARAMETERS', 'PROVIDE_SAMPLES']
177 181 return getDicByCodes(dicCodes).then(results => {
178 182 this.dicOptions.ENTERPRISE_TYPE = results.ENTERPRISE_TYPE.data || []
179 183 this.dicOptions.SAMPLE_TYPE = results.SAMPLE_TYPE.data || []
  184 + this.dicOptions.CLEAR_PARAMETERS = results.CLEAR_PARAMETERS.data || []
  185 + this.dicOptions.PROVIDE_SAMPLES = results.PROVIDE_SAMPLES.data || []
  186 +
180 187 this.enterpriseTypeLocal = (this.dicOptions.ENTERPRISE_TYPE || []).map(it => ({
181 188 value: it.code,
182 189 label: it.name
... ... @@ -185,13 +192,25 @@ export default {
185 192 value: it.code,
186 193 label: it.name
187 194 }))
  195 + this.provideSamplesOptions = (this.dicOptions.PROVIDE_SAMPLES || []).map(it => ({
  196 + value: it.code,
  197 + label: it.name
  198 + }))
  199 + this.clearParametersOptions = (this.dicOptions.CLEAR_PARAMETERS || []).map(it => ({
  200 + value: it.code,
  201 + label: it.name
  202 + }))
188 203 }).catch(() => {
189 204 this.dicOptions = {
190 205 ENTERPRISE_TYPE: [], // 客户类型
191 206 SAMPLE_TYPE: [], // 试样种类
  207 + CLEAR_PARAMETERS: [], // 是否提供明确参数
  208 + PROVIDE_SAMPLES: [], // 是否提供样品
192 209 }
193 210 this.enterpriseTypeLocal = []
194 211 this.sampleTypeLocal = []
  212 + this.provideSamplesOptions = []
  213 + this.clearParametersOptions = []
195 214 })
196 215 },
197 216 validateRequired() {
... ...
... ... @@ -17,68 +17,57 @@
17 17
18 18 <view v-if="mode === 'add'" class="section">
19 19 <view v-for="(item, idx) in items" :key="'a-' + idx" class="block">
20   - <view class="row"><text class="label">行业</text><text class="value">{{ item.industry }}</text></view>
21   - <view class="row"><text class="label">品质</text><text class="value">{{ item.quality }}</text></view>
22 20 <view class="row"><text class="label">牌号</text><text class="value">{{ item.brand }}</text></view>
23   -
24   - <view v-show="!item.collapsed">
25   - <!-- 厚(公差) * 宽(公差) * 长(公差) -->
26   - <view class="row row-spec"><text class="label">规格(mm)</text>
27   - <view class="value value-spec">
28   - <view v-if="item.thickness" class="value-spec_val">{{ item.thickness }}</view>
29   - <view v-if="item.thickness" class="value-spec_box">
30   - <view v-if="item.thicknessTolPos" class="value-spec_box_1">+{{ item.thicknessTolPos }}
31   - </view>
32   - <view v-if="item.thicknessTolNeg" class="value-spec_box_2">-{{ item.thicknessTolNeg }}
33   - </view>
34   - </view>
35   - <view v-if="item.width" class="value-spec_val p12">*</view>
36   - <view v-if="item.width" class="value-spec_val">{{ item.width }}</view>
37   - <view v-if="item.width" class="value-spec_box">
38   - <view v-if="item.widthTolPos" class="value-spec_box_1">{{ item.widthTolPos > 0 ? '+' + item.widthTolPos : item.widthTolPos }}</view>
39   - <view v-if="item.widthTolNeg" class="value-spec_box_2">{{ item.widthTolNeg > 0 ? '+' + item.widthTolNeg : item.widthTolNeg }}</view>
  21 + <!-- 厚(公差) * 宽(公差) * 长(公差) -->
  22 + <view class="row row-spec"><text class="label">规格(mm)</text>
  23 + <view class="value value-spec">
  24 + <view v-if="item.thickness" class="value-spec_val">{{ item.thickness }}</view>
  25 + <view v-if="item.thickness" class="value-spec_box">
  26 + <view v-if="item.thicknessTolPos" class="value-spec_box_1">{{ item.thicknessTolPos > 0 ? '+' + item.thicknessTolPos : item.thicknessTolPos }}
40 27 </view>
41   - <view v-if="item.length" class="value-spec_val p12">*</view>
42   - <view v-if="item.length" class="value-spec_val">{{ item.length }}</view>
43   - <view v-if="item.length" class="value-spec_box">
44   - <view v-if="item.lengthTolPos" class="value-spec_box_1">{{ item.lengthTolPos > 0 ? '+' + item.lengthTolPos : item.lengthTolPos }}</view>
45   - <view v-if="item.lengthTolNeg" class="value-spec_box_2">{{ item.lengthTolNeg > 0 ? '+' + item.lengthTolNeg : item.lengthTolNeg }}</view>
  28 + <view v-if="item.thicknessTolNeg" class="value-spec_box_2">{{ item.thicknessTolNeg > 0 ? '+' + item.thicknessTolNeg : item.thicknessTolNeg }}
46 29 </view>
47 30 </view>
  31 + <view v-if="item.width" class="value-spec_val p12">*</view>
  32 + <view v-if="item.width" class="value-spec_val">{{ item.width }}</view>
  33 + <view v-if="item.width" class="value-spec_box">
  34 + <view v-if="item.widthTolPos" class="value-spec_box_1">{{ item.widthTolPos > 0 ? '+' +
  35 + item.widthTolPos : item.widthTolPos }}</view>
  36 + <view v-if="item.widthTolNeg" class="value-spec_box_2">{{ item.widthTolNeg > 0 ? '+' +
  37 + item.widthTolNeg : item.widthTolNeg }}</view>
  38 + </view>
  39 + <view v-if="item.length" class="value-spec_val p12">*</view>
  40 + <view v-if="item.length" class="value-spec_val">{{ item.length }}</view>
  41 + <view v-if="item.length" class="value-spec_box">
  42 + <view v-if="item.lengthTolPos" class="value-spec_box_1">{{ item.lengthTolPos > 0 ? '+' +
  43 + item.lengthTolPos : item.lengthTolPos }}</view>
  44 + <view v-if="item.lengthTolNeg" class="value-spec_box_2">{{ item.lengthTolNeg > 0 ? '+' +
  45 + item.lengthTolNeg : item.lengthTolNeg }}</view>
  46 + </view>
48 47 </view>
49   - <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view>
  48 + </view>
  49 + <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view>
  50 + <view v-show="!item.collapsed">
  51 +
50 52 <view class="row" :class="{ 'noneStyle': !item.showSalesPrice }"><text
51 53 class="label">数量kg</text><text class="value">{{ item.quantity }}</text>
52 54 </view>
53   - <view class="row" :class="{ 'noneStyle': item.showSalesPrice }" v-if="item.showSalesPrice"><text
54   - class="label">销售价格</text><text class="value">{{
55   - item.salesPrice }}</text></view>
  55 +
56 56 <uni-list class="edit-list">
57   - <uni-list-item class="amount-item">
  57 + <uni-list-item class="select-item"
  58 + :class="item.provideSamplesName ? 'is-filled' : 'is-empty'" clickable
  59 + @click="openProductSheet(idx, 'provideSamples')"
  60 + :rightText="item.provideSamplesName || '请选择是否提供样品'" showArrow>
58 61 <template v-slot:body>
59   - <view class="item-title"><text>包装费</text></view>
60   - </template>
61   - <template v-slot:footer>
62   - <view class="amount-row">
63   - <uni-easyinput type="digit" v-model="item.packagingFee" placeholder="0.00"
64   - :inputBorder="false"
65   - @input="onNonNegativeNumberInput($event, item, idx, 'packagingFee')"
66   - @blur="onNonNegativeNumberBlur(item, idx, 'packagingFee')" />
67   - <text class="unit">元</text>
68   - </view>
  62 + <view class="item-title"><text>是否提供样品</text></view>
69 63 </template>
70 64 </uni-list-item>
71   - <uni-list-item title="发货日期">
72   - <template v-slot:footer>
73   - <uni-datetime-picker type="date" v-model="item.deliveryDate" :start="minDeliveryDate"
74   - @change="onDeliveryChange($event, item, idx)" />
75   - </template>
76   - </uni-list-item>
77   - <uni-list-item title="考核超协">
78   - <template v-slot:footer>
79   - <uni-easyinput :disabled="pageType === 'modify'"
80   - v-model="item.assessmentExceedsAgreement"
81   - :placeholder="pageType === 'modify' ? '' : '请输入考核超协'" :inputBorder="false" />
  65 + <uni-list-item class="select-item"
  66 + :class="item.clearParametersName ? 'is-filled' : 'is-empty'" clickable
  67 + @click="openProductSheet(idx, 'clearParameters')"
  68 + :rightText="item.clearParametersName || '请选择是否提供明确参数'" showArrow>
  69 + <template v-slot:body>
  70 + <view class="item-title"><text>是否提供明确参数</text></view>
82 71 </template>
83 72 </uni-list-item>
84 73 </uni-list>
... ... @@ -111,12 +100,12 @@
111 100 <view v-if="item.thicknessTolPos" class="value-spec_box_1">{{ item.thicknessTolPos >
112 101 0 ? '+'
113 102 +
114   - item.thicknessTolPos : item.thicknessTolPos }}
  103 + item.thicknessTolPos : item.thicknessTolPos }}
115 104 </view>
116 105 <view v-if="item.thicknessTolNeg" class="value-spec_box_2">{{ item.thicknessTolNeg >
117 106 0 ? '+'
118 107 +
119   - item.thicknessTolNeg : item.thicknessTolNeg }}
  108 + item.thicknessTolNeg : item.thicknessTolNeg }}
120 109 </view>
121 110 </view>
122 111 <view v-if="item.width" class="value-spec_val p12">*</view>
... ... @@ -149,7 +138,7 @@
149 138 <view v-show="!item.collapsed">
150 139 <uni-list-item title="状态">
151 140 <template v-slot:footer>
152   - <text class="value">{{ item.status }}</text>
  141 + <text class="value">{{ item.status }}</text>
153 142 </template>
154 143 </uni-list-item>
155 144 <uni-list-item title="需发数量(kg)">
... ... @@ -164,12 +153,11 @@
164 153 </uni-list-item>
165 154 <uni-list-item title="需求补货数量(kg)">
166 155 <template v-slot:footer>
167   - <uni-easyinput v-if="canEditSupplementary" type="digit" v-model="item.supplementaryQuantity"
168   - placeholder="请输入需求补货数量kg" :inputBorder="false"
  156 + <uni-easyinput v-if="canEditSupplementary" type="digit"
  157 + v-model="item.supplementaryQuantity" placeholder="请输入需求补货数量kg" :inputBorder="false"
169 158 @input="onTwoDecimalInput($event, item, idx, 'supplementaryQuantity')"
170   - @blur="onTwoDecimalBlur(item, idx, 'supplementaryQuantity')"
171   - />
172   - <text v-else class="value">{{ item.supplementaryQuantity }}</text>
  159 + @blur="onTwoDecimalBlur(item, idx, 'supplementaryQuantity')" />
  160 + <text v-else class="value">{{ item.supplementaryQuantity }}</text>
173 161 </template>
174 162 </uni-list-item>
175 163 <uni-list-item class="amount-item" title="单价(元/kg)">
... ... @@ -183,7 +171,7 @@
183 171 </template>
184 172 </uni-list-item>
185 173 <uni-list-item title="生产科(车间)确认交付时间">
186   - <template v-slot:footer>
  174 + <template v-slot:footer>
187 175 <text class="value">{{ item.confirmedDeliveryDate }}</text>
188 176 </template>
189 177 </uni-list-item>
... ... @@ -247,15 +235,21 @@
247 235 <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view>
248 236 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ item.quantity }}</text>
249 237 </view>
250   - <view class="row"><text class="label">是否提供样品</text><text class="value">{{ item.provideSamplesName }}</text></view>
251   - <view class="row"><text class="label">是否提供明确参数</text><text class="value">{{ item.clearParametersName }}</text></view>
  238 + <view class="row"><text class="label">是否提供样品</text><text class="value">{{ item.provideSamplesName
  239 + }}</text>
  240 + </view>
  241 + <view class="row"><text class="label">是否提供明确参数</text><text class="value">{{ item.clearParametersName
  242 + }}</text>
  243 + </view>
252 244 </view>
253 245 </view>
254 246
  247 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" />
255 248 </view>
256 249 </template>
257 250 <script>
258 251 import { uuid } from '@/utils/uuid.js'
  252 +import SingleSelectSheet from '@/components/single-select/index.vue'
259 253 export default {
260 254 name: 'Product',
261 255 props: {
... ... @@ -263,17 +257,16 @@ export default {
263 257 mode: { type: String, default: 'add' },
264 258 list: { type: Array, default: () => [] },
265 259 max: { type: Number, default: 8 },
266   - totalQuantity: { type: Number, default: 0 },
267   - totalShippedQuantity: { type: Number, default: 0 },
268   - totalSupplementaryQuantity: { type: Number, default: 0 },
269   - orderDate: { type: String, default: '' },
270   - canEditSupplementary: { type: Boolean, default: false }
  260 + provideSamplesOptions: { type: Array, default: () => [] },
  261 + clearParametersOptions: { type: Array, default: () => [] },
271 262 },
  263 + components: { SingleSelectSheet },
272 264 data() {
273 265 return {
274 266 items: [],
275 267 collapsedView: false,
276 268 roleCodes: [],
  269 + sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1, mode: '' }
277 270 }
278 271 },
279 272 computed: {
... ... @@ -293,9 +286,9 @@ export default {
293 286 return `${yy}/${mm}/${dd}`
294 287 },
295 288 // roleCodes() {
296   - // const g = this.$store && this.$store.getters
297   - // return (g && g.roleCodes) || [];
298   - // },
  289 + // const g = this.$store && this.$store.getters
  290 + // return (g && g.roleCodes) || [];
  291 + // },
299 292 },
300 293 watch: {
301 294 items: {
... ... @@ -423,12 +416,12 @@ export default {
423 416 if (isNaN(n)) item[field] = ''
424 417 if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
425 418 },
426   - // 限制输入为2位小数
  419 + // 限制输入为2位小数
427 420 onTwoDecimalInput(val, item, idx, field) {
428 421 let v = String(val != null ? val : (item && item[field]) || '')
429 422 v = v.replace(/[^0-9.]/g, '')
430 423 v = v.replace(/(\..*)\./g, '$1')
431   -
  424 +
432 425 // Restrict to 2 decimal places
433 426 const decimalIndex = v.indexOf('.')
434 427 if (decimalIndex !== -1 && v.length > decimalIndex + 3) {
... ... @@ -436,14 +429,14 @@ export default {
436 429 }
437 430
438 431 if (v.startsWith('.')) v = '0' + v
439   -
  432 +
440 433 // If the value was modified (truncated or cleaned)
441 434 if (String(val) !== v) {
442 435 // Hack: Temporarily set the dirty value to trigger Vue update mechanism
443 436 // This ensures that when we set the clean value back, Vue detects a change
444 437 item[field] = val
445 438 if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
446   -
  439 +
447 440 // Then revert to the clean value asynchronously
448 441 setTimeout(() => {
449 442 item[field] = v
... ... @@ -491,7 +484,36 @@ export default {
491 484 this.$set(this.items, idx, { ...item })
492 485 uni.showToast({ title: '发货日期必须大于订货日期', icon: 'none' })
493 486 }
494   - }
  487 + },
  488 + openProductSheet(idx, mode = 'provideSamples') {
  489 + let opts = []
  490 + let title = ''
  491 + let value = ''
  492 + const item = this.items[idx]
  493 +
  494 + if (mode === 'provideSamples') {
  495 + opts = this.provideSamplesOptions
  496 + value = item.provideSamples
  497 + title = '选择是否提供样品'
  498 + } else if (mode === 'clearParameters') {
  499 + opts = this.clearParametersOptions;
  500 + value = item.clearParameters
  501 + title = '是否提供明确参数'
  502 + }
  503 + console.log('____', { ...this.sheet, visible: true, title, options: opts, idx, value, mode })
  504 + this.sheet = { ...this.sheet, visible: true, title, options: opts, idx, value, mode }
  505 + },
  506 + onProductConfirm({ value, label }) {
  507 + const idx = this.sheet.idx
  508 + const _mode = this.sheet.mode;
  509 + const it = this.items[idx]
  510 + if (!it) { this.sheet.visible = false; return }
  511 + it[_mode] = value
  512 + it[_mode + 'Name'] = label || ''
  513 + this.$set(this.items, idx, it)
  514 + this.sheet.visible = false
  515 + this.emitChange()
  516 + },
495 517 }
496 518 }
497 519 </script>
... ...