update 管理员列表
This commit is contained in:
parent
1d5aba6455
commit
21d7df2237
@ -4,11 +4,21 @@ import http from '../utils/http'
|
|||||||
* 管理员列表
|
* 管理员列表
|
||||||
*/
|
*/
|
||||||
// 获取管理员列表
|
// 获取管理员列表
|
||||||
export const apiGetSysUserList = params => {
|
export const apiSysUserList = params => {
|
||||||
return http({ url: '/renren-fast-server/sys/user/list', method: 'get', params })
|
return http({ url: '/renren-fast-server/sys/user/list', method: 'get', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取管理员列表
|
// 获取管理员列表
|
||||||
export const apiGetSysRoleSelect = params => {
|
export const apiSysRoleSelect = params => {
|
||||||
return http({ url: '/renren-fast-server/sys/role/select', method: 'get', params })
|
return http({ url: '/renren-fast-server/sys/role/select', method: 'get', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增管理员
|
||||||
|
export const apiSysUserSave = data => {
|
||||||
|
return http({ url: '/renren-fast-server/sys/user/save', method: 'post', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑管理员
|
||||||
|
export const apiSysUserUpdate = data => {
|
||||||
|
return http({ url: '/renren-fast-server/sys/user/update', method: 'post', data })
|
||||||
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
:title="!dataForm.id ? '新增' : '修改'"
|
:title="!dataForm.id ? '新增' : '修改'"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:visible.sync="visible">
|
:visible.sync="visible">
|
||||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="handleConfirm()" label-width="80px">
|
||||||
<el-form-item label="用户名" prop="userName">
|
<el-form-item label="用户名" prop="username">
|
||||||
<el-input v-model="dataForm.userName" placeholder="登录帐号"></el-input>
|
<el-input v-model="dataForm.username" placeholder="登录帐号"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密码" prop="password" :class="{ 'is-required': !dataForm.id }">
|
<el-form-item label="密码" prop="password" :class="{ 'is-required': !dataForm.id }">
|
||||||
<el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
|
<el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<el-input v-model="dataForm.email" placeholder="邮箱"></el-input>
|
<el-input v-model="dataForm.email" placeholder="邮箱"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="手机号" prop="mobile">
|
<el-form-item label="手机号" prop="mobile">
|
||||||
<el-input v-model="dataForm.mobile" placeholder="手机号"></el-input>
|
<el-input v-model="dataForm.mobile" placeholder="手机号" maxlength="11"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="角色" size="mini" prop="roleIdList">
|
<el-form-item label="角色" size="mini" prop="roleIdList">
|
||||||
<el-checkbox-group v-model="dataForm.roleIdList">
|
<el-checkbox-group v-model="dataForm.roleIdList">
|
||||||
@ -33,14 +33,14 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button @click="visible = false">取消</el-button>
|
<el-button @click="visible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
<el-button type="primary" @click="handleConfirm()">确定</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isEmail, isMobile } from '@/utils/validate'
|
import { isEmail, isMobile } from '@/utils/validate'
|
||||||
import { apiGetSysRoleSelect } from '@/api/api_sys'
|
import { apiSysRoleSelect, apiSysUserSave, apiSysUserUpdate } from '@/api/api_sys'
|
||||||
import { apiGetUserInfo } from '@/api/api_user'
|
import { apiGetUserInfo } from '@/api/api_user'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -80,7 +80,7 @@
|
|||||||
roleList: [],
|
roleList: [],
|
||||||
dataForm: {
|
dataForm: {
|
||||||
id: 0,
|
id: 0,
|
||||||
userName: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
comfirmPassword: '',
|
comfirmPassword: '',
|
||||||
salt: '',
|
salt: '',
|
||||||
@ -90,7 +90,7 @@
|
|||||||
status: 1
|
status: 1
|
||||||
},
|
},
|
||||||
dataRule: {
|
dataRule: {
|
||||||
userName: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
username: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
||||||
password: [{ validator: validatePassword, trigger: 'blur' }],
|
password: [{ validator: validatePassword, trigger: 'blur' }],
|
||||||
comfirmPassword: [{ validator: validateComfirmPassword, trigger: 'blur' }],
|
comfirmPassword: [{ validator: validateComfirmPassword, trigger: 'blur' }],
|
||||||
email: [
|
email: [
|
||||||
@ -101,53 +101,29 @@
|
|||||||
{ required: true, message: '手机号不能为空', trigger: 'blur' },
|
{ required: true, message: '手机号不能为空', trigger: 'blur' },
|
||||||
{ validator: validateMobile, trigger: 'blur' }
|
{ validator: validateMobile, trigger: 'blur' }
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
apiName: '' // 新增/编辑接口名
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init1 (id) {
|
init (id) {
|
||||||
this.dataForm.id = id || 0
|
if (id) {
|
||||||
this.$http({
|
this.dataForm.id = id || 0
|
||||||
url: this.$http.adornUrl('/sys/role/select'),
|
this.handleEdit()
|
||||||
method: 'get',
|
this.apiName = apiSysUserUpdate
|
||||||
params: this.$http.adornParams()
|
} else {
|
||||||
}).then(({data}) => {
|
this.handleAdd()
|
||||||
this.roleList = data && data.code === 0 ? data.list : []
|
this.apiName = apiSysUserSave
|
||||||
}).then(() => {
|
}
|
||||||
this.visible = true
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs['dataForm'].resetFields()
|
|
||||||
})
|
|
||||||
}).then(() => {
|
|
||||||
if (this.dataForm.id) {
|
|
||||||
this.$http({
|
|
||||||
url: this.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`),
|
|
||||||
method: 'get',
|
|
||||||
params: this.$http.adornParams()
|
|
||||||
}).then(({data}) => {
|
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.dataForm.userName = data.user.username
|
|
||||||
this.dataForm.salt = data.user.salt
|
|
||||||
this.dataForm.email = data.user.email
|
|
||||||
this.dataForm.mobile = data.user.mobile
|
|
||||||
this.dataForm.roleIdList = data.user.roleIdList
|
|
||||||
this.dataForm.status = data.user.status
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
// 新增/修改
|
// 新增
|
||||||
handleAdd (id) {
|
handleAdd (id) {
|
||||||
this.dataForm.id = id || 0
|
apiSysRoleSelect({}).then(res => {
|
||||||
apiGetSysRoleSelect({}).then(res => {
|
|
||||||
this.roleList = res && res.code === 0 ? res.list : []
|
this.roleList = res && res.code === 0 ? res.list : []
|
||||||
this.visible = true
|
this.visible = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs['dataForm'].resetFields()
|
this.$refs['dataForm'].resetFields()
|
||||||
})
|
})
|
||||||
}).then(() => {
|
|
||||||
this.handleEdit()
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 编辑
|
// 编辑
|
||||||
@ -155,7 +131,7 @@
|
|||||||
apiGetUserInfo({}, `/${this.dataForm.id}`).then(res => {
|
apiGetUserInfo({}, `/${this.dataForm.id}`).then(res => {
|
||||||
if (res && res.code === 0) {
|
if (res && res.code === 0) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.dataForm.userName = res.user.username
|
this.dataForm.username = res.user.username
|
||||||
this.dataForm.salt = res.user.salt
|
this.dataForm.salt = res.user.salt
|
||||||
this.dataForm.email = res.user.email
|
this.dataForm.email = res.user.email
|
||||||
this.dataForm.mobile = res.user.mobile
|
this.dataForm.mobile = res.user.mobile
|
||||||
@ -166,25 +142,12 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 表单提交
|
// 提交
|
||||||
dataFormSubmit () {
|
handleConfirm () {
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$http({
|
this.apiName(this.dataForm).then(res => {
|
||||||
url: this.$http.adornUrl(`/sys/user/${!this.dataForm.id ? 'save' : 'update'}`),
|
if (res && res.code === 0) {
|
||||||
method: 'post',
|
|
||||||
data: this.$http.adornData({
|
|
||||||
'userId': this.dataForm.id || undefined,
|
|
||||||
'username': this.dataForm.userName,
|
|
||||||
'password': this.dataForm.password,
|
|
||||||
'salt': this.dataForm.salt,
|
|
||||||
'email': this.dataForm.email,
|
|
||||||
'mobile': this.dataForm.mobile,
|
|
||||||
'status': this.dataForm.status,
|
|
||||||
'roleIdList': this.dataForm.roleIdList
|
|
||||||
})
|
|
||||||
}).then(({data}) => {
|
|
||||||
if (data && data.code === 0) {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '操作成功',
|
message: '操作成功',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@ -195,7 +158,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(data.msg)
|
this.$message.error(res.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AddOrUpdate from './user-add-or-update'
|
import AddOrUpdate from './user-add-or-update'
|
||||||
import { apiGetSysUserList } from '../../../api/api_sys'
|
import { apiSysUserList } from '../../../api/api_sys'
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -71,7 +71,7 @@
|
|||||||
methods: {
|
methods: {
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
handleGetTableList () {
|
handleGetTableList () {
|
||||||
apiGetSysUserList({
|
apiSysUserList({
|
||||||
'page': this.pageIndex,
|
'page': this.pageIndex,
|
||||||
'limit': this.pageSize,
|
'limit': this.pageSize,
|
||||||
'username': this.dataForm.userName
|
'username': this.dataForm.userName
|
||||||
@ -105,7 +105,7 @@
|
|||||||
handleAddOrUpdate (id) {
|
handleAddOrUpdate (id) {
|
||||||
this.addOrUpdateVisible = true
|
this.addOrUpdateVisible = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdate.handleAdd(id)
|
this.$refs.addOrUpdate.init(id)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 删除
|
// 删除
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user