| | |
| | | clearable |
| | | size="small" |
| | | style="width: 240px" |
| | | maxlength="50" |
| | | @keyup.enter.native="reGetList" |
| | | /> |
| | | </el-form-item> |
| | |
| | | |
| | | <el-table :data="list"> |
| | | <el-table-column type="index" label="序号" align="center" width="60" /> |
| | | <el-table-column label="姓名" prop="name" align="center" min-width="120" /> |
| | | <el-table-column label="名称" prop="name" align="center" min-width="120" /> |
| | | <el-table-column label="账号" prop="account" align="center" min-width="120" /> |
| | | <el-table-column label="账号类型" prop="account" align="center" min-width="120"> |
| | | <template slot-scope="scope"> |
| | | <span v-if="accountTypeOptions[scope.row.type]">{{ accountTypeOptions[scope.row.type].name }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="角色" prop="roleName" align="center" min-width="120" /> |
| | | <!-- <el-table-column label="最近登录时间" prop="loginTime" align="center" min-width="180" /> --> |
| | | <el-table-column label="状态" align="center" min-width="100"> |
| | |
| | | /> |
| | | |
| | | <!-- 新增&编辑 --> |
| | | <el-dialog :title="adminDialogData.type=='add'?'新增管理员':'编辑管理员'" width="500px" :visible.sync="isShowadminDialog" append-to-body> |
| | | <el-form ref="adminDialog" :model="adminDialogData" label-width="80px" :rules="rules"> |
| | | <el-dialog v-el-drag-dialog :title="adminDialogData.type==='add'?'新增管理员':'编辑管理员'" width="500px" :visible.sync="adminDialogVisible" append-to-body :close-on-click-modal="false"> |
| | | <el-form ref="adminDialog" :model="adminDialogData" label-width="80px" :rules="rules" size="small"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="adminDialogData.name" placeholder="请输入名称" /> |
| | | <el-input v-model="adminDialogData.name" placeholder="请输入名称" maxlength="50" /> |
| | | </el-form-item> |
| | | <el-form-item label="账号" prop="account"> |
| | | <el-input v-model="adminDialogData.account" placeholder="请输入帐号" :disabled="adminDialogData.type!='add'" /> |
| | | <el-input v-model="adminDialogData.account" placeholder="请输入帐号" maxlength="20" :disabled="adminDialogData.type!='add'" /> |
| | | </el-form-item> |
| | | <el-form-item label="密码" prop="password"> |
| | | <el-input v-model="adminDialogData.password" type="password" placeholder="请输入密码" /> |
| | | <el-form-item label="密码" :prop="adminDialogData.type==='add'?'password':'none'"> |
| | | <el-input v-model="adminDialogData.password" type="password" placeholder="请输入密码" maxlength="20" /> |
| | | </el-form-item> |
| | | <el-form-item label="确认密码" prop="passwordSure"> |
| | | <el-input v-model="adminDialogData.passwordSure" type="password" placeholder="请输入确认密码" /> |
| | | <el-form-item label="确认密码" :prop="adminDialogData.type==='add'?'passwordSure':'none'"> |
| | | <el-input v-model="adminDialogData.passwordSure" type="password" placeholder="请输入确认密码" maxlength="20" /> |
| | | </el-form-item> |
| | | <!-- 账号类型 --> |
| | | <el-form-item label="账号类型" prop="accountType"> |
| | | <el-select |
| | | v-model="adminDialogData.accountType" |
| | | clearable |
| | | placeholder="账号类型" |
| | | style="width: 100%" |
| | | > |
| | | <el-option v-for="item in accountTypeOptions" :key="item.id" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- 角色 --> |
| | | <!-- 选择框 --> |
| | | <el-form-item label="角色" prop="sysRoleId"> |
| | | <el-select |
| | | v-model="adminDialogData.sysRoleId" |
| | | clearable |
| | | placeholder="角色" |
| | | class="com-edit-input" |
| | | style="width: 100%" |
| | | > |
| | | <el-option v-for="item in roleArr" :key="item.id" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="是否启用" prop="isUse"> |
| | | <el-switch |
| | | v-model="adminDialogData.isUse" |
| | | :active-value="1" |
| | | :inactive-value="0" |
| | | /> |
| | | </el-form-item> |
| | | |
| | | </el-form> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | export default { |
| | | name: 'Admin', |
| | | data() { |
| | |
| | | |
| | | // 角色列表 |
| | | roleArr: [], |
| | | // 账号类型 |
| | | accountTypeOptions: [ |
| | | { name: '普通管理员', id: 1 }, |
| | | { name: '超级管理员', id: 0 } |
| | | ], |
| | | |
| | | isShowadminDialog: false, |
| | | adminDialogVisible: false, |
| | | adminDialogData: {}, |
| | | |
| | | // 分页 ↓↓↓↓↓↓↓↓↓↓ |
| | |
| | | ], |
| | | sysRoleId: [ |
| | | { required: true, message: '角色不能为空', trigger: 'change' } |
| | | ], |
| | | accountType: [ |
| | | { required: true, message: '账号类型不能为空', trigger: 'change' } |
| | | ], |
| | | isUse: [ |
| | | { required: true, message: '是否启用不能为空', trigger: 'change' } |
| | | ] |
| | | } |
| | | } |
| | |
| | | // 获取角色列表 |
| | | getRoleList() { |
| | | this.postFN({ |
| | | url: 'admin/roleList', |
| | | url: 'admin/role/list', |
| | | params: { |
| | | pageNum: 1, |
| | | pageSize: 9999 |
| | | }, |
| | | mockData: { |
| | | code: 100, |
| | | msg: '', |
| | | data: [{ |
| | | id: 'xxx', |
| | | name: '野马发' |
| | | }] |
| | | data: { |
| | | list: [{ |
| | | id: 'xxx', |
| | | name: '野马发' |
| | | }] |
| | | } |
| | | } |
| | | }, (inf) => { |
| | | this.roleArr = inf || [] |
| | | this.roleArr = inf.list || [] |
| | | }) |
| | | }, |
| | | |
| | |
| | | url: 'admin/list', |
| | | params: { |
| | | pageNum: pageNum, |
| | | rowCount: pageSize, |
| | | pageSize: pageSize, |
| | | keyWord: keyWord |
| | | }, |
| | | mockData: { |
| | |
| | | account: '', |
| | | password: '', |
| | | passwordSure: '', |
| | | sysRoleId: '' |
| | | sysRoleId: '', |
| | | isUse: 1, |
| | | accountType: 1 |
| | | } |
| | | this.adminDialogData = adminDialogData |
| | | this.isShowadminDialog = true |
| | | this.adminDialogVisible = true |
| | | this.$nextTick(() => { |
| | | this.adminDialogData = adminDialogData |
| | | this.$refs['adminDialog'].resetFields() |
| | | }) |
| | | }, |
| | | // 打开编辑分类弹框 |
| | | showEditAdminDialog(item) { |
| | |
| | | password: '', |
| | | passwordSure: '', |
| | | sysRoleId: item.roId, |
| | | id: item.id |
| | | id: item.id, |
| | | isUse: item.isUse, |
| | | accountType: item.type |
| | | } |
| | | this.adminDialogData = adminDialogData |
| | | this.isShowadminDialog = true |
| | | this.adminDialogVisible = true |
| | | this.$nextTick(() => { |
| | | this.adminDialogData = adminDialogData |
| | | this.$refs['adminDialog'].resetFields() |
| | | }) |
| | | }, |
| | | // 关闭编辑弹窗 |
| | | hideAdminDialog() { |
| | | this.adminDialogData = {} |
| | | this.isShowadminDialog = false |
| | | this.adminDialogVisible = false |
| | | }, |
| | | // 提交新增&编辑 |
| | | submitAdmin(type) { |
| | |
| | | var params = { |
| | | name: adminDialogData.name, |
| | | account: adminDialogData.account, |
| | | password: adminDialogData.password, |
| | | sysAdRoleId: adminDialogData.sysRoleId |
| | | sysAdRoleId: adminDialogData.sysRoleId, |
| | | isUse: adminDialogData.isUse, |
| | | type: adminDialogData.accountType |
| | | } |
| | | if (adminDialogData.password) params.password = adminDialogData.password |
| | | var isAdd = adminDialogData.type === 'add' |
| | | var url = isAdd ? 'admin/add' : 'admin/update' |
| | | |
| | |
| | | }, () => { |
| | | this.$messageSuc('保存成功') |
| | | this.hideAdminDialog() |
| | | this.getList() |
| | | isAdd ? this.reGetList() : this.getList() |
| | | }) |
| | | } |
| | | }) |