<template>
|
<!-- 设备校准计划-->
|
<div>
|
<div style="margin: 10px 0 14px;">
|
<div class="plan-top">
|
<div class="plan-top-left">
|
<span class="title" style="margin-bottom: 0;">{{ planInfo.planName || (planYear + '年度设备校准计划') }}</span>
|
<el-select v-model="planYear" size="small" style="width: 110px; margin-left: 16px;" @change="handleYearChange">
|
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y"></el-option>
|
</el-select>
|
</div>
|
<div>
|
<el-button size="small" type="primary" @click="loadPlan">刷新</el-button>
|
<el-button size="small" type="primary" :disabled="planInfo.ratifyStatus === 1"
|
@click="tellApprove">批准通知</el-button>
|
<el-button size="small" type="primary"
|
:disabled="planInfo.ratifyStatus === 1 || userId != planInfo.ratifyUserId" @click="handleApprove">批准</el-button>
|
<el-button size="small" type="primary" @click="downLoadPost">导出</el-button>
|
</div>
|
</div>
|
<div class="plan-info-bar">
|
<span>编制人:{{ planInfo.writeName || '—' }}</span>
|
<span>编制日期:{{ planInfo.writeTimeStr || '—' }}</span>
|
<span v-if="planInfo.ratifyStatus === 1">批准状态:<el-tag type="success">批准</el-tag></span>
|
<span v-else-if="planInfo.ratifyStatus === 0">批准状态:<el-tag type="danger">不批准</el-tag></span>
|
<span v-if="planInfo.ratifyRemark">批准内容:{{ planInfo.ratifyRemark }}</span>
|
<span v-if="isRatified && planInfo.ratifyName">批准人:{{ planInfo.ratifyName }}</span>
|
<span v-if="isRatified && planInfo.ratifyTimeStr">批准时间:{{ planInfo.ratifyTimeStr }}</span>
|
</div>
|
</div>
|
<div class="search">
|
<div>
|
<el-form :model="searchForm" ref="searchForm" size="small" :inline="true">
|
<el-form-item label="设备名称及型号" prop="deviceName">
|
<el-input v-model="searchForm.deviceName" clearable @keyup.enter="handleQuery"
|
size="small"></el-input>
|
</el-form-item>
|
<el-form-item label="仪器编号" prop="deviceNumber">
|
<el-input v-model="searchForm.deviceNumber" @keyup.enter="handleQuery" clearable
|
size="small"></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" size="small" @click="handleQuery">查询</el-button>
|
<el-button size="small" @click="reset">重置</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
</div>
|
<div>
|
<el-table ref="yearTableDetailData" v-loading="yearTableDetailDataLoading" :data="yearTableDetailData" border
|
:row-class-name="tableRowClassName" :height="'calc(100vh - 29em)'" style="width: 100% ;">
|
<!-- 表格列 -->
|
<el-table-column align="center" header-align="center" label="序号" prop="prop" type="index"
|
width="70"></el-table-column>
|
<el-table-column label="设备名称及型号" min-width="180" prop="deviceName" show-overflow-tooltip></el-table-column>
|
<el-table-column label="设备数量" min-width="90" prop="deviceAmount"></el-table-column>
|
<el-table-column label="仪器编号" min-width="150" prop="deviceNumber"></el-table-column>
|
<el-table-column label="检定单位" min-width="150" prop="verificationUnit"> </el-table-column>
|
<el-table-column label="检定周期" min-width="100" prop="verificationCycles"></el-table-column>
|
<el-table-column label="最近检定时间" min-width="130" prop="lastDate"
|
:formatter="formatDateCell"></el-table-column>
|
<el-table-column label="本年计划校准时间" min-width="130" prop="planDate"
|
:formatter="formatDateCell"></el-table-column>
|
<el-table-column label="备注" min-width="130" prop="remark"></el-table-column>
|
<!-- 操作按钮 -->
|
<el-table-column align="center" fixed="right" label="操作" min-width="210">
|
<template #default="scope">
|
<el-button size="small" link type="primary" :disabled="!scope.row.deviceId"
|
@click="handleExecute(scope.row)">执行</el-button>
|
<el-button size="small" link type="primary" :disabled="planInfo.ratifyStatus === 1"
|
@click="handleForm('edit', scope.row)">编辑</el-button>
|
<el-button size="small" link type="primary" @click="handleForm('view', scope.row)">查看</el-button>
|
<el-button size="small" link type="danger" :disabled="planInfo.ratifyStatus === 1"
|
@click="deleteFun1(scope.row.planDetailId)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination :current-page="pagination1.current" :page-size="pagination1.size" :page-sizes="[10, 20, 30, 50, 100]"
|
background :total="pagination1.total" layout="->,total, sizes, prev, pager, next, jumper"
|
@size-change="handleSizeChange1" @current-change="handleCurrentChange1">
|
</el-pagination>
|
</div>
|
<el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-model="dialogVisible" title="设备校准计划"
|
width="80%" @close="resetForm">
|
<el-form ref="modelForm" :model="form" :rules="rules" label-width="150px">
|
<el-col :span="12">
|
<el-form-item label="设备名称及型号:" prop="deviceName">
|
<el-input v-model="form.deviceName" :disabled="operationType === 'view'" clearable size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="设备数量:" prop="deviceAmount">
|
<el-input v-model="form.deviceAmount" :disabled="operationType === 'view'" clearable
|
size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="仪器编号:" prop="deviceNumber">
|
<el-input v-model="form.deviceNumber" :disabled="operationType === 'view'" clearable
|
size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="检定单位:" prop="verificationUnit">
|
<el-input v-model="form.verificationUnit" :disabled="operationType === 'view'" clearable
|
size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="检定周期:" prop="verificationCycles">
|
<el-input v-model="form.verificationCycles" :disabled="operationType === 'view'" clearable
|
size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="最近检定时间:" prop="lastDate">
|
<el-date-picker v-model="form.lastDate" :disabled="operationType === 'view'" clearable format="YYYY-MM-DD"
|
placeholder="选择日期" size="small" style="width:100%" type="date" value-format="YYYY-MM-DD">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="本年计划校准时间:" prop="planDate">
|
<el-date-picker v-model="form.planDate" :disabled="operationType === 'view'" clearable format="YYYY-MM-DD"
|
placeholder="选择日期" size="small" style="width:100%" type="date" value-format="YYYY-MM-DD">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="备注:" prop="remark">
|
<el-input v-model="form.remark" :disabled="operationType === 'view'" clearable size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-form>
|
<template #footer><span class="dialog-footer">
|
<el-button @click="resetForm">取 消</el-button>
|
<el-button :loading="submitFormLoading" type="primary" @click="submitForm" v-if="operationType !== 'view'">确
|
认</el-button>
|
</span></template>
|
</el-dialog>
|
<el-dialog v-model="approvalDialog" title="批准" width="30%" @close="approvalDialog = false">
|
<span>
|
批准备注:
|
<el-input v-model="ratifyRemark" type="textarea"></el-input>
|
</span>
|
<template #footer><span class="dialog-footer">
|
<el-button :loading="approvalLoading" @click="handleApproval(0)">不批准</el-button>
|
<el-button :loading="approvalLoading" type="primary" @click="handleApproval(1)">批 准</el-button>
|
</span></template>
|
</el-dialog>
|
<el-dialog v-model="notificationDia" title="提交批准" width="30%" @close="closeNotificationDia">
|
<span style="margin-top: 10px;display: inline-block">
|
请选择批准人:
|
<el-select v-model="ratifyUserId" clearable filterable size="small" style="width: 90%;">
|
<el-option v-for="item in responsibleOptions" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</span>
|
<template #footer><span class="dialog-footer">
|
<el-button :loading="notificationLoading" @click="closeNotificationDia">取 消</el-button>
|
<el-button :loading="notificationLoading" type="primary" @click="notification">提 交</el-button>
|
</span></template>
|
</el-dialog>
|
<!-- 添加/查看校准记录弹窗 -->
|
<calibration-record-dia ref="calibrationRecordDia" @success="getYearTableDetailData"></calibration-record-dia>
|
</div>
|
</template>
|
|
<script>
|
import CalibrationRecordDia from "./calibrationRecordDia.vue";
|
import {
|
pageDeviceCalibrationPlan,
|
getCalibrationPlanByYear,
|
submiatRatifyDeviceCalibrationPlan,
|
exportDeviceCalibrationPlanDetail,
|
delDeviceCalibrationPlanDetail,
|
pageDeviceCalibrationPlanDetail,
|
updateDeviceCalibrationPlanDetail,
|
ratifyDeviceCalibrationPlan,
|
} from '@/api/cnas/resourceDemand/device.js'
|
import { selectUserCondition } from "@/api/performance/class";
|
import { mapGetters } from "@/utils/store-compat";
|
import { formatDateOnly } from './dateFormat'
|
import { saveBlobOrShowError } from '@/utils/saveBlob'
|
export default {
|
name: "equipment-calibration-plan",
|
// import 引入的组件需要注入到对象中才能使用
|
components: { CalibrationRecordDia },
|
props: {
|
clickNodeVal: {
|
type: Object,
|
default: () => {
|
return {};
|
}
|
}
|
},
|
data() {
|
// 这里存放数据
|
return {
|
planYear: '',
|
yearOptions: [],
|
planInfo: {},
|
dialogVisible: false,
|
searchForm: {
|
deviceName: '',
|
deviceNumber: '',
|
},
|
yearTableDetailData: [],
|
pagination1: {
|
size: 10,
|
current: 1,
|
total: 0,
|
},
|
form: {
|
deviceName: '',
|
deviceAmount: '',
|
deviceNumber: '',
|
verificationUnit: '',
|
verificationCycles: '',
|
lastDate: '',
|
planDate: '',
|
remark: '',
|
planId: '',
|
planDetailId: '',
|
},
|
operationType: '',
|
rules: {
|
deviceNumber: [{ required: true, message: '请填写仪器编号', trigger: 'blur' }],
|
planDate: [{ required: true, message: '请选择日期', trigger: 'change' }],
|
},
|
yearTableDetailDataLoading: false,
|
approvalDialog: false,
|
approvalLoading: false,
|
submitFormLoading: false,
|
ratifyRemark: '',
|
currentRowId: '',
|
responsibleOptions: [],
|
notificationDia: false,
|
notificationLoading: false,
|
ratifyUserId: '',
|
}
|
},
|
mounted() {
|
this.loadYearOptions()
|
},
|
// 方法集合
|
methods: {
|
// 年份下拉选项:已有计划年份 + 当前年份
|
loadYearOptions() {
|
pageDeviceCalibrationPlan({
|
current: 1,
|
size: 99,
|
}).then(res => {
|
let years = []
|
if (res.code == 200) {
|
years = (res.data.records || []).map(r => r.planYear).filter(Boolean)
|
}
|
const currentYear = String(new Date().getFullYear())
|
if (years.indexOf(currentYear) === -1) {
|
years.push(currentYear)
|
}
|
this.yearOptions = [...new Set(years)].sort((a, b) => b.localeCompare(a))
|
this.planYear = currentYear
|
this.loadPlan()
|
})
|
},
|
// 切换年份
|
handleYearChange() {
|
this.pagination1.current = 1
|
this.loadPlan()
|
},
|
// 查询年份计划(不存在自动创建并补全到点明细),随后刷新明细
|
loadPlan() {
|
getCalibrationPlanByYear({ planYear: this.planYear }).then(res => {
|
if (res.code == 200) {
|
this.planInfo = res.data || {}
|
}
|
this.getYearTableDetailData()
|
}).catch(() => {
|
this.planInfo = {}
|
this.yearTableDetailData = []
|
this.pagination1.total = 0
|
this.yearTableDetailDataLoading = false
|
})
|
},
|
// 查询条件变化后从第一页开始查
|
handleQuery() {
|
this.pagination1.current = 1
|
this.getYearTableDetailData()
|
},
|
// 明细-查询
|
getYearTableDetailData() {
|
if (!this.planInfo.planId) {
|
return
|
}
|
this.yearTableDetailDataLoading = true
|
pageDeviceCalibrationPlanDetail({
|
current: this.pagination1.current,
|
size: this.pagination1.size,
|
planId: this.planInfo.planId,
|
deviceName: this.searchForm.deviceName,
|
deviceNumber: this.searchForm.deviceNumber,
|
}).then(res => {
|
if (res.code == 200) {
|
this.yearTableDetailData = res.data.records
|
this.pagination1.total = res.data.total
|
}
|
this.yearTableDetailDataLoading = false
|
}).catch(err => {
|
this.yearTableDetailDataLoading = false
|
})
|
},
|
formatDateCell(row, column, cellValue) {
|
return formatDateOnly(cellValue)
|
},
|
// 到点需校准的行标红
|
tableRowClassName({ row }) {
|
return row.redFlag === 1 ? 'red-row' : ''
|
},
|
reset() {
|
this.searchForm = {
|
deviceName: '',
|
deviceNumber: '',
|
}
|
this.pagination1.current = 1
|
this.getYearTableDetailData()
|
},
|
// 分页
|
handleSizeChange1(val) {
|
this.pagination1.size = val
|
this.getYearTableDetailData()
|
},
|
// 分页
|
handleCurrentChange1(val) {
|
this.pagination1.current = val
|
this.getYearTableDetailData()
|
},
|
// 执行:打开校准记录弹窗录入
|
handleExecute(row) {
|
this.$refs.calibrationRecordDia.open(row.deviceId, 'add')
|
},
|
// 打开明细弹框
|
handleForm(type, row) {
|
this.operationType = type
|
this.dialogVisible = true
|
this.$nextTick(() => {
|
this.form = this.HaveJson(row)
|
})
|
},
|
// 提交表单
|
submitForm() {
|
this.$refs.modelForm.validate(valid => {
|
if (valid) {
|
this.submitFormLoading = true
|
updateDeviceCalibrationPlanDetail(this.form).then(res => {
|
if (res.code == 200) {
|
this.$message.success('修改成功')
|
this.dialogVisible = false
|
this.getYearTableDetailData()
|
}
|
this.submitFormLoading = false
|
}).catch(err => {
|
this.submitFormLoading = false
|
})
|
}
|
})
|
},
|
// 明细-删除
|
deleteFun1(id) {
|
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
delDeviceCalibrationPlanDetail({ planDetailsId: id }).then(res => {
|
this.$message.success('删除成功!');
|
this.getYearTableDetailData()
|
});
|
}).catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
// 打开提交批准弹框
|
tellApprove() {
|
this.getUserList()
|
this.notificationDia = true
|
},
|
// 关闭提交批准弹框
|
closeNotificationDia() {
|
this.notificationDia = false
|
this.ratifyUserId = ''
|
},
|
// 提交批准通知
|
notification() {
|
if (!this.ratifyUserId) {
|
this.$message.warning('请选择批准人')
|
return
|
}
|
this.notificationLoading = true
|
submiatRatifyDeviceCalibrationPlan({
|
ratifyUserId: this.ratifyUserId,
|
planId: this.planInfo.planId,
|
}).then(res => {
|
this.notificationLoading = false
|
if (res.code == 200) {
|
this.closeNotificationDia()
|
this.loadPlan()
|
}
|
}).catch(err => {
|
this.notificationLoading = false
|
})
|
},
|
// 批准
|
handleApprove() {
|
this.currentRowId = this.planInfo.planId
|
this.approvalDialog = true
|
},
|
// 提交批准结果
|
handleApproval(status) {
|
const personTrainingUpdateDto = {
|
planId: this.currentRowId,
|
ratifyRemark: this.ratifyRemark,
|
ratifyStatus: status
|
}
|
this.approvalLoading = true
|
ratifyDeviceCalibrationPlan(personTrainingUpdateDto).then(res => {
|
if (res.code === 200) {
|
this.$message.success('提交成功!');
|
this.approvalDialog = false
|
this.loadPlan()
|
}
|
this.approvalLoading = false
|
}).catch(() => {
|
this.approvalLoading = false
|
})
|
},
|
// 导出
|
downLoadPost() {
|
exportDeviceCalibrationPlanDetail({ planId: this.planInfo.planId }).then(res => {
|
saveBlobOrShowError(res, '设备校准计划.docx', 'application/msword')
|
}).catch(() => { })
|
},
|
resetForm() {
|
this.$refs.modelForm.resetFields();
|
this.dialogVisible = false
|
},
|
// 获取负责人信息接口
|
getUserList() {
|
selectUserCondition().then(res => {
|
if (res.code == 200) {
|
let data = [];
|
res.data.forEach((a) => {
|
data.push({
|
label: a.name,
|
value: a.id,
|
});
|
});
|
this.responsibleOptions = data
|
}
|
});
|
}
|
},
|
computed: {
|
...mapGetters(["userId"]),
|
// 是否已完成审批(批准/不批准)
|
isRatified() {
|
return this.planInfo.ratifyStatus === 0 || this.planInfo.ratifyStatus === 1;
|
},
|
},
|
}
|
</script>
|
|
<style scoped>
|
.title {
|
position: relative;
|
font-size: 16px;
|
color: var(--lims-text);
|
font-weight: 400;
|
padding-left: 10px;
|
margin-bottom: 10px;
|
}
|
|
.title::before {
|
position: absolute;
|
left: 0;
|
top: 4px;
|
content: '';
|
width: 4px;
|
height: 16px;
|
background-color: var(--el-color-primary);
|
border-radius: 2px;
|
}
|
|
.plan-top {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
flex-wrap: wrap;
|
}
|
|
.plan-top-left {
|
display: flex;
|
align-items: center;
|
}
|
|
.plan-info-bar {
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
gap: 32px;
|
background: #f5f7fa;
|
border-radius: 4px;
|
padding: 10px 16px;
|
margin-top: 14px;
|
font-size: 14px;
|
color: #606266;
|
}
|
|
.search {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 10px;
|
}
|
|
:deep(.red-row td) {
|
background: #ffcccc !important;
|
}
|
</style>
|