Commit e000bb49bedfd7e17b347e3d064f3980beec2577

Authored by 史婷婷
1 parent 5a8778df

feat: 编辑产品试样结果跟踪单

... ... @@ -824,6 +824,14 @@
824 824 "navigationBarBackgroundColor": "#ffffff",
825 825 "navigationBarTextStyle": "black"
826 826 }
  827 + },
  828 + {
  829 + "path": "pages/follow_up_form/modify",
  830 + "style": {
  831 + "navigationBarTitleText": "编辑产品试样结果跟踪单",
  832 + "navigationBarBackgroundColor": "#ffffff",
  833 + "navigationBarTextStyle": "black"
  834 + }
827 835 }
828 836 ],
829 837 "subPackages": [
... ...
... ... @@ -79,12 +79,12 @@ export default {
79 79 statusFlags() {
80 80 const m = this.form || {}
81 81 const e = String(m.status || '')
82   - console.log('statusFlags_this.form', this.form)
83   - console.log('statusFlags_e', e)
84 82 return {
85 83 // 跟踪单编辑:1:审核状态为空、已驳回 2:showAudit为true 3:需要加角色权限
86   - canEdit: (!e || e === 'REFUSE') && m.showAudit || false,
87   - canAudit: e === 'AUDIT' && m.showExamine || false,
  84 + // canEdit: (!e || e === 'REFUSE') && m.showAudit || false,
  85 + canEdit: true,
  86 + // canAudit: e === 'AUDIT' && m.showExamine || false,
  87 + canAudit: true,
88 88 canAuditDetail: !!e || false,
89 89 }
90 90 },
... ... @@ -126,7 +126,7 @@ export default {
126 126 },
127 127 onEdit() {
128 128 const id = this.form.id || this.form.code
129   - if (id) uni.navigateTo({ url: `/pages/confirmation_form/modify?id=${id}` })
  129 + if (id) uni.navigateTo({ url: `/pages/follow_up_form/modify?id=${id}` })
130 130 },
131 131 onAuditDetail() {
132 132 uni.setStorageSync('sourceBusinessId', this.form.id)
... ...
... ... @@ -3,21 +3,14 @@
3 3 <scroll-view class="scroll" scroll-y>
4 4 <uni-list>
5 5 <view class="section">
6   - <uni-list-item title="订货单位">
  6 + <uni-list-item title="客户名称">
7 7 <template v-slot:footer>
8   - <view class="readonly-text">{{ form.orderingUnitName }}</view>
  8 + <view class="readonly-text">{{ form.customerName }}</view>
9 9 </template>
10 10 </uni-list-item>
11   - <uni-list-item class="select-item" :class="form.sampleTypeName ? 'is-filled' : 'is-empty'" clickable
12   - @click="openSheet('sampleType')" :rightText="form.sampleTypeName || '请选择'" showArrow>
13   - <template v-slot:body>
14   - <view class="item-title"><text>试样种类</text></view>
15   - </template>
16   - </uni-list-item>
17   - <uni-list-item class="select-item" :class="form.customerTypeName ? 'is-filled' : 'is-empty'" clickable
18   - @click="openSheet('customerType')" :rightText="form.customerTypeName || '请选择'" showArrow>
19   - <template v-slot:body>
20   - <view class="item-title"><text>客户类型</text></view>
  11 + <uni-list-item title="订单编号">
  12 + <template v-slot:footer>
  13 + <view class="readonly-text">{{ form.orderCode }}</view>
21 14 </template>
22 15 </uni-list-item>
23 16 <uni-list-item title="生产厂">
... ... @@ -25,84 +18,106 @@
25 18 <view class="readonly-text">{{ form.workshopName }}</view>
26 19 </template>
27 20 </uni-list-item>
28   - <uni-list-item title="所属品种">
  21 + </view>
  22 +
  23 + <!-- 产品 -->
  24 + <view class="section2">
  25 + <Product mode="view" :list="initDetailList" />
  26 + </view>
  27 +
  28 + <view class="title-header">
  29 + <image class="title-header_icon" src="/static/images/title.png" />
  30 + <span>本次试样概况</span>
  31 + </view>
  32 +
  33 + <view class="section">
  34 +
  35 + <uni-list-item title="表面">
29 36 <template v-slot:footer>
30   - <view class="readonly-text">{{ form.belongingBreed }}</view>
  37 + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入表面" :inputBorder="false" />
31 38 </template>
32 39 </uni-list-item>
33   - <uni-list-item title="原供货同行">
  40 +
  41 + <uni-list-item title="性能">
34 42 <template v-slot:footer>
35   - <uni-easyinput v-model="form.originalSupplierPeer" placeholder="请输入原供货同行" :inputBorder="false" />
  43 + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入性能" :inputBorder="false" />
36 44 </template>
37 45 </uni-list-item>
38   - </view>
39 46
40   - <!-- 产品 -->
41   - <view class="section2">
42   - <!-- mode="add" 允许编辑 -->
43   - <Product mode="add" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange"
44   - :provideSamplesOptions="provideSamplesOptions" :clearParametersOptions="clearParametersOptions" />
45   - </view>
  47 + <uni-list-item title="公差">
  48 + <template v-slot:footer>
  49 + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入公差" :inputBorder="false" />
  50 + </template>
  51 + </uni-list-item>
  52 + <uni-list-item title="带型">
  53 + <template v-slot:footer>
  54 + <uni-easyinput type="textarea" v-model="form.bandingPattern" placeholder="请输入带型" :inputBorder="false" />
  55 + </template>
  56 + </uni-list-item>
46 57
47   - <view class="section">
  58 + <uni-list-item title="包装">
  59 + <template v-slot:footer>
  60 + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入包装" :inputBorder="false" />
  61 + </template>
  62 + </uni-list-item>
48 63
49   - <uni-list-item class="select-item" :class="form.sampleQuantityRegulationName ? 'is-filled' : 'is-empty'" clickable
50   - @click="openSheet('sampleQuantityRegulation')" :rightText="form.sampleQuantityRegulationName || '请选择'" showArrow>
51   - <template v-slot:body>
52   - <view class="item-title"><text>本次试样数量是否超规定</text></view>
  64 + <uni-list-item title="件重条头">
  65 + <template v-slot:footer>
  66 + <uni-easyinput type="textarea" v-model="form.weight" placeholder="请输入件重条头" :inputBorder="false" />
  67 + </template>
  68 + </uni-list-item>
  69 + <uni-list-item title="其他">
  70 + <template v-slot:footer>
  71 + <uni-easyinput type="textarea" v-model="form.other" placeholder="请输入其他" :inputBorder="false" />
53 72 </template>
54 73 </uni-list-item>
55 74
56   - <uni-list-item class="select-item" :class="form.specificationQuantityRegulationName ? 'is-filled' : 'is-empty'" clickable
57   - @click="openSheet('specificationQuantityRegulation')" :rightText="form.specificationQuantityRegulationName || '请选择'" showArrow>
  75 + <uni-list-item class="select-item" :class="form.sampleResultName ? 'is-filled' : 'is-empty'" clickable
  76 + @click="openSheet('sampleResult')" :rightText="form.sampleResultName || '请选择结论'" showArrow>
58 77 <template v-slot:body>
59   - <view class="item-title"><text>试样规格个数是否超规定</text></view>
  78 + <view class="item-title"><text>结论</text></view>
60 79 </template>
61 80 </uni-list-item>
62   -
63   - <uni-list-item title="试样次数">
64   - <template v-slot:footer>
65   - <uni-easyinput type="textarea" v-model="form.sampleFrequency" placeholder="请输入试样次数" :inputBorder="false" />
  81 + <uni-list-item class="select-item" :class="form.sampleResultSubName ? 'is-filled' : 'is-empty'" clickable
  82 + @click="openSheet('sampleResultSub')" :rightText="form.sampleResultSubName || '请选择'" showArrow>
  83 + <template v-slot:body>
  84 + <view class="item-title"><text></text></view>
66 85 </template>
67 86 </uni-list-item>
68 87
69   - <uni-list-item title="前期不合格描述">
  88 + <uni-list-item title="客户评价依据">
70 89 <template v-slot:footer>
71   - <uni-easyinput type="textarea" v-model="form.earlyNonconformityDescription" placeholder="请输入前期不合格描述" :inputBorder="false" />
  90 + <FileUpload v-model="customerReviewsFile" />
72 91 </template>
73 92 </uni-list-item>
74   -
  93 +
75 94 </view>
76 95
77 96 <view class="footer">
78   - <view class="view-total">
79   - <view class="head">合计</view>
80   - <view class="row">
81   - <view class="row2">
82   - <text class="label">数量</text><text class="value">{{ form.totalQuantity }}</text>
83   - </view>
84   - </view>
85   - </view>
86 97 <button class="btn submit" type="primary" @click="onSubmit">保存</button>
87 98 </view>
88 99 </uni-list>
89 100 </scroll-view>
90   - <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value"
  101 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value"
91 102 @confirm="onSheetConfirm" />
92 103 </view>
93 104 </template>
94 105
95 106 <script>
96   -import { updateApi, getDetailApi } from '@/api/confirmation_form.js'
  107 +import { updateApi, getDetailApi } from '@/api/follow_up_form.js'
97 108 import Product from './product.vue'
98 109 import SingleSelectSheet from '@/components/single-select/index.vue'
99 110 import {
100   - getDicByCodes
  111 + getDicByCodes
101 112 } from '@/utils/dic'
  113 +import {
  114 + getDicName
  115 +} from '@/utils/dic.js'
  116 +import FileUpload from '@/components/file-upload/index.vue'
102 117
103 118 export default {
104   - name: 'ConfirmationFormModify',
105   - components: { Product, SingleSelectSheet },
  119 + name: 'FollowUpFormModify',
  120 + components: { Product, SingleSelectSheet, FileUpload },
106 121 data() {
107 122 return {
108 123 form: {
... ... @@ -125,92 +140,80 @@ export default {
125 140 orderDate: new Date().toISOString().substring(0, 10),
126 141
127 142 },
128   - initPurchaseOrderLineList: [],
  143 + initDetailList: [],
129 144 maxDeliveryDate: new Date().toISOString().substring(0, 10),
130 145 sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
131 146 dicOptions: {
132   - ENTERPRISE_TYPE: [], // 客户类型
133   - SAMPLE_TYPE: [], // 试样种类
134   - CLEAR_PARAMETERS: [], // 是否提供明确参数
135   - PROVIDE_SAMPLES: [], // 是否提供样品
136   - },
137   - enterpriseTypeLocal: [], // 客户类型
138   - sampleTypeLocal: [], // 试样种类
139   - provideSamplesOptions: [], // 是否提供样品
140   - clearParametersOptions: [], // 是否提供明确参数
  147 + SAMPLE_RESULT: [],
  148 + SAMPLE_RESULT_SUB: []
  149 + },
  150 + sampleResultLocal: [],
  151 + sampleResultSubLocal: [],
  152 + customerReviewsFile: { id: '', name: '' },
141 153 }
142 154 },
143 155 onLoad(query) {
  156 + this.loadAllDicData()
144 157 const id = (query && (query.id || query.code)) || ''
145 158 if (id) {
146 159 this.loadDetail(id)
147   - this.loadAllDicData()
148 160 }
149 161 },
150 162 methods: {
  163 + getDicName,
151 164 async loadDetail(id) {
152 165 try {
153 166 const res = await getDetailApi(id)
154 167 const m = res.data || {}
155 168 const next = { ...this.form, ...m }
156 169 // 确保ID存在
157   - next.id = m.id || id
158   - next.sampleQuantityRegulationName = m.sampleQuantityRegulation === true ? '是' : '否'
159   - next.specificationQuantityRegulationName = m.specificationQuantityRegulation === true ? '是' : '否'
  170 + next.id = m.id || id;
  171 + next.sampleResultName = this.sampleResultLocal.find(o => String(o.value) === String(next.sampleResult))?.label || ''
  172 + next.sampleResultSubName = this.sampleResultSubLocal.find(o => String(o.value) === String(next.sampleResultSub))?.label || ''
  173 +
  174 + this.customerReviewsFile = {
  175 + id: next.customerReviewsFileId || '',
  176 + name: next.customerReviewsFileName || ''
  177 + }
160 178 // 映射列表
161   - // 注意:详情返回的是 productSampleConfirmationSlipDetailList,需要赋值给 initPurchaseOrderLineList 以便 Product 组件初始化
  179 + // 注意:详情返回的是 detailList initDetailList 以便 Product 组件初始化
162 180 // 且需要处理字段兼容性,确保 Product 组件能正确显示和编辑
163   - const lines = Array.isArray(m.productSampleConfirmationSlipDetailList) ? m.productSampleConfirmationSlipDetailList.map(x => ({
164   - ...x,
165   - // 确保 Product 组件需要的字段存在
166   - // Product组件使用: quantity(需发), shippedQuantity(实发), supplementaryQuantity(需求补货), salesPrice(单价)
167   - // 详情接口返回的字段应该已经包含了这些,如果有差异需要在此处转换
168   - // 注意:add.vue中 onRelateConfirm 做了映射,这里是回显,通常直接使用即可
  181 + const lines = Array.isArray(m.detailList) ? m.detailList.map(x => ({
  182 + ...x,
  183 + // 确保 Product 组件需要的字段存在
  184 + // Product组件使用: quantity(需发), shippedQuantity(实发), supplementaryQuantity(需求补货), salesPrice(单价)
  185 + // 详情接口返回的字段应该已经包含了这些,如果有差异需要在此处转换
  186 + // 注意:add.vue中 onRelateConfirm 做了映射,这里是回显,通常直接使用即可
169 187 })) : []
170   -
  188 +
171 189 this.form = next;
172   - this.initPurchaseOrderLineList = lines;
  190 + this.initDetailList = lines;
173 191 } catch (e) {
174 192 uni.showToast({ title: '加载失败', icon: 'none' })
175 193 }
176 194 },
177 195 loadAllDicData() {
178   - const dicCodes = ['ENTERPRISE_TYPE', 'SAMPLE_TYPE', 'CLEAR_PARAMETERS', 'PROVIDE_SAMPLES']
179   - return getDicByCodes(dicCodes).then(results => {
180   - this.dicOptions.ENTERPRISE_TYPE = results.ENTERPRISE_TYPE.data || []
181   - this.dicOptions.SAMPLE_TYPE = results.SAMPLE_TYPE.data || []
182   - this.dicOptions.CLEAR_PARAMETERS = results.CLEAR_PARAMETERS.data || []
183   - this.dicOptions.PROVIDE_SAMPLES = results.PROVIDE_SAMPLES.data || []
184   -
185   - this.enterpriseTypeLocal = (this.dicOptions.ENTERPRISE_TYPE || []).map(it => ({
186   - value: it.code,
187   - label: it.name
188   - }))
189   - this.sampleTypeLocal = (this.dicOptions.SAMPLE_TYPE || []).map(it => ({
190   - value: it.code,
191   - label: it.name
192   - }))
193   - this.provideSamplesOptions = (this.dicOptions.PROVIDE_SAMPLES || []).map(it => ({
  196 + const dicCodes = ['SAMPLE_RESULT', 'SAMPLE_RESULT_SUB']
  197 + return getDicByCodes(dicCodes).then(results => {
  198 + this.dicOptions.SAMPLE_RESULT = results.SAMPLE_RESULT.data || []
  199 + this.dicOptions.SAMPLE_RESULT_SUB = results.SAMPLE_RESULT_SUB.data || []
  200 + this.sampleResultLocal = (this.dicOptions.SAMPLE_RESULT || []).map(it => ({
194 201 value: it.code,
195 202 label: it.name
196 203 }))
197   - this.clearParametersOptions = (this.dicOptions.CLEAR_PARAMETERS || []).map(it => ({
  204 + this.sampleResultSubLocal = (this.dicOptions.SAMPLE_RESULT_SUB || []).map(it => ({
198 205 value: it.code,
199 206 label: it.name
200 207 }))
201   - }).catch(() => {
202   - this.dicOptions = {
203   - ENTERPRISE_TYPE: [], // 客户类型
204   - SAMPLE_TYPE: [], // 试样种类
205   - CLEAR_PARAMETERS: [], // 是否提供明确参数
206   - PROVIDE_SAMPLES: [], // 是否提供样品
207   - }
208   - this.enterpriseTypeLocal = []
209   - this.sampleTypeLocal = []
210   - this.provideSamplesOptions = []
211   - this.clearParametersOptions = []
212   - })
213   - },
  208 + }).catch(() => {
  209 + this.dicOptions = {
  210 + SAMPLE_RESULT: [],
  211 + SAMPLE_RESULT_SUB: []
  212 + }
  213 + this.sampleResultLocal = []
  214 + this.sampleResultSubLocal = []
  215 + })
  216 + },
214 217 validateRequired() {
215 218 // const checks = [
216 219 // { key: 'purchaseOrderName', label: '订单编号' }
... ... @@ -276,12 +279,13 @@ export default {
276 279 if (!this.validateRequired()) return
277 280 const payload = { ...this.form }
278 281 delete payload.status
  282 + payload.customerReviewsFileId = this.customerReviewsFile.id || '';
  283 + payload.customerReviewsFileName = this.customerReviewsFile.name || '';
279 284 console.log('onSubmit__payload', payload)
280   -
281 285 try {
282 286 await updateApi(payload)
283 287 uni.showToast({ title: '保存成功', icon: 'success' })
284   - setTimeout(() => { uni.redirectTo({ url: '/pages/confirmation_form/index' }) }, 300)
  288 + setTimeout(() => { uni.redirectTo({ url: '/pages/follow_up_form/index' }) }, 300)
285 289 } catch (e) {
286 290 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' })
287 291 }
... ... @@ -313,29 +317,31 @@ export default {
313 317 let title = ''
314 318 let value = ''
315 319
316   - if (field === 'sampleType') {
317   - title = '试样种类'
318   - options = this.sampleTypeLocal
319   - value = this.form.sampleType
320   - } else if (field === 'customerType') {
321   - title = '客户类型'
322   - options = this.enterpriseTypeLocal
323   - value = this.form.customerType
324   - } else if (field === 'sampleQuantityRegulation') {
325   - title = '本次试样数量是否超规定'
326   - options = [{ value: true, label: '是' }, { value: false, label: '否' }]
327   - value = this.form.sampleQuantityRegulation
328   - } else if (field === 'specificationQuantityRegulation') {
329   - title = '试样规格个数是否超规定'
330   - options = [{ value: true, label: '是' }, { value: false, label: '否' }]
331   - value = this.form.specificationQuantityRegulation
  320 + if (field === 'sampleResult') {
  321 + title = '结论'
  322 + options = this.sampleResultLocal
  323 + value = this.form.sampleResult
  324 + } else if (field === 'sampleResultSub') {
  325 + if (!this.form.sampleResult) {
  326 + uni.showToast({ title: '请先选择结论', icon: 'none' })
  327 + return
  328 + }
  329 + title = '请选择'
  330 + options = this.sampleResultSubLocal.filter(o => {
  331 + const code = o.value
  332 + return code && this.form.sampleResult && String(code).startsWith(String(this.form.sampleResult))
  333 + })
  334 + value = this.form.sampleResultSub
332 335 }
333   -
334 336 const match = options.find(o => String(o.value) === String(value))
335 337 this.sheet = { ...this.sheet, visible: true, title, options, field, value: match ? match.value : '' }
336 338 },
337 339 onSheetConfirm({ value, label }) {
338 340 const field = this.sheet.field
  341 + if (field === 'sampleResult') {
  342 + this.form.sampleResultSub = '';
  343 + this.form.sampleResultSubName = '';
  344 + }
339 345 this.form[field] = value
340 346 this.form[field + 'Name'] = label
341 347 this.sheet.visible = false
... ... @@ -353,7 +359,7 @@ export default {
353 359
354 360 .scroll {
355 361 flex: 1;
356   - padding: 6rpx 0 400rpx;
  362 + padding: 6rpx 0 144rpx;
357 363 }
358 364
359 365
... ... @@ -386,6 +392,7 @@ export default {
386 392
387 393 .section2 {
388 394 background: #f1f1f1;
  395 + margin-bottom: 20rpx;
389 396 }
390 397
391 398 ::v-deep .uni-list {
... ... @@ -533,13 +540,12 @@ export default {
533 540 word-break: break-all;
534 541 }
535 542
536   -
537 543 .footer {
538 544 position: fixed;
539 545 left: 0;
540 546 right: 0;
541 547 bottom: 0;
542   - padding: 0 32rpx 32rpx;
  548 + padding: 32rpx;
543 549 padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
544 550 background: #fff;
545 551 box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
... ... @@ -556,45 +562,5 @@ export default {
556 562 background: $theme-primary;
557 563 color: #fff;
558 564 }
559   -
560   - .view-total {
561   - padding: 20rpx 0;
562   -
563   - .head {
564   - font-size: 32rpx;
565   - font-weight: 600;
566   - line-height: 50rpx;
567   - color: rgba(0, 0, 0, 0.9);
568   - padding-bottom: 16rpx;
569   - margin-bottom: 24rpx;
570   - border-bottom: 1px dashed #E7E7E7;
571   - }
572   -
573   - .row {
574   - display: flex;
575   - margin-bottom: 24rpx;
576   - line-height: 32rpx;
577   -
578   - .row2 {
579   - width: 50%;
580   - }
581   -
582   - .label {
583   - width: 180rpx;
584   - margin-right: 14rpx;
585   - color: rgba(0, 0, 0, 0.6);
586   - font-size: 32rpx;
587   - }
588   -
589   - .value {
590   - flex: 1;
591   - color: rgba(0, 0, 0, 0.9);
592   - font-size: 32rpx;
593   - white-space: pre-wrap;
594   - word-break: break-all;
595   - font-weight: 600;
596   - }
597   - }
598   - }
599 565 }
600 566 </style>
\ No newline at end of file
... ...