<!-- 合同执行变更登记表 --> <script name="ContractList" lang="ts" setup> import { ElMessage, ElMessageBox, dayjs } from 'element-plus' import type { DateModelType } from 'element-plus' import type { IList, IListQuery } from './contract-interface' import type { TableColumn } from '@/components/NormalTable/table_interface' import type { IMenu } from '@/components/buttonBox/buttonBox' import { SCHEDULE } from '@/utils/scheduleDict' import ApprovalDialog from '@/components/Approval/ApprovalDialog.vue' import { approvalDelete, cancelApproval, draftDelete, getCustomerContractList, refuseApproval, rejectApproval } from '@/api/resource/contract' import { getDictByCode } from '@/api/system/dict' import useBridgeCount from '@/components/buttonBox/useBridgeCount' import type { deptType } from '@/global' // 定义常量 const buttonBoxActive = 'resourceCustomerContract' // 存储在sessionstorage里面的字段名,用于记录右上角buttonbox点击状态 const { proxy } = getCurrentInstance() as any const $router = useRouter() const active = ref('') // 选中的审批状态按钮 const menu = ref<IMenu[]>([]) // 审批状态按钮组合 const approvalDialog = ref() // 弹窗子组件 // 查询条件 const listQuery = ref<IListQuery>({ approvalStatus: active.value, // 审批状态类型code,导出接口不用传 createTimeEnd: '', // 创建时间结束 createTimeStart: '', // 创建时间开始 createUserName: '', // 创建人 customerAdvice: '', // 委托方意见(同意/拒绝) customerAdviceTimeEnd: '', // 委托方意见时间结束 customerAdviceTimeStart: '', // 委托方意见时间开始 customerId: '', // 委托方id customerName: '', // 委托方名字 examineName: '', // 合同评审表名称 examineNo: '', // 合同评审表编号 formNo: '', // 文件编号 groupCode: '', // 部门 labCode: '', // 实验室 sendStatus: '', // 通知发送状态(1/2) formId: SCHEDULE.CONTRACT_EXECUTE_CHANGE, // 表单id(流程定义对应的表单id,等价于业务id),此处为固定值 offset: 1, limit: 20, }) const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const timeRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const total = ref(0) // 数据条数 const totalToApproval = ref(0) // 待审批数据条数 const totalApproval = ref(0) // 审批中数据条数 const totalRefuse = ref(0) // 未通过数据条数 const loadingTable = ref(false) // 表格loading // 表头 const columns = ref<TableColumn[]>([ { text: '实验室', value: 'labCodeName', align: 'center', width: '120' }, { text: '部门', value: 'groupCodeName', align: 'center', width: '120' }, { text: '文件发放号', value: 'fileDistributeNo', align: 'center' }, { text: '文件编号', value: 'formNo', align: 'center' }, { text: '文件名称', value: 'formName', align: 'center' }, { text: '合同名称及编号', value: 'contractNameAndNo_hide', align: 'center', followLink: true, width: '380' }, { text: '委托方', value: 'customerName', align: 'center' }, { text: '创建人', value: 'createUserName', align: 'center' }, { text: '创建时间', value: 'createTime', align: 'center', width: '180' }, { text: '通知发送状态', value: 'sendStatusName', align: 'center', width: '90', styleFilter: (row: { sendStatusName: string }) => { return row.sendStatusName == '未发送' ? 'color: red' : 'color: #1aa034' } }, { text: '委托方意见', value: 'customerAdvice', align: 'center', width: '90', styleFilter: (row: { customerAdvice: string }) => { return row.customerAdvice == '拒绝' ? 'color: red' : 'color: #1aa034' } }, { text: '委托方意见时间', value: 'customerAdviceTime', align: 'center', width: '180' }, ]) const list = ref<IList[]>([]) // 表格数据 const checkoutList = ref<IList[]>([]) // 多选数据 // -----------------------------------------字典-------------------------------------------------------------- const groupCodeList = ref<deptType[]>([]) // 部门 const groupCodeDict = ref({}) as any// 部门 const labCodeList = ref<deptType[]>([]) // 实验室 const labCodeDict = ref({}) as any// 实验室 // 查询字典 const getDict = async () => { loadingTable.value = true // 审批状态 const res = await getDictByCode('approvalStatus') // 制作右上角的菜单 const tempMenu = ['全部', '已审批', '待审批', '审批', '草稿箱', '审批中', '已通过', '未通过', '已取消'] tempMenu.forEach((item) => { const tempFindData = res.data.find((e: { name: string; value: string }) => e.name === item) if (tempFindData) { menu.value.push({ name: tempFindData.name, id: `${tempFindData.value}`, }) } }) // 实验室 const resLabCode = await getDictByCode('bizLabCode') labCodeList.value = resLabCode.data resLabCode.data.forEach((item: { value: string;name: string }) => { labCodeDict.value[`${item.value}`] = item.name }) // 部门 const resGroupCode = await getDictByCode('bizGroupCode') groupCodeList.value = resGroupCode.data resGroupCode.data.forEach((item: { value: string;name: string }) => { groupCodeDict.value[`${item.value}`] = item.name }) } // ----------------------------------------列表数据---------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } if (listQuery.value.approvalStatus === '10') { listQuery.value.approvalStatus = '' } // 审批状态不允许传字典要求传'' getCustomerContractList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: any) => { return { ...item, sendStatusName: `${item.sendStatus}` === '1' ? '已发送' : `${item.sendStatus}` === '2' ? '未发送' : item.sendStatus, labCodeName: item.labCode ? labCodeDict.value[item.labCode] : item.labCode, // 实验室 groupCodeName: item.groupCode ? groupCodeDict.value[item.groupCode] : item.groupCode, // 部门 examineNameAndNo: item.examineName + item.examineNo, followLinkArr: [item.examineName + item.examineNo], } }) total.value = parseInt(response.data.total) loadingTable.value = false }) // 获取待审批,审批中,未通过数据数量 useBridgeCount(listQuery.value).then((res: any) => { totalToApproval.value = res.totalToApproval // 待审批数据条数 totalApproval.value = res.totalApproval // 审批中数据条数 totalRefuse.value = res.totalRefuse // 未通过数据条数 }) } // 多选发生改变时 function handleSelectionChange(e: any) { checkoutList.value = e.map((item: { id: string }) => item.id) } // 重置 const clearList = () => { listQuery.value = { approvalStatus: active.value, // 审批状态类型code,导出接口不用传 createTimeEnd: '', // 创建时间结束 createTimeStart: '', // 创建时间开始 createUserName: '', // 创建人 customerAdvice: '', // 委托方意见(同意/拒绝) customerAdviceTimeEnd: '', // 委托方意见时间结束 customerAdviceTimeStart: '', // 委托方意见时间开始 customerId: '', // 委托方id customerName: '', // 委托方名字 examineName: '', // 合同评审表名称 examineNo: '', // 合同评审表编号 formNo: '', // 文件编号 groupCode: '', // 部门 labCode: '', // 实验室 sendStatus: '', // 通知发送状态(1/2) formId: SCHEDULE.CONTRACT_EXECUTE_CHANGE, // 表单id(流程定义对应的表单id,等价于业务id),此处为固定值 offset: 1, limit: 20, } dateRange.value = ['', ''] timeRange.value = ['', ''] fetchData() } // 搜索 const searchList = () => { fetchData(true) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size?: number; page?: number }) => { if (val && val.size) { listQuery.value.limit = val.size } if (val && val.page) { listQuery.value.offset = val.page } fetchData(true) } // ----------------------------------------按钮------------------------------------------------- // 新建 const add = () => { $router.push({ path: 'contract/add', }) } // ----------------------------------------------操作--------------------------------------------------- const handleEdit = (row: any, type: string) => { if (type === 'edit' || type === 'detail') { // 编辑、详情 if (active.value === '0' && type === 'detail') { $router.push({ path: `contractDoc/${type}/${row.id}`, query: { approvalStatusName: '全部', // 审批状态名称 customerName: row.customerName, // 委托方名称 contractExecutionFile: row.contractExecutionFile, decisionItem: row.decisionItem, taskId: row.taskId, }, }) } else { $router.push({ path: `contract/${type}/${row.id}`, query: { approvalStatusName: active.value === '0' ? '全部' : active.value === '7' ? '已审批' : menu.value.find(item => item.id === row.approvalStatus)!.name, // 审批状态名称 processId: row.processId, // 流程实例id taskId: row.taskId, // 任务id labCode: row.labCode, // 实验室 groupCode: row.groupCode, // 部门 formNo: row.formNo, // 申请单编号 formName: row.formName, // 申请单名称 createUserId: row.createUserId, // 创建人id createUserName: row.createUserName, // 创建人名称 createTime: row.createTime, // 创建时间 examineId: row.examineId, // 合同评审表id examineName: row.examineName, // 合同评审表名称 examineNo: row.examineNo, // 合同评审表编号 examineNameAndNo: row.examineNameAndNo, // 合同名称及编号 customerId: row.customerId, // 委托方id(存储为deptId) customerName: row.customerName, // 委托方名称 changeContent: row.changeContent, // 变更内容 changeReason: row.changeReason, // 变更原因 customerUserId: row.customerUserId, // 发送给的委托方用户id decisionItem: row.decisionItem, }, }) } } else if (type === '同意') { approvalDialog.value.initDialog('agree', row.taskId) } else if (type === '驳回') { approvalDialog.value.initDialog('reject', row.taskId, row.id) } else if (type === '拒绝') { approvalDialog.value.initDialog('refuse', row.taskId, row.id) } else if (type === '取消') { const params = { processInstanceId: row.processId!, comments: '', id: row.id, } ElMessageBox.confirm( '确认取消该审批吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ) .then(() => { cancelApproval(params).then((res) => { ElMessage({ type: 'success', message: '已取消', }) fetchData(true) }) }) } else { ElMessageBox.confirm( `确认${type}吗?`, '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then(() => { // 草稿箱删除 if (type === '删除' && row.approvalStatus === '1') { draftDelete({ id: row.id }).then(() => { ElMessage.success(`已${type}`) fetchData() }) } // 审批删除--已取消、全部 else if (type === '删除' && (row.approvalStatus === '6' || active.value === '0')) { approvalDelete({ id: row.id, taskId: row.taskId! }).then(() => { ElMessage.success(`已${type}`) fetchData() }) } }) } } // 拒绝 const refuse = (comments: string, taskId: string, id: string) => { const params = { id, taskId, // 任务id comments, // 拒绝原因 } refuseApproval(params).then((res) => { ElMessage({ type: 'success', message: '已拒绝', }) fetchData(true) }) } // 驳回 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}`) } fetchData(true) }) } // -----------------------------------------审批------------------------------------------------ // 审批结束回调 const approvalSuccess = () => { fetchData(true) } // 切换tab状态 const changeCurrentButton = (val: string) => { active.value = val window.sessionStorage.setItem(buttonBoxActive, val) listQuery.value.approvalStatus = val console.log('1111111', active.value) fetchData() } // ------------------------------------------钩子------------------------------------------------ const router = useRouter() // 点击记录编号 const handleClickFollowLink = (row: any, title: string) => { router.push({ query: { id: row.examineId, }, path: '/customer/examine/approved/detail', }) } watch(dateRange, (val) => { if (val) { listQuery.value.createTimeStart = `${val[0]}` listQuery.value.createTimeEnd = `${val[1]}` } else { listQuery.value.createTimeStart = '' listQuery.value.createTimeEnd = '' } }) watch(timeRange, (val) => { if (val) { listQuery.value.customerAdviceTimeStart = `${val[0]}` listQuery.value.customerAdviceTimeEnd = `${val[1]}` } else { listQuery.value.customerAdviceTimeStart = '' listQuery.value.customerAdviceTimeEnd = '' } }) watch(() => active.value, (val) => { if (val === '10') { // 审批把审批状态加上 if (columns.value[columns.value.length - 1].value !== 'approvalStatusName') { columns.value.push({ text: '审批状态', value: 'approvalStatusName', align: 'center' }) } } else { // 其他不显示审批状态 if (columns.value[columns.value.length - 1].value === 'approvalStatusName') { columns.value.pop() } } }, { immediate: true }) onMounted(async () => { await getDict() if (window.sessionStorage.getItem(buttonBoxActive)) { active.value = window.sessionStorage.getItem(buttonBoxActive)! } else { active.value = menu.value.find(item => item.name === '全部')!.id as string // 全部 } }) </script> <template> <app-container> <!-- 筛选条件 --> <search-area :need-clear="true" @search="searchList" @clear="clearList"> <search-item> <el-select v-model="listQuery.labCode" style="width: 140px;" placeholder="实验室" clearable> <el-option v-for="dict in labCodeList" :key="dict.id" :value="dict.value" :label="dict.name" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.groupCode" style="width: 140px;" placeholder="部门" clearable> <el-option v-for="dict in groupCodeList" :key="dict.id" :value="dict.value" :label="dict.name" /> </el-select> </search-item> <search-item> <el-input v-model="listQuery.formNo" placeholder="文件编号" clearable /> </search-item> <search-item> <el-input v-model="listQuery.examineNo" placeholder="合同编号" clearable /> </search-item> <search-item> <el-input v-model="listQuery.customerName" placeholder="委托方" clearable /> </search-item> <search-item> <el-input v-model="listQuery.createUserName" placeholder="创建人" clearable /> </search-item> <search-item> <el-date-picker v-model="dateRange" class="short-input" type="datetimerange" range-separator="至" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="创建时间(开始)" end-placeholder="创建时间(结束)" /> </search-item> <search-item> <el-select v-model="listQuery.sendStatus" style="width: 140px;" placeholder="通知发送状态" clearable> <el-option v-for="item in [{ value: '1', name: '已发送' }, { value: '2', name: '未发送' }]" :key="item.value" :value="item.value" :label="item.name" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.customerAdvice" style="width: 140px;" placeholder="委托方意见" clearable> <el-option v-for="item in [{ value: '1', name: '同意' }, { value: '2', name: '拒绝' }]" :key="item.value" :value="item.name" :label="item.name" /> </el-select> </search-item> <search-item> <el-date-picker v-model="timeRange" class="short-input" type="datetimerange" range-separator="至" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="委托方意见时间(开始)" end-placeholder="委托方意见时间(结束)" /> </search-item> </search-area> <!-- 表格数据展示 --> <table-container> <!-- 表头区域 --> <template #btns-right> <icon-button v-if="active === '0'" icon="icon-add" title="新建" @click="add" /> </template> <!-- 表格区域 --> <normal-table :data="list" :total="total" :columns="columns" :query="{ limit: listQuery.limit, offset: listQuery.offset }" :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange" @handle-click-follow-link="handleClickFollowLink" > <template #preColumns> <el-table-column label="序号" width="55" align="center"> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> <template #columns> <el-table-column fixed="right" label="操作" align="center" width="180"> <template #default="{ row }"> <el-button v-if="active !== '1' && active !== '6' && active !== '5'" size="small" type="primary" link @click="handleEdit(row, 'detail')" > 查看 </el-button> <el-button v-if=" active === '1' || active === '6' || active === '5'" size="small" type="primary" link @click="handleEdit(row, 'edit')" > 查看 </el-button> <el-button v-if="row.approvalStatus === '2'" size="small" link type="primary" @click="handleEdit(row, '同意')" > 同意 </el-button> <el-button v-if="row.approvalStatus === '2' && (`${row.decisionItem}` === '1' || `${row.decisionItem}` === '2')" size="small" link type="warning" @click="handleEdit(row, '驳回')" > 驳回 </el-button> <el-button v-if="row.approvalStatus === '2' && (`${row.decisionItem}` === '1' || `${row.decisionItem}` === '3')" size="small" link type="danger" @click="handleEdit(row, '拒绝')" > 拒绝 </el-button> <!-- <el-button v-if="active === '0'" size="small" link type="primary" @click="handleEdit(row, 'edit')" > 编辑 </el-button> --> <!-- 是发起者且审批中可以取消 --> <el-button v-if="row.approvalStatus === '3' && active !== '7' && active !== '0'" size="small" link type="info" @click="handleEdit(row, '取消')" > 取消 </el-button> <el-button v-if="active !== '7' && (row.approvalStatus === '1' || row.approvalStatus === '6')" size="small" link type="danger" @click="handleEdit(row, '删除')" > 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> <!-- 审批单弹窗 --> <approval-dialog ref="approvalDialog" @on-success="approvalSuccess" @refuse="refuse" @reject="reject" /> <!-- 右上角按钮集合 --> <button-box :active="active" :total-refuse="totalRefuse" :total-approval="totalApproval" :total-to-approval="totalToApproval" :menu="menu" @change-current-button="changeCurrentButton" /> </app-container> </template>