| | |
| | | <template> |
| | | <div> |
| | | <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-model="dialogVisible" |
| | | :title="currentStep === 0 ? '新增核查记录' : '设备核查记录'" width="50%" @close="resetForm"> |
| | | <el-steps v-if="currentStep === 1" :active="1" align-center finish-status="success"> |
| | | :title="currentStep === 0 ? '新增核查记录' : '设备核查记录'" top="5vh" width="960px" @close="resetForm"> |
| | | <el-steps v-if="currentStep === 1" class="record-steps" :active="1" align-center finish-status="success"> |
| | | <el-step title="填写核查记录"></el-step> |
| | | <el-step title="审核"></el-step> |
| | | </el-steps> |
| | | <el-form ref="recordForm" :model="form" :rules="rules" label-width="110px"> |
| | | <el-form-item label="设备编号:" prop="deviceNumber"> |
| | | <el-input v-model="form.deviceNumber" disabled size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="设备名称:" prop="deviceName"> |
| | | <el-form ref="recordForm" :model="form" :rules="rules" label-width="104px"> |
| | | <div class="form-section"> |
| | | <div class="form-section-title">基本信息</div> |
| | | <el-row :gutter="12"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仪器名称:" prop="deviceName"> |
| | | <el-select v-if="currentStep === 0" v-model="selectedDeviceId" clearable filterable |
| | | placeholder="请选择设备" size="small" style="width: 100%" @change="changeMachineName"> |
| | | <el-option v-for="item in equipOptions" :key="item.id" :label="item.label + '-' + item.value" |
| | |
| | | </el-select> |
| | | <el-input v-else v-model="form.deviceName" disabled size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="核查时间:" prop="checkTime"> |
| | | <el-date-picker v-model="form.checkTime" :disabled="currentStep !== 0" clearable format="YYYY-MM" |
| | | placeholder="选择日期" size="small" style="width: 100%" type="month" value-format="YYYY-MM"> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检查日期:" prop="checkTime"> |
| | | <el-date-picker v-if="currentStep === 0" v-model="form.checkTime" clearable format="YYYY-MM-DD" |
| | | placeholder="选择检查日期" size="small" style="width: 100%" type="date" value-format="YYYY-MM-DD" |
| | | @change="resolveAttachmentPlan"> |
| | | </el-date-picker> |
| | | <el-input v-else v-model="form.checkTime" disabled size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="核查指标:" prop="checkIndex"> |
| | | <el-input v-model="form.checkIndex" :disabled="currentStep !== 0" clearable size="small"></el-input> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="管理编号:" prop="deviceNumber"> |
| | | <el-input v-model="form.deviceNumber" disabled size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="核查方法:" prop="checkMethod"> |
| | | <el-input v-model="form.checkMethod" :disabled="currentStep !== 0" clearable size="small" |
| | | type="textarea"></el-input> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="设备型号:" prop="deviceModel"> |
| | | <el-input v-model="form.deviceModel" disabled size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="结果如何判定:" prop="howResults"> |
| | | <el-input v-model="form.howResults" :disabled="currentStep !== 0" clearable size="small" |
| | | type="textarea"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="核查责任人:" prop="checkChargerUserId"> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="核查人:" prop="checkChargerUserId"> |
| | | <el-select v-if="currentStep === 0" v-model="form.checkChargerUserId" clearable filterable |
| | | placeholder="请选择" size="small" style="width: 100%" @change="setCheckChargerUser"> |
| | | <el-option v-for="item in chargerOptions" :key="item.id" :label="item.name" |
| | |
| | | </el-select> |
| | | <el-input v-else v-model="form.checkChargerUser" disabled size="small"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | <div class="form-section"> |
| | | <div class="form-section-title">核查内容</div> |
| | | <el-row :gutter="12"> |
| | | <el-col :span="8"> |
| | | <el-form-item label="环境温湿度:" prop="environment"> |
| | | <el-input v-model="form.environment" :disabled="currentStep !== 0" clearable size="small" |
| | | placeholder="如:25℃ / 50%RH"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="核查依据:" prop="checkBasis"> |
| | | <el-input v-model="form.checkBasis" :disabled="currentStep !== 0" clearable size="small"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="核查指标:" prop="checkIndex"> |
| | | <el-input v-model="form.checkIndex" :disabled="currentStep !== 0" clearable size="small"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="核查方式:" prop="checkMethod"> |
| | | <el-input v-model="form.checkMethod" :disabled="currentStep !== 0" clearable :rows="2" size="small" |
| | | type="textarea"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="结果如何判定:" prop="howResults"> |
| | | <el-input v-model="form.howResults" :disabled="currentStep !== 0" clearable :rows="2" size="small" |
| | | type="textarea"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="外观情况:"> |
| | | <el-radio-group v-model="form.appearanceStatus" :disabled="currentStep !== 0"> |
| | | <el-radio value="良好">良好</el-radio> |
| | | <el-radio value="一般">一般</el-radio> |
| | | <el-radio value="损坏">损坏</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="运行状态:"> |
| | | <el-radio-group v-model="form.runningStatus" :disabled="currentStep !== 0"> |
| | | <el-radio value="正常">正常</el-radio> |
| | | <el-radio value="异常">异常</el-radio> |
| | | <el-radio value="停机">停机</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="备注:" prop="remark"> |
| | | <el-input v-model="form.remark" :disabled="currentStep !== 0" clearable size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="附件:"> |
| | | <el-upload v-if="currentStep === 0" :action="javaApi + '/deviceScope/uploadFile'" :headers="uploadHeader" |
| | | :limit="1" :on-exceed="handleUploadExceed" :before-upload="beforeAttachmentUpload" |
| | | :on-success="handleAttachmentSuccess" :on-remove="handleAttachmentRemove"> |
| | | <el-button size="small" type="primary">选择附件</el-button> |
| | | </el-upload> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | <div class="form-section"> |
| | | <div class="form-section-title">附件资料</div> |
| | | <el-form-item label-width="0"> |
| | | <lims-attachment ref="recordAttachment" inline upload-url="/deviceExaminePlan/uploadAttachment" |
| | | select-url="/deviceExaminePlan/selectAttachments" delete-url="/deviceExaminePlan/deleteAttachment" |
| | | id-param="planDetailsId" name-field="deviceName" title="核查记录附件" |
| | | :main-id="form.planDetailsId" :readonly="currentStep === 1" |
| | | :defer-upload="currentStep === 0" :tip="attachmentTip"></lims-attachment> |
| | | <el-link v-if="form.fileUrl" type="primary" @click="openAttachment"> |
| | | {{ form.fileName || '查看附件' }} |
| | | {{ form.fileName || '查看原附件' }} |
| | | </el-link> |
| | | <span v-else-if="currentStep !== 0">—</span> |
| | | </el-form-item> |
| | | </div> |
| | | </el-form> |
| | | <template #footer><span class="dialog-footer"> |
| | | <el-button @click="resetForm">取 消</el-button> |
| | |
| | | addExamineRecord, |
| | | reviewExamineRecord, |
| | | deviceScopeSearch, |
| | | findExaminePlanDetail, |
| | | resolveExaminePlanDetail, |
| | | updateDeviceExaminePlanDetail, |
| | | } from '@/api/cnas/resourceDemand/device.js' |
| | | import { selectUserCondition } from "@/api/performance/class"; |
| | | import draftSave from '@/mixins/draftSave' |
| | | import LimsAttachment from '@/components/Attachment/lims-attachment.vue' |
| | | |
| | | const createEmptyForm = () => ({ |
| | | deviceId: '', |
| | | deviceName: '', |
| | | deviceNumber: '', |
| | | deviceModel: '', |
| | | checkTime: '', |
| | | checkIndex: '', |
| | | checkMethod: '', |
| | | howResults: '', |
| | | checkChargerUserId: '', |
| | | checkChargerUser: '', |
| | | environment: '', |
| | | checkBasis: '', |
| | | appearanceStatus: '', |
| | | runningStatus: '', |
| | | remark: '', |
| | | fileName: '', |
| | | fileUrl: '', |
| | |
| | | }) |
| | | export default { |
| | | name: "check-record", |
| | | mixins: [draftSave], |
| | | components: { LimsAttachment }, |
| | | data() { |
| | | // 这里存放数据 |
| | | return { |
| | |
| | | submitFormLoading: false, |
| | | userList: [], |
| | | rules: { |
| | | checkMethod: [{ required: true, message: '请填写核查方法', trigger: 'blur' }], |
| | | checkMethod: [{ required: true, message: '请填写核查方式', trigger: 'blur' }], |
| | | }, |
| | | } |
| | | }, |
| | |
| | | deviceId: row.deviceId || '', |
| | | deviceName: row.deviceName || '', |
| | | deviceNumber: row.deviceNumber || '', |
| | | checkTime: (row.checkTime || '').substring(0, 7), |
| | | deviceModel: row.deviceModel || '', |
| | | checkTime: row.checkTime || '', |
| | | checkIndex: row.checkIndex || '', |
| | | checkMethod: row.checkMethod || '', |
| | | howResults: row.howResults || '', |
| | | checkChargerUserId: row.checkChargerUserId || '', |
| | | checkChargerUser: row.checkChargerUser || '', |
| | | environment: row.environment || '', |
| | | checkBasis: row.checkBasis || '', |
| | | appearanceStatus: row.appearanceStatus || '', |
| | | runningStatus: row.runningStatus || '', |
| | | remark: row.remark || '', |
| | | fileName: row.fileName || '', |
| | | fileUrl: row.fileUrl || '', |
| | |
| | | this.form = createEmptyForm() |
| | | this.selectedDeviceId = '' |
| | | const now = new Date() |
| | | this.form.checkTime = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') |
| | | this.form.checkTime = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') |
| | | this.getEquipOptions() |
| | | this.getUserList() |
| | | this.$nextTick(() => { |
| | | if (this.$refs.recordForm) { |
| | | this.$refs.recordForm.clearValidate() |
| | | } |
| | | this.draftRestore('checkRecordForm', 'form', 'new', 'dialogVisible') |
| | | if (this.form.deviceId) { |
| | | this.selectedDeviceId = this.form.deviceId |
| | | } |
| | | this.resolveAttachmentPlan() |
| | | }) |
| | | }, |
| | | // 按设备 id 回填名称和编号,避免同名设备选错 |
| | |
| | | this.form.deviceId = item.id |
| | | this.form.deviceName = item.deviceName |
| | | this.form.deviceNumber = item.managementNumber |
| | | this.form.deviceModel = item.specificationModel || '' |
| | | } else { |
| | | this.form.deviceId = '' |
| | | this.form.deviceName = '' |
| | | this.form.deviceNumber = '' |
| | | this.form.deviceModel = '' |
| | | } |
| | | this.resolveAttachmentPlan() |
| | | }, |
| | | setCheckChargerUser(value) { |
| | | const item = this.userList.find(user => user.id === value) |
| | |
| | | if (this.form.howResults) params.howResults = this.form.howResults |
| | | if (this.form.checkChargerUserId) params.checkChargerUserId = this.form.checkChargerUserId |
| | | if (this.form.checkChargerUser) params.checkChargerUser = this.form.checkChargerUser |
| | | if (this.form.deviceModel) params.deviceModel = this.form.deviceModel |
| | | params.environment = this.form.environment || '' |
| | | params.checkBasis = this.form.checkBasis || '' |
| | | params.appearanceStatus = this.form.appearanceStatus || '' |
| | | params.runningStatus = this.form.runningStatus || '' |
| | | if (this.form.remark) params.remark = this.form.remark |
| | | if (this.form.fileName) params.fileName = this.form.fileName |
| | | if (this.form.fileUrl) params.fileUrl = this.form.fileUrl |
| | | // 附件先暂存在页面上,确认提交时再连同核查记录一起保存,取消则什么都不留 |
| | | const attachmentRef = this.$refs.recordAttachment |
| | | const flushPending = attachmentRef ? attachmentRef.flushPending(planDetailsId) : Promise.resolve() |
| | | flushPending.then(() => { |
| | | updateDeviceExaminePlanDetail(params).then(res => { |
| | | if (res.code !== 200) { |
| | | this.$message.error(res.msg || '保存核查记录失败') |
| | |
| | | addExamineRecord({ planDetailsId }).then(recordRes => { |
| | | if (recordRes.code == 200) { |
| | | this.$message.success('核查记录已提交,等待审核') |
| | | this.draftClear('checkRecordForm') |
| | | this.resetForm() |
| | | } else { |
| | | this.$message.error(recordRes.msg || '提交核查记录失败') |
| | |
| | | this.submitFormLoading = false |
| | | }) |
| | | }).catch(() => { |
| | | this.submitFormLoading = false |
| | | }) |
| | | }).catch(() => { |
| | | // 上传失败的具体原因由 request 拦截器统一提示 |
| | | this.submitFormLoading = false |
| | | }) |
| | | }, |
| | |
| | | reviewExamineRecord(params).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success(statue === 1 ? '审核通过' : '已退回') |
| | | this.draftClear('checkRecordForm') |
| | | this.resetForm() |
| | | } |
| | | this.submitFormLoading = false |
| | |
| | | }) |
| | | }, |
| | | resetForm() { |
| | | this.draftStop('checkRecordForm') |
| | | this.dialogVisible = false |
| | | this.$emit('closeDialog1') |
| | | }, |
| | |
| | | this.userList = res.data |
| | | }) |
| | | }, |
| | | // 附件 |
| | | beforeAttachmentUpload(file) { |
| | | if (file.size > 1024 * 1024 * 10) { |
| | | this.$message.error('上传文件不超过10M') |
| | | return false |
| | | // 附件内嵌在表单里:设备+日期确定后只查可复用明细,不提前建档,避免取消后留下空记录 |
| | | resolveAttachmentPlan() { |
| | | if (this.currentStep !== 0 || !this.selectedDeviceId || !this.form.checkTime) { |
| | | this.form.planDetailsId = '' |
| | | return |
| | | } |
| | | return true |
| | | }, |
| | | handleUploadExceed() { |
| | | this.$message.warning('仅支持一个附件,请先移除已上传的附件') |
| | | }, |
| | | handleAttachmentSuccess(response) { |
| | | if (response.code == 200) { |
| | | this.form.fileName = response.data.name |
| | | this.form.fileUrl = response.data.url |
| | | this.$message.success('附件上传成功') |
| | | } else { |
| | | this.$message.error(response.msg || '附件上传失败') |
| | | const deviceId = this.selectedDeviceId |
| | | const checkTime = this.form.checkTime |
| | | this.form.planDetailsId = '' |
| | | findExaminePlanDetail({ deviceId, checkTime }).then(res => { |
| | | if (res.code !== 200 || !res.data) { |
| | | return |
| | | } |
| | | // 请求期间用户可能已切换设备或日期,避免回填过期明细 |
| | | if (this.selectedDeviceId === deviceId && this.form.checkTime === checkTime) { |
| | | this.form.planDetailsId = res.data.planDetailsId |
| | | } |
| | | }).catch(() => { |
| | | }) |
| | | }, |
| | | handleAttachmentRemove() { |
| | | this.form.fileName = '' |
| | | this.form.fileUrl = '' |
| | | }, |
| | | // 兼容历史单附件 |
| | | openAttachment() { |
| | | if (!this.form.fileUrl) { |
| | | return |
| | |
| | | }, |
| | | }, |
| | | computed: { |
| | | // 附件不提前上传,选好后随核查记录一起提交保存 |
| | | attachmentTip() { |
| | | return '可直接选择附件,点“确认”时随核查记录一起保存' |
| | | }, |
| | | // 责任人下拉:已保存的责任人不在候选列表时补一条,避免回显成用户ID |
| | | chargerOptions() { |
| | | const list = this.userList || [] |
| | |
| | | }, |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .record-steps { |
| | | margin-bottom: 14px; |
| | | } |
| | | |
| | | .form-section { |
| | | padding: 12px 14px 0; |
| | | border: 1px solid #ebeef5; |
| | | border-radius: 6px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .form-section:last-child { |
| | | margin-bottom: 0; |
| | | } |
| | | |
| | | .form-section-title { |
| | | display: flex; |
| | | align-items: center; |
| | | padding-left: 8px; |
| | | border-left: 3px solid var(--el-color-primary); |
| | | margin-bottom: 12px; |
| | | font-size: 14px; |
| | | font-weight: 600; |
| | | line-height: 1; |
| | | color: #303133; |
| | | } |
| | | |
| | | .form-section :deep(.el-form-item) { |
| | | margin-bottom: 12px; |
| | | } |
| | | </style> |