Showing
7 changed files
with
56 additions
and
11 deletions
| ... | ... | @@ -68,7 +68,7 @@ export function assayReportApplyOptionsApi(params) { |
| 68 | 68 | /** |
| 69 | 69 | * 新增化验报告单 |
| 70 | 70 | * data: { weighingTicketId, reportDate, procurementPlanId, productId, |
| 71 | - * lines: [{ assayApplyId, cu, zn, pb, fe, p, sn, ni, al, cd, cr6, hg, bi }] } | |
| 71 | + * lines: [{ assayApplyId, assayApplyLineId, cu, zn, pb, fe, p, sn, ni, al, cd, cr6, hg, bi }] } | |
| 72 | 72 | */ |
| 73 | 73 | export function assayReportCreateApi(data) { |
| 74 | 74 | return request({ |
| ... | ... | @@ -92,7 +92,8 @@ export function assayReportDetailApi(params) { |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * 修改化验报告单 |
| 95 | - * data: { id, weighingTicketId, reportDate, procurementPlanId, productId, lines } | |
| 95 | + * data: { id, weighingTicketId, reportDate, procurementPlanId, productId, | |
| 96 | + * lines: [{ assayApplyId, assayApplyLineId, cu, zn, pb, fe, p, sn, ni, al, cd, cr6, hg, bi }] } | |
| 96 | 97 | */ |
| 97 | 98 | export function assayReportUpdateApi(data) { |
| 98 | 99 | return request({ | ... | ... |
| ... | ... | @@ -262,6 +262,7 @@ export default { |
| 262 | 262 | const list = (res && res.data) || [] |
| 263 | 263 | this.applyDetailOptions = (list || []).map(item => ({ |
| 264 | 264 | assayApplyId: item.assayApplyId || item.id || '', |
| 265 | + assayApplyLineId: item.assayApplyLineId || '', | |
| 265 | 266 | assayApplyCode: item.assayApplyCode || '', |
| 266 | 267 | sampleCode: item.sampleCode || '', |
| 267 | 268 | productName: item.productName || '', | ... | ... |
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | <view v-for="(row, idx) in rows" :key="'line-' + idx" class="card"> |
| 14 | 14 | <view class="card-index">第 {{ idx + 1 }} 行</view> |
| 15 | 15 | |
| 16 | - <view class="row"> | |
| 16 | + <!-- <view class="row"> | |
| 17 | 17 | <text class="label">送样编号</text> |
| 18 | 18 | <picker |
| 19 | 19 | class="picker-box" |
| ... | ... | @@ -25,11 +25,20 @@ |
| 25 | 25 | {{ row.assayApplyCode || '请选择送样编号' }} |
| 26 | 26 | </view> |
| 27 | 27 | </picker> |
| 28 | - </view> | |
| 29 | - <!-- 取样编号:随送样编号带出,固定展示 --> | |
| 28 | + </view> --> | |
| 29 | + <!-- 取样编号:下拉选择(数据源与送样编号一致,按 sampleCode 字段展示/取值) --> | |
| 30 | 30 | <view class="row"> |
| 31 | 31 | <text class="label">取样编号</text> |
| 32 | - <text class="value">{{ row.sampleCode || '-' }}</text> | |
| 32 | + <picker | |
| 33 | + class="picker-box" | |
| 34 | + mode="selector" | |
| 35 | + :range="getRowSampleLabels(row)" | |
| 36 | + @change="onSampleCodeChange($event, idx)" | |
| 37 | + > | |
| 38 | + <view class="picker-value" :class="{ placeholder: !row.sampleCode }"> | |
| 39 | + {{ row.sampleCode || '请选择取样编号' }} | |
| 40 | + </view> | |
| 41 | + </picker> | |
| 33 | 42 | </view> |
| 34 | 43 | <view class="row"> |
| 35 | 44 | <text class="label">样品</text> |
| ... | ... | @@ -107,6 +116,7 @@ export default { |
| 107 | 116 | testCode: String(index + 1), |
| 108 | 117 | assayApplyCode: (item && item.assayApplyCode) || '', |
| 109 | 118 | assayApplyId: (item && item.assayApplyId) || '', |
| 119 | + assayApplyLineId: (item && item.assayApplyLineId) || '', | |
| 110 | 120 | sampleCode: (item && item.sampleCode) || '' |
| 111 | 121 | } |
| 112 | 122 | ALL_COMPONENT_KEYS.forEach(key => { |
| ... | ... | @@ -122,12 +132,15 @@ export default { |
| 122 | 132 | setRows(list) { |
| 123 | 133 | this.rows = (list || []).map((item, index) => this.buildRow(item, index)) |
| 124 | 134 | }, |
| 125 | - // 获取提交用明细行(含各行成分值,未填/分厂未包含的成分为 null) | |
| 135 | + // 获取提交用明细行(含行ID与各行成分值,未填/分厂未包含的成分为 null) | |
| 126 | 136 | getLines() { |
| 127 | 137 | return (this.rows || []) |
| 128 | 138 | .filter(row => row.assayApplyId) |
| 129 | 139 | .map(row => { |
| 130 | - const line = { assayApplyId: row.assayApplyId } | |
| 140 | + const line = { | |
| 141 | + assayApplyId: row.assayApplyId, | |
| 142 | + assayApplyLineId: row.assayApplyLineId || '' | |
| 143 | + } | |
| 131 | 144 | ALL_COMPONENT_KEYS.forEach(key => { |
| 132 | 145 | const val = row[key] |
| 133 | 146 | line[key] = (val === undefined || val === null || val === '') ? null : Number(val) |
| ... | ... | @@ -157,10 +170,38 @@ export default { |
| 157 | 170 | row.productId = item.productId || '' |
| 158 | 171 | row.assayApplyCode = item.assayApplyCode || '' |
| 159 | 172 | row.assayApplyId = item.assayApplyId || '' |
| 173 | + row.assayApplyLineId = item.assayApplyLineId || '' | |
| 160 | 174 | row.category = item.category || '' |
| 161 | 175 | row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : '' |
| 162 | 176 | row.sampleCode = item.sampleCode || '' |
| 163 | 177 | }, |
| 178 | + // 取样编号下拉标签(数据源与送样编号一致,按 sampleCode 展示,排除已被其他行选中的) | |
| 179 | + getRowSampleLabels(row) { | |
| 180 | + return this.getRowSampleOptions(row).map(it => it.label) | |
| 181 | + }, | |
| 182 | + getRowSampleOptions(row) { | |
| 183 | + const selectedSamples = (this.rows || []) | |
| 184 | + .filter(r => r !== row && r.sampleCode) | |
| 185 | + .map(r => r.sampleCode) | |
| 186 | + return (this.options || []) | |
| 187 | + .filter(item => item.sampleCode && !selectedSamples.includes(item.sampleCode)) | |
| 188 | + .map(item => ({ label: item.sampleCode, value: item.sampleCode })) | |
| 189 | + }, | |
| 190 | + // 取样编号下拉变化:与送样编号选择一致,按 sampleCode 找到对应数据带出 | |
| 191 | + onSampleCodeChange(e, index) { | |
| 192 | + const row = this.rows[index] | |
| 193 | + if (!row) return | |
| 194 | + const opt = this.getRowSampleOptions(row)[Number(e.detail.value)] | |
| 195 | + if (!opt) return | |
| 196 | + const item = (this.options || []).find(i => i.sampleCode === opt.value) || {} | |
| 197 | + row.productId = item.productId || '' | |
| 198 | + row.assayApplyCode = item.assayApplyCode || '' | |
| 199 | + row.assayApplyId = item.assayApplyId || '' | |
| 200 | + row.assayApplyLineId = item.assayApplyLineId || '' | |
| 201 | + row.category = item.category || '' | |
| 202 | + row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : '' | |
| 203 | + row.sampleCode = item.sampleCode || opt.value || '' | |
| 204 | + }, | |
| 164 | 205 | // 成份值输入:仅允许数字与小数点,空值重置为 null |
| 165 | 206 | onComponentInput(e, index, key) { |
| 166 | 207 | const row = this.rows[index] | ... | ... |
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | <view class="row"><text class="label">样品</text><text class="value">{{ safeText(item.productName) }}</text></view> |
| 34 | 34 | <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> |
| 35 | 35 | <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> |
| 36 | - <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> | |
| 36 | + <!-- <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> --> | |
| 37 | 37 | <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view> |
| 38 | 38 | <view v-for="key in componentKeys" :key="key" class="row"> |
| 39 | 39 | <text class="label">{{ componentLabels[key] || key }}</text> | ... | ... |
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | <view class="row"><text class="label">样品</text><text class="value">{{ safeText(item.productName) }}</text></view> |
| 29 | 29 | <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> |
| 30 | 30 | <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> |
| 31 | - <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> | |
| 31 | + <!-- <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> --> | |
| 32 | 32 | <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view> |
| 33 | 33 | <view v-for="key in componentKeys" :key="key" class="row"> |
| 34 | 34 | <text class="label">{{ componentLabels[key] || key }}</text> | ... | ... |
| ... | ... | @@ -254,6 +254,7 @@ export default { |
| 254 | 254 | .then(res => { |
| 255 | 255 | const list = ((res && res.data) || []).map(item => ({ |
| 256 | 256 | assayApplyId: item.assayApplyId || item.id || '', |
| 257 | + assayApplyLineId: item.assayApplyLineId || '', | |
| 257 | 258 | assayApplyCode: item.assayApplyCode || '', |
| 258 | 259 | sampleCode: item.sampleCode || '', |
| 259 | 260 | productName: item.productName || '', |
| ... | ... | @@ -357,6 +358,7 @@ export default { |
| 357 | 358 | .then(res => { |
| 358 | 359 | const list = ((res && res.data) || []).map(item => ({ |
| 359 | 360 | assayApplyId: item.assayApplyId || item.id || '', |
| 361 | + assayApplyLineId: item.assayApplyLineId || '', | |
| 360 | 362 | assayApplyCode: item.assayApplyCode || '', |
| 361 | 363 | sampleCode: item.sampleCode || '', |
| 362 | 364 | productName: item.productName || '', | ... | ... |
| ... | ... | @@ -29,7 +29,7 @@ |
| 29 | 29 | <view class="row"><text class="label">样品</text><text class="value">{{ safeText(item.productName) }}</text></view> |
| 30 | 30 | <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> |
| 31 | 31 | <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> |
| 32 | - <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> | |
| 32 | + <!-- <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> --> | |
| 33 | 33 | <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view> |
| 34 | 34 | <view v-for="key in componentKeys" :key="key" class="row"> |
| 35 | 35 | <text class="label">{{ componentLabels[key] || key }}</text> | ... | ... |