<!-- 人员登记列表 --> <script name="RegisterList" lang="ts" setup> import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import type { IListQuery } from './person-regitster' import { getStaffList } from '@/api/resource/register' // 定义变量 const { proxy } = getCurrentInstance() as any const $router = useRouter() const searchQuery = reactive<IListQuery>({ name: '', deptName: '', offset: 1, limit: 20, sort: '', order: '', }) const loadingTable = ref<boolean>(false) // 表格loading const total = ref<number>(0) // 数据总条数 const columns = ref([ { text: '人员编号', value: 'staffNo', align: 'center', width: '160' }, { text: '姓名', value: 'staffName', align: 'center' }, { text: '岗位', value: 'station', align: 'center' }, { text: '证号', value: 'certificateNumber', align: 'center' }, { text: '工作部门', value: 'deptName', align: 'center' }, { text: '计量专业', value: 'major', align: 'center' }, ]) // 表头 const list = ref([]) // 表格数据 // 逻辑 const reset = () => { searchQuery.name = '' searchQuery.deptName = '' searchQuery.offset = 1 searchQuery.limit = 20 searchQuery.sort = '' searchQuery.order = '' } const add = () => { $router.push({ query: { title: '新建', operation: 'create', }, path: '/person/register/detail', }) } // 获取数据列表 const getList = () => { loadingTable.value = true getStaffList(searchQuery).then((res) => { if (res.code === 200) { list.value = res.data.rows total.value = Number(res.data.total) } loadingTable.value = false }).catch((_) => { loadingTable.value = false }) } const search = () => { getList() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size?: number; page?: number }) => { if (val && val.size) { searchQuery.limit = val.size } if (val && val.page) { searchQuery.offset = val.page } getList() } onMounted(() => { getList() }) </script> <template> <app-container> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model="searchQuery.name" placeholder="姓名" clearable /> </search-item> <search-item> <el-input v-model="searchQuery.deptName" placeholder="工作部门" clearable /> </search-item> </search-area> <!-- 表格数据展示 --> <table-container> <!-- 表头区域 --> <template #btns-right> <input v-show="(searchQuery.limit === 0)" ref="fileRef" type="file" multiple @change="onFileChange"> <icon-button v-if="proxy.hasPerm(`/measure/person/list/add`)" icon="icon-resource" title="筛选参数持证" @click="add" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/add`)" icon="icon-excel" title="导出参数持证表" @click="add" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/add`)" icon="icon-excel" title="导出人员持证表" @click="add" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/add`)" icon="icon-excel" title="导出任职一览表" @click="add" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/add`)" icon="icon-excel" title="导出人员统计表" @click="add" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/add`)" icon="icon-add" title="新建" @click="add" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/import`)" icon="icon-import" title="批量导入" @click="batchImport" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/mould`)" icon="icon-template" title="模板下载" @click="templateDownload" /> <icon-button v-if="proxy.hasPerm(`/measure/person/list/export`)" icon="icon-export" title="导出" @click="exportExcelBtn" /> </template> <!-- 表格区域 --> <normal-table id="registerTabel" :data="list" :total="total" :columns="columns as any" :query="{ limit: searchQuery.limit, offset: searchQuery.offset }" :list-loading="loadingTable" @change="changePage" > <template #preColumns> <el-table-column label="序号" width="55" align="center"> <template #default="scope"> {{ (searchQuery.offset - 1) * searchQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> <template #columns> <el-table-column fixed="right" label="操作" align="center" width="130"> <template #default="{ row }"> <el-button v-if="proxy.hasPerm(`/measure/person/list/update`)" size="small" type="primary" link @click="update(row)"> 编辑 </el-button> <el-button v-if="proxy.hasPerm(`/measure/person/list/detail`)" size="small" type="primary" link @click="detail(row)"> 详情 </el-button> <el-button v-if="proxy.hasPerm(`/measure/person/list/delete`)" size="small" type="danger" link @click="remove(row)"> 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>