<!-- 委托方意见登记表 --> <script lang="ts" setup name="ClientOpinionForm"> import { reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import ApprovalDialog from './ApprovalDialog.vue' import { cancelOpinion, delOpinion, getListPage, submitOpinion } from '@/api/eqpt/MeasurementBusiness/opinion' import { SCHEDULE } from '@/utils/scheduleDict' import { toTreeList } from '@/utils/structure' import { getDeptTreeList } from '@/api/system/dept' import { getDictByCode } from '@/api/system/dict' import { getAdminDept, getUserDept, getUserDeptSon, getUserList } from '@/api/system/user' import { keepSearchParams } from '@/utils/keepQuery' const $props = defineProps({ statusName: { type: String, default: '', }, }) const { proxy } = getCurrentInstance() as any const applyDict = ref<{ [key: string]: string }>({ 审批: '', 草稿箱: '1', 审批中: '3', 已通过: '4', 未通过: '5', 已取消: '6', }) onBeforeRouteLeave((to: any) => { keepSearchParams(to.path, 'ClientOpinionForm') }) const listQuery = reactive({ approvalStatus: '0', createTimeEnd: '', createTimeStart: '', createUserName: '', // customerDeptName: '', // customerName: '', customerId: '', customerDeptId: '', handleStatus: '', formId: SCHEDULE.CUSTOMER_OPINION_APPROVAL, formNo: '', offset: 1, limit: 20, }) // 证书有效期开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { listQuery.createTimeStart = '' listQuery.createTimeEnd = '' if (Array.isArray(newVal)) { if (newVal.length) { listQuery.createTimeStart = `${newVal[0]} 00:00:00` listQuery.createTimeEnd = `${newVal[1]} 23:59:59` } } }) const columns = ref([ { text: '文件编号', value: 'formNo', align: 'center', }, { text: '标题', value: 'formName', align: 'center', }, { text: '单位', value: 'customerName', align: 'center', }, { text: '部门', value: 'customerDeptName', align: 'center', }, { text: '创建人', value: 'createUserName', align: 'center', }, { text: '创建时间', value: 'createTime', align: 'center', }, ]) const list = ref([]) const total = ref(0) const listLoading = ref(true) // 获取数据 const fetchData = (isNowPage = true) => { listLoading.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.offset = 1 } getListPage(listQuery, $props.statusName).then((response) => { list.value = response.data.rows total.value = parseInt(response.data.total) listLoading.value = false }) } // 审批状态发生变化 watch(() => $props.statusName, (newVal) => { if (newVal) { listQuery.handleStatus = '' listQuery.approvalStatus = applyDict.value[newVal] as string fetchData() } }, { deep: true, immediate: true, }) // 查询数据 const search = () => { fetchData(false) } // 重置 const reset = () => { datetimerange.value = [] listQuery.formNo = '' // listQuery.createUserName = '' listQuery.createTimeEnd = '' listQuery.createTimeStart = '' listQuery.customerId = '' listQuery.customerDeptId = '' listQuery.handleStatus = '' listQuery.createUserName = '' listQuery.offset = 1 listQuery.limit = 20 search() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size: number; page: number }) => { if (val && val.size) { listQuery.limit = val.size } if (val && val.page) { listQuery.offset = val.page } fetchData() } const $router = useRouter() // 新建编辑操作 // const handler = (row: any, type: string) => { // $router.push({ // path: `/opinion/${type}`, // query: { // row: JSON.stringify(row), // id: row.id, // }, // }) // } // 提交 const submit = (row: any) => { ElMessageBox.confirm( '确认提交吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then((res) => { submitOpinion({ id: row.id, formId: SCHEDULE.CUSTOMER_OPINION_APPROVAL }).then((res) => { ElMessage.success('已提交') search() }) }) } // 同意拒绝 const approvalDialogRef = ref() const approveHandler = (row: any, type: string) => { approvalDialogRef.value.initDialog(type, row.taskId, row.processId, row.id) } // 删除 const delHandler = (row: any) => { ElMessageBox.confirm( '确认删除此记录吗?', '确认', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then(() => { delOpinion({ id: row.id, taskId: row.taskId }).then((res) => { ElMessage.success('操作成功') search() }) }) } // 取消 const canHandler = (row: any) => { ElMessageBox.confirm( '确认取消此申请吗?', '确认', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then(() => { cancelOpinion({ id: row.id, processInstanceId: row.processId, comments: '' }).then((res) => { ElMessage.success('操作成功') // close() search() }) }) } // 新建编辑操作 const handler = (row: any, type: string) => { $router.push({ path: `opinion/${type}`, query: { row: JSON.stringify(row), id: row.id, statusName: $props.statusName, }, }) } // 详情 const detail = (row: any) => { if ($props.statusName === '草稿箱' || $props.statusName === '未通过' || $props.statusName === '已取消') { handler(row, 'update') } else { $router.push({ path: 'opinion/detail', query: { row: JSON.stringify(row), id: row.id, statusName: $props.statusName, }, }) } } const permUrl = { add: '/tested/business/opinion/add', edit: '/tested/business/opinion/edit', agree: '/tested/business/opinion/agree', reject: '/tested/business/opinion/reject', submit: '/tested/business/opinion/submit', cancel: '/tested/business/opinion/cancel', del: '/tested/business/opinion/delete', } // 所在单位 const companyList = ref<{ id: string; value: string; name: string }[]>([]) // 部门 const deptList = ref<{ id: string; value: string; name: string }[]>([]) // 处置情况 const handleStatusList = ref<{ id: string; value: string; name: string }[]>([]) // 获取字典 const fetchDict = () => { getUserDept().then((res) => { if (res.data.fullName === '顶级' || res.data.version === '1' || res.data.version === 1) { getAdminDept({}).then((res) => { companyList.value = res.data.map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) }) } else { companyList.value = [ { name: res.data.fullName, value: res.data.id, id: res.data.id, }, ] } }) // 处置情况 getDictByCode('eqptHandleStatus').then((res) => { handleStatusList.value = res.data }) } fetchDict() // 监听单位,修改部门 // watch(() => listQuery.customerId, (newVal) => { // listQuery.customerDeptId = '' // if (newVal) { // getDeptTreeList({ pid: newVal }).then((res) => { // deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) as any[] // }) // } // else { // deptList.value = [] // } // }, { // deep: true, // }) </script> <template> <app-container> <!-- 审批弹窗 --> <approval-dialog ref="approvalDialogRef" @on-success="search" /> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model.trim="listQuery.formNo" placeholder="文件编号" clearable /> </search-item> <!-- <search-item> <el-input v-model.trim="listQuery.createUserName" placeholder="创建人" clearable /> </search-item> --> <search-item> <el-select v-model="listQuery.customerId" clearable filterable placeholder="所在单位"> <el-option v-for="item in companyList" :key="item.id" :label="item.name" :value="item.id" /> </el-select> </search-item> <!-- <search-item> <el-tree-select v-model="listQuery.customerDeptId" style="width: 100%;" :data="deptList" :render-after-expand="false" check-strictly placeholder="部门" /> </search-item> --> <search-item> <el-input v-model.trim="listQuery.createUserName" placeholder="创建人" clearable /> </search-item> <search-item> <el-date-picker v-model="datetimerange" type="daterange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" range-separator="至" start-placeholder="创建开始时间" end-placeholder="创建结束时间" clearable /> </search-item> <search-item v-if="$props.statusName === '全部'"> <el-select v-model="listQuery.handleStatus" clearable placeholder="处置情况"> <el-option v-for="item in handleStatusList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </search-item> </search-area> <table-container> <template v-if="$props.statusName === '全部'" #btns-right> <icon-button v-if="proxy.hasPerm('/tested/business/opinion/add')" icon="icon-add" title="新增" @click="handler({}, 'create')" /> <!-- <icon-button icon="icon-add" title="新增" @click="handler({}, 'create')" /> --> </template> <!-- 普通表格 --> <normal-table :data="list" :total="total" :columns="columns as any" :query="listQuery" :list-loading="listLoading" :is-showmulti-select="true" @change="changePage" > <template #columns> <el-table-column v-if="$props.statusName === '全部'" label="审核人" align="center"> <template #default=" scope "> {{ scope.row.approveUserName }} </template> </el-table-column> <el-table-column v-if="$props.statusName === '全部'" label="处置情况" align="center"> <template #default=" scope "> {{ scope.row.handleStatusName }} </template> </el-table-column> <el-table-column v-if="$props.statusName !== '全部'" label="审批状态" align="center"> <template #default=" scope "> {{ scope.row.approvalStatusName }} </template> </el-table-column> <el-table-column label="操作" width="160" align="center"> <template #default=" scope "> <el-button link type="primary" size="small" @click="detail(scope.row)"> 查看 </el-button> <el-button v-if="proxy.buttonPerm.edit.if({ approvalStatusName: $props.statusName }, permUrl.edit) && $props.statusName !== '全部'" link type="primary" size="small" @click="handler(scope.row, 'update')" > 编辑 </el-button> <el-button v-if="proxy.buttonPerm.agree.if({ approvalStatusName: $props.statusName }, permUrl.agree)" link type="primary" size="small" @click="approveHandler(scope.row, 'agree')" > 同意 </el-button> <el-button v-if="proxy.buttonPerm.reject.if({ approvalStatusName: $props.statusName }, permUrl.reject)" link type="primary" size="small" @click="approveHandler(scope.row, 'refuse')" > 拒绝 </el-button> <el-button v-if="proxy.buttonPerm.submit.if({ approvalStatusName: $props.statusName }, permUrl.submit)" link type="primary" size="small" @click="submit(scope.row)" > 提交 </el-button> <el-button v-if="proxy.buttonPerm.cancel.if({ approvalStatusName: $props.statusName }, permUrl.cancel)" link type="primary" size="small" @click="canHandler(scope.row)" > 取消 </el-button> <el-button v-if="proxy.buttonPerm.delete.if({ approvalStatusName: $props.statusName }, permUrl.del) && $props.statusName !== '全部'" link type="danger" size="small" @click="delHandler(scope.row)" > 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>