| | |
| | | </el-select> |
| | | </el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="原始记录模板" prop="templateIds"> |
| | | <el-select v-model="form.templateIds" multiple collapse-tags filterable style="width: 100%" placeholder="可选择多个模板"> |
| | | <el-select v-model="form.templateIds" multiple collapse-tags filterable style="width: 100%" |
| | | :loading="templateBindingLoading" :disabled="!form.standardMethodId" |
| | | :placeholder="form.standardMethodId ? '请选择原始记录模板' : '请先选择检测标准'" |
| | | :no-data-text="form.standardMethodId ? '该检测标准暂未绑定原始记录模板' : '请先选择检测标准'"> |
| | | <el-option v-for="item in templateOptions" :key="item.id" :value="item.id" :label="item.name" /> |
| | | </el-select> |
| | | <div v-if="form.standardMethodId && !templateBindingLoading && templateOptions.length === 0" |
| | | style="font-size: 12px; line-height: 18px; color: var(--el-color-warning); margin-top: 4px;"> |
| | | 该检测标准在标准库中尚未绑定原始记录模板,请先在标准库中完成绑定。 |
| | | </div> |
| | | </el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="样品名称"><el-input v-model="form.sampleName" /></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="样品规格"><el-input v-model="form.sampleSpec" /></el-form-item></el-col> |
| | |
| | | } from "@/api/cnas/process/ensureResults/qualityMonitor"; |
| | | import { selectStandardMethodList } from '@/api/cnas/process/method/standardMethod'; |
| | | import { selectStandardTemplatePageList } from '@/api/standard/model'; |
| | | import { selectTemplateBindingsByStandardMethod } from '@/api/standard/standardLibrary'; |
| | | import { selectUserCondition } from '@/api/performance/class'; |
| | | |
| | | export default { |
| | |
| | | dueDate: null, |
| | | }, |
| | | standardOptions: [], |
| | | allTemplateOptions: [], |
| | | templateOptions: [], |
| | | templateBindingLoading: false, |
| | | userOptions: [], |
| | | rules: { |
| | | monitorProject: [{ required: true, message: '请输入质控项目', trigger: 'blur' }], |
| | |
| | | methods: { |
| | | openDia(type, row) { |
| | | this.formDia = true |
| | | selectStandardMethodList({ current: 1, size: 1000 }).then(res => { this.standardOptions = res.data?.records || res.data || [] }) |
| | | selectStandardTemplatePageList({ current: 1, size: 1000 }).then(res => { this.templateOptions = res.data?.records || res.data || [] }) |
| | | selectUserCondition({ type: 1 }).then(res => { this.userOptions = res.data || [] }) |
| | | this.operationType = type |
| | | this.templateOptions = [] |
| | | this.allTemplateOptions = [] |
| | | this.templateBindingLoading = false |
| | | selectStandardMethodList({ current: 1, size: 1000 }).then(res => { this.standardOptions = res.data?.records || res.data || [] }) |
| | | selectStandardTemplatePageList({ current: 1, size: 1000 }).then(res => { this.allTemplateOptions = res.data?.records || res.data || [] }) |
| | | selectUserCondition({ type: 1 }).then(res => { this.userOptions = res.data || [] }) |
| | | if (type === 'edit') { |
| | | this.searchInfo(row) |
| | | if (row.itemKind === 'INSPECTION' && row.standardMethodId) { |
| | | this.loadBoundTemplates(row.standardMethodId, this.form.templateIds) |
| | | } |
| | | } |
| | | }, |
| | | searchInfo (row) { |
| | |
| | | if (standard) this.form.technicalStandardText = `${standard.code || ''} ${standard.name || ''}`.trim() |
| | | this.form.templateIds = [] |
| | | this.form.templateId = null |
| | | // 和委托下单保持一致:选择检测标准后,只展示该标准在标准库中已绑定的原始记录模板 |
| | | this.loadBoundTemplates(id) |
| | | }, |
| | | loadBoundTemplates(standardMethodId, selectedIds = null) { |
| | | const currentIds = Array.isArray(selectedIds) ? selectedIds.map(Number) : null |
| | | this.templateOptions = [] |
| | | if (currentIds === null) this.form.templateIds = [] |
| | | if (!standardMethodId) return |
| | | this.templateBindingLoading = true |
| | | selectTemplateBindingsByStandardMethod({ standardMethodId }).then(res => { |
| | | const bound = (res.data || []).map(item => ({ id: Number(item.templateId), name: item.name })) |
| | | this.templateOptions = bound |
| | | if (currentIds === null) { |
| | | // 新增或切换检测标准时,默认选中该标准已绑定的全部模板 |
| | | this.form.templateIds = bound.map(item => item.id) |
| | | return |
| | | } |
| | | // 编辑时保留原选择;若模板后来被解绑,补充名称避免下拉框只显示 ID |
| | | const boundIds = new Set(bound.map(item => item.id)) |
| | | currentIds.forEach(id => { |
| | | if (!boundIds.has(id)) { |
| | | const template = this.allTemplateOptions.find(item => Number(item.id) === id) |
| | | if (template) this.templateOptions.push({ id: Number(template.id), name: template.name }) |
| | | } |
| | | }) |
| | | this.form.templateIds = currentIds |
| | | }).catch(() => { |
| | | this.templateOptions = [] |
| | | }).finally(() => { |
| | | this.templateBindingLoading = false |
| | | }) |
| | | }, |
| | | buildEntity () { |
| | | const entity = this.HaveJson(this.form) |