<BaseTable ref="baseTable"
:table-url='tableUrl'
:auto-search-flag="true"
:search-options='searchOptions'
:columns='columns'
:slot-columns="slotColumns"
:call-style='callStyle'
:table-event-btn='eventBtnList'>
<template #file='{ row }'>
<el-button v-if='row.file' type="primary" link @click='reportViewHandler(row)'>查看</el-button>
<el-button v-else link>未上传</el-button>
</template>
<template #think='{ row }'>
<el-button v-if='row.think' type="primary" link @click='thinkViewHandler(row)'>查看</el-button>
<el-button v-else link>未上传</el-button>
</template>
<template #eventType="{row}">
{{formatListByKey(eventType,row.eventType)}}
</template>
<template #maintenanceStatus="{row}">
{{formatListByKey(maintenanceStatus,row.maintenanceStatus)}}
</template>
<template #isoVersion="{row}">
{{ row.event.isoFileVersion?row.event.isoFileVersion:'--' }}
</template>
<template #executeTime="{row}">
{{ row.executeTime }} ~ {{ row.executeEndTime }}
</template>
<template #approvedStatus="{row}">
<el-tag effect="dark" v-if='row.approvedStatus === "0"'>未审核</el-tag>
<el-tag effect="dark" v-if='row.approvedStatus === "1"' type="success">审核通过</el-tag>
<el-tag effect="dark" v-if='row.approvedStatus === "2"' type="danger">审核驳回</el-tag>
</template>
<template #action="{row}">
<el-button style='margin: 1px;' type="primary" link size="small" @click="handleDetailMethod(row)">查看</el-button>
<el-button style='margin: 1px;' type="primary" link size="small" @click="handleApprovedMethod(row)" v-if='row.approvedStatus === "0"' v-hasPermi='["qa:history:approved"]'>审核</el-button>
<el-button style='margin: 1px;' type="primary" link size="small" @click="handleUpdateMethod(row)" v-hasPermi='["device:history:edit"]' class="mr10">编辑</el-button>
<el-popconfirm title="Are you sure to delete this?"
@confirm="handleDeleteMethod(row)">
<template #reference>
<el-button style='margin: 1px;' link type="danger" size="small" v-hasPermi='["device:history:del:admin"]' class="mr10">删除</el-button>
</template>
</el-popconfirm>
<el-upload :show-file-list="false" style='display: inline-block'
:action="actionUrl" :http-request="httpRequest">
<el-button link style='margin: 1px;' v-if="row.maintenanceStatus === '2'" type="success" size="small" @click="beforeUpload(row)" v-hasPermi='["device:history:edit"]'>重新导入</el-button>
</el-upload>
<el-button style='margin: 1px;' link type="primary" size="small" @click="handleReportMethod(row)">提交报告</el-button>
<el-button style='margin: 1px;' link type="primary" size="small" @click="handleThinkMethod(row)">提交改进与思考</el-button>
<el-popconfirm title="确定要发送催办邮件吗?"
@confirm="remind(row)">
<template #reference>
<el-button v-if='row.approvedStatus === "2"' style='margin: 1px;' link type="primary" size="small" v-hasPermi='["qa:history:remind"]'>催办</el-button>
</template>
</el-popconfirm>
</template>
</BaseTable>
<el-dialog v-model="reportFormDialog.dialogVisible" :title="reportFormDialog.title" width="40%" class='form-dialog' @close="handleCloseReportFormDialog" style='border-radius: 5px;'>
<BaseForm ref='baseReportForm' v-if='reportFormDialog.dialogVisible'
:form-options='reportFormDialog.formOptions'
:form-modal='reportFormDialog.formModal'
:form-rules='reportFormDialog.formRules'
@resolve-params='getReportFormDialogParams'
>
</BaseForm>
<template #footer>
<el-button @click="handleCloseReportFormDialog">取消</el-button>
<el-button type="primary" @click="handleSubmitReportFormDialog">保存</el-button>
</template>
</el-dialog>
<el-dialog v-model="thinkFormDialog.dialogVisible" :title="thinkFormDialog.title" width="60%" class='form-dialog' @close="handleCloseThinkFormDialog" style='border-radius: 5px;'>
<BaseForm ref='baseThinkForm' v-if='thinkFormDialog.dialogVisible'
:form-options='thinkFormDialog.formOptions'
:form-modal='thinkFormDialog.formModal'
:form-rules='thinkFormDialog.formRules'
@resolve-params='getThinkFormDialogParams'
>
</BaseForm>
<template #footer>
<el-button @click="handleCloseThinkFormDialog">取消</el-button>
<el-button type="primary" @click="handleSubmitThinkFormDialog">保存</el-button>
</template>
</el-dialog>
<el-dialog v-model="unGeneraldetailDialog.dialogVisible" :title="unGeneraldetailDialog.title" width="60%" class='form-dialog' style='border-radius: 5px;' @close="unGeneraldetailDialog.dialogVisible = false">
<detail-view v-if="unGeneraldetailDialog.dialogVisible" ref="detailViewUnGeneral" :detail-dialog="unGeneraldetailDialog"></detail-view>
</el-dialog>
<el-dialog v-model="detailDialog.dialogVisible" :title="detailDialog.title" width="60%" class='form-dialog' @close="handleCancelDetail" style='border-radius: 5px;'>
<detail-view v-if="detailDialog.dialogVisible" ref="detailView" :detail-dialog="detailDialog"></detail-view>
</el-dialog>
<el-dialog v-model="formDialog.dialogVisible" :title="formDialog.title" width="40%" @close="handleCloseFormDialog" class='form-dialog' style='border-radius: 5px;'>
<BaseForm ref='baseForm' v-if='formDialog.dialogVisible'
:form-options='formDialog.formOptions'
:form-modal='formDialog.formModal'
:form-rules='formDialog.formRules'
@resolve-params='getFormDialogParams'
>
</BaseForm>
<template #footer v-if='formDialog.type != "info"'>
<el-button @click="handleCloseFormDialog">取消</el-button>
<el-button type="primary" @click="handleSubmitFormDialog">保存</el-button>
</template>
</el-dialog>
<el-dialog v-model="approvedDialog.dialogFormVisible" title="PM历史审核" width='500px' style='border-radius: 5px;'>
<el-form :model="approvedDialog.form" status-icon ref="ruleFormRef" :rules="approvedDialog.rules">
<el-form-item label="审核状态:" prop='status'>
<el-select v-model="approvedDialog.form.status" style='width: 100%' placeholder="Please select a status">
<el-option label="审核通过" value="1" />
<el-option label="审核驳回" value="2" />
</el-select>
</el-form-item>
<el-form-item label="审核意见:" prop='advise'>
<el-input type='textarea' :autosize="{ minRows: 2, maxRows: 4 }" v-model="approvedDialog.form.advise" autocomplete="off" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="approvedDialog.dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="approvedConfirm">
确定
</el-button>
</template>
</el-dialog>
<el-dialog v-model="thinkView.thinkViewFlag" title="思考&改进" width="40%" style='border-radius: 5px;'>
<Divider title='思考&改进' style='margin-bottom: 15px;'></Divider>
<Divider title='附件' style='margin-bottom: 15px;'></Divider>
<el-link :href="`${baseUrl}${item}`" :underline="true" target="_blank">
{{ getFileName(item) }}
</el-link>
</el-dialog>
<el-dialog v-model="reportView.reportViewFlag" title="报告" width="80%">
<Divider title="PM CheckList 报告" style="margin-bottom: 15px;"></Divider>
<el-link :href="`${baseUrl}${item}`" :underline="true" target="_blank">
{{ getFileName(item) }}
</el-link>
<Divider title="PM 验证报告" style="margin-bottom: 15px;"></Divider>
<el-link :href="`${baseUrl}${item}`" :underline="true" target="_blank">
{{ getFileName(item) }}
</el-link>
<el-table :data="tableData" style="width: 100%">
<el-table-column v-for="col in columns" :key="col.key" :prop="col.key" :label="col.label"></el-table-column>
</el-table>
{{ reportView.formModel.createBy }}:{{ reportView.formModel.uploadTime }}
</el-dialog>
</template>
<script setup lang="ts" name="ExecuteHistory">
import Divider from '@/views/pms/tool-modules/divider.vue';
const baseUrl = import.meta.env.VITE_APP_BASE_API;
import {cloneDeep as _cloneDeep} from "lodash";
import { searchOptionsInterface } from '@/components/BaseTable/modules/interface';
import { downloadBlobFile, formatListByKey, getObjectKeys } from '@/utils/ruoyi';
import {
eventType,
getEventTypeList,
getMaintenanceStatus, getPeriodsUnitList,
intervalType,
maintenanceStatus
} from "@/views/pms/common/variable";
import {getEqpId} from "@/api/pms/check-list";
import { importMaintenanceById, updateMaintenanceInHis, approved, delById, exportHis, remindHis } from '@/api/pms/execute';
import {ElMessage} from "element-plus";
import {ComponentInternalInstance, getCurrentInstance} from "vue";
import DetailView from "@/views/pms/common/modules/detail-view.vue";
import {getEqpIdByEqpArea} from "@/api/pms/eqp";
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { saveReport,saveThink } from '@/api/pms/file'
const columns = ref([
// { type: 'checkbox',width:60,field:'eventType'},
{ field: 'eventType', title: '类型',slots:{default:'eventType'},width: 100,fixed:'left'},
{ field: 'eqpId', title: '机台ID',width: 100,fixed:'left'},
{ field: 'eqpType', title: '机台型号',width: 100,fixed:'left'},
{ field: 'maintenanceStatus', title: '状态',slots:{default:'maintenanceStatus'},width: 80,fixed:'left'},
{ field: 'lastExeDate', title: '上次实际执行时间',width: 150,fixed:'left'},
{ field: 'maintenanceTime', title: '计划执行时间',width: 150},
{ field: 'executeTime', title: '实际执行时间',width: 280,slots:{default:'executeTime'}},
// { field: 'executeEndTime', title: '实际完成时间',width: 150},
{ field: 'realityPeopleNum', title: '实际人力',width: 100},
{ field: 'nextMaintenanceTime', title: '预计下次执行时间',width: 150},
{ field: 'approvedStatus', title: '审核状态',slots: {default: 'approvedStatus'},width: 100},
{ field: 'approvedAdvice', title: '审核意见',width: 100},
{ field: 'approvedUser', title: '审核人',width: 100},
{ field: 'event.isoFileVersion', title: 'ISO版本',slots: {default: 'isoVersion'},width: 100},
{ field: 'file', title: 'CheckItem报告&PM验证报告',slots: {default: 'file'},width: 200},
{ field: 'think', title: '思考&改进',slots: {default: 'think'},width: 120},
{ field: 'maintenanceRemark', title: '备注',width: 100},
{ field: 'action', title: '操作栏',slots:{default: 'action'},width:240,fixed:'right'},
])
const searchOptions = ref([
{field:'eqpArea',title:'机台区域',type:'select',options:[],optionType:1,handle:changeEqpArea},
{field:'eqpId',title:'机台Id',type:'select',options:[],optionType:1,handle:changeEqpId },
{field:'startTime',title:'开始时间',type:'date' },
{field:'endTime',title:'结束时间',type:'date' },
{field:'approvedStatus',title:'审核状态',type:'select',
options:[{label:'审核通过',value:'1'},{label:'驳回',value:'2'},{label:'未审核',value:'0'}],
optionFormatter:{ label:'label' , value:'value' },labelType:1 },
{field:'eventType',title:'类型',type:'select',options:eventType,optionType:2,labelType:1,optionFormatter:{ label:'label' , value:'value' }},
{field:'maintenanceStatus',title:'状态',type:'select',options:maintenanceStatus,optionType:2,labelType:1,optionFormatter:{ label:'label' , value:'value' }},
{field:'id',title:'ID',type:'input' },
])
const tableUrl = ref('/maintenance/eqpId/his')
const slotColumns = ref(['action','eventType','maintenanceStatus','approvedStatus','isoVersion','file','think','executeTime'])
let formDialog = reactive({
dialogVisible: false,
title: '',
type:'',
formOptions: [
{ name: '实际执行时间', field: 'executeTime', type: 'dateTime',col: 24 },
{ name: '实际完成时间', field: 'executeEndTime', type: 'dateTime',col: 24 },
{ name: '实际人力', field: 'realityPeopleNum', type: 'input',col: 24 },
{ name: '备注', field: 'maintenanceRemark', type: 'textarea',col: 24 },
],
formModal:{
id:'',
executeTime:'',
executeEndTime:'',
realityPeopleNum:'',
maintenanceRemark:'',
},
formRules: {},
})
function exportHandler(){
let params = proxy.$refs.baseTable.getSearchParams()
exportHis(params).then(res =>{
if(res){
let fileName = moment().format('YYYY-MM-DD') + '_保养历史.xlsx'
downloadBlobFile(res,fileName)
}
})
}
const eventBtnList = ref([
{ name: '导出', handle:exportHandler , type: 'primary' },
]);
/** 报告 report */
let reportFormDialog = reactive({
dialogVisible: false,
title: '',
formOptions: [
{ name: 'PMCheckList报告', field: 'checkListFilePath', type: 'file',col: 24 },
{ name: 'PM验证报告', field: 'pmReportFilePath', type: 'file',col: 24, },
{ name: '备注', field: 'remark', type: 'textarea',col: 24 },
],
formModal:{
maintenanceId:'',
checkListFilePath:'',
pmReportFilePath:'',
remark:'',
},
formRules: {},
})
let thinkFormDialog = reactive({
dialogVisible: false,
title: '',
formOptions: [
{ name: '思考&改进', field: 'content', type: 'edit',col: 24 },
{ name: '附件', field: 'filePath', type: 'file',col: 24, },
{ name: '备注', field: 'remark', type: 'textarea',col: 24 },
],
formModal:{
maintenanceId:'',
content:'',
filePath:'',
remark:'',
},
formRules: {},
})
let unGeneraldetailDialog = reactive({
dialogVisible: false,
title: '',
type:'',
formOptions: [
{ name: '保养时间', field: 'schedulingStartTime', type: 'dateTime',col: 24 },
{ name: '负责人', field: 'schedulingUser', type: 'input',col: 24 },
{ name: 'email', field: 'email', type: 'textarea',col: 24 },
{ name: '标准作业时间', field: 'jobTime', type: 'input',col: 24 },
{ name: '标准人力', field: 'jobPeopleNum', type: 'input',col: 24 },
/* { name: '保养周期', field: 'schedulingPeriods', type: 'input',col: 24 },
{ name: '保养周期类型', field: 'schedulingPeriodsUnit', type: 'select',col: 24,options:intervalType },*/
{ name: 'PM原因', field: 'schedulingDes', type: 'input',col: 24 },
{ name: '提前通知时间/H', field: 'schedulingNoticeBeforeTime', type: 'input',col: 24 },
{ name: '延后通知时间/H', field: 'schedulingNoticeAfterTime', type: 'input',col: 24 }
],
formModal:{
id:'',
schedulingStartTime:'',
schedulingUser:'',
email:'',
jobTime:'',
jobPeopleNum:'',
schedulingDes:'',
/* schedulingPeriods:'',
schedulingPeriodsUnit:'',*/
schedulingNoticeBeforeTime:'',
schedulingNoticeAfterTime:'',
},
formRules: {},
activeName:'first',
currentRow:null
})
let detailDialog = reactive({
dialogVisible: false,
title: '',
type:'',
formOptions: [
{ name: '第一次保养时间', field: 'schedulingStartTime', type: 'dateTime',col: 24 },
{ name: '负责人', field: 'schedulingUser', type: 'input',col: 24 },
{ name: 'email', field: 'email', type: 'textarea',col: 24 },
{ name: '标准作业时间', field: 'jobTime', type: 'input',col: 24 },
{ name: '标准人力', field: 'jobPeopleNum', type: 'input',col: 24 },
{ name: '保养周期', field: 'schedulingPeriods', type: 'input',col: 24 },
{ name: '保养周期类型', field: 'schedulingPeriodsUnit', type: 'select',col: 24,options:intervalType },
{ name: '提前通知时间/H', field: 'schedulingNoticeBeforeTime', type: 'input',col: 24 },
{ name: '延后通知时间/H', field: 'schedulingNoticeAfterTime', type: 'input',col: 24 }
],
formModal:{
id:'',
schedulingStartTime:'',
schedulingUser:'',
email:'',
jobTime:'',
jobPeopleNum:'',
schedulingPeriods:'',
schedulingPeriodsUnit:'',
schedulingNoticeBeforeTime:'',
schedulingNoticeAfterTime:'',
},
formRules: {},
activeName:'first',
currentRow:null
})
const resetDetailDialog = _cloneDeep(detailDialog)
const resetFormDialog = _cloneDeep(formDialog)
const actionUrl = ref('')
const currentRow = ref('')
const eqpAreaMap = ref(null)
let approvedDialog = reactive({
form:{
status:"",
advise:"",
maintenanceId:""
},
rules:{
status: [
{ required: true, message: '选择审核状态', trigger: 'blur' },
],
advise: [
{ required: true, message: '输入审核意见', trigger: 'blur' },
],
},
dialogFormVisible:false
})
import { useRouter } from 'vue-router';
import moment from 'moment';
const route = useRouter()
watch(() => route.currentRoute.value,(newValue) => {
if (newValue.query){
searchOptions.value[7].value = newValue.query.id
nextTick(() =>{
proxy.$refs.baseTable.getTableList()
})
}
},{immediate:true,deep:true} )
watch(()=> approvedDialog.form.status,(newValue,oldValue) => {
if (newValue === '1'){
approvedDialog.form.advise = '审核通过'
}
if (newValue === '2'){
approvedDialog.form.advise = ''
}
},{immediate:true,deep:true})
getEqpIdList()
getEventTypeList()
getMaintenanceStatus()
getPeriodsUnitList()
getEqpAreaAndEqp()
function getEqpAreaAndEqp(){
getEqpIdByEqpArea().then(response => {
if(response.code === 200){
eqpAreaMap.value = response.data
setOptions(searchOptions.value,'eqpArea',Object.keys(response.data))
}else{
ElMessage.error(response.msg)
}
})
}
function callStyle({ row,column}){
if (row.approvedStatus === '2'){
return { background: 'rgba(238, 180, 180,.3)'}
}
if (row.approvedStatus === '1'){
return { background: 'rgba(155, 205, 155,.3)'}
}
}
function changeEqpArea(value){
setOptions(searchOptions.value,'eqpId',eqpAreaMap.value[value])
}
function handleCancelDetail(){
type formType = keyof typeof resetDetailDialog;
getObjectKeys(resetDetailDialog).forEach(<K extends formType>(item: K)=>{
detailDialog[item] = _cloneDeep(resetDetailDialog[item])
})
}
function handleApprovedMethod(row){
approvedDialog.form.maintenanceId = row.id
approvedDialog.form.status = ''
approvedDialog.form.advise = ''
approvedDialog.dialogFormVisible = true
}
function approvedConfirm() {
proxy.$refs.ruleFormRef.validate(vali =>{
if (vali){
approved(approvedDialog.form).then(res => {
if (res.code === 200){
approvedDialog.dialogFormVisible = false
proxy.$refs.baseTable.getTableList()
ElMessage.success(res.msg)
}else{
ElMessage.error(res.msg)
}
})
}
})
}
function handleDetailMethod(row){
let type = formatListByKey(eventType.value,row.eventType)
if (type === 'unGeneral'){
unGeneraldetailDialog.dialogVisible = true
unGeneraldetailDialog.title = '详情'
getObjectKeys(unGeneraldetailDialog.formModal).forEach(item=>{
unGeneraldetailDialog.formModal[item] = row.scheduling[item]
})
unGeneraldetailDialog.currentRow = row
}else {
detailDialog.dialogVisible = true
detailDialog.title = '详情'
getObjectKeys(detailDialog.formModal).forEach(item=>{
detailDialog.formModal[item] = row.scheduling[item]
})
detailDialog.currentRow = row
}
}
function beforeUpload(row){
currentRow.value = row
}
function httpRequest({file}){
let formData = new FormData()
formData.append('file',file)
formData.append('id',currentRow.value.id)
importMaintenanceById(formData).then(response=>{
if(response.code === 200){
proxy.$refs.baseTable.getTableList()
}else{
ElMessage.error(response.msg)
}
})
}
function changeEqpId(){
proxy.$refs.baseTable.getTableList()
}
// 向初始条件的options里添加值
function setOptions(list: Array<searchOptionsInterface>,name:string,options:Array<any>){
let result = list.find((item)=>item.field === name)
if(result){
result.options = options
}
}
function getFormDialogParams(){
updateMaintenanceInHis(formDialog.formModal).then(res =>{
if(res.code === 200){
ElMessage.success(res.msg)
handleCloseFormDialog()
proxy.$refs.baseTable.getTableList()
}else{
ElMessage.error(res.msg)
}
})
}
function handleSubmitFormDialog(){
proxy.$refs.baseForm.getFormParams()
}
function handleCloseFormDialog(){
type formType = keyof typeof resetFormDialog;
getObjectKeys(resetFormDialog).forEach(<K extends formType>(item: K)=>{
formDialog[item] = _cloneDeep(resetFormDialog[item])
})
}
function handleUpdateMethod(row){
setOptions(formDialog.formOptions,'maintenanceStatus',maintenanceStatus.value)
formDialog.dialogVisible = true
formDialog.title = '修改信息'
getObjectKeys(formDialog.formModal).forEach(item=>{
formDialog.formModal[item] = row[item]
})
}
function handleDeleteMethod(row) {
delById(row.id).then(res =>{
if (res.data){
ElMessage.success('操作成功')
proxy.$refs.baseTable.getTableList()
}
})
}
function getEqpIdList(){
getEqpId({pageSize:9999,pageNum:1}).then(res =>{
if(res.code === 200){
setOptions(searchOptions.value,'eqpId',res.rows.map((item:{eqpId:string})=>item.eqpId))
}
})
}
function handleReportMethod(row) {
let { file } = row
reportFormDialog.formModal = { ... file}
reportFormDialog.formModal.maintenanceId = row.id
reportFormDialog.dialogVisible = true
reportFormDialog.title = '新增/修改报告'
}
function handleThinkMethod(row) {
let { think } = row
thinkFormDialog.formModal = {... think }
thinkFormDialog.formModal.maintenanceId = row.id
thinkFormDialog.dialogVisible = true
}
function getReportFormDialogParams() {
saveReport(reportFormDialog.formModal).then(res =>{
ElMessage.success(res.msg)
handleCloseReportFormDialog()
proxy.$refs.baseTable.getTableList()
})
}
function getThinkFormDialogParams(){
saveThink(thinkFormDialog.formModal).then(res =>{
ElMessage.success(res.msg)
handleCloseThinkFormDialog()
proxy.$refs.baseTable.getTableList()
})
}
function handleCloseReportFormDialog() {
reportFormDialog.dialogVisible = false
}
function handleCloseThinkFormDialog(){
thinkFormDialog.dialogVisible = false
}
function handleSubmitReportFormDialog() {
proxy.$refs.baseReportForm.getFormParams()
}
function handleSubmitThinkFormDialog() {
proxy.$refs.baseThinkForm.getFormParams()
}
function getFileName(name: any) {
if (name.lastIndexOf('/') > -1) {
return name.slice(name.lastIndexOf('/') + 1);
} else {
return '';
}
}
function remind(row) {
console.log(row)
remindHis(row).then(res => {
if (res.code === 200) {
ElMessage.success(res.msg)
} else {
ElMessage.error(res.msg)
}
});
}
const reportView = reactive({
reportViewFlag:false,
formModel:{
checkListFilePath:'',
pmReportFilePath:'',
createBy:'',
uploadTime:''
}
})
const thinkView = reactive({
thinkViewFlag:false,
formModel:{
content:'',
filePath:'',
createBy:'',
uploadTime:''
}
})
function thinkViewHandler({ think }){
thinkView.thinkViewFlag = true
Object.assign(thinkView.formModel,think)
}
function reportViewHandler({ file }) {
reportView.reportViewFlag = true
Object.assign(reportView.formModel,file)
}
</script>
<style scoped lang="scss">
</style>这是完整代码改为点击PM CheckList 报告和PM 验证报告那个文件才展示xlsx的文件内容