| | |
| | | <p v-if="!templateBindings.length" class="binding-tip">请为当前标准绑定原始记录模板。</p> |
| | | <el-table :data="templateBindings" border size="small"> |
| | | <el-table-column type="index" label="顺序" width="70" /><el-table-column label="模板编号" prop="number" width="180" /><el-table-column label="模板名称" prop="name" /><el-table-column label="检测依据(模板备注)" prop="remark" /> |
| | | <el-table-column label="设备绑定" min-width="360"> |
| | | <template slot-scope="scope"> |
| | | <el-select v-model="scope.row.deviceIds" |
| | | :disabled="!checkPermi(['standard:standardLibrary:upStandardProduct'])" |
| | | multiple filterable clearable size="small" |
| | | placeholder="请选择该模板的默认设备" style="width:100%"> |
| | | <el-option v-for="device in deviceOptions" :key="device.id" |
| | | :label="device.label" :value="device.id" /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" label="操作" width="150"><template slot-scope="scope"><el-button type="text" :disabled="scope.$index === 0" @click="moveBinding(scope.$index, -1)">上移</el-button><el-button type="text" :disabled="scope.$index === templateBindings.length - 1" @click="moveBinding(scope.$index, 1)">下移</el-button><el-button type="text" @click="removeBinding(scope.$index)">移除</el-button></template></el-table-column> |
| | | </el-table> |
| | | <el-select v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" v-model="templateToBind" filterable placeholder="选择原始记录模板" size="small" style="width:320px;margin-top:16px" @change="addBinding"><el-option v-for="template in templateList.filter(item => !templateBindings.some(binding => binding.templateId === item.id))" :key="template.id" :label="template.number ? template.number + ' - ' + template.name : template.name" :value="template.id" /></el-select> |
| | | <el-select v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" v-model="templateToBind" multiple filterable placeholder="选择原始记录模板" size="small" style="width:320px;margin-top:16px"><el-option v-for="template in templateList.filter(item => !templateBindings.some(binding => binding.templateId === item.id))" :key="template.id" :label="template.number ? template.number + ' - ' + template.name : template.name" :value="template.id" /></el-select> |
| | | <el-button v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" type="primary" size="small" style="margin-top:16px;margin-left:8px" @click="confirmAddBindings">确认</el-button> |
| | | </el-card> |
| | | <el-empty v-else description="请选择二级标准,维护其原始记录模板" /> |
| | | <div v-if="false"> |
| | |
| | | getStandardTemplate, |
| | | selectTemplateBindings, |
| | | saveTemplateBindings, |
| | | searchDevices, |
| | | } from "@/api/standard/standardLibrary"; |
| | | import bindSupplierDensityDialogAsk from "./components/bindSupplierDensityDialogAsk.vue"; |
| | | import BatchCopy from "./components/BatchCopy.vue"; |
| | |
| | | sectionList: [], |
| | | templateList: [], |
| | | templateBindings: [], |
| | | templateToBind: null, |
| | | templateToBind: [], |
| | | deviceOptions: [], |
| | | total: 0, |
| | | currentPage: 1, |
| | | standardId: 0, |
| | |
| | | this.selectEnumByCategoryForSonLaboratory(); |
| | | this.selectEnumByCategoryForsampleType(); |
| | | this.getStandardTemplate(); |
| | | this.loadDeviceOptions(); |
| | | this.selectStandardMethodsSec(); |
| | | this.token = { |
| | | token: sessionStorage.getItem("token"), |
| | |
| | | this.templateList = res.data; |
| | | }); |
| | | }, |
| | | loadTemplateBindings(standardTreeId) { |
| | | selectTemplateBindings({ standardTreeId }).then((res) => { |
| | | this.templateBindings = res.data || []; |
| | | this.templateToBind = null; |
| | | loadDeviceOptions() { |
| | | searchDevices({ status: 0 }).then((res) => { |
| | | this.deviceOptions = (res.data || []).map((device) => ({ |
| | | id: device.id, |
| | | label: `${device.deviceName}--${device.managementNumber}`, |
| | | })); |
| | | }); |
| | | }, |
| | | addBinding(templateId) { |
| | | const template = this.templateList.find((item) => item.id === templateId); |
| | | if (template && !this.templateBindings.some((item) => item.templateId === templateId)) { |
| | | this.templateBindings.push({ ...template, templateId, sort: this.templateBindings.length }); |
| | | } |
| | | this.templateToBind = null; |
| | | loadTemplateBindings(standardTreeId) { |
| | | selectTemplateBindings({ standardTreeId }).then((res) => { |
| | | this.templateBindings = (res.data || []).map((item) => ({ |
| | | ...item, |
| | | deviceIds: Array.isArray(item.deviceIds) ? [...item.deviceIds] : [], |
| | | })); |
| | | this.templateToBind = []; |
| | | }); |
| | | }, |
| | | confirmAddBindings() { |
| | | const selectedIds = Array.isArray(this.templateToBind) ? this.templateToBind : []; |
| | | selectedIds.forEach((templateId) => { |
| | | const template = this.templateList.find((item) => item.id === templateId); |
| | | if (template && !this.templateBindings.some((item) => item.templateId === templateId)) { |
| | | this.templateBindings.push({ ...template, templateId, sort: this.templateBindings.length, deviceIds: [] }); |
| | | } |
| | | }); |
| | | this.templateToBind = []; |
| | | }, |
| | | removeBinding(index) { |
| | | this.templateBindings.splice(index, 1); |
| | |
| | | }, |
| | | saveBindings() { |
| | | saveTemplateBindings({ standardTreeId: this.selected.id, |
| | | templates: this.templateBindings.map((item, index) => ({ templateId: item.templateId, sort: index })) |
| | | templates: this.templateBindings.map((item, index) => ({ |
| | | templateId: item.templateId, |
| | | sort: index, |
| | | deviceIds: Array.isArray(item.deviceIds) ? [...item.deviceIds] : [], |
| | | })) |
| | | }).then(() => { |
| | | this.$message.success("模板绑定已保存"); |
| | | this.loadTemplateBindings(this.selected.id); |