Commit 7684cdd580951667c0e5aa94e8e9cb5aa34b40fe

Authored by gesilong
1 parent 09c39e99

commit:修复测试问题

@@ -477,6 +477,7 @@ export default { @@ -477,6 +477,7 @@ export default {
477 emitChange() { 477 emitChange() {
478 if (!this._initialized) return 478 if (!this._initialized) return
479 if (this._emitSuppressed) return 479 if (this._emitSuppressed) return
  480 + var self = this
480 var list = (this.items || []).map(function (it) { 481 var list = (this.items || []).map(function (it) {
481 var c = Object.assign({}, it) 482 var c = Object.assign({}, it)
482 var key = c._key 483 var key = c._key
@@ -485,7 +486,7 @@ export default { @@ -485,7 +486,7 @@ export default {
485 delete c._selected 486 delete c._selected
486 delete c.fixedLossRate 487 delete c.fixedLossRate
487 if (!c.itemId) c.itemId = key 488 if (!c.itemId) c.itemId = key
488 - if (!this.isAnyBuyout) c.estimatedLoss = null 489 + if (!self.isAnyBuyout) c.estimatedLoss = null
489 return c 490 return c
490 }) 491 })
491 this.$emit('change', list) 492 this.$emit('change', list)
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 </uni-list> 65 </uni-list>
66 66
67 <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) --> 67 <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) -->
68 - <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-name="ticketWorkshopName" /> 68 + <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-code="ticketWorkshopCode" :workshop-name="ticketWorkshopName" />
69 </scroll-view> 69 </scroll-view>
70 70
71 <view class="footer"> 71 <view class="footer">
@@ -125,7 +125,10 @@ export default { @@ -125,7 +125,10 @@ export default {
125 } 125 }
126 }, 126 },
127 computed: { 127 computed: {
128 - // 码单分厂名称,决定化验明细成分项集合 128 + // 码单分厂编码/名称,决定化验明细成份项集合
  129 + ticketWorkshopCode() {
  130 + return (this.selectedTicketRow && this.selectedTicketRow.workshopCode) || ''
  131 + },
129 ticketWorkshopName() { 132 ticketWorkshopName() {
130 return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || '' 133 return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || ''
131 }, 134 },
@@ -261,6 +264,7 @@ export default { @@ -261,6 +264,7 @@ export default {
261 assayApplyId: item.assayApplyId || item.id || '', 264 assayApplyId: item.assayApplyId || item.id || '',
262 assayApplyCode: item.assayApplyCode || '', 265 assayApplyCode: item.assayApplyCode || '',
263 productName: item.productName || '', 266 productName: item.productName || '',
  267 + category: item.category || '',
264 productId: item.productId || '', 268 productId: item.productId || '',
265 quantity: item.quantity 269 quantity: item.quantity
266 })) 270 }))
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 </view> 28 </view>
29 <view class="row"> 29 <view class="row">
30 <text class="label">样品</text> 30 <text class="label">样品</text>
31 - <text class="value">{{ row.productName || '-' }}</text> 31 + <text class="value">{{ row.category || '-' }}</text>
32 </view> 32 </view>
33 <view class="row"> 33 <view class="row">
34 <text class="label">数量</text> 34 <text class="label">数量</text>
@@ -68,7 +68,12 @@ export default { @@ -68,7 +68,12 @@ export default {
68 type: Array, 68 type: Array,
69 default: () => [] 69 default: () => []
70 }, 70 },
71 - // 码单分厂名称,决定成份%项集合 71 + // 码单分厂编码(ticketPage 返回 workshopCode),决定成份%项集合
  72 + workshopCode: {
  73 + type: String,
  74 + default: ''
  75 + },
  76 + // 码单分厂名称(workshopCode 缺失时兜底匹配)
72 workshopName: { 77 workshopName: {
73 type: String, 78 type: String,
74 default: '' 79 default: ''
@@ -82,16 +87,16 @@ export default { @@ -82,16 +87,16 @@ export default {
82 } 87 }
83 }, 88 },
84 computed: { 89 computed: {
85 - // 当前分厂对应的成分项 key 列表 90 + // 当前分厂对应的成分项 key 列表(按 workshopCode 匹配,名称兜底)
86 componentKeys() { 91 componentKeys() {
87 - return getComponentKeys(this.workshopName) 92 + return getComponentKeys(this.workshopCode, this.workshopName)
88 } 93 }
89 }, 94 },
90 methods: { 95 methods: {
91 - // 构造行对象(初始化全部成分字段,保证响应式) 96 + // 构造行对象(初始化全部成分字段,保证响应式;样品取 category,对齐 PC 端 buildRow)
92 buildRow(item, index) { 97 buildRow(item, index) {
93 const row = { 98 const row = {
94 - productName: (item && item.productName) || '', 99 + category: (item && item.category) || '',
95 productId: (item && item.productId) || '', 100 productId: (item && item.productId) || '',
96 quantity: item ? item.quantity : '', 101 quantity: item ? item.quantity : '',
97 testCode: String(index + 1), 102 testCode: String(index + 1),
@@ -146,7 +151,7 @@ export default { @@ -146,7 +151,7 @@ export default {
146 row.productId = item.productId || '' 151 row.productId = item.productId || ''
147 row.assayApplyCode = item.assayApplyCode || '' 152 row.assayApplyCode = item.assayApplyCode || ''
148 row.assayApplyId = item.assayApplyId || '' 153 row.assayApplyId = item.assayApplyId || ''
149 - row.productName = item.productName || '' 154 + row.category = item.category || ''
150 row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : '' 155 row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : ''
151 }, 156 },
152 // 成份值输入:仅允许数字与小数点,空值重置为 null 157 // 成份值输入:仅允许数字与小数点,空值重置为 null
@@ -19,19 +19,35 @@ export const COMPONENT_LABELS = { @@ -19,19 +19,35 @@ export const COMPONENT_LABELS = {
19 // 提交接口要求的全部成分字段(分厂未包含的成分提交 null) 19 // 提交接口要求的全部成分字段(分厂未包含的成分提交 null)
20 export const ALL_COMPONENT_KEYS = ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg', 'bi'] 20 export const ALL_COMPONENT_KEYS = ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg', 'bi']
21 21
22 -// 各分厂成分配置(按码单分厂名匹配,紫铜优先) 22 +// 各分厂成分配置(按 workshopCode 匹配:yfc-一分厂 efc-二分厂 sfc-三分厂 ztfc-紫铜分厂,紫铜优先)
23 const WORKSHOP_COMPONENTS = [ 23 const WORKSHOP_COMPONENTS = [
  24 + { match: 'ztfc', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'bi'] },
  25 + { match: 'efc', keys: ['cu', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg'] },
  26 + { match: 'sfc', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] },
  27 + { match: 'yfc', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] }
  28 +]
  29 +
  30 +// 名称兜底配置(详情接口未返回 workshopCode 时按分厂名匹配)
  31 +const WORKSHOP_NAME_FALLBACK = [
24 { match: '紫铜', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'bi'] }, 32 { match: '紫铜', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'bi'] },
25 { match: '二', keys: ['cu', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg'] }, 33 { match: '二', keys: ['cu', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg'] },
26 - { match: '三', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] } 34 + { match: '三', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] },
  35 + { match: '一', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] }
27 ] 36 ]
28 37
29 // 默认成分(一分厂/未匹配到分厂时) 38 // 默认成分(一分厂/未匹配到分厂时)
30 const DEFAULT_COMPONENT_KEYS = ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] 39 const DEFAULT_COMPONENT_KEYS = ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al']
31 40
32 -// 按分厂名获取成分 key 列表  
33 -export function getComponentKeys(workshopName) { 41 +// 按 workshopCode 获取成分 key 列表;code 缺失或未匹配时按分厂名兜底
  42 +export function getComponentKeys(workshopCode, workshopName) {
  43 + const code = String(workshopCode || '')
  44 + if (code) {
  45 + const config = WORKSHOP_COMPONENTS.find(item => code.includes(item.match))
  46 + if (config) {
  47 + return config.keys
  48 + }
  49 + }
34 const name = String(workshopName || '') 50 const name = String(workshopName || '')
35 - const config = WORKSHOP_COMPONENTS.find(item => name.includes(item.match))  
36 - return config ? config.keys : DEFAULT_COMPONENT_KEYS 51 + const fallback = WORKSHOP_NAME_FALLBACK.find(item => name.includes(item.match))
  52 + return fallback ? fallback.keys : DEFAULT_COMPONENT_KEYS
37 } 53 }
@@ -101,7 +101,8 @@ export default { @@ -101,7 +101,8 @@ export default {
101 }, 101 },
102 computed: { 102 computed: {
103 componentKeys() { 103 componentKeys() {
104 - return getComponentKeys(this.form.workshopName) 104 + // 按 workshopCode 匹配成分项,名称兜底
  105 + return getComponentKeys(this.form.workshopCode, this.form.workshopName)
105 }, 106 },
106 // 是否有质量问题名称(兼容 1/0、true/false、'1'/'0' 返回,无值返回空不展示) 107 // 是否有质量问题名称(兼容 1/0、true/false、'1'/'0' 返回,无值返回空不展示)
107 hasQualityProblemName() { 108 hasQualityProblemName() {
@@ -102,7 +102,8 @@ export default { @@ -102,7 +102,8 @@ export default {
102 return this.nodeCode === 'assay_report_gyglkzg2' 102 return this.nodeCode === 'assay_report_gyglkzg2'
103 }, 103 },
104 componentKeys() { 104 componentKeys() {
105 - return getComponentKeys(this.form.workshopName) 105 + // 按 workshopCode 匹配成分项,名称兜底
  106 + return getComponentKeys(this.form.workshopCode, this.form.workshopName)
106 }, 107 },
107 // 是否有质量问题名称(兼容 1/0、true/false、'1'/'0' 返回,无值返回空不展示) 108 // 是否有质量问题名称(兼容 1/0、true/false、'1'/'0' 返回,无值返回空不展示)
108 hasQualityProblemName() { 109 hasQualityProblemName() {
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 </uni-list> 65 </uni-list>
66 66
67 <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) --> 67 <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) -->
68 - <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-name="ticketWorkshopName" /> 68 + <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-code="ticketWorkshopCode" :workshop-name="ticketWorkshopName" />
69 </scroll-view> 69 </scroll-view>
70 70
71 <view class="footer"> 71 <view class="footer">
@@ -127,7 +127,10 @@ export default { @@ -127,7 +127,10 @@ export default {
127 } 127 }
128 }, 128 },
129 computed: { 129 computed: {
130 - // 码单分厂名称,决定化验明细成分项集合 130 + // 码单分厂编码/名称,决定化验明细成份项集合
  131 + ticketWorkshopCode() {
  132 + return (this.selectedTicketRow && this.selectedTicketRow.workshopCode) || ''
  133 + },
131 ticketWorkshopName() { 134 ticketWorkshopName() {
132 return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || '' 135 return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || ''
133 }, 136 },
@@ -166,7 +169,12 @@ export default { @@ -166,7 +169,12 @@ export default {
166 } 169 }
167 // 码单编号回显:用详情返回的码单ID/编号构造已选行,供分厂成分联动使用 170 // 码单编号回显:用详情返回的码单ID/编号构造已选行,供分厂成分联动使用
168 this.selectedTicketRow = data.weighingTicketId 171 this.selectedTicketRow = data.weighingTicketId
169 - ? { id: data.weighingTicketId, code: data.weighingTicketCode || '', workshopName: data.workshopName || '' } 172 + ? {
  173 + id: data.weighingTicketId,
  174 + code: data.weighingTicketCode || '',
  175 + workshopCode: data.workshopCode || '',
  176 + workshopName: data.workshopName || ''
  177 + }
170 : null 178 : null
171 // 计划编号/品种下拉:先用详情数据兜底,再异步刷新真实选项 179 // 计划编号/品种下拉:先用详情数据兜底,再异步刷新真实选项
172 this.planOptions = data.procurementPlanId 180 this.planOptions = data.procurementPlanId
@@ -248,6 +256,7 @@ export default { @@ -248,6 +256,7 @@ export default {
248 assayApplyId: item.assayApplyId || item.id || '', 256 assayApplyId: item.assayApplyId || item.id || '',
249 assayApplyCode: item.assayApplyCode || '', 257 assayApplyCode: item.assayApplyCode || '',
250 productName: item.productName || '', 258 productName: item.productName || '',
  259 + category: item.category || '',
251 productId: item.productId || '', 260 productId: item.productId || '',
252 quantity: item.quantity 261 quantity: item.quantity
253 })) 262 }))
@@ -349,6 +358,7 @@ export default { @@ -349,6 +358,7 @@ export default {
349 assayApplyId: item.assayApplyId || item.id || '', 358 assayApplyId: item.assayApplyId || item.id || '',
350 assayApplyCode: item.assayApplyCode || '', 359 assayApplyCode: item.assayApplyCode || '',
351 productName: item.productName || '', 360 productName: item.productName || '',
  361 + category: item.category || '',
352 productId: item.productId || '', 362 productId: item.productId || '',
353 quantity: item.quantity 363 quantity: item.quantity
354 })) 364 }))
@@ -106,7 +106,8 @@ export default { @@ -106,7 +106,8 @@ export default {
106 }, 106 },
107 computed: { 107 computed: {
108 componentKeys() { 108 componentKeys() {
109 - return getComponentKeys(this.form.workshopName) 109 + // 按 workshopCode 匹配成分项,名称兜底
  110 + return getComponentKeys(this.form.workshopCode, this.form.workshopName)
110 }, 111 },
111 approvalStatusName() { 112 approvalStatusName() {
112 const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus) 113 const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus)
@@ -468,6 +468,7 @@ export default { @@ -468,6 +468,7 @@ export default {
468 emitChange() { 468 emitChange() {
469 if (!this._initialized) return 469 if (!this._initialized) return
470 if (this._emitSuppressed) return 470 if (this._emitSuppressed) return
  471 + var self = this
471 var list = (this.items || []).map(function (it) { 472 var list = (this.items || []).map(function (it) {
472 var c = Object.assign({}, it) 473 var c = Object.assign({}, it)
473 var key = c._key 474 var key = c._key
@@ -476,7 +477,7 @@ export default { @@ -476,7 +477,7 @@ export default {
476 delete c._selected 477 delete c._selected
477 delete c.fixedLossRate 478 delete c.fixedLossRate
478 if (!c.itemId) c.itemId = key 479 if (!c.itemId) c.itemId = key
479 - if (!this.isAnyBuyout) c.estimatedLoss = null 480 + if (!self.isAnyBuyout) c.estimatedLoss = null
480 return c 481 return c
481 }) 482 })
482 this.$emit('change', list) 483 this.$emit('change', list)
@@ -409,7 +409,7 @@ export default { @@ -409,7 +409,7 @@ export default {
409 } 409 }
410 var m = Math.pow(10, digits) 410 var m = Math.pow(10, digits)
411 var rounded = Math.round(val * m) / m 411 var rounded = Math.round(val * m) / m
412 - it[field] = rounded 412 + it[field] = String(rounded)
413 this.$set(this.items, idx, it) 413 this.$set(this.items, idx, it)
414 }, 414 },
415 getProductOption(productId) { 415 getProductOption(productId) {
@@ -623,7 +623,7 @@ export default { @@ -623,7 +623,7 @@ export default {
623 delete c._selected 623 delete c._selected
624 delete c.fixedLossRate 624 delete c.fixedLossRate
625 if (!c.itemId) c.itemId = key 625 if (!c.itemId) c.itemId = key
626 - if (!this.isAnyBuyout) c.estimatedLoss = null 626 + if (!self.isAnyBuyout) c.estimatedLoss = null
627 return c 627 return c
628 }) 628 })
629 var sig = list.length + '|' + list.map(function (r) { 629 var sig = list.length + '|' + list.map(function (r) {