| | |
| | | <el-table-column prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column> |
| | | <el-table-column label="操作" width="100"> |
| | | <template #default="scope"> |
| | | <el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onOpenUserDialog('修改',scope.row)">修改</el-button> |
| | | <el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onRowDel(scope.row)">删除</el-button> |
| | | <el-button |
| | | :disabled="scope.row.userName === 'admin'" |
| | | size="small" |
| | | text |
| | | type="primary" |
| | | @click="onOpenUserDialog('修改', scope.row)" |
| | | >修改</el-button |
| | | > |
| | | <el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onRowDel(scope.row)" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <br /> |
| | | <el-pagination |
| | | @size-change="onHandleSizeChange" |
| | | @current-change="onHandleCurrentChange" |
| | | class="mt15" |
| | | class="page-position" |
| | | :pager-count="5" |
| | | :page-sizes="[10, 20, 30]" |
| | | v-model:current-page="userTableData.listQuery.pageIndex" |
| | |
| | | :total="userTableData.total" |
| | | > |
| | | </el-pagination> |
| | | <br /> |
| | | <br /> |
| | | </el-card> |
| | | <userDialog ref="userRef" @getUserList = "initUserTableData"/> |
| | | </div> |
| | |
| | | import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue'; |
| | | import { ElMessageBox, ElMessage } from 'element-plus'; |
| | | import userDialog from '/@/views/system/user/component/userDialog.vue'; |
| | | import {userApi} from "/@/api/user"; |
| | | import {departmentApi} from "/@/api/department"; |
| | | import {useRoleApi} from "/@/api/role"; |
| | | import { userApi } from '/@/api/user'; |
| | | import { departmentApi } from '/@/api/department'; |
| | | import { useRoleApi } from '/@/api/role'; |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface TableDataRow { |
| | |
| | | describe: string; |
| | | createTime: string; |
| | | } |
| | | interface DepartmentDataRow{ |
| | | |
| | | } |
| | | interface DepartmentDataRow {} |
| | | interface TableDataState { |
| | | userTableData: { |
| | | data: Array<TableDataRow>; |
| | |
| | | loading: boolean; |
| | | listQuery: { |
| | | searchParams:{ |
| | | username:string, |
| | | realName:string, |
| | | }, |
| | | username: string; |
| | | realName: string; |
| | | }; |
| | | pageIndex: number; |
| | | pageSize: number; |
| | | }; |
| | |
| | | listQuery: { |
| | | searchParams:{ |
| | | username:'', |
| | | realName:'', |
| | | realName: '' |
| | | }, |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | }, |
| | | pageSize: 10 |
| | | } |
| | | }, |
| | | departmentList:[], |
| | | roleList:[], |
| | | roleList: [] |
| | | }); |
| | | // 初始化表格数据 |
| | | const initUserTableData = async () => { |
| | | let res = await userApi().getUserList(state.userTableData.listQuery) |
| | | let res = await userApi().getUserList(state.userTableData.listQuery); |
| | | if(res.data.code === '200'){ |
| | | state.userTableData.data = res.data.data; |
| | | state.userTableData.total = res.data.data.length; |
| | | state.userTableData.total = res.data.total; |
| | | }else{ |
| | | ElMessage({ |
| | | type:'warning', |
| | | message:res.data.msg |
| | | }) |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | const getDepartmentData = async () => { |
| | | let res = await departmentApi().getDepartmentList() |
| | | let res = await departmentApi().getDepartmentList(); |
| | | if(res.data.code === '200'){ |
| | | state.departmentList = res.data.data |
| | | state.departmentList = res.data.data; |
| | | }else{ |
| | | ElMessage({ |
| | | type:'warning', |
| | | message:res.data.msg |
| | | }) |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | const getRoleData = async () => { |
| | | let res = await useRoleApi().getRoleList() |
| | | let res = await useRoleApi().getRoleList(); |
| | | if(res.data.code === '200'){ |
| | | state.roleList = res.data.data |
| | | state.roleList = res.data.data; |
| | | }else{ |
| | | ElMessage({ |
| | | type:'warning', |
| | | message:res.data.msg |
| | | }) |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // 打开新增修改用户弹窗 |
| | | const onOpenUserDialog = (type: string,value: any) => { |
| | |
| | | ElMessageBox.confirm(`此操作将永久删除账户名称:“${row.userName}”,是否继续?`, '提示', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | type: 'warning' |
| | | }) |
| | | .then(() => { |
| | | ElMessage.success('删除成功'); |
| | | }).catch(() => {}); |
| | | }) |
| | | .catch(() => {}); |
| | | }; |
| | | // 分页改变 |
| | | const onHandleSizeChange = (val: number) => { |
| | | state.userTableData.listQuery.pageSize = val; |
| | | initUserTableData() |
| | | initUserTableData(); |
| | | }; |
| | | // 分页改变 |
| | | const onHandleCurrentChange = (val: number) => { |
| | | state.userTableData.listQuery.pageSize = val; |
| | | initUserTableData() |
| | | state.userTableData.listQuery.pageIndex = val; |
| | | initUserTableData(); |
| | | }; |
| | | // 页面加载时 |
| | | onMounted(() => { |
| | |
| | | onHandleSizeChange, |
| | | initUserTableData, |
| | | onHandleCurrentChange, |
| | | ...toRefs(state), |
| | | ...toRefs(state) |
| | | }; |
| | | }, |
| | | } |
| | | }); |
| | | </script> |