Commit a566f00ba56a4e8f18ce83dd2a14060e9941cd18

Authored by 史婷婷
1 parent 8f71e713

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

@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 <view class="section2"> 41 <view class="section2">
42 <!-- mode="add" 允许编辑 --> 42 <!-- mode="add" 允许编辑 -->
43 <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange" 43 <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange"
44 - :orderDate="form.orderDate" /> 44 + :provideSamplesOptions="provideSamplesOptions" :clearParametersOptions="clearParametersOptions" />
45 </view> 45 </view>
46 46
47 <view class="section"> 47 <view class="section">
@@ -131,9 +131,13 @@ export default { @@ -131,9 +131,13 @@ export default {
131 dicOptions: { 131 dicOptions: {
132 ENTERPRISE_TYPE: [], // 客户类型 132 ENTERPRISE_TYPE: [], // 客户类型
133 SAMPLE_TYPE: [], // 试样种类 133 SAMPLE_TYPE: [], // 试样种类
  134 + CLEAR_PARAMETERS: [], // 是否提供明确参数
  135 + PROVIDE_SAMPLES: [], // 是否提供样品
134 }, 136 },
135 enterpriseTypeLocal: [], // 客户类型 137 enterpriseTypeLocal: [], // 客户类型
136 sampleTypeLocal: [], // 试样种类 138 sampleTypeLocal: [], // 试样种类
  139 + provideSamplesOptions: [], // 是否提供样品
  140 + clearParametersOptions: [], // 是否提供明确参数
137 } 141 }
138 }, 142 },
139 onLoad(query) { 143 onLoad(query) {
@@ -173,10 +177,13 @@ export default { @@ -173,10 +177,13 @@ export default {
173 } 177 }
174 }, 178 },
175 loadAllDicData() { 179 loadAllDicData() {
176 - const dicCodes = ['ENTERPRISE_TYPE', 'SAMPLE_TYPE'] 180 + const dicCodes = ['ENTERPRISE_TYPE', 'SAMPLE_TYPE', 'CLEAR_PARAMETERS', 'PROVIDE_SAMPLES']
177 return getDicByCodes(dicCodes).then(results => { 181 return getDicByCodes(dicCodes).then(results => {
178 this.dicOptions.ENTERPRISE_TYPE = results.ENTERPRISE_TYPE.data || [] 182 this.dicOptions.ENTERPRISE_TYPE = results.ENTERPRISE_TYPE.data || []
179 this.dicOptions.SAMPLE_TYPE = results.SAMPLE_TYPE.data || [] 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 this.enterpriseTypeLocal = (this.dicOptions.ENTERPRISE_TYPE || []).map(it => ({ 187 this.enterpriseTypeLocal = (this.dicOptions.ENTERPRISE_TYPE || []).map(it => ({
181 value: it.code, 188 value: it.code,
182 label: it.name 189 label: it.name
@@ -185,13 +192,25 @@ export default { @@ -185,13 +192,25 @@ export default {
185 value: it.code, 192 value: it.code,
186 label: it.name 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 }).catch(() => { 203 }).catch(() => {
189 this.dicOptions = { 204 this.dicOptions = {
190 ENTERPRISE_TYPE: [], // 客户类型 205 ENTERPRISE_TYPE: [], // 客户类型
191 SAMPLE_TYPE: [], // 试样种类 206 SAMPLE_TYPE: [], // 试样种类
  207 + CLEAR_PARAMETERS: [], // 是否提供明确参数
  208 + PROVIDE_SAMPLES: [], // 是否提供样品
192 } 209 }
193 this.enterpriseTypeLocal = [] 210 this.enterpriseTypeLocal = []
194 this.sampleTypeLocal = [] 211 this.sampleTypeLocal = []
  212 + this.provideSamplesOptions = []
  213 + this.clearParametersOptions = []
195 }) 214 })
196 }, 215 },
197 validateRequired() { 216 validateRequired() {
@@ -17,68 +17,57 @@ @@ -17,68 +17,57 @@
17 17
18 <view v-if="mode === 'add'" class="section"> 18 <view v-if="mode === 'add'" class="section">
19 <view v-for="(item, idx) in items" :key="'a-' + idx" class="block"> 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 <view class="row"><text class="label">牌号</text><text class="value">{{ item.brand }}</text></view> 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 </view> 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 </view> 29 </view>
47 </view> 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 </view> 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 <view class="row" :class="{ 'noneStyle': !item.showSalesPrice }"><text 52 <view class="row" :class="{ 'noneStyle': !item.showSalesPrice }"><text
51 class="label">数量kg</text><text class="value">{{ item.quantity }}</text> 53 class="label">数量kg</text><text class="value">{{ item.quantity }}</text>
52 </view> 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 <uni-list class="edit-list"> 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 <template v-slot:body> 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 </template> 63 </template>
70 </uni-list-item> 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 </template> 71 </template>
83 </uni-list-item> 72 </uni-list-item>
84 </uni-list> 73 </uni-list>
@@ -111,12 +100,12 @@ @@ -111,12 +100,12 @@
111 <view v-if="item.thicknessTolPos" class="value-spec_box_1">{{ item.thicknessTolPos > 100 <view v-if="item.thicknessTolPos" class="value-spec_box_1">{{ item.thicknessTolPos >
112 0 ? '+' 101 0 ? '+'
113 + 102 +
114 - item.thicknessTolPos : item.thicknessTolPos }} 103 + item.thicknessTolPos : item.thicknessTolPos }}
115 </view> 104 </view>
116 <view v-if="item.thicknessTolNeg" class="value-spec_box_2">{{ item.thicknessTolNeg > 105 <view v-if="item.thicknessTolNeg" class="value-spec_box_2">{{ item.thicknessTolNeg >
117 0 ? '+' 106 0 ? '+'
118 + 107 +
119 - item.thicknessTolNeg : item.thicknessTolNeg }} 108 + item.thicknessTolNeg : item.thicknessTolNeg }}
120 </view> 109 </view>
121 </view> 110 </view>
122 <view v-if="item.width" class="value-spec_val p12">*</view> 111 <view v-if="item.width" class="value-spec_val p12">*</view>
@@ -149,7 +138,7 @@ @@ -149,7 +138,7 @@
149 <view v-show="!item.collapsed"> 138 <view v-show="!item.collapsed">
150 <uni-list-item title="状态"> 139 <uni-list-item title="状态">
151 <template v-slot:footer> 140 <template v-slot:footer>
152 - <text class="value">{{ item.status }}</text> 141 + <text class="value">{{ item.status }}</text>
153 </template> 142 </template>
154 </uni-list-item> 143 </uni-list-item>
155 <uni-list-item title="需发数量(kg)"> 144 <uni-list-item title="需发数量(kg)">
@@ -164,12 +153,11 @@ @@ -164,12 +153,11 @@
164 </uni-list-item> 153 </uni-list-item>
165 <uni-list-item title="需求补货数量(kg)"> 154 <uni-list-item title="需求补货数量(kg)">
166 <template v-slot:footer> 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 @input="onTwoDecimalInput($event, item, idx, 'supplementaryQuantity')" 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 </template> 161 </template>
174 </uni-list-item> 162 </uni-list-item>
175 <uni-list-item class="amount-item" title="单价(元/kg)"> 163 <uni-list-item class="amount-item" title="单价(元/kg)">
@@ -183,7 +171,7 @@ @@ -183,7 +171,7 @@
183 </template> 171 </template>
184 </uni-list-item> 172 </uni-list-item>
185 <uni-list-item title="生产科(车间)确认交付时间"> 173 <uni-list-item title="生产科(车间)确认交付时间">
186 - <template v-slot:footer> 174 + <template v-slot:footer>
187 <text class="value">{{ item.confirmedDeliveryDate }}</text> 175 <text class="value">{{ item.confirmedDeliveryDate }}</text>
188 </template> 176 </template>
189 </uni-list-item> 177 </uni-list-item>
@@ -247,15 +235,21 @@ @@ -247,15 +235,21 @@
247 <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view> 235 <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view>
248 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ item.quantity }}</text> 236 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ item.quantity }}</text>
249 </view> 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 </view> 244 </view>
253 </view> 245 </view>
254 246
  247 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onProductConfirm" />
255 </view> 248 </view>
256 </template> 249 </template>
257 <script> 250 <script>
258 import { uuid } from '@/utils/uuid.js' 251 import { uuid } from '@/utils/uuid.js'
  252 +import SingleSelectSheet from '@/components/single-select/index.vue'
259 export default { 253 export default {
260 name: 'Product', 254 name: 'Product',
261 props: { 255 props: {
@@ -263,17 +257,16 @@ export default { @@ -263,17 +257,16 @@ export default {
263 mode: { type: String, default: 'add' }, 257 mode: { type: String, default: 'add' },
264 list: { type: Array, default: () => [] }, 258 list: { type: Array, default: () => [] },
265 max: { type: Number, default: 8 }, 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 data() { 264 data() {
273 return { 265 return {
274 items: [], 266 items: [],
275 collapsedView: false, 267 collapsedView: false,
276 roleCodes: [], 268 roleCodes: [],
  269 + sheet: { visible: false, title: '请选择产品', options: [], value: '', idx: -1, mode: '' }
277 } 270 }
278 }, 271 },
279 computed: { 272 computed: {
@@ -293,9 +286,9 @@ export default { @@ -293,9 +286,9 @@ export default {
293 return `${yy}/${mm}/${dd}` 286 return `${yy}/${mm}/${dd}`
294 }, 287 },
295 // roleCodes() { 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 watch: { 293 watch: {
301 items: { 294 items: {
@@ -423,12 +416,12 @@ export default { @@ -423,12 +416,12 @@ export default {
423 if (isNaN(n)) item[field] = '' 416 if (isNaN(n)) item[field] = ''
424 if (typeof idx === 'number') this.$set(this.items, idx, { ...item }) 417 if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
425 }, 418 },
426 - // 限制输入为2位小数 419 + // 限制输入为2位小数
427 onTwoDecimalInput(val, item, idx, field) { 420 onTwoDecimalInput(val, item, idx, field) {
428 let v = String(val != null ? val : (item && item[field]) || '') 421 let v = String(val != null ? val : (item && item[field]) || '')
429 v = v.replace(/[^0-9.]/g, '') 422 v = v.replace(/[^0-9.]/g, '')
430 v = v.replace(/(\..*)\./g, '$1') 423 v = v.replace(/(\..*)\./g, '$1')
431 - 424 +
432 // Restrict to 2 decimal places 425 // Restrict to 2 decimal places
433 const decimalIndex = v.indexOf('.') 426 const decimalIndex = v.indexOf('.')
434 if (decimalIndex !== -1 && v.length > decimalIndex + 3) { 427 if (decimalIndex !== -1 && v.length > decimalIndex + 3) {
@@ -436,14 +429,14 @@ export default { @@ -436,14 +429,14 @@ export default {
436 } 429 }
437 430
438 if (v.startsWith('.')) v = '0' + v 431 if (v.startsWith('.')) v = '0' + v
439 - 432 +
440 // If the value was modified (truncated or cleaned) 433 // If the value was modified (truncated or cleaned)
441 if (String(val) !== v) { 434 if (String(val) !== v) {
442 // Hack: Temporarily set the dirty value to trigger Vue update mechanism 435 // Hack: Temporarily set the dirty value to trigger Vue update mechanism
443 // This ensures that when we set the clean value back, Vue detects a change 436 // This ensures that when we set the clean value back, Vue detects a change
444 item[field] = val 437 item[field] = val
445 if (typeof idx === 'number') this.$set(this.items, idx, { ...item }) 438 if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
446 - 439 +
447 // Then revert to the clean value asynchronously 440 // Then revert to the clean value asynchronously
448 setTimeout(() => { 441 setTimeout(() => {
449 item[field] = v 442 item[field] = v
@@ -491,7 +484,36 @@ export default { @@ -491,7 +484,36 @@ export default {
491 this.$set(this.items, idx, { ...item }) 484 this.$set(this.items, idx, { ...item })
492 uni.showToast({ title: '发货日期必须大于订货日期', icon: 'none' }) 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 </script> 519 </script>