<!-- 内部审核不符合项报告编辑页面 --> <script name="InternalDissatisfiedHandler" lang="ts" setup> import type { FormInstance, FormRules, UploadUserFile } from 'element-plus' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import dayjs from 'dayjs' import checkDialog from './checkDialog.vue' import { getSearchDept } from '@/api/quality/supervise/record' import { getDictByCode } from '@/api/system/dict' import useUserStore from '@/store/modules/user' import { AGREE, TASKNAME } from '@/views/quality/agree' import { SCHEDULE } from '@/utils/scheduleDict' import ApprovalDialog from '@/components/ApprovalCustom/ApprovalDialog.vue' import { UploadFile, getPhotoUrl } from '@/api/file' import { addQualityDissatisfied, approvalDelete, cancelApproval, delteQualityDissatisfied, detailQualityDissatisfied, draftDelete, refuseApproval, rejectApproval, submitQualityDissatisfied, updateQualityDissatisfied } from '@/api/quality/internal/dissatisfied' import selectUser from '@/views/quality/components/selectUser.vue' import { getWorkList } from '@/api/quality/internal/workManage' import { getUserList } from '@/api/system/user' import { getStaffList } from '@/api/resource/register' import { filterUser } from '@/views/quality/internal/workManage/components/filterUser' import quality from '/public/config/quality.json' const $route = useRoute() const $router = useRouter() const userStore = useUserStore() const decisionItem = ref('') const ruleFormRef = ref<FormInstance>() // from组件 // 当前审批状态名字 const approvalStatusName = $route.query.approvalStatusName as string const watchFlag = ref(true) const ruleForm = ref({ creatorName: '', creator: '', createTime: '', fileCode: '', fileName: '内部审核不符合项报告', bizLabCode: '', deptId: '', reviewForm: { fileName: '', }, viewFormId: '', deptManagerName: '', deptManager: '', auditorName: '', auditorId: '', auditLeaderId: '', nonDescription: '', category: '', nonReviewFiles: [] as any, corrTerms: '', id: '', taskId: '', yearNum: '', yearTime: '', }) // 表单 const rules = ref<FormRules>({ reviewForm: [{ required: true, message: '关联内部审核检查表必选', trigger: ['blur', 'change'] }], bizLabCode: [{ required: true, message: '实验室必选', trigger: ['blur', 'change'] }], deptId: [{ required: true, message: '受审核部门必选', trigger: ['blur', 'change'] }], }) // 表单验证规则 onMounted(() => { decisionItem.value = $route.query.decisionItem as string if ($route.path.includes('create')) { watchFlag.value = false ruleForm.value.createTime = dayjs().format('YYYY-MM-DD HH:mm') // 记录时间 ruleForm.value.creator = userStore.id ruleForm.value.creatorName = userStore.name ruleForm.value.auditorId = userStore.id ruleForm.value.auditorName = userStore.name } else { rules.value.fileCode = [{ required: true, message: '文件编号必填', trigger: ['blur', 'change'] }] detailQualityDissatisfied({ id: $route.query.id }).then((res) => { console.log(res.data, '详情') ruleForm.value = res.data ruleForm.value.category = String(res.data.category) setTimeout(() => { watchFlag.value = false }, 500) nextTick(() => { ruleFormRef.value.clearValidate() }) }) } }) const labelList = ref<{ id: string; value: string; name: string }[]>()// 实验室 const deptList = ref<{ deptName: string; deptId: string }[]>([]) // 部门列表 const deptAllList = ref<{ deptName: string; deptId: string }[]>([]) // 部门列表 const fetchDict = () => { // 获取实验室字典 getDictByCode('bizLabCode').then((res) => { labelList.value = res.data }) getSearchDept({ labCode: '' }).then((res) => { deptList.value = res.data deptAllList.value = res.data }) } fetchDict() watch(() => ruleForm.value.bizLabCode, (newVal) => { if (newVal) { if ($route.path.includes('detail') || watchFlag.value) { return } ruleForm.value.deptId = '' getSearchDept({ labCode: newVal }).then((res) => { deptList.value = res.data }) } else { getSearchDept({}).then((res) => { deptList.value = res.data }) } }, { deep: true, }) // ---------------------------------------------保存相关-------------------------------------- const infoId = ref('') const createRow = (data: any) => { addQualityDissatisfied(data).then((res) => { ElMessage.success('操作成功') infoId.value = res.data }) } const updateRow = (data: any) => { updateQualityDissatisfied(data).then((res) => { ElMessage.success('操作成功') infoId.value = res.data if (approvalStatusName === '已取消' || approvalStatusName === '未通过') { handleSubmit() } if (approvalStatusName === '全部') { // close() $router.go(-1) } }) } const saveForm = async (formEl: FormInstance | undefined) => { if (!formEl) { return } await formEl.validate((valid, fields) => { if (valid) { const data = { ...ruleForm.value, groupNo: deptAllList.value.filter((item: any) => item.deptId === ruleForm.value.deptId)[0]?.groupNo, // DissatisfiedSchedules: scheduleRef.value.list, // fileName: `${ruleForm.value.yearTime}年第${ruleForm.value.yearNum}次内部审核检查表`, } 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 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 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 userRef = ref() // 点击提交 function handleSubmit() { if (infoId.value || ruleForm.value.id) { // 选择审批人 userRef.value.initDialog() } else { ElMessage.warning('请先保存') } } // 确认审批人 const confirmUser = (data: any) => { // ruleForm.value.assignees = data submitQualityDissatisfied({ formId: SCHEDULE.INTERNAL_AUDIT_NONCONFORMITIES_APPROVAL, // processId: infoId.value, id: infoId.value || ruleForm.value.id, assignees: data, }).then(() => { ElMessage.success('提交成功') $router.go(-1) }) } // 点击提交 // function handleSubmit() { // if (infoId.value || ruleForm.value.id) { // submitQualityDissatisfied({ // formId: SCHEDULE.INTERNAL_AUDIT_NONCONFORMITIES_APPROVAL, // // processId: infoId.value, // id: infoId.value || ruleForm.value.id, // }).then(() => { // ElMessage.success('提交成功') // close() // }) // } // else { // ElMessage.warning('请先保存') // } // } // 点击编辑 const handleEdit = () => { $router.push({ path: `/internaldissatisfied/update/${ruleForm.value.id}`, query: { ...$route.query }, }) } const del = () => { if (approvalStatusName === '草稿箱') { draftDelete({ id: ruleForm.value.id }).then(() => { ElMessage.success('已删除') $router.go(-1) }) } else if (approvalStatusName === '已取消') { approvalDelete({ id: ruleForm.value.id, taskId: ruleForm.value.taskId }).then(() => { ElMessage.success('已删除') $router.go(-1) }) } else if (approvalStatusName === '全部') { // 全部的删除 delteQualityDissatisfied({ id: ruleForm.value.id }).then(() => { ElMessage.success('已删除') $router.go(-1) }) } } // 关闭页面 function close() { $router.push({ path: '/internal/internaldissatisfied', }) } const showMenu = ref('基本信息') defineExpose({ ruleForm, showMenu, }) // 点击 关联检查表 const checkRef = ref() const selectCheck = () => { checkRef.value.initDialog(ruleForm.value.bizLabCode) } // 确认 关联检查表 const confirmCheck = (data: any) => { console.log(data, '需要限制实验室') ruleForm.value.reviewForm = data ruleForm.value.viewFormId = data.id ruleForm.value.bizLabCode = data.bizLabCode ruleForm.value.yearNum = data.yearNum ruleForm.value.yearTime = data.yearTime // ruleForm.value.deptManagerName = data.deptManagerName // 找到对应的 内部审核工作管理用来填充 部门负责人 deptManagerName 内审员 auditorName 内审组长 auditLeaderId getWorkList({ offset: 1, limit: 1, bizLabCode: data.bizLabCode, yearNum: data.yearNum, yearTime: data.yearTime, status: '1' }).then(res => { console.log(res.data, '内部审核工作管理') if (res.data.rows.length) { const data = res.data.rows[0] // console.log(data, 'data[0]') // 组长 ruleForm.value.auditLeaderId = internalAudit.value.filter(item => item.name === data.groupLeader)[0]?.id || '' // 内审员 // auditorName teamMembers // 质量负责人 // deptManagerName commanderId ruleForm.value.deptManagerName = userList1.value.filter(item => item.id === data.commanderId)[0]?.name || '' } else { ElMessage.warning('未找到对应的内审工作管理,请确认') ruleForm.value.reviewForm = { } ruleForm.value.viewFormId = '' ruleForm.value.bizLabCode = '' ruleForm.value.yearNum = '' ruleForm.value.yearTime = '' ruleForm.value.auditLeaderId = '' ruleForm.value.deptManagerName = '' } }) setTimeout(() => { ruleForm.value.deptId = data.deptId }, 500) } // 上传附件 const fileRef = ref() // 文件上传input,获取input的引用 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, }) }) } }) } } // 导入 const importList = () => { fileRef.value.click() } // 删除 const closeFile = (index: number) => { ruleForm.value.nonReviewFiles.splice(index, 1) } const { proxy } = getCurrentInstance() as any const userList1 = ref<any[]>([]) // 用户列表 const userList2 = ref<any[]>([]) // 用户列表 const userList3 = ref<any[]>([]) // 用户列表 const internalAudit = ref<any[]>([]) // 内审员列表 const loading = ref(true) const fetchDict1 = async () => { loading.value = true const res = await getUserList({ limit: 9999, offset: 1 }) const allUserList = res.data.rows // 获取内审员 getStaffList({ limit: 9999, offset: 1 }).then((res) => { internalAudit.value = res.data.rows.filter((item: any) => item.auditorCertificate === 1).map((item: any) => ({ deptName: item.deptName, name: item.staffName, id: allUserList.filter(citem => citem.account === item.account)[0]?.id, })) }) userList1.value = await filterUser(quality.roleTips['质量负责人']) // userList2.value = await filterUser(quality.roleTips['内审组长']) userList3.value = await filterUser(quality.roleTips['内审组员']) loading.value = false } fetchDict1() </script> <template> <app-container style="overflow: hidden;"> <!-- 审批弹窗 --> <approval-dialog ref="approvalDialog" :agree="AGREE.INTERNAL_AUDIT_NONCONFORMITIES_APPROVAL" :last-name="TASKNAME.INTERNAL_AUDIT_NONCONFORMITIES_APPROVAL" @on-success="approvalSuccess" @refuse="refuse" @reject="reject" :form-id="SCHEDULE.INTERNAL_AUDIT_NONCONFORMITIES_APPROVAL" :show-next-text="true" /> <!-- 选择审批人 --> <select-user :form-id="SCHEDULE.INTERNAL_AUDIT_NONCONFORMITIES_APPROVAL" :show-next-text="true" ref="userRef" @confirm="confirmUser" /> <!-- 关联检查表 --> <check-dialog ref="checkRef" @add="confirmCheck" /> <detail-page title="内部审核不符合项报告"> <template #btns> <el-button v-if="$route.path.includes('detail') && approvalStatusName === '待审批' && showApprovalButton && proxy.hasPerm('/quality/internal/dissatisfied/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/dissatisfied/reject')" type="danger" @click="handleApprove('拒绝')"> 拒绝 </el-button> <el-button v-if="$route.path.includes('detail') && approvalStatusName === '审批中' && showApprovalButton && proxy.hasPerm('/quality/internal/dissatisfied/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/dissatisfied/submit')" type="primary" @click="handleSubmit"> 提交 </el-button> <el-button v-if="approvalStatusName !== '已审批' && $route.path.includes('detail') && approvalStatusName === '未通过' && proxy.hasPerm('/quality/internal/dissatisfied/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')" 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-loading="loading" 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="6"> <el-form-item label="内部审核检查表" prop="fileName"> {{ ruleForm.reviewForm.fileName }} <el-button v-if="!$route.path.includes('detail')" type="primary" @click="selectCheck"> 选择 </el-button> </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="fileName"> <el-input v-model.trim="ruleForm.fileName" placeholder="文件名称" /> </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-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="deptId"> <el-select v-model="ruleForm.deptId" placeholder="受审核部门" class="short-input" filterable style="width: 100%;"> <el-option v-for="item in deptList" :key="item.deptId" :label="item.deptName" :value="item.deptId" /> </el-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="部门负责人" prop="deptManagerName"> <!-- <el-input v-model.trim="ruleForm.deptManagerName" placeholder="部门负责人" disabled /> --> <el-select v-model="ruleForm.deptManagerName" filterable clearable placeholder="质量负责人" style="width: 100%;"> <el-option v-for="(item) in userList1" :key="item.id" :label="item.name" :value="item.name"> <span style="float: left;">{{ item.name }}</span> <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.deptName }}</span> </el-option> </el-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="内审员" prop="auditorName"> <!-- <el-input v-model.trim="ruleForm.auditorName" placeholder="内审员" disabled />--> <el-select v-model="ruleForm.auditorName" filterable clearable placeholder="内审员" style="width: 100%;"> <el-option v-for="(item) in userList3" :key="item.id" :label="item.name" :value="item.name"> <span style="float: left;">{{ item.name }}</span> <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.deptName }}</span> </el-option> </el-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="内审组长" prop="auditLeaderId"> <!-- <el-input v-model.trim="ruleForm.auditLeaderId" placeholder="内审组长" disabled />--> <el-select v-model="ruleForm.auditLeaderId" filterable clearable placeholder="内审组组长" style="width: 100%;"> <el-option v-for="(item) in internalAudit" :key="item.id" :label="item.name" :value="item.id"> <span style="float: left;">{{ item.name }}</span> <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.deptName }}</span> </el-option> </el-select> </el-form-item> </el-col> </el-row> </detail-block> <detail-block title=""> <el-row :gutter="24" class="marg"> <el-col :span="24"> <el-form-item label="不符合项描述" prop="nonDescription"> <el-input v-model="ruleForm.nonDescription" placeholder="不符合项描述" :rows="3" type="textarea" /> </el-form-item> </el-col> </el-row> <el-row :gutter="24" class="marg"> <el-col :span="12"> <el-form-item label="判定类别" prop="category"> <el-radio-group v-model="ruleForm.category" class="ml-4"> <el-radio label="0"> 一般不符合 </el-radio> <el-radio label="1"> 严重不符合 </el-radio> </el-radio-group> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="对应条款" prop="corrTerms"> <el-input v-model="ruleForm.corrTerms" placeholder="对应条款" /> </el-form-item> </el-col> </el-row> <el-row :gutter="24" class="marg"> <el-col :span="24"> <el-form-item label="问题文件附件" prop="fileName" label-width="160px"> <a v-for="(item, index) in ruleForm.nonReviewFiles" :key="item.fileName" class="link" :href="item.filePath" type="primary" style="margin-right: 10px;" target="_blank"> {{ item.fileName }} <span v-if="!$route.path.includes('detail')" class="close" @click.stop.capture.prevent="closeFile(index)">x</span> </a> <el-button v-if="!$route.path.includes('detail')" type="primary" @click="importList"> 上传 </el-button> <input ref="fileRef" style="display: none;" type="file" accept=".doc,.docx,.pdf,.xls,.xlsx" @change="onFileChange"> </el-form-item> </el-col> </el-row> </detail-block> </el-form> <!-- 审批详情 --> <approval-record-table-custom v-if="showMenu === '审批详情'" :process-id="processId" /> </app-container> </template> <style lang="scss" scoped> .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; } .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; } } } .info-radio { ::v-deep(.header) { display: none !important; } } .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>