<!-- 分包项目申请列表 --> <script lang="ts" setup name="apply"> 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 ButtonBox from '@/components/buttonBox/buttonBox.vue' import { detail, getListPage } from '@/api/business/subpackage/apply' import { SCHEDULE } from '@/utils/scheduleDict' const $router = useRouter() const { proxy } = getCurrentInstance() as any const TabActiveButton = 'SubpackageApplyActive' 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_APPLY, // 表单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: 'applicantName', align: 'center', width: '160px' }, { text: '分包方名称', value: 'outsourcerName', align: 'center' }, { text: '分包原因', value: 'outsourceReasonName', align: 'center' }, { text: '申请时间', value: 'createTime', align: 'center', width: '180px' }, { text: '审批状态', value: 'applyApprovalStatusName', align: 'center', width: '180px' }, ]) const list = ref([]) const total = ref(0) // 时间变更 watch(timeRange, (val) => { if (val) { listQuery.value.applicantStartTime = `${val[0]}` listQuery.value.applicantEndTime = `${val[1]}` } else { listQuery.value.applicantStartTime = '' listQuery.value.applicantEndTime = '' } }) // 数据查询 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 clearList = () => { listQuery.value = { applicantEndTime: '', // 开始时间 applicantName: '', // 申请人名称 applicantStartTime: '', // 结束时间 approvalStatus: active.value, // 申请状态 formId: SCHEDULE.BUSINESS_SUBPACKAGE_APPLY, // 表单id outsourcerName: '', // 分包方名称 projectName: '', // 分包项目名称 projectNo: '', // 分包项目编号 offset: 1, limit: 20, } timeRange.value = ['', ''] fetchData() } // 搜索 const searchList = () => { fetchData(true) } // 新建 const add = () => { } // 导出 const exportAll = () => { } // 打印 const printList = () => { } // 分页 const changePage = () => { } // 选中 const handleSelectionChange = () => { } // 详情或者编辑 const handleEdit = (row: IApplyList, status: string) => { if (status !== 'edit') { detail({ id: row.id }).then((res) => { console.log(res) }) } } // 取消 const handleCancle = (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="handleEdit(row, 'edit')"> 编辑 </el-button> <el-button size="small" link type="primary" @click="handleEdit(row, 'detail')"> 详情 </el-button> <el-button size="small" link type="danger" @click="handleCancle(row.id)"> 取消 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> <button-box :active="active" :menu="menu" @changeCurrentButton="changeCurrentButton" /> </app-container> </div> </template>