Commit 36bb746d30c1b152bfc544a43c2be9cd8a5127e3

Authored by gesilong
1 parent 34204d1a

commit:修复优化

@@ -64,7 +64,8 @@ export function assayApplyBreedOptionsApi(params) { @@ -64,7 +64,8 @@ export function assayApplyBreedOptionsApi(params) {
64 64
65 /** 65 /**
66 * 新增化验送样单 66 * 新增化验送样单
67 - * data: { weighingTicketId, procurementPlanId, productId, department } 67 + * data: { code, weighingTicketId, procurementPlanId, productId, department,
  68 + * lines: [{ sampleNo, sampleCode }] }
68 */ 69 */
69 export function assayApplyCreateApi(data) { 70 export function assayApplyCreateApi(data) {
70 return request({ 71 return request({
@@ -88,7 +89,8 @@ export function assayApplyDetailApi(params) { @@ -88,7 +89,8 @@ export function assayApplyDetailApi(params) {
88 89
89 /** 90 /**
90 * 修改化验送样单 91 * 修改化验送样单
91 - * data: { id, weighingTicketId, procurementPlanId, productId, department } 92 + * data: { id, code, weighingTicketId, procurementPlanId, productId, department,
  93 + * lines: [{ sampleNo, sampleCode }] }
92 */ 94 */
93 export function assayApplyUpdateApi(data) { 95 export function assayApplyUpdateApi(data) {
94 return request({ 96 return request({
@@ -263,6 +263,7 @@ export default { @@ -263,6 +263,7 @@ export default {
263 this.applyDetailOptions = (list || []).map(item => ({ 263 this.applyDetailOptions = (list || []).map(item => ({
264 assayApplyId: item.assayApplyId || item.id || '', 264 assayApplyId: item.assayApplyId || item.id || '',
265 assayApplyCode: item.assayApplyCode || '', 265 assayApplyCode: item.assayApplyCode || '',
  266 + sampleCode: item.sampleCode || '',
266 productName: item.productName || '', 267 productName: item.productName || '',
267 category: item.category || '', 268 category: item.category || '',
268 productId: item.productId || '', 269 productId: item.productId || '',
@@ -26,6 +26,11 @@ @@ -26,6 +26,11 @@
26 </view> 26 </view>
27 </picker> 27 </picker>
28 </view> 28 </view>
  29 + <!-- 取样编号:随送样编号带出,固定展示 -->
  30 + <view class="row">
  31 + <text class="label">取样编号</text>
  32 + <text class="value">{{ row.sampleCode || '-' }}</text>
  33 + </view>
29 <view class="row"> 34 <view class="row">
30 <text class="label">样品</text> 35 <text class="label">样品</text>
31 <text class="value">{{ row.category || '-' }}</text> 36 <text class="value">{{ row.category || '-' }}</text>
@@ -101,7 +106,8 @@ export default { @@ -101,7 +106,8 @@ export default {
101 quantity: item ? item.quantity : '', 106 quantity: item ? item.quantity : '',
102 testCode: String(index + 1), 107 testCode: String(index + 1),
103 assayApplyCode: (item && item.assayApplyCode) || '', 108 assayApplyCode: (item && item.assayApplyCode) || '',
104 - assayApplyId: (item && item.assayApplyId) || '' 109 + assayApplyId: (item && item.assayApplyId) || '',
  110 + sampleCode: (item && item.sampleCode) || ''
105 } 111 }
106 ALL_COMPONENT_KEYS.forEach(key => { 112 ALL_COMPONENT_KEYS.forEach(key => {
107 row[key] = (item && item[key] !== undefined && item[key] !== null) ? item[key] : null 113 row[key] = (item && item[key] !== undefined && item[key] !== null) ? item[key] : null
@@ -153,6 +159,7 @@ export default { @@ -153,6 +159,7 @@ export default {
153 row.assayApplyId = item.assayApplyId || '' 159 row.assayApplyId = item.assayApplyId || ''
154 row.category = item.category || '' 160 row.category = item.category || ''
155 row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : '' 161 row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : ''
  162 + row.sampleCode = item.sampleCode || ''
156 }, 163 },
157 // 成份值输入:仅允许数字与小数点,空值重置为 null 164 // 成份值输入:仅允许数字与小数点,空值重置为 null
158 onComponentInput(e, index, key) { 165 onComponentInput(e, index, key) {
@@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
34 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> 34 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view>
35 <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> 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 + <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view>
37 <view v-for="key in componentKeys" :key="key" class="row"> 38 <view v-for="key in componentKeys" :key="key" class="row">
38 <text class="label">{{ componentLabels[key] || key }}</text> 39 <text class="label">{{ componentLabels[key] || key }}</text>
39 <text class="value">{{ formatNumber(item[key]) }}</text> 40 <text class="value">{{ formatNumber(item[key]) }}</text>
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> 29 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view>
30 <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> 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 + <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view>
32 <view v-for="key in componentKeys" :key="key" class="row"> 33 <view v-for="key in componentKeys" :key="key" class="row">
33 <text class="label">{{ componentLabels[key] || key }}</text> 34 <text class="label">{{ componentLabels[key] || key }}</text>
34 <text class="value">{{ formatNumber(item[key]) }}</text> 35 <text class="value">{{ formatNumber(item[key]) }}</text>
@@ -255,6 +255,7 @@ export default { @@ -255,6 +255,7 @@ export default {
255 const list = ((res && res.data) || []).map(item => ({ 255 const list = ((res && res.data) || []).map(item => ({
256 assayApplyId: item.assayApplyId || item.id || '', 256 assayApplyId: item.assayApplyId || item.id || '',
257 assayApplyCode: item.assayApplyCode || '', 257 assayApplyCode: item.assayApplyCode || '',
  258 + sampleCode: item.sampleCode || '',
258 productName: item.productName || '', 259 productName: item.productName || '',
259 category: item.category || '', 260 category: item.category || '',
260 productId: item.productId || '', 261 productId: item.productId || '',
@@ -357,6 +358,7 @@ export default { @@ -357,6 +358,7 @@ export default {
357 const list = ((res && res.data) || []).map(item => ({ 358 const list = ((res && res.data) || []).map(item => ({
358 assayApplyId: item.assayApplyId || item.id || '', 359 assayApplyId: item.assayApplyId || item.id || '',
359 assayApplyCode: item.assayApplyCode || '', 360 assayApplyCode: item.assayApplyCode || '',
  361 + sampleCode: item.sampleCode || '',
360 productName: item.productName || '', 362 productName: item.productName || '',
361 category: item.category || '', 363 category: item.category || '',
362 productId: item.productId || '', 364 productId: item.productId || '',
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> 30 <view class="row"><text class="label">数量(kg)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view>
31 <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.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 + <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view>
33 <view v-for="key in componentKeys" :key="key" class="row"> 34 <view v-for="key in componentKeys" :key="key" class="row">
34 <text class="label">{{ componentLabels[key] || key }}</text> 35 <text class="label">{{ componentLabels[key] || key }}</text>
35 <text class="value">{{ formatNumber(item[key]) }}</text> 36 <text class="value">{{ formatNumber(item[key]) }}</text>
@@ -66,6 +66,39 @@ @@ -66,6 +66,39 @@
66 </uni-list-item> 66 </uni-list-item>
67 </uni-list> 67 </uni-list>
68 68
  69 + <!-- 取样明细(可编辑) -->
  70 + <view class="sub-table">
  71 + <view class="header">
  72 + <image class="opCollapse" src="/static/images/title.png" />
  73 + <text class="title">取样明细</text>
  74 + <view class="ops">
  75 + <image class="opAdd" @click="addSampleLine" src="/static/images/plus.png" />
  76 + </view>
  77 + </view>
  78 + <view class="add-list">
  79 + <view v-if="!sampleLines.length" class="empty-tip">暂无明细,请添加</view>
  80 + <view v-for="(item, idx) in sampleLines" :key="'s-' + (item.id || idx)" class="block">
  81 + <uni-list>
  82 + <uni-list-item title="取样次序">
  83 + <template v-slot:footer>
  84 + <uni-easyinput :value="item.sampleNo" :inputBorder="false" disabled />
  85 + </template>
  86 + </uni-list-item>
  87 + <uni-list-item title="取样编号">
  88 + <template v-slot:footer>
  89 + <uni-easyinput :value="item.sampleCode" :inputBorder="false" disabled />
  90 + </template>
  91 + </uni-list-item>
  92 + </uni-list>
  93 + <view class="block-ops">
  94 + <div class="del" @click="removeSampleLine(idx)">
  95 + <image src="/static/images/delete.png" class="icon" />删除
  96 + </div>
  97 + </view>
  98 + </view>
  99 + </view>
  100 + </view>
  101 +
69 <view class="footer"> 102 <view class="footer">
70 <button class="btn submit" type="primary" @click="onSubmit">保存</button> 103 <button class="btn submit" type="primary" @click="onSubmit">保存</button>
71 </view> 104 </view>
@@ -101,6 +134,8 @@ export default { @@ -101,6 +134,8 @@ export default {
101 productId: '', 134 productId: '',
102 department: '' 135 department: ''
103 }, 136 },
  137 + // 取样明细(可编辑)
  138 + sampleLines: [],
104 dicOptions: { DEPARTMENT: [] }, 139 dicOptions: { DEPARTMENT: [] },
105 // 计划编号下拉选项(所选码单下的计划) 140 // 计划编号下拉选项(所选码单下的计划)
106 planOptions: [], 141 planOptions: [],
@@ -130,6 +165,12 @@ export default { @@ -130,6 +165,12 @@ export default {
130 return (this.dicOptions.DEPARTMENT || []).map(it => it.name) 165 return (this.dicOptions.DEPARTMENT || []).map(it => it.name)
131 } 166 }
132 }, 167 },
  168 + watch: {
  169 + // 送样编号生成/变更后同步刷新取样编号
  170 + 'form.code'() {
  171 + this.syncSampleCode()
  172 + }
  173 + },
133 created() { 174 created() {
134 this.ticketSheet.fetchFn = this.fetchTickets.bind(this) 175 this.ticketSheet.fetchFn = this.fetchTickets.bind(this)
135 this.loadDicData() 176 this.loadDicData()
@@ -247,6 +288,31 @@ export default { @@ -247,6 +288,31 @@ export default {
247 if (!opt) return 288 if (!opt) return
248 this.form.department = opt.code != null ? String(opt.code) : '' 289 this.form.department = opt.code != null ? String(opt.code) : ''
249 }, 290 },
  291 + // 取样明细-新增一行(取样次序从1开始递增,取样编号=送样编号_次序)
  292 + addSampleLine() {
  293 + const lines = this.sampleLines || []
  294 + const sampleNo = String(lines.length + 1)
  295 + lines.push({
  296 + id: genRowId(),
  297 + sampleNo,
  298 + sampleCode: `${this.form.code || ''}_${sampleNo}`
  299 + })
  300 + this.sampleLines = lines
  301 + },
  302 + // 取样明细-删除行并按当前顺序重新连续编号
  303 + removeSampleLine(idx) {
  304 + this.sampleLines.splice(idx, 1)
  305 + this.syncSampleCode()
  306 + },
  307 + // 按当前顺序重新生成取样次序与取样编号
  308 + syncSampleCode() {
  309 + const code = this.form.code || ''
  310 + ;(this.sampleLines || []).forEach((item, index) => {
  311 + const sampleNo = String(index + 1)
  312 + item.sampleNo = sampleNo
  313 + item.sampleCode = `${code}_${sampleNo}`
  314 + })
  315 + },
250 validate() { 316 validate() {
251 const f = this.form 317 const f = this.form
252 if (!f.code) return this.tip('请生成送样编号') 318 if (!f.code) return this.tip('请生成送样编号')
@@ -254,6 +320,8 @@ export default { @@ -254,6 +320,8 @@ export default {
254 if (!f.procurementPlanId) return this.tip('请选择计划编号') 320 if (!f.procurementPlanId) return this.tip('请选择计划编号')
255 if (!f.productId) return this.tip('请选择品种') 321 if (!f.productId) return this.tip('请选择品种')
256 if (!f.department) return this.tip('请选择科室') 322 if (!f.department) return this.tip('请选择科室')
  323 + // 取样明细必填:至少添加一行
  324 + if (!this.sampleLines.length) return this.tip('请至少添加一行取样明细')
257 return true 325 return true
258 }, 326 },
259 tip(msg) { 327 tip(msg) {
@@ -272,7 +340,12 @@ export default { @@ -272,7 +340,12 @@ export default {
272 weighingTicketId: this.form.weighingTicketId, 340 weighingTicketId: this.form.weighingTicketId,
273 procurementPlanId: this.form.procurementPlanId, 341 procurementPlanId: this.form.procurementPlanId,
274 productId: this.form.productId, 342 productId: this.form.productId,
275 - department: this.form.department 343 + department: this.form.department,
  344 + // 取样明细(仅提交业务字段)
  345 + lines: (this.sampleLines || []).map(it => ({
  346 + sampleNo: it.sampleNo,
  347 + sampleCode: it.sampleCode
  348 + }))
276 }) 349 })
277 .then(() => { 350 .then(() => {
278 uni.hideLoading() 351 uni.hideLoading()
@@ -287,6 +360,11 @@ export default { @@ -287,6 +360,11 @@ export default {
287 } 360 }
288 } 361 }
289 } 362 }
  363 +
  364 +// 生成前端临时行 id
  365 +function genRowId() {
  366 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  367 +}
290 </script> 368 </script>
291 369
292 <style lang="scss" scoped> 370 <style lang="scss" scoped>
@@ -357,6 +435,29 @@ export default { @@ -357,6 +435,29 @@ export default {
357 &__container { 435 &__container {
358 padding: 32rpx; 436 padding: 32rpx;
359 437
  438 + .uni-easyinput {
  439 + &__placeholder-class {
  440 + font-size: 32rpx;
  441 + color: rgba(0, 0, 0, 0.4);
  442 + }
  443 +
  444 + &__content {
  445 + border: none;
  446 + background-color: #ffffff !important;
  447 +
  448 + &-input {
  449 + padding-left: 0 !important;
  450 + height: 48rpx;
  451 + line-height: 48rpx;
  452 + font-size: 32rpx;
  453 + }
  454 +
  455 + .content-clear-icon {
  456 + font-size: 44rpx !important;
  457 + }
  458 + }
  459 + }
  460 +
360 .item-title, 461 .item-title,
361 .uni-list-item__content { 462 .uni-list-item__content {
362 flex: none; 463 flex: none;
@@ -435,4 +536,81 @@ export default { @@ -435,4 +536,81 @@ export default {
435 color: rgba(0, 0, 0, 0.4); 536 color: rgba(0, 0, 0, 0.4);
436 } 537 }
437 } 538 }
  539 +
  540 +.sub-table {
  541 + margin-top: 20rpx;
  542 + background: #fff;
  543 +}
  544 +
  545 +.header {
  546 + display: flex;
  547 + align-items: center;
  548 + padding: 24rpx 32rpx;
  549 + border-bottom: 1rpx solid #f0f0f0;
  550 +
  551 + .opCollapse {
  552 + width: 32rpx;
  553 + height: 28rpx;
  554 + margin-right: 16rpx;
  555 + margin-top: 8rpx;
  556 + }
  557 +
  558 + .title {
  559 + font-size: 32rpx;
  560 + color: rgba(0, 0, 0, 0.9);
  561 + font-weight: 600;
  562 + flex: 1;
  563 + }
  564 +
  565 + .ops {
  566 + display: flex;
  567 + align-items: center;
  568 +
  569 + .opAdd {
  570 + width: 40rpx;
  571 + height: 40rpx;
  572 + }
  573 + }
  574 +}
  575 +
  576 +.add-list {
  577 + padding: 0 0 16rpx;
  578 +
  579 + .empty-tip {
  580 + text-align: center;
  581 + padding: 60rpx 0;
  582 + color: rgba(0, 0, 0, 0.4);
  583 + font-size: 28rpx;
  584 + }
  585 +
  586 + .block {
  587 + border-bottom: 1rpx solid #f0f0f0;
  588 +
  589 + &:last-child {
  590 + border-bottom: none;
  591 + }
  592 +
  593 + .block-ops {
  594 + display: flex;
  595 + align-items: center;
  596 + justify-content: flex-end;
  597 + gap: 48rpx;
  598 + padding: 20rpx 32rpx;
  599 + background: #f8f8f8;
  600 +
  601 + .del {
  602 + display: flex;
  603 + align-items: center;
  604 + font-size: 28rpx;
  605 + color: #d54941;
  606 +
  607 + .icon {
  608 + width: 32rpx;
  609 + height: 32rpx;
  610 + margin-right: 8rpx;
  611 + }
  612 + }
  613 + }
  614 + }
  615 +}
438 </style> 616 </style>
@@ -13,6 +13,26 @@ @@ -13,6 +13,26 @@
13 <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> 13 <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view>
14 <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> 14 <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view>
15 </view> 15 </view>
  16 +
  17 + <!-- 取样明细 -->
  18 + <view class="sub-table">
  19 + <view class="sub-header">
  20 + <image class="sub-bar" src="/static/images/title.png" />
  21 + <text class="sub-title">取样明细</text>
  22 + <view class="sub-toggle" @click="toggle('sample')">
  23 + <image class="sub-toggle_icon" :src="collapse.sample ? '/static/images/down.png' : '/static/images/up.png'" />
  24 + <text class="sub-toggle_text">{{ collapse.sample ? '展开' : '收起' }}</text>
  25 + </view>
  26 + </view>
  27 + <view v-if="!collapse.sample" class="sub-body">
  28 + <view v-if="!sampleLines.length" class="empty-tip">暂无明细</view>
  29 + <view v-for="(item, idx) in sampleLines" :key="'s-' + idx" class="card">
  30 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  31 + <view class="row"><text class="label">取样次序</text><text class="value">{{ safeText(item.sampleNo) }}</text></view>
  32 + <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view>
  33 + </view>
  34 + </view>
  35 + </view>
16 </view> 36 </view>
17 </scroll-view> 37 </scroll-view>
18 <detail-buttons :buttons="displayButtons" @click="handleButtonClick" /> 38 <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
@@ -36,6 +56,9 @@ export default { @@ -36,6 +56,9 @@ export default {
36 return { 56 return {
37 id: '', 57 id: '',
38 form: {}, 58 form: {},
  59 + // 取样明细
  60 + sampleLines: [],
  61 + collapse: { sample: false },
39 currentUserId: '', 62 currentUserId: '',
40 dicOptions: { 63 dicOptions: {
41 DEPARTMENT: [], 64 DEPARTMENT: [],
@@ -107,6 +130,9 @@ export default { @@ -107,6 +130,9 @@ export default {
107 this.loadDetail() 130 this.loadDetail()
108 }, 131 },
109 methods: { 132 methods: {
  133 + toggle(key) {
  134 + this.collapse = { ...this.collapse, [key]: !this.collapse[key] }
  135 + },
110 async loadDicData() { 136 async loadDicData() {
111 try { 137 try {
112 const results = await getDicByCodes(['DEPARTMENT', 'AUDIT_STATUS']) 138 const results = await getDicByCodes(['DEPARTMENT', 'AUDIT_STATUS'])
@@ -134,6 +160,8 @@ export default { @@ -134,6 +160,8 @@ export default {
134 .then(res => { 160 .then(res => {
135 const data = res && res.data ? res.data : {} 161 const data = res && res.data ? res.data : {}
136 this.form = Object.assign({}, data) 162 this.form = Object.assign({}, data)
  163 + // 取样明细回显
  164 + this.sampleLines = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
137 }) 165 })
138 .catch(() => { 166 .catch(() => {
139 uni.showToast({ title: '详情加载失败', icon: 'none' }) 167 uni.showToast({ title: '详情加载失败', icon: 'none' })
@@ -280,4 +308,80 @@ export default { @@ -280,4 +308,80 @@ export default {
280 word-break: break-all; 308 word-break: break-all;
281 } 309 }
282 } 310 }
  311 +
  312 +.sub-table {
  313 + background: #fff;
  314 + margin-bottom: 20rpx;
  315 +}
  316 +.sub-header {
  317 + display: flex;
  318 + align-items: center;
  319 + padding: 16rpx 0 16rpx 32rpx;
  320 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  321 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  322 + .sub-toggle {
  323 + display: flex;
  324 + align-items: center;
  325 + padding: 0 12rpx;
  326 + height: 56rpx;
  327 + .sub-toggle_icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  328 + .sub-toggle_text { font-size: 26rpx; color: rgba(0, 0, 0, 0.6); }
  329 + }
  330 +}
  331 +.sub-body {
  332 + padding: 0 32rpx 24rpx;
  333 + .empty-tip {
  334 + text-align: center;
  335 + padding: 60rpx 0;
  336 + color: rgba(0, 0, 0, 0.4);
  337 + font-size: 28rpx;
  338 + }
  339 + .card {
  340 + position: relative;
  341 + background: #fafafa;
  342 + border-radius: 12rpx;
  343 + padding: 32rpx 28rpx 20rpx;
  344 + margin-bottom: 24rpx;
  345 + &:last-child { margin-bottom: 0; }
  346 + .card-index {
  347 + position: absolute;
  348 + top: 0;
  349 + right: 0;
  350 + background: rgba(24, 144, 255, 0.08);
  351 + color: $theme-primary;
  352 + font-size: 22rpx;
  353 + line-height: 36rpx;
  354 + padding: 0 16rpx;
  355 + border-bottom-left-radius: 12rpx;
  356 + border-top-right-radius: 12rpx;
  357 + }
  358 + .row {
  359 + align-items: center;
  360 + justify-content: space-between;
  361 + padding: 14rpx 0;
  362 + margin-bottom: 0;
  363 + border-bottom: 1rpx dashed #f2f2f2;
  364 + &:last-child { border-bottom: none; }
  365 + .label {
  366 + flex-shrink: 0;
  367 + width: 220rpx;
  368 + max-width: none;
  369 + margin-right: 0;
  370 + font-size: 28rpx;
  371 + color: rgba(0, 0, 0, 0.6);
  372 + line-height: 40rpx;
  373 + }
  374 + .value {
  375 + flex: 1;
  376 + text-align: right;
  377 + font-size: 28rpx;
  378 + color: rgba(0, 0, 0, 0.9);
  379 + line-height: 40rpx;
  380 + overflow: hidden;
  381 + text-overflow: ellipsis;
  382 + white-space: nowrap;
  383 + }
  384 + }
  385 + }
  386 +}
283 </style> 387 </style>
@@ -63,6 +63,39 @@ @@ -63,6 +63,39 @@
63 </uni-list-item> 63 </uni-list-item>
64 </uni-list> 64 </uni-list>
65 65
  66 + <!-- 取样明细(可编辑) -->
  67 + <view class="sub-table">
  68 + <view class="header">
  69 + <image class="opCollapse" src="/static/images/title.png" />
  70 + <text class="title">取样明细</text>
  71 + <view class="ops">
  72 + <image class="opAdd" @click="addSampleLine" src="/static/images/plus.png" />
  73 + </view>
  74 + </view>
  75 + <view class="add-list">
  76 + <view v-if="!sampleLines.length" class="empty-tip">暂无明细,请添加</view>
  77 + <view v-for="(item, idx) in sampleLines" :key="'s-' + (item.id || idx)" class="block">
  78 + <uni-list>
  79 + <uni-list-item title="取样次序">
  80 + <template v-slot:footer>
  81 + <uni-easyinput :value="item.sampleNo" :inputBorder="false" disabled />
  82 + </template>
  83 + </uni-list-item>
  84 + <uni-list-item title="取样编号">
  85 + <template v-slot:footer>
  86 + <uni-easyinput :value="item.sampleCode" :inputBorder="false" disabled />
  87 + </template>
  88 + </uni-list-item>
  89 + </uni-list>
  90 + <view class="block-ops">
  91 + <div class="del" @click="removeSampleLine(idx)">
  92 + <image src="/static/images/delete.png" class="icon" />删除
  93 + </div>
  94 + </view>
  95 + </view>
  96 + </view>
  97 + </view>
  98 +
66 <view class="footer"> 99 <view class="footer">
67 <button class="btn submit" type="primary" @click="onSubmit">保存</button> 100 <button class="btn submit" type="primary" @click="onSubmit">保存</button>
68 </view> 101 </view>
@@ -99,6 +132,8 @@ export default { @@ -99,6 +132,8 @@ export default {
99 productId: '', 132 productId: '',
100 department: '' 133 department: ''
101 }, 134 },
  135 + // 取样明细(可编辑)
  136 + sampleLines: [],
102 dicOptions: { DEPARTMENT: [] }, 137 dicOptions: { DEPARTMENT: [] },
103 // 计划编号下拉选项(所选码单下的计划) 138 // 计划编号下拉选项(所选码单下的计划)
104 planOptions: [], 139 planOptions: [],
@@ -128,6 +163,12 @@ export default { @@ -128,6 +163,12 @@ export default {
128 return (this.dicOptions.DEPARTMENT || []).map(it => it.name) 163 return (this.dicOptions.DEPARTMENT || []).map(it => it.name)
129 } 164 }
130 }, 165 },
  166 + watch: {
  167 + // 送样编号变更后同步刷新取样编号
  168 + 'form.code'() {
  169 + this.syncSampleCode()
  170 + }
  171 + },
131 created() { 172 created() {
132 this.ticketSheet.fetchFn = this.fetchTickets.bind(this) 173 this.ticketSheet.fetchFn = this.fetchTickets.bind(this)
133 this.loadDicData() 174 this.loadDicData()
@@ -169,6 +210,8 @@ export default { @@ -169,6 +210,8 @@ export default {
169 this.productOptions = this.form.productId 210 this.productOptions = this.form.productId
170 ? [{ label: data.productName || '', value: this.form.productId }] 211 ? [{ label: data.productName || '', value: this.form.productId }]
171 : [] 212 : []
  213 + // 取样明细回显
  214 + this.sampleLines = (Array.isArray(data.lines) ? data.lines : []).map(it => ({ ...it, id: it.id || genRowId() }))
172 if (this.form.weighingTicketId) { 215 if (this.form.weighingTicketId) {
173 this.loadPlanOptions(this.form.weighingTicketId) 216 this.loadPlanOptions(this.form.weighingTicketId)
174 } 217 }
@@ -301,12 +344,39 @@ export default { @@ -301,12 +344,39 @@ export default {
301 if (!opt) return 344 if (!opt) return
302 this.form.department = opt.code != null ? String(opt.code) : '' 345 this.form.department = opt.code != null ? String(opt.code) : ''
303 }, 346 },
  347 + // 取样明细-新增一行(取样次序从1开始递增,取样编号=送样编号_次序)
  348 + addSampleLine() {
  349 + const lines = this.sampleLines || []
  350 + const sampleNo = String(lines.length + 1)
  351 + lines.push({
  352 + id: genRowId(),
  353 + sampleNo,
  354 + sampleCode: `${this.form.code || ''}_${sampleNo}`
  355 + })
  356 + this.sampleLines = lines
  357 + },
  358 + // 取样明细-删除行并按当前顺序重新连续编号
  359 + removeSampleLine(idx) {
  360 + this.sampleLines.splice(idx, 1)
  361 + this.syncSampleCode()
  362 + },
  363 + // 按当前顺序重新生成取样次序与取样编号
  364 + syncSampleCode() {
  365 + const code = this.form.code || ''
  366 + ;(this.sampleLines || []).forEach((item, index) => {
  367 + const sampleNo = String(index + 1)
  368 + item.sampleNo = sampleNo
  369 + item.sampleCode = `${code}_${sampleNo}`
  370 + })
  371 + },
304 validate() { 372 validate() {
305 const f = this.form 373 const f = this.form
306 if (!f.weighingTicketId) return this.tip('请选择码单编号') 374 if (!f.weighingTicketId) return this.tip('请选择码单编号')
307 if (!f.procurementPlanId) return this.tip('请选择计划编号') 375 if (!f.procurementPlanId) return this.tip('请选择计划编号')
308 if (!f.productId) return this.tip('请选择品种') 376 if (!f.productId) return this.tip('请选择品种')
309 if (!f.department) return this.tip('请选择科室') 377 if (!f.department) return this.tip('请选择科室')
  378 + // 取样明细必填:至少添加一行
  379 + if (!this.sampleLines.length) return this.tip('请至少添加一行取样明细')
310 return true 380 return true
311 }, 381 },
312 tip(msg) { 382 tip(msg) {
@@ -326,7 +396,12 @@ export default { @@ -326,7 +396,12 @@ export default {
326 weighingTicketId: this.form.weighingTicketId, 396 weighingTicketId: this.form.weighingTicketId,
327 procurementPlanId: this.form.procurementPlanId, 397 procurementPlanId: this.form.procurementPlanId,
328 productId: this.form.productId, 398 productId: this.form.productId,
329 - department: this.form.department 399 + department: this.form.department,
  400 + // 取样明细(仅提交业务字段)
  401 + lines: (this.sampleLines || []).map(it => ({
  402 + sampleNo: it.sampleNo,
  403 + sampleCode: it.sampleCode
  404 + }))
330 }) 405 })
331 .then(() => { 406 .then(() => {
332 uni.hideLoading() 407 uni.hideLoading()
@@ -344,6 +419,11 @@ export default { @@ -344,6 +419,11 @@ export default {
344 } 419 }
345 } 420 }
346 } 421 }
  422 +
  423 +// 生成前端临时行 id
  424 +function genRowId() {
  425 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  426 +}
347 </script> 427 </script>
348 428
349 <style lang="scss" scoped> 429 <style lang="scss" scoped>
@@ -414,6 +494,29 @@ export default { @@ -414,6 +494,29 @@ export default {
414 &__container { 494 &__container {
415 padding: 32rpx; 495 padding: 32rpx;
416 496
  497 + .uni-easyinput {
  498 + &__placeholder-class {
  499 + font-size: 32rpx;
  500 + color: rgba(0, 0, 0, 0.4);
  501 + }
  502 +
  503 + &__content {
  504 + border: none;
  505 + background-color: #ffffff !important;
  506 +
  507 + &-input {
  508 + padding-left: 0 !important;
  509 + height: 48rpx;
  510 + line-height: 48rpx;
  511 + font-size: 32rpx;
  512 + }
  513 +
  514 + .content-clear-icon {
  515 + font-size: 44rpx !important;
  516 + }
  517 + }
  518 + }
  519 +
417 .item-title, 520 .item-title,
418 .uni-list-item__content { 521 .uni-list-item__content {
419 flex: none; 522 flex: none;
@@ -476,4 +579,81 @@ export default { @@ -476,4 +579,81 @@ export default {
476 color: rgba(0, 0, 0, 0.4); 579 color: rgba(0, 0, 0, 0.4);
477 } 580 }
478 } 581 }
  582 +
  583 +.sub-table {
  584 + margin-top: 20rpx;
  585 + background: #fff;
  586 +}
  587 +
  588 +.header {
  589 + display: flex;
  590 + align-items: center;
  591 + padding: 24rpx 32rpx;
  592 + border-bottom: 1rpx solid #f0f0f0;
  593 +
  594 + .opCollapse {
  595 + width: 32rpx;
  596 + height: 28rpx;
  597 + margin-right: 16rpx;
  598 + margin-top: 8rpx;
  599 + }
  600 +
  601 + .title {
  602 + font-size: 32rpx;
  603 + color: rgba(0, 0, 0, 0.9);
  604 + font-weight: 600;
  605 + flex: 1;
  606 + }
  607 +
  608 + .ops {
  609 + display: flex;
  610 + align-items: center;
  611 +
  612 + .opAdd {
  613 + width: 40rpx;
  614 + height: 40rpx;
  615 + }
  616 + }
  617 +}
  618 +
  619 +.add-list {
  620 + padding: 0 0 16rpx;
  621 +
  622 + .empty-tip {
  623 + text-align: center;
  624 + padding: 60rpx 0;
  625 + color: rgba(0, 0, 0, 0.4);
  626 + font-size: 28rpx;
  627 + }
  628 +
  629 + .block {
  630 + border-bottom: 1rpx solid #f0f0f0;
  631 +
  632 + &:last-child {
  633 + border-bottom: none;
  634 + }
  635 +
  636 + .block-ops {
  637 + display: flex;
  638 + align-items: center;
  639 + justify-content: flex-end;
  640 + gap: 48rpx;
  641 + padding: 20rpx 32rpx;
  642 + background: #f8f8f8;
  643 +
  644 + .del {
  645 + display: flex;
  646 + align-items: center;
  647 + font-size: 28rpx;
  648 + color: #d54941;
  649 +
  650 + .icon {
  651 + width: 32rpx;
  652 + height: 32rpx;
  653 + margin-right: 8rpx;
  654 + }
  655 + }
  656 + }
  657 + }
  658 +}
479 </style> 659 </style>
@@ -12,6 +12,22 @@ @@ -12,6 +12,22 @@
12 <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> 12 <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view>
13 <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> 13 <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view>
14 </view> 14 </view>
  15 +
  16 + <!-- 取样明细 -->
  17 + <view class="sub-table">
  18 + <view class="sub-header">
  19 + <image class="sub-bar" src="/static/images/title.png" />
  20 + <text class="sub-title">取样明细</text>
  21 + </view>
  22 + <view class="sub-body">
  23 + <view v-if="!sampleLines.length" class="empty-tip">暂无明细</view>
  24 + <view v-for="(item, idx) in sampleLines" :key="'s-' + idx" class="card">
  25 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  26 + <view class="row"><text class="label">取样次序</text><text class="value">{{ safeText(item.sampleNo) }}</text></view>
  27 + <view class="row"><text class="label">取样编号</text><text class="value">{{ safeText(item.sampleCode) }}</text></view>
  28 + </view>
  29 + </view>
  30 + </view>
15 </scroll-view> 31 </scroll-view>
16 </view> 32 </view>
17 </template> 33 </template>
@@ -26,6 +42,8 @@ export default { @@ -26,6 +42,8 @@ export default {
26 data() { 42 data() {
27 return { 43 return {
28 form: {}, 44 form: {},
  45 + // 取样明细
  46 + sampleLines: [],
29 dicOptions: { 47 dicOptions: {
30 DEPARTMENT: [], 48 DEPARTMENT: [],
31 AUDIT_STATUS: [] 49 AUDIT_STATUS: []
@@ -71,6 +89,8 @@ export default { @@ -71,6 +89,8 @@ export default {
71 .then(res => { 89 .then(res => {
72 const data = res && res.data ? res.data : {} 90 const data = res && res.data ? res.data : {}
73 this.form = Object.assign({}, data) 91 this.form = Object.assign({}, data)
  92 + // 取样明细回显
  93 + this.sampleLines = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
74 }) 94 })
75 .catch(() => { 95 .catch(() => {
76 uni.showToast({ title: '详情加载失败', icon: 'none' }) 96 uni.showToast({ title: '详情加载失败', icon: 'none' })
@@ -138,4 +158,95 @@ export default { @@ -138,4 +158,95 @@ export default {
138 word-break: break-all; 158 word-break: break-all;
139 } 159 }
140 } 160 }
  161 +.sub-table {
  162 + background: #fff;
  163 + margin-bottom: 20rpx;
  164 +}
  165 +.sub-header {
  166 + display: flex;
  167 + align-items: center;
  168 + padding: 16rpx 0 16rpx 32rpx;
  169 +
  170 + .sub-bar {
  171 + width: 6rpx;
  172 + height: 32rpx;
  173 + margin-right: 14rpx;
  174 + }
  175 +
  176 + .sub-title {
  177 + font-size: 30rpx;
  178 + font-weight: 600;
  179 + color: rgba(0, 0, 0, 0.9);
  180 + flex: 1;
  181 + line-height: 42rpx;
  182 + }
  183 +}
  184 +.sub-body {
  185 + padding: 0 32rpx 24rpx;
  186 +
  187 + .empty-tip {
  188 + text-align: center;
  189 + padding: 60rpx 0;
  190 + color: rgba(0, 0, 0, 0.4);
  191 + font-size: 28rpx;
  192 + }
  193 +
  194 + .card {
  195 + position: relative;
  196 + background: #fafafa;
  197 + border-radius: 12rpx;
  198 + padding: 32rpx 28rpx 20rpx;
  199 + margin-bottom: 24rpx;
  200 +
  201 + &:last-child {
  202 + margin-bottom: 0;
  203 + }
  204 +
  205 + .card-index {
  206 + position: absolute;
  207 + top: 0;
  208 + right: 0;
  209 + background: rgba(24, 144, 255, 0.08);
  210 + color: $theme-primary;
  211 + font-size: 22rpx;
  212 + line-height: 36rpx;
  213 + padding: 0 16rpx;
  214 + border-bottom-left-radius: 12rpx;
  215 + border-top-right-radius: 12rpx;
  216 + }
  217 +
  218 + .row {
  219 + align-items: center;
  220 + justify-content: space-between;
  221 + padding: 14rpx 0;
  222 + margin-bottom: 0;
  223 + border-bottom: 1rpx dashed #f2f2f2;
  224 +
  225 + &:last-child {
  226 + border-bottom: none;
  227 + }
  228 +
  229 + .label {
  230 + flex-shrink: 0;
  231 + width: 220rpx;
  232 + max-width: none;
  233 + margin-right: 0;
  234 + font-size: 28rpx;
  235 + color: rgba(0, 0, 0, 0.6);
  236 + line-height: 40rpx;
  237 + }
  238 +
  239 + .value {
  240 + flex: 1;
  241 + text-align: right;
  242 + font-size: 28rpx;
  243 + color: rgba(0, 0, 0, 0.9);
  244 + line-height: 40rpx;
  245 + overflow: hidden;
  246 + text-overflow: ellipsis;
  247 + white-space: nowrap;
  248 + }
  249 + }
  250 + }
  251 +}
141 </style> 252 </style>