<!-- 分包验收列表 --> <script lang="ts" setup name="check"> import type { Ref } from 'vue' import { ElLoading, ElMessage } from 'element-plus' import type { DateModelType } from 'element-plus' import type { IApplyList, IListQuery } from '../subpackage-interface' import { printJSON } from '@/utils/printUtils' import { exportFile } from '@/utils/exportUtils' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getDictByCode } from '@/api/system/dict' import type { dictType } from '@/views/device/receive/receive' import type { IMenu } from '@/components/buttonBox/buttonBox' import { SCHEDULE } from '@/utils/scheduleDict' import ButtonBox from '@/components/buttonBox/buttonBox.vue' import { getListPage } from '@/api/business/subpackage/check' const $route = useRoute() const $router = useRouter() const { proxy } = getCurrentInstance() as any const TabActiveButton = 'SubpackageCheckActive' const loadingTable = ref(false) const timeRange = ref<[DateModelType, DateModelType]>(['', '']) const menu = ref<IMenu[]>([]) // 审批状态按钮组合 const active = ref('') // 查询条件 const listQuery: Ref<IListQuery> = ref({ applicantEndTime: '', // 开始时间 applicantName: '', // 申请人名称 applicantStartTime: '', // 结束时间 approvalStatus: active.value, // 申请状态 formId: SCHEDULE.BUSINESS_SUBPACKAGE_CHECK, // 表单id outsourcerName: '', // 分包方名称 projectName: '', // 分包项目名称 projectNo: '', // 分包项目编号 offset: 1, limit: 20, }) // 表头 const columns = ref<TableColumn[]>([ { text: '分包项目编号', value: 'projectNo', align: 'center', width: '160px' }, { text: '分包项目名称', value: 'projectName', align: 'center', width: '160px' }, { text: '验收人', value: 'checkerName', align: 'center', width: '160px' }, { text: '分包方名称', value: 'outsourcerName', align: 'center', width: '160px' }, { text: '验收结论', value: 'checkerName', align: 'center' }, { text: '验收时间', value: 'checkTime', align: 'center', width: '180px' }, { text: '审批状态', value: 'applyApprovalStatusName', align: 'center', width: '180px' }, ]) const list = ref([]) const total = ref(0) const permUrl = { edit: `${$route.path}/edit`, // 编辑 agree: `${$route.path}/agree`, // 同意 reject: `${$route.path}/reject`, // 驳回 拒绝 cancel: `${$route.path}/cancle`, // 取消 delete: `${$route.path}/delete`, // 删除 } // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } // 模拟数据 loadingTable.value = false getListPage(listQuery.value).then((response) => { list.value = response.data.rows let interfaceStr = '' for (const key in response.data.rows[0]) { const item = response.data.rows[0][key] interfaceStr += `${key}:${typeof (item)}\n` } console.log(interfaceStr) total.value = parseInt(response.data.total) loadingTable.value = false }) } // 搜索 const searchList = () => { fetchData(true) } // 清除条件 const clearList = () => { listQuery.value = { applicantEndTime: '', // 开始时间 applicantName: '', // 申请人名称 applicantStartTime: '', // 结束时间 approvalStatus: active.value, // 申请状态 formId: SCHEDULE.BUSINESS_SUBPACKAGE_CHECK, // 表单id outsourcerName: '', // 分包方名称 projectName: '', // 分包项目名称 projectNo: '', // 分包项目编号 offset: 1, limit: 20, } timeRange.value = ['', ''] fetchData() } // 时间变更 watch(timeRange, (val) => { if (val) { listQuery.value.applicantStartTime = `${val[0]}` listQuery.value.applicantEndTime = `${val[1]}` } else { listQuery.value.applicantStartTime = '' listQuery.value.applicantEndTime = '' } }) // 新建 const add = () => { $router.push({ name: 'subpackageCheckDetail', params: { type: 'add', }, query: { title: '新建', }, }) } // 导出 const exportAll = () => { } // 打印 const printList = () => { } // 分页 const changePage = () => { } // 选中 const handleSelectionChange = () => { } // 详情 const detail = (row: IApplyList) => { $router.push({ name: 'subpackageCheckDetail', params: { type: 'detail', id: row.id, }, query: { title: '详情', approvalStatusName: menu.value.find(item => item.id === active.value)!.name as string, }, }) } // 编辑 const update = (row: IApplyList) => { $router.push({ name: 'subpackageCheckDetail', params: { type: 'edit', id: row.id, }, query: { title: '编辑', approvalStatusName: menu.value.find(item => item.id === active.value)!.name as string, }, }) } // 提交 const submit = (row: IApplyList) => { } // 同意 const agree = (row: IApplyList) => { } // 驳回 const reject = (row: IApplyList) => { } // 拒绝 const refuse = (row: IApplyList) => { } // 取消 const cancel = (row: IApplyList) => { } // 删除 const remove = (row: IApplyList) => { } // 获取字典值 const getDict = async () => { // 审批状态 const res = await getDictByCode('approvalStatus') // 制作右上角的菜单 res.data.forEach((item: dictType) => { if (item.name === '全部' || item.name === '草稿箱' || item.name === '待审批' || item.name === '审批中' || item.name === '已通过' || item.name === '未通过' || item.name === '已取消') { menu.value.push({ name: item.name, id: `${item.value}`, }) } }) } // 切换tab状态 const changeCurrentButton = (val: string) => { active.value = val window.sessionStorage.setItem(TabActiveButton, val) clearList() } onMounted(async () => { await getDict() if (window.sessionStorage.getItem(TabActiveButton)) { active.value = window.sessionStorage.getItem(TabActiveButton)! } else { active.value = menu.value.find(item => item.name === '全部')!.id as string // 全部 } }) </script> <template> <div> <!-- 布局 --> <app-container> <search-area :need-clear="true" @search="searchList" @clear="clearList"> <search-item> <el-input v-model.trim="listQuery.projectNo" placeholder="分包项目编号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.projectName" placeholder="分包项目名称" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.applicantName" placeholder="验收人" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.outsourcerName" placeholder="分包方名称" class="short-input" clearable /> </search-item> <search-item> <el-date-picker v-model="timeRange" 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 icon="icon-add" title="新建" type="primary" @click="add" /> <icon-button icon="icon-export" title="导出" type="primary" @click="exportAll" /> <icon-button icon="icon-print" title="打印" type="primary" @click="printList" /> </template> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange" > <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 label="操作" align="center" fixed="right" width="120"> <template #default="{ row }"> <el-button size="small" type="primary" link @click="detail(row)" > 查看 </el-button> <el-button v-if="proxy.buttonPerm.edit.if(row, permUrl.edit)" size="small" type="primary" link @click="update(row)" > 编辑 </el-button> <el-button v-if="proxy.buttonPerm.submit.if(row)" size="small" type="primary" link @click="submit(row)" > 提交 </el-button> <el-button v-if="proxy.buttonPerm.agree.if(row, permUrl.agree)" size="small" type="primary" link :disabled="proxy.buttonPerm.agree.disabled(row)" @click="agree(row)" > 同意 </el-button> <el-button v-if="proxy.buttonPerm.reject.if(row, permUrl.reject)" size="small" type="primary" link :disabled="proxy.buttonPerm.reject.disabled(row)" @click="reject(row)" > 驳回 </el-button> <el-button v-if="proxy.buttonPerm.refuse.if(row, permUrl.reject)" size="small" type="danger" link :disabled="proxy.buttonPerm.refuse.disabled(row)" @click="refuse(row)" > 拒绝 </el-button> <el-button v-if="proxy.buttonPerm.cancel.if(row, permUrl.cancel)" size="small" type="info" link :disabled="proxy.buttonPerm.cancel.disabled(row)" @click="cancel(row)" > 取消 </el-button> <el-button v-show="menu.find(item => item.id === active)!.name as string === '草稿箱' ? true : false" v-if="proxy.buttonPerm.delete.if(row, permUrl.delete)" :disabled="proxy.buttonPerm.delete.disabled(row)" size="small" type="danger" link @click="remove(row)" > 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> <button-box :active="active" :menu="menu" @changeCurrentButton="changeCurrentButton" /> </app-container> </div> </template>