<!-- 内部审核工作登记表编辑页面 --> <script name="QualityRegistrationHandler" lang="ts" setup> import type { FormInstance, FormRules, UploadUserFile } from 'element-plus' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import dayjs from 'dayjs' import { getDictByCode } from '@/api/system/dict' import useUserStore from '@/store/modules/user' import { getUserList } from '@/api/system/user' import { AGREE, TASKNAME } from '@/views/quality/agree' import { SCHEDULE } from '@/utils/scheduleDict' import { addApprovalUser } from '@/api/system/process' import ApprovalDialog from '@/components/ApprovalCustom/ApprovalDialog.vue' import { UploadFile, getPhotoUrl } from '@/api/file' import { addQualityRegistration, approvalDelete, cancelApproval, delteQualityRegistration, detailQualityRegistration, draftDelete, getRegistrationList, refuseApproval, rejectApproval, submitQualityRegistration, updateQualityRegistration } from '@/api/quality/internal/registration' import selectUser from '@/views/quality/components/selectUser.vue' import { detailWork, getWorkList } from '@/api/quality/internal/workManage' import { valiateWork } from '@/utils/valiateWork' import quality from '/public/config/quality.json' import { filterUser } from '@/views/quality/internal/workManage/components/filterUser' const $props = defineProps({ showInfo: { type: Boolean, default: true, }, }) const $route = useRoute() const $router = useRouter() const userStore = useUserStore() const ruleFormRef = ref<FormInstance>() // from组件 // 当前审批状态名字 const approvalStatusName = $route.query.approvalStatusName as string const ruleForm = ref({ yearTime: '', yearNum: '', fileCode: '', bizLabCode: '', creatorName: '', creatorId: '', createTime: '', id: '', taskId: '', isShow: '', scheduleList: [ { stageType: '1', stageTypeName: '内审组建立', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '2', stageTypeName: '内部审核计划公示', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '3', stageTypeName: '《内部审核检查表》编制', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '4', stageTypeName: '首次会议', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], scheduleFileList: [] as any[], }, { stageType: '5', stageTypeName: '现场审核', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '6', stageTypeName: '内审组内部会议', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], scheduleFileList: [] as any[], }, { stageType: '7', stageTypeName: '交换意见', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '8', stageTypeName: '末次会议', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], scheduleFileList: [] as any[], }, { stageType: '9', stageTypeName: '措施制定', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '10', stageTypeName: '措施实施', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '11', stageTypeName: '效果验证', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, { stageType: '12', stageTypeName: '记录存档', scheduleTime: '', remarks: '', isCompleted: '', // 是否完成(0 未完成 1 完成) scheduleUserList: [] as any[], }, ] as any[], }) // 表单 const decisionItem = ref('') watch( [() => ruleForm.value.yearTime, () => ruleForm.value.yearNum], (newVal, oldVal) => { if (newVal[0] && newVal[1]) { if ($route.query.data) { return } // 获取对应内审工作 getWorkList({ yearTime: '', limit: 1000, offset: 1, status: '1' }).then((res) => { const data = res.data.rows.filter((item: any) => item.workName.includes(`${newVal[0]}年第${newVal[1]}次`)) if (data.length) { ruleForm.value.bizLabCode = data[0].bizLabCode } }) } } , { deep: true, }, ) const hasFileUpload = ['首次会议', '末次会议', '内审组内部会议'] const rules = ref<FormRules>({ yearTime: [{ required: true, message: '年份必选', trigger: ['blur', 'change'] }], yearNum: [{ required: true, message: '月份必选', trigger: ['blur', 'change'] }], bizLabCode: [{ required: true, message: '实验室必选', trigger: ['blur', 'change'] }], }) // 表单验证规则 onMounted(() => { decisionItem.value = $route.query.decisionItem as string if ($route.path.includes('create')) { ruleForm.value.createTime = dayjs().format('YYYY-MM-DD HH:mm') ruleForm.value.creatorId = userStore.id ruleForm.value.creatorName = userStore.name // 自动填充数据 if ($route.query.data) { const data = JSON.parse($route.query.data as string) ruleForm.value.yearNum = data.yearNum ruleForm.value.yearTime = data.yearTime ruleForm.value.bizLabCode = data.bizLabCode } } else { rules.value.fileCode = [{ required: true, message: '文件编号必填', trigger: ['blur', 'change'] }] // 获取详情 detailQualityRegistration({ id: $route.query.id }).then((res) => { console.log(res.data, '详情') ruleForm.value = res.data if (ruleForm.value.scheduleList) { ruleForm.value.scheduleList = ruleForm.value.scheduleList.map((item: any) => { return { ...item, scheduleUserList: item.scheduleUserList.map((citem: any) => citem.userName), } }) } nextTick(() => { ruleFormRef.value?.clearValidate() }) }) } }) const labelList = ref<{ id: string; value: string; name: string }[]>()// 实验室+ const yearList = ref<{ id: string; value: string; name: string }[]>([])// 年度 const monthList = ref<{ id: string; value: string; name: string }[]>([])// 月份 const userList = ref<any[]>([]) // 获取字典值 const fetchDict = async () => { // 获取实验室字典 getDictByCode('bizLabCode').then((res) => { labelList.value = res.data }) // 循环出最近十年的year // 获取当前年份 const year = new Date().getFullYear() + 5 for (let i = year; i > year - 10; i--) { yearList.value?.push({ name: String(i), value: String(i), id: String(i), }) } yearList.value?.reverse() // 月份 for (let i = 1; i < 13; i++) { monthList.value?.push({ name: String(i), value: String(i), id: String(i), }) } // 用户 // getUserList({ offset: 1, limit: 99999 }).then((res) => { // userList.value = res.data.rows.filter((item: any) => item.roleName.includes('组员')) // }) // userList.value = [...await filterUser(quality.roleTips['质量负责人']), ...await filterUser(quality.roleTips['内审组长']), ...await filterUser(quality.roleTips['内审组员'])] userList.value = [...await filterUser(quality.roleTips['内审组员'])] } fetchDict() // ---------------------------------------------保存相关-------------------------------------- const infoId = ref('') const createRow = (data: any) => { addQualityRegistration(data).then((res) => { ElMessage.success('操作成功') infoId.value = res.data }) } const updateRow = (data: any) => { updateQualityRegistration(data).then((res) => { ElMessage.success('操作成功') infoId.value = res.data if (approvalStatusName === '已取消' || approvalStatusName === '未通过') { handleSubmit() } if (approvalStatusName === '全部') { close() } }) } const saveForm = async (formEl: FormInstance | undefined) => { if (!formEl) { return } await formEl.validate(async (valid, fields) => { if (valid) { const ress = await valiateWork(ruleForm.value.yearTime, ruleForm.value.yearNum, ruleForm.value.bizLabCode, '内部审核') if (!ress) { return } const data = { ...ruleForm.value, fileName: `${ruleForm.value.yearTime}年第${ruleForm.value.yearNum}次内部审核工作登记表`, scheduleList: ruleForm.value.scheduleList.map((item: any) => ({ ...item, scheduleUserList: item.scheduleUserList.map((citem: any) => ({ userId: userList.value.filter((ccitem: any) => ccitem.name === citem)[0]?.id, userName: citem, })), })), } // console.log(data, 'data') if ($route.path.includes('create')) { createRow(data) } else if ($route.path.includes('update')) { updateRow(data) } } }) } // ---------------------------------------------审批-------------------------------------- const taskId = ref($route.query.taskId as string || '') // 任务id,用于同意、驳回、拒绝审批 const processId = ref($route.query.processId as string || '') // 流程实例id const approvalDialog = ref() // 审批组件ref const showApprovalButton = ref(true) // 是否展示审批按钮 // 审批结束回调 const approvalSuccess = () => { showApprovalButton.value = false } // 审批 const handleApprove = (val: string) => { if (val === '取消') { const params = { processInstanceId: processId.value!, comments: '', id: ruleForm.value.id, } ElMessageBox.confirm( '确认取消该审批吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ) .then(() => { cancelApproval(params).then((res) => { ElMessage({ type: 'success', message: '已取消', }) showApprovalButton.value = false }) }) } else if (val === '同意') { approvalDialog.value.initDialog('agree', taskId.value, ruleForm.value.id, processId.value) } else if (val === '驳回') { approvalDialog.value.initDialog('reject', taskId.value, ruleForm.value.id, processId.value!) } else if (val === '拒绝') { approvalDialog.value.initDialog('refuse', taskId.value, ruleForm.value.id, processId.value) } } // 拒绝 const refuse = (comments: string, taskId: string, id: string) => { const params = { id, taskId, // 任务id comments, // 拒绝原因 } refuseApproval(params).then((res) => { ElMessage({ type: 'success', message: '已拒绝', }) showApprovalButton.value = false }) } // 驳回 const reject = (comments: string, taskId: string, id: string) => { const param = { id, taskId, // 任务id comments, // 拒绝原因 } rejectApproval(param).then((res) => { if (res.code === 200) { ElMessage.success('已驳回') } else { ElMessage.error(`驳回失败:${res.message}`) } showApprovalButton.value = false }) } // 选择审批人 const userRef = ref() // 点击提交 function handleSubmit() { if (infoId.value || ruleForm.value.id) { // 选择审批人 userRef.value.initDialog() } else { ElMessage.warning('请先保存') } } // 确认审批人 const confirmUser = (data: any) => { // ruleForm.value.assignees = data submitQualityRegistration({ formId: SCHEDULE.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL, // processId: infoId.value, id: infoId.value || ruleForm.value.id, assignees: data, }).then(() => { ElMessage.success('提交成功') // $router.go(-1) close() }) } // 点击提交 // function handleSubmit() { // if (infoId.value || ruleForm.value.id) { // submitQualityRegistration({ // formId: SCHEDULE.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL, // // processId: infoId.value, // id: infoId.value || ruleForm.value.id, // }).then(() => { // ElMessage.success('提交成功') // close() // // getRegistrationList({ // // formId: SCHEDULE.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL, // // limit: 9999, // // offset: 1, // // approvalStatus: '3', // // }).then((res) => { // // const data = res.data.rows[0] // // addApprovalUser({ // // assignees: ['3'], // // processInstanceId: data.processId, // // }) // // }) // }) // } // else { // ElMessage.warning('请先保存') // } // } // 点击编辑 const handleEdit = () => { $router.push({ path: `/internalregistration/update/${ruleForm.value.id}`, query: { ...$route.query }, }) } const del = () => { if (approvalStatusName === '草稿箱') { draftDelete({ id: ruleForm.value.id }).then(() => { ElMessage.success('已删除') close() }) } else if (approvalStatusName === '已取消') { approvalDelete({ id: ruleForm.value.id, taskId: ruleForm.value.taskId }).then(() => { ElMessage.success('已删除') close() }) } else if (approvalStatusName === '全部') { // 全部的删除 delteQualityRegistration({ id: ruleForm.value.id }).then(() => { ElMessage.success('已删除') close() }) } } // 关闭页面 function close() { if ($route.query.data) { $router.go(-1) } else { $router.push({ path: '/internal/internalregistration', }) } } const showMenu = ref('基本信息') defineExpose({ ruleForm, showMenu, }) // 上传附件 const fileRef = ref() // 文件上传input,获取input的引用 const uploadIndex = ref(-1) const onFileChange = (event: any) => { // 原生上传 if (event.target.files?.length !== 0) { const fd = new FormData() fd.append('multipartFile', event.target.files[0]) UploadFile(fd).then((res1) => { fileRef.value.value = '' if (res1.code === 200) { ElMessage.success('上传成功') getPhotoUrl(res1.data[0]).then((res) => { // ruleForm.value.nonReviewFiles.push({ // fileName: res1.data[0], // filePath: res.data, // }) ruleForm.value.scheduleList[uploadIndex.value].scheduleFileList.push({ fileName: res1.data[0], filePath: res.data, }) }) } }) } } // 导入 const importList = (index: number) => { uploadIndex.value = index fileRef.value.click() } // 删除 const closeFile = (index: number, cindex: number) => { ruleForm.value.scheduleList[index].scheduleFileList.splice(cindex, 1) } const { proxy } = getCurrentInstance() as any </script> <template> <app-container style="overflow: hidden;"> <!-- 审批弹窗 --> <approval-dialog ref="approvalDialog" :agree="AGREE.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL" :last-name="TASKNAME.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL" @on-success="approvalSuccess" @refuse="refuse" @reject="reject" :form-id="SCHEDULE.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL" :show-next-text="true" /> <!-- 选择审批人 --> <select-user :form-id="SCHEDULE.INTERNAL_AUDIT_WORK_REGITRATION_APPROVAL" :show-next-text="true" ref="userRef" @confirm="confirmUser" /> <detail-page title="内部审核工作登记表"> <template #btns> <el-button v-if="$route.path.includes('detail') && approvalStatusName === '待审批' && showApprovalButton && proxy.hasPerm('/quality/internal/registration/agree')" type="primary" @click="handleApprove('同意')"> 同意 </el-button> <el-button v-if="(`${decisionItem}` === '1' || `${decisionItem}` === '2') && $route.path.includes('detail') && approvalStatusName === '待审批' && showApprovalButton" type="warning" @click="handleApprove('驳回')"> 驳回 </el-button> <el-button v-if="(`${decisionItem}` === '1' || `${decisionItem}` === '3') && $route.path.includes('detail') && approvalStatusName === '待审批' && showApprovalButton && proxy.hasPerm('/quality/internal/registration/reject')" type="danger" @click="handleApprove('拒绝')"> 拒绝 </el-button> <el-button v-if="$route.path.includes('detail') && approvalStatusName === '审批中' && showApprovalButton && proxy.hasPerm('/quality/internal/registration/cancel')" type="info" @click="handleApprove('取消')"> 取消 </el-button> <!-- :disabled="!infoId" --> <el-button v-if="($route.path.includes('create') || ($route.path.includes('update') && approvalStatusName !== '未通过' && approvalStatusName !== '已取消' && approvalStatusName !== '全部')) && proxy.hasPerm('/quality/internal/registration/submit')" type="primary" @click="handleSubmit" > 提交 </el-button> <el-button v-if="approvalStatusName !== '已审批' && $route.path.includes('detail') && approvalStatusName === '未通过' && proxy.hasPerm('/quality/internal/registration/update')" type="primary" @click="handleEdit"> 编辑 </el-button> <el-button v-if="!$route.path.includes('detail')" type="primary" @click="saveForm(ruleFormRef)"> 保存 </el-button> <el-button v-if="approvalStatusName === '已取消'" type="danger" @click="del"> 删除 </el-button> <el-button type="info" @click="close"> 关闭 </el-button> </template> </detail-page> <detail-page v-if="approvalStatusName !== '草稿箱' && !$route.path.includes('create') && $props.showInfo" title="" class="info-radio"> <el-radio-group v-model="showMenu"> <el-radio-button label="基本信息" /> <el-radio-button label="审批详情" /> </el-radio-group> </detail-page> <el-form v-show="showMenu === '基本信息'" ref="ruleFormRef" :model="ruleForm" :class="$route.path.includes('detail') ? 'isDetail' : ''" :rules="rules" label-position="right" label-width="120px" class="form" :disabled="$route.path.includes('detail')"> <detail-block title=""> <el-row :gutter="24" class="marg"> <el-col :span="7"> <el-form-item label="计划名称" style="display: flex;"> <el-form-item label="" label-width="0px" prop="yearTime"> <el-select v-model="ruleForm.yearTime" placeholder="年份" class="short-input" filterable style="width: 80px;" > <el-option v-for="item in yearList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> 年第 </el-form-item> <el-form-item label="" label-width="0px" prop="yearNum"> <el-select v-model="ruleForm.yearNum" placeholder="次数" class="short-input" filterable style="width: 80px;" > <el-option v-for="item in monthList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> 次内部审核工作登记表 </el-form-item> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="文件编号" prop="fileCode"> <el-input v-model.trim="ruleForm.fileCode" :placeholder="$route.path.includes('create') ? '系统自动生成' : ''" /> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="实验室" prop="bizLabCode"> <el-select v-model="ruleForm.bizLabCode" placeholder="实验室" class="short-input" filterable style="width: 100%;" > <el-option v-for="item in labelList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="24" class="marg"> <el-col :span="6"> <el-form-item label="质量负责人" prop="creatorName"> <el-input v-model.trim="ruleForm.creatorName" placeholder="质量负责人" disabled /> </el-form-item> </el-col> <el-col :span="1" /> <el-col :span="6"> <el-form-item label="创建时间" prop="createTime"> <el-date-picker v-model="ruleForm.createTime" type="datetime" placeholder="创建时间" value-format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm" style="width: 100%;" disabled /> </el-form-item> </el-col> </el-row> </detail-block> <!-- scheduleList --> <!-- 进度 --> <detail-block v-if="$props.showInfo" title=""> <el-row :gutter="24" class="marg"> <el-col :span="24"> <el-form-item label="内部审核进度" label-width="180"> <el-row :gutter="24" style="width: 100%;"> <el-col :span="2" /> <el-col :span="4"> <el-form-item> <el-checkbox v-model="ruleForm.isShow" :true-label="1" :false-label="0" label="展示在工作台" /> </el-form-item> </el-col> </el-row> <el-row :gutter="24" style="width: 100%;"> <el-col :span="24"> <el-form-item> <div class="content-pro-container"> <div v-for="(item) in ruleForm.scheduleList" :key="item.stageTypeName" class="content-pro"> <div class="circle" :class="item.isCompleted === '1' ? 'true' : 'false'" /> <div class="name"> {{ item.stageTypeName }} </div> <div class="time"> {{ item.scheduleTime }} </div> </div> </div> </el-form-item> </el-col> </el-row> </el-form-item> </el-col> </el-row> </detail-block> <input ref="fileRef" style="display: none;" type="file" accept=".doc,.docx,.pdf,.xls,.xlsx" @change="onFileChange"> <template v-if="$props.showInfo"> <detail-block v-for="(item, index) in ruleForm.scheduleList" :key="item.stageTypeName" title=""> <el-row :gutter="24" class="marg"> <el-col :span="24"> <el-form-item :label="item.stageTypeName" label-width="180"> <el-row :gutter="24" class="marg" style="width: 100%;"> <el-col :span="6"> <el-form-item label="时间"> <el-date-picker v-model="item.scheduleTime" type="date" placeholder="选择时间" format="YYYY-MM-DD" value-format="YYYY-MM-DD" style="width: 100%;" /> </el-form-item> </el-col> <el-col :span="4"> <el-form-item> <el-checkbox v-model="item.isCompleted" true-label="1" false-label="0" label="是否已完成" /> </el-form-item> </el-col> <el-col v-if="hasFileUpload.includes(item.stageTypeName)" :span="12"> <el-form-item label="关联会议记录"> <a v-for="(citem, cindex) in item.scheduleFileList" :key="citem.fileName" class="link" :href="item.filePath" type="primary" style="margin-right: 10px;" target="_blank"> {{ citem.fileName }} <span v-if="!$route.path.includes('detail')" class="close" @click.stop.capture.prevent="closeFile(index, cindex)">x</span> </a> <el-button v-if="!$route.path.includes('detail')" type="primary" @click="importList(index)"> 上传 </el-button> </el-form-item> </el-col> </el-row> <el-row :gutter="24" class="marg" style="width: 100%;"> <el-col :span="6"> <el-form-item label="参与人员"> <el-select v-model="item.scheduleUserList" multiple filterable clearable placeholder="内审组组员" style="width: 100%;"> <el-option v-for="(citem) in userList" :key="citem.id" :label="citem.name" :value="citem.name"> <span style="float: left;">{{ citem.name }}</span> <span style="float: right; color: #8492a6; font-size: 13px;">{{ citem.deptName }}</span> </el-option> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="24" class="marg" style="width: 100%;"> <el-col :span="20"> <el-form-item label="完成情况及说明"> <el-input v-model="item.remarks" :rows="3" type="textarea" /> </el-form-item> </el-col> </el-row> </el-form-item> </el-col> </el-row> </detail-block> </template> </el-form> <!-- 审批详情 --> <approval-record-table-custom v-if="showMenu === '审批详情'" :process-id="processId" /> </app-container> </template> <style lang="scss" scoped> .content-pro-container { width: 100%; display: flex; justify-content: space-around; margin-top: 15px; position: relative; &::after { display: block; content: ""; width: 90%; height: 3px; background-color: #5d93ff; position: absolute; top: 6px; z-index: 1; padding: 0 15px; left: 50%; transform: translateX(-50%); } .content-pro { text-align: center; position: relative; z-index: 2; .circle { width: 15px; height: 15px; border-radius: 50%; margin: 0 auto; } .true { background-color: #5d93ff; } .false { background-color: #666; } .name, .time { margin-top: 10px; } } } .user-container { width: 100%; height: 120px; overflow-y: scroll; border: 1px solid #dcdfe6; border-radius: 5px; } .mx-1 { margin-top: 5px; margin-right: 5px; margin-left: 5px; } .info-radio { ::v-deep(.header) { display: none !important; } } .isDetail { ::v-deep { .el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap > .el-form-item__label::before, .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label::before { content: ""; display: none; } } } .marg { margin-top: 10px; } .link { position: relative; color: #5d93ff; display: inline-block; font-size: 16px; text-decoration: none; // margin-right: 10px; padding-right: 10px; height: 33px; line-height: 33px; &:hover { text-decoration: underline; .close { display: block; } } .close { position: absolute; top: -20px; right: -10px; display: none; z-index: 99; height: 40px; width: 40px; color: rgb(121 118 115); // background-color: #ccc; text-align: center; } // &::before { // content: "x"; // width: 15px; // height: 15px; // position: absolute; // right: -4px; // top: -16px; // color: #817d7d; // font-size: 16px; // // background-color: #ccc; // // border-radius: 50%; // display: none; // } // &:hover { // &::before { // display: block; // } // } } </style>