<template>
|
<div>
|
<el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-model="dialogVisible"
|
: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="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"
|
:value="item.id"></el-option>
|
</el-select>
|
<el-input v-else v-model="form.deviceName" disabled size="small"></el-input>
|
</el-form-item>
|
</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-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-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-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"
|
:value="item.id"></el-option>
|
</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-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 || '查看原附件' }}
|
</el-link>
|
</el-form-item>
|
</div>
|
</el-form>
|
<template #footer><span class="dialog-footer">
|
<el-button @click="resetForm">取 消</el-button>
|
<el-button v-if="currentStep === 0" :loading="submitFormLoading" type="primary" @click="submitCheck">确
|
认</el-button>
|
<el-button v-if="currentStep === 1" :loading="submitFormLoading" @click="examine(0)">不通过</el-button>
|
<el-button v-if="currentStep === 1" :loading="submitFormLoading" type="primary" @click="examine(1)">通
|
过</el-button>
|
</span></template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
addExamineRecord,
|
reviewExamineRecord,
|
deviceScopeSearch,
|
findExaminePlanDetail,
|
resolveExaminePlanDetail,
|
updateDeviceExaminePlanDetail,
|
} from '@/api/cnas/resourceDemand/device.js'
|
import { selectUserCondition } from "@/api/performance/class";
|
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: '',
|
planDetailsId: '',
|
})
|
export default {
|
name: "check-record",
|
components: { LimsAttachment },
|
data() {
|
// 这里存放数据
|
return {
|
dialogVisible: false,
|
form: createEmptyForm(),
|
currentStep: 0,
|
equipOptions: [],
|
selectedDeviceId: '',
|
submitFormLoading: false,
|
userList: [],
|
rules: {
|
checkMethod: [{ required: true, message: '请填写核查方式', trigger: 'blur' }],
|
},
|
}
|
},
|
// 方法集合
|
methods: {
|
// 审核已提交的核查记录
|
openDialog(row) {
|
this.dialogVisible = true
|
this.currentStep = 1
|
this.selectedDeviceId = row.deviceId || ''
|
this.form = {
|
deviceId: row.deviceId || '',
|
deviceName: row.deviceName || '',
|
deviceNumber: row.deviceNumber || '',
|
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 || '',
|
planDetailsId: row.planDetailsId,
|
}
|
},
|
// 新增核查记录:自选设备,提交时自动匹配/创建本轮计划明细
|
openAddDialog() {
|
this.dialogVisible = true
|
this.currentStep = 0
|
this.form = createEmptyForm()
|
this.selectedDeviceId = ''
|
const now = new Date()
|
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.resolveAttachmentPlan()
|
})
|
},
|
// 按设备 id 回填名称和编号,避免同名设备选错
|
changeMachineName(value) {
|
const item = this.equipOptions.find(device => device.id === value)
|
if (item) {
|
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)
|
this.form.checkChargerUser = item ? item.name : ''
|
},
|
// 提交核查记录
|
submitCheck() {
|
if (!this.selectedDeviceId) {
|
this.$message.error('请选择设备')
|
return
|
}
|
if (!this.form.checkTime) {
|
this.$message.error('请选择核查时间')
|
return
|
}
|
this.$refs.recordForm.validate(valid => {
|
if (!valid) {
|
return
|
}
|
this.submitFormLoading = true
|
resolveExaminePlanDetail({ deviceId: this.selectedDeviceId, checkTime: this.form.checkTime }).then(res => {
|
if (res.code !== 200) {
|
this.$message.error(res.msg || '获取核查计划失败')
|
this.submitFormLoading = false
|
return
|
}
|
this.saveRecord(res.data.planDetailsId)
|
}).catch(() => {
|
this.submitFormLoading = false
|
})
|
})
|
},
|
saveRecord(planDetailsId) {
|
this.form.planDetailsId = planDetailsId
|
const params = {
|
planDetailsId,
|
deviceId: this.form.deviceId,
|
deviceName: this.form.deviceName,
|
deviceNumber: this.form.deviceNumber,
|
checkTime: this.form.checkTime,
|
}
|
if (this.form.checkIndex) params.checkIndex = this.form.checkIndex
|
if (this.form.checkMethod) params.checkMethod = this.form.checkMethod
|
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 || '保存核查记录失败')
|
this.submitFormLoading = false
|
return
|
}
|
addExamineRecord({ planDetailsId }).then(recordRes => {
|
if (recordRes.code == 200) {
|
this.$message.success('核查记录已提交,等待审核')
|
this.resetForm()
|
} else {
|
this.$message.error(recordRes.msg || '提交核查记录失败')
|
}
|
this.submitFormLoading = false
|
}).catch(() => {
|
this.submitFormLoading = false
|
})
|
}).catch(() => {
|
this.submitFormLoading = false
|
})
|
}).catch(() => {
|
// 上传失败的具体原因由 request 拦截器统一提示
|
this.submitFormLoading = false
|
})
|
},
|
// 提交审核
|
examine(statue) {
|
this.submitFormLoading = true
|
const params = {
|
planDetailsId: this.form.planDetailsId,
|
reviewStatus: statue,
|
}
|
reviewExamineRecord(params).then(res => {
|
if (res.code == 200) {
|
this.$message.success(statue === 1 ? '审核通过' : '已退回')
|
this.resetForm()
|
}
|
this.submitFormLoading = false
|
}).catch(err => {
|
this.submitFormLoading = false
|
})
|
},
|
resetForm() {
|
this.dialogVisible = false
|
this.$emit('closeDialog1')
|
},
|
// 获取所有设备
|
getEquipOptions() {
|
this.equipOptions = []
|
deviceScopeSearch({ status: 0 }).then(res => {
|
if (res.code === 200 && res.data) {
|
this.equipOptions = res.data.map(m => {
|
m.value = m.managementNumber
|
m.label = m.deviceName
|
m.id = m.id
|
return m
|
})
|
}
|
}).catch(error => {
|
console.error(error)
|
})
|
},
|
getUserList() {
|
selectUserCondition({ type: 4 }).then(res => {
|
this.userList = res.data
|
})
|
},
|
// 附件内嵌在表单里:设备+日期确定后只查可复用明细,不提前建档,避免取消后留下空记录
|
resolveAttachmentPlan() {
|
if (this.currentStep !== 0 || !this.selectedDeviceId || !this.form.checkTime) {
|
this.form.planDetailsId = ''
|
return
|
}
|
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(() => {
|
})
|
},
|
// 兼容历史单附件
|
openAttachment() {
|
if (!this.form.fileUrl) {
|
return
|
}
|
const isImage = /\.(jpg|jpeg|png|gif)$/i.test(this.form.fileUrl)
|
window.open(this.javaApi + (isImage ? '/img/' : '/word/') + this.form.fileUrl, '_blank')
|
},
|
},
|
computed: {
|
// 附件不提前上传,选好后随核查记录一起提交保存
|
attachmentTip() {
|
return '可直接选择附件,点“确认”时随核查记录一起保存'
|
},
|
// 责任人下拉:已保存的责任人不在候选列表时补一条,避免回显成用户ID
|
chargerOptions() {
|
const list = this.userList || []
|
const id = this.form.checkChargerUserId
|
if (id && !list.some(item => String(item.id) === String(id))) {
|
return [...list, { id, name: this.form.checkChargerUser || String(id) }]
|
}
|
return list
|
},
|
},
|
}
|
</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>
|