提交 60d01465 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 用户管理完善

上级 ccecdc8c
...@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper; ...@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
import io.dataease.commons.utils.PageUtils; import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager; import io.dataease.commons.utils.Pager;
import io.dataease.controller.sys.request.SysUserCreateRequest; import io.dataease.controller.sys.request.SysUserCreateRequest;
import io.dataease.controller.sys.request.SysUserStateRequest;
import io.dataease.controller.sys.request.UserGridRequest; import io.dataease.controller.sys.request.UserGridRequest;
import io.dataease.controller.sys.response.SysUserGridResponse; import io.dataease.controller.sys.response.SysUserGridResponse;
import io.dataease.service.sys.SysUserService; import io.dataease.service.sys.SysUserService;
...@@ -47,4 +48,11 @@ public class SysUserController { ...@@ -47,4 +48,11 @@ public class SysUserController {
public void delete(@PathVariable("userId") Long userId){ public void delete(@PathVariable("userId") Long userId){
sysUserService.delete(userId); sysUserService.delete(userId);
} }
@ApiOperation("更新用户状态")
@PostMapping("/updateStatus")
public void updateStatus(@RequestBody SysUserStateRequest request){
sysUserService.updateStatus(request);
}
} }
package io.dataease.controller.sys.request;
import lombok.Data;
import java.io.Serializable;
@Data
public class SysUserStateRequest implements Serializable {
private Long userId;
private Long enabled;
}
...@@ -10,6 +10,7 @@ import io.dataease.base.mapper.ext.ExtSysUserMapper; ...@@ -10,6 +10,7 @@ import io.dataease.base.mapper.ext.ExtSysUserMapper;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CodingUtil; import io.dataease.commons.utils.CodingUtil;
import io.dataease.controller.sys.request.SysUserCreateRequest; import io.dataease.controller.sys.request.SysUserCreateRequest;
import io.dataease.controller.sys.request.SysUserStateRequest;
import io.dataease.controller.sys.request.UserGridRequest; import io.dataease.controller.sys.request.UserGridRequest;
import io.dataease.controller.sys.response.SysUserGridResponse; import io.dataease.controller.sys.response.SysUserGridResponse;
import io.dataease.controller.sys.response.SysUserRole; import io.dataease.controller.sys.response.SysUserRole;
...@@ -74,6 +75,14 @@ public class SysUserService { ...@@ -74,6 +75,14 @@ public class SysUserService {
return sysUserMapper.updateByPrimaryKey(user); return sysUserMapper.updateByPrimaryKey(user);
} }
public int updateStatus(SysUserStateRequest request){
SysUser sysUser = new SysUser();
sysUser.setUserId(request.getUserId());
sysUser.setEnabled(request.getEnabled());
return sysUserMapper.updateByPrimaryKeySelective(sysUser);
}
/** /**
* 删除用户角色关联 * 删除用户角色关联
* @param userId * @param userId
......
import request from '@/utils/request' import request from '@/utils/request'
const pathMap = {
queryPath: '/api/user/userGrid/',
deletePath: '/api/user/delete/',
createPath: '/api/user/create',
updatePath: '/api/user/update',
editPasswordPath: '/api/user/password',
editStatusPath: '/api/user/updateStatus'
}
export function userLists(page, size, data) { export function userLists(page, size, data) {
return request({ return request({
url: 'api/user/userGrid/' + page + '/' + size, url: pathMap.queryPath + page + '/' + size,
method: 'post',
data
})
}
export const addUser = (data) => {
return request({
url: pathMap.createPath,
method: 'post', method: 'post',
data data
}) })
} }
export const editUser = (data) => {
return request({
url: pathMap.updatePath,
method: 'post',
data
})
}
export const delUser = (userId) => {
return request({
url: pathMap.deletePath + userId,
method: 'post'
})
}
export const editPassword = (data) => {
return request({
url: pathMap.editPasswordPath,
method: 'post',
data
})
}
export const editStatus = (data) => {
return request({
url: pathMap.editStatusPath,
method: 'post',
data
})
}
export default { editPassword, delUser, editUser, addUser, userLists, editStatus }
import request from '@/utils/request' import Mock from 'mockjs'
const data = Mock.mock({
'items|30': [{
id: '@id',
title: '@sentence(10, 20)',
'status|1': ['published', 'draft', 'deleted'],
author: 'name',
display_time: '@datetime',
pageviews: '@integer(300, 5000)'
}]
})
export function getList(params) { export function getList(params) {
return request({ // return request({
url: '/vue-admin-template/table/list', // url: '/vue-admin-template/table/list',
method: 'get', // method: 'get',
params // params
// })
return new Promise((resolve, reject) => {
const items = data.items
const result = {
code: 20000,
data: {
total: items.length,
items: items
}
}
resolve(result)
}) })
} }
<template> <template>
<el-aside :width="width" class="ms-aside-container" <el-aside
:style="{'margin-left': !asideHidden ? 0 : '-' + width}"> :width="width"
class="ms-aside-container"
:style="{'margin-left': !asideHidden ? 0 : '-' + width}"
>
<!--<div v-if="enableAsideHidden" class="hiddenBottom" @click="asideHidden = !asideHidden">--> <!--<div v-if="enableAsideHidden" class="hiddenBottom" @click="asideHidden = !asideHidden">-->
<!--<i v-if="!asideHidden" class="el-icon-arrow-left"/>--> <!--<i v-if="!asideHidden" class="el-icon-arrow-left"/>-->
<!--<i v-if="asideHidden" class="el-icon-arrow-right"/>--> <!--<i v-if="asideHidden" class="el-icon-arrow-right"/>-->
<!--</div>--> <!--</div>-->
<slot></slot> <slot />
<ms-horizontal-drag-bar/> <ms-horizontal-drag-bar />
</el-aside> </el-aside>
</template> </template>
<script> <script>
import MsHorizontalDragBar from "./dragbar/MsLeft2RightDragBar"; import MsHorizontalDragBar from './dragbar/MsLeft2RightDragBar'
export default { export default {
name: "MsAsideContainer", name: 'MsAsideContainer',
components: {MsHorizontalDragBar}, components: { MsHorizontalDragBar },
props: { props: {
width: { width: {
type: String, type: String,
default: '300px' default: '300px'
}, },
enableAsideHidden: { enableAsideHidden: {
type: Boolean, type: Boolean,
default: true default: true
},
},
data() {
return {
asideHidden: false
}
}
} }
},
data() {
return {
asideHidden: false
}
}
}
</script> </script>
<style scoped> <style scoped>
......
<template> <template>
<el-container class="ms-container"> <el-container class="ms-container">
<slot></slot> <slot />
</el-container> </el-container>
</template> </template>
<script> <script>
export default { export default {
name: "MsContainer" name: 'MsContainer'
} }
</script> </script>
<style scoped> <style scoped>
......
<template> <template>
<el-dialog :close-on-click-modal="false" <el-dialog
:title="title" :close-on-click-modal="false"
:visible.sync="dialogVisible" :title="title"
class="delete-confirm" > :visible.sync="dialogVisible"
class="delete-confirm"
>
<el-row> <el-row>
<el-col> <el-col>
<span>{{$t('commons.delete_confirm')}}</span> <span>{{ $t('commons.delete_confirm') }}</span>
<span class="delete-tip"> DELETE-{{record.name || record.title}}</span> <span class="delete-tip"> DELETE-{{ record.name || record.title }}</span>
<br/> <br>
</el-col> </el-col>
</el-row> </el-row>
<el-row class="tip" v-if="withTip"> <el-row v-if="withTip" class="tip">
<span> <span>
<slot class="tip"></slot> <slot class="tip" />
</span> </span>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="15"> <el-col :span="15">
<el-input v-model="value" :placeholder="$t('commons.input_content')"/> <el-input v-model="value" :placeholder="$t('commons.input_content')" />
</el-col> </el-col>
</el-row> </el-row>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{$t('commons.cancel')}}</el-button> <el-button @click="dialogVisible = false">{{ $t('commons.cancel') }}</el-button>
<el-button type="primary" @click="confirm">{{$t('commons.confirm')}}</el-button> <el-button type="primary" @click="confirm">{{ $t('commons.confirm') }}</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
export default { export default {
name: "MsDeleteConfirm", name: 'MsDeleteConfirm',
data() { props: {
return { title: {
dialogVisible: false, type: String,
value: '', default() {
record: {}, return this.$t('commons.title')
}
},
props: {
title: {
type: String,
default() {
return this.$t('commons.title')
}
},
withTip: {
type: Boolean,
default() {
return false
}
}
},
methods: {
open(record) {
this.dialogVisible = true;
this.value = '';
this.record = record;
},
confirm() {
if (this.value.trim() != 'DELETE-' + (this.record.name || this.record.title) ) {
this.$warning(this.$t('commons.incorrect_input'));
return;
}
this.$emit('delete', this.record);
this.dialogVisible = false;
}
} }
},
withTip: {
type: Boolean,
default() {
return false
}
}
},
data() {
return {
dialogVisible: false,
value: '',
record: {}
} }
},
methods: {
open(record) {
this.dialogVisible = true
this.value = ''
this.record = record
},
confirm() {
if (this.value.trim() !== 'DELETE-' + (this.record.name || this.record.title)) {
this.$warning(this.$t('commons.incorrect_input'))
return
}
this.$emit('delete', this.record)
this.dialogVisible = false
}
}
}
</script> </script>
<style scoped> <style scoped>
......
<template> <template>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="cancel">{{$t('commons.cancel')}}</el-button> <el-button @click="cancel">{{ $t('commons.cancel') }}</el-button>
<el-button type="warning" v-if="isShowValidate" @click="validate" @keydown.enter.native.prevent>{{$t('commons.validate')}}</el-button> <el-button v-if="isShowValidate" type="warning" @click="validate" @keydown.enter.native.prevent>{{ $t('commons.validate') }}</el-button>
<el-button type="primary" :disabled="disabled" @click="confirm" @keydown.enter.native.prevent>{{$t('commons.confirm')}}</el-button> <el-button type="primary" :disabled="disabled" @click="confirm" @keydown.enter.native.prevent>{{ $t('commons.confirm') }}</el-button>
<el-button type="primary" v-if="isShow" @click="saveAsEdit" @keydown.enter.native.prevent>{{title}}</el-button> <el-button v-if="isShow" type="primary" @click="saveAsEdit" @keydown.enter.native.prevent>{{ title }}</el-button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "MsDialogFooter", name: 'MsDialogFooter',
props: { props: {
isShow: { isShow: {
type: Boolean, type: Boolean,
default: false, default: false
},
isShowValidate: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
title:String,
}, },
methods: { isShowValidate: {
cancel() { type: Boolean,
this.$emit("cancel"); default: false
}, },
validate() { disabled: {
this.$emit("validate"); type: Boolean,
}, default: false
confirm() { },
this.$emit("confirm"); title: String
}, },
saveAsEdit() { methods: {
this.$emit("saveAsEdit"); cancel() {
} this.$emit('cancel')
},
validate() {
this.$emit('validate')
},
confirm() {
this.$emit('confirm')
},
saveAsEdit() {
this.$emit('saveAsEdit')
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
<template> <template>
<el-main class="ms-main-container"> <el-main class="ms-main-container">
<slot></slot> <slot />
</el-main> </el-main>
</template> </template>
<script> <script>
export default { export default {
name: "MsMainContainer" name: 'MsMainContainer'
} }
</script> </script>
<style scoped> <style scoped>
......
...@@ -12,13 +12,11 @@ ...@@ -12,13 +12,11 @@
</template> </template>
<script> <script>
import MsTableButton from './MsTableButton'
import MsTipButton from './MsTipButton' import MsTipButton from './MsTipButton'
import { checkoutTestManagerOrTestUser, hasRoles } from '@/metersphere/common/js/utils' import { checkoutTestManagerOrTestUser } from '@/metersphere/common/js/utils'
import { ROLE_TEST_MANAGER, ROLE_TEST_USER } from '@/metersphere/common/js/constants'
export default { export default {
name: 'MsTableOperatorButton', name: 'MsTableOperatorButton',
components: { MsTipButton, MsTableButton }, components: { MsTipButton },
props: { props: {
icon: { icon: {
type: String, type: String,
...@@ -29,7 +27,8 @@ export default { ...@@ -29,7 +27,8 @@ export default {
default: 'primary' default: 'primary'
}, },
tip: { tip: {
type: String type: String,
default: ''
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
......
...@@ -19,10 +19,11 @@ export default { ...@@ -19,10 +19,11 @@ export default {
name: 'MsTableSearchBar', name: 'MsTableSearchBar',
props: { props: {
condition: { condition: {
type: Object type: Object,
default: null
}, },
tip: { tip: {
String, type: String,
default() { default() {
return this.$t('commons.search_by_name') return this.$t('commons.search_by_name')
} }
......
@import './main.css'; @import './main.css';
@import './menu-header.css'; /* @import './menu-header.css';
@import '../theme/index.css'; @import '../theme/index.css'; */
\ No newline at end of file
import {Message} from 'element-ui'; import { Message } from 'element-ui'
export default { export default {
install(Vue) { install(Vue) {
if (!Message) { if (!Message) {
window.console.error('You have to install Message of ElementUI'); window.console.error('You have to install Message of ElementUI')
return return
} }
Vue.prototype.$success = function (message) { Vue.prototype.$success = function(message) {
Message.success({ Message.success({
message: message, message: message,
type: "success", type: 'success',
showClose: true, showClose: true,
duration: 1500 duration: 1500
}) })
}; }
Vue.prototype.$info = function (message, duration) { Vue.prototype.$info = function(message, duration) {
Message.info({ Message.info({
message: message, message: message,
type: "info", type: 'info',
showClose: true, showClose: true,
duration: duration || 3000 duration: duration || 3000
}) })
}; }
Vue.prototype.$warning = function (message) { Vue.prototype.$warning = function(message) {
Message.warning({ Message.warning({
message: message, message: message,
type: "warning", type: 'warning',
showClose: true, showClose: true,
duration: 5000 duration: 5000
}) })
}; }
Vue.prototype.$error = function (message, duration) { Vue.prototype.$error = function(message, duration) {
Message.error({ Message.error({
message: message, message: message,
type: "error", type: 'error',
showClose: true, showClose: true,
duration: duration || 10000 duration: duration || 10000
}) })
}; }
} }
} }
...@@ -64,61 +64,29 @@ export const constantRoutes = [ ...@@ -64,61 +64,29 @@ export const constantRoutes = [
component: () => import('@/views/dashboard/index'), component: () => import('@/views/dashboard/index'),
meta: { title: '首页', icon: 'dashboard' } meta: { title: '首页', icon: 'dashboard' }
}] }]
} },
// {
// path: '/system',
// component: Layout,
// redirect: '/system/user',
// name: '系统管理',
// meta: {
// title: '系统管理',
// icon: 'system'
// },
// children: [
// {
// path: 'user',
// name: '用户管理',
// meta: {
// title: ' 用户管理',
// icon: 'peoples'
// }
// },
// {
// path: 'menu',
// name: '菜单管理',
// meta: {
// title: ' 菜单管理',
// icon: 'menu'
// }
// }
// ]
// },
// { {
// path: '/example', path: '/example',
// component: Layout, component: Layout,
// redirect: '/example/table', redirect: '/example/table',
// name: 'Example', name: 'Example',
// meta: { title: 'Example', icon: 'example' }, meta: { title: 'Example', icon: 'example' },
// children: [ children: [
// { {
// path: 'table', path: 'table',
// name: 'Table', name: 'Table',
// component: () => import('@/views/table/index'), component: () => import('@/views/table/index'),
// meta: { title: 'Table', icon: 'table' } meta: { title: 'Table', icon: 'table' }
// }, },
// { {
// path: 'tree', path: 'tree',
// name: 'Tree', name: 'Tree',
// component: () => import('@/views/tree/index'), component: () => import('@/views/tree/index'),
// meta: { title: 'Tree', icon: 'tree' } meta: { title: 'Tree', icon: 'tree' }
// } }
// ] ]
// }, }
// { // {
// path: '/form', // path: '/form',
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
@import './sidebar.scss'; @import './sidebar.scss';
@import './topbar.scss'; @import './topbar.scss';
@import '../metersphere/common/css/index.css'; // @import '../metersphere/common/css/index.css';
body { body {
......
<template> <template>
<el-col> <el-col>
<span>{{table.name}}</span> <span>{{ table.name }}</span>
<el-table <el-table
size="mini" size="mini"
:data="data" :data="data"
height="40vh" height="40vh"
border border
style="width: 100%;margin-top: 6px;"> style="width: 100%;margin-top: 6px;"
<el-table-column >
min-width="200px" <el-table-column
v-for="field in fields" v-for="field in fields"
:key="field.originName" :key="field.originName"
:prop="field.originName" min-width="200px"
:label="field.name"> :prop="field.originName"
</el-table-column> :label="field.name"
</el-table> />
</el-col> </el-table>
</el-col>
</template> </template>
<script> <script>
export default { export default {
name: 'DatasetTableData',
props: { props: {
table: Object table: Object
}, },
name: "DatasetTableData",
data() { data() {
return { return {
fields: [], fields: [],
data: [] data: []
} }
}, },
watch: {
table() {
this.initData()
}
},
created() { created() {
this.initData(); this.initData()
}, },
mounted() { mounted() {
}, },
methods: { methods: {
initData() { initData() {
this.resetData(); this.resetData()
if (this.table.id) { if (this.table.id) {
this.$post('/dataset/table/getPreviewData', this.table, response => { this.$post('/dataset/table/getPreviewData', this.table, response => {
this.fields = response.data.fields; this.fields = response.data.fields
this.data = response.data.data; this.data = response.data.data
}); })
} }
}, },
resetData() { resetData() {
this.fields = []; this.fields = []
this.data = []; this.data = []
}
},
watch: {
table() {
this.initData();
} }
} }
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<div class="block"> <div class="block">
<el-tree <el-tree
:default-expanded-keys="expandedArray" :default-expanded-keys="expandedArray"
:data="data" :data="tData"
node-key="id" node-key="id"
:expand-on-click-node="true" :expand-on-click-node="true"
@node-click="nodeClick" @node-click="nodeClick"
...@@ -240,7 +240,7 @@ export default { ...@@ -240,7 +240,7 @@ export default {
search: '', search: '',
editGroup: false, editGroup: false,
editTable: false, editTable: false,
data: [], tData: [],
tableData: [], tableData: [],
currGroup: {}, currGroup: {},
expandedArray: [], expandedArray: [],
...@@ -462,7 +462,7 @@ export default { ...@@ -462,7 +462,7 @@ export default {
tree(group) { tree(group) {
groupTree(group).then(res => { groupTree(group).then(res => {
this.data = res.data.data this.tData = res.data.data
}) })
}, },
......
...@@ -159,7 +159,6 @@ ...@@ -159,7 +159,6 @@
</template> </template>
<script> <script>
import MsCreateBox from '../CreateBox'
import MsTablePagination from '@/metersphere/common/pagination/TablePagination' import MsTablePagination from '@/metersphere/common/pagination/TablePagination'
import MsTableHeader from '@/metersphere/common/components/MsTableHeader' import MsTableHeader from '@/metersphere/common/components/MsTableHeader'
import MsTableOperator from '@/metersphere/common/components/MsTableOperator' import MsTableOperator from '@/metersphere/common/components/MsTableOperator'
...@@ -176,7 +175,6 @@ export default { ...@@ -176,7 +175,6 @@ export default {
name: 'DEDatasource', name: 'DEDatasource',
components: { components: {
MsDeleteConfirm, MsDeleteConfirm,
MsCreateBox,
MsTablePagination, MsTablePagination,
MsTableHeader, MsTableHeader,
MsTableOperator, MsTableOperator,
...@@ -356,7 +354,7 @@ export default { ...@@ -356,7 +354,7 @@ export default {
}, },
changeType() { changeType() {
for (let i = 0; i < this.allTypes.length; i++) { for (let i = 0; i < this.allTypes.length; i++) {
if (this.allTypes[i].name == this.form.type) { if (this.allTypes[i].name === this.form.type) {
this.form.configuration.dataSourceType = this.allTypes[i].type this.form.configuration.dataSourceType = this.allTypes[i].type
} }
} }
...@@ -388,7 +386,7 @@ export default { ...@@ -388,7 +386,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
@import "~@/metersphere/common/css/index.css";
.member-size { .member-size {
text-decoration: underline; text-decoration: underline;
} }
......
...@@ -395,7 +395,7 @@ export default { ...@@ -395,7 +395,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
@import "~@/metersphere/common/css/index.css";
.member-size { .member-size {
text-decoration: underline; text-decoration: underline;
} }
......
...@@ -262,7 +262,10 @@ export default { ...@@ -262,7 +262,10 @@ export default {
treeByArr(arr) { treeByArr(arr) {
if (!Array.isArray(arr) || !arr.length) return if (!Array.isArray(arr) || !arr.length) return
const map = {} const map = {}
arr.forEach(item => map[item.id] = item)
arr.forEach(item => {
map[item.id] = item
})
const roots = [] const roots = []
arr.forEach(item => { arr.forEach(item => {
...@@ -289,7 +292,7 @@ export default { ...@@ -289,7 +292,7 @@ export default {
return obj return obj
}) })
if (!row) { if (!row) {
data.some(node => node.children = null) // data.some(node => node.children = null)
_self.tableData = data _self.tableData = data
_self.menus = [] _self.menus = []
_self.menus.push(_self.topMunu) _self.menus.push(_self.topMunu)
...@@ -404,7 +407,7 @@ export default { ...@@ -404,7 +407,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
@import "~@/metersphere/common/css/index.css";
.member-size { .member-size {
text-decoration: underline; text-decoration: underline;
} }
......
...@@ -258,5 +258,5 @@ export default { ...@@ -258,5 +258,5 @@ export default {
</script> </script>
<style scoped> <style scoped>
@import "~@/metersphere/common/css/index.css";
</style> </style>
...@@ -17,9 +17,7 @@ ...@@ -17,9 +17,7 @@
<script> <script>
import EmailSetting from './EmailSetting' import EmailSetting from './EmailSetting'
import LdapSetting from './LdapSetting'
import UiSetting from './UiSetting' import UiSetting from './UiSetting'
import BaseSetting from './BaseSetting'
import { hasLicense } from '@/metersphere/common/js/utils' import { hasLicense } from '@/metersphere/common/js/utils'
// const requireComponent = require.context('@/metersphere/common/components/xpack/', true, /\.vue$/) // const requireComponent = require.context('@/metersphere/common/components/xpack/', true, /\.vue$/)
...@@ -29,10 +27,8 @@ import { hasLicense } from '@/metersphere/common/js/utils' ...@@ -29,10 +27,8 @@ import { hasLicense } from '@/metersphere/common/js/utils'
export default { export default {
name: 'SystemParameterSetting', name: 'SystemParameterSetting',
components: { components: {
BaseSetting,
UiSetting, UiSetting,
EmailSetting, EmailSetting
LdapSetting,
// 'MsDisplay': display.default, // 'MsDisplay': display.default,
// 'MsAuth': auth.default // 'MsAuth': auth.default
}, },
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="status" :label="$t('commons.status')" width="120"> <el-table-column prop="status" :label="$t('commons.status')" width="120">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-switch v-model="scope.row.enabled" inactive-color="#DCDFE6" @change="changeSwitch(scope.row)" /> <el-switch v-model="scope.row.enabled" :active-value="1" :inactive-value="0" inactive-color="#DCDFE6" @change="changeSwitch(scope.row)" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="createTime" :label="$t('commons.create_time')"> <el-table-column prop="createTime" :label="$t('commons.create_time')">
...@@ -88,8 +88,8 @@ ...@@ -88,8 +88,8 @@
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
<el-radio-group v-model="form.enabled" style="width: 140px"> <el-radio-group v-model="form.enabled" style="width: 140px">
<el-radio label="1">启用</el-radio> <el-radio :label="1">启用</el-radio>
<el-radio label="0">停用</el-radio> <el-radio :label="0">停用</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="部门" prop="dept"> <el-form-item label="部门" prop="dept">
...@@ -176,9 +176,9 @@ import { PHONE_REGEX } from '@/metersphere/common/js/regex' ...@@ -176,9 +176,9 @@ import { PHONE_REGEX } from '@/metersphere/common/js/regex'
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect' import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { userLists } from '@/api/system/user' import { userLists, addUser, editUser, delUser, editPassword, editStatus } from '@/api/system/user'
import { allRoles } from '@/api/system/role' import { allRoles } from '@/api/system/role'
import { getMenusTree } from '@/api/system/menu' import { getDeptTree } from '@/api/system/dept'
export default { export default {
name: 'MsUser', name: 'MsUser',
components: { components: {
...@@ -268,7 +268,7 @@ export default { ...@@ -268,7 +268,7 @@ export default {
} }
] ]
}, },
defaultForm: { id: null, username: null, nickName: null, gender: '男', email: null, enabled: '1', deptId: null, phone: null }, defaultForm: { id: null, username: null, nickName: null, gender: '男', email: null, enabled: 1, deptId: null, phone: null },
depts: null, depts: null,
roles: [], roles: [],
roleDatas: [], roleDatas: [],
...@@ -307,7 +307,7 @@ export default { ...@@ -307,7 +307,7 @@ export default {
cancelButtonText: this.$t('commons.cancel'), cancelButtonText: this.$t('commons.cancel'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get(this.deletePath + encodeURIComponent(row.userId), () => { delUser(encodeURIComponent(row.userId)).then(res => {
this.$success(this.$t('commons.delete_success')) this.$success(this.$t('commons.delete_success'))
this.search() this.search()
}) })
...@@ -318,8 +318,8 @@ export default { ...@@ -318,8 +318,8 @@ export default {
createUser(createUserForm) { createUser(createUserForm) {
this.$refs[createUserForm].validate(valid => { this.$refs[createUserForm].validate(valid => {
if (valid) { if (valid) {
const url = this.formType === 'add' ? this.createPat : this.updatePath const method = this.formType === 'add' ? addUser : editUser
this.result = this.$post(url, this.form, () => { method(this.form).then(res => {
this.$success(this.$t('commons.save_success')) this.$success(this.$t('commons.save_success'))
this.search() this.search()
this.dialogVisible = false this.dialogVisible = false
...@@ -329,23 +329,11 @@ export default { ...@@ -329,23 +329,11 @@ export default {
} }
}) })
}, },
updateUser(updateUserForm) {
this.$refs[updateUserForm].validate(valid => {
if (valid) {
this.result = this.$post(this.updatePath, this.form, () => {
this.$success(this.$t('commons.modify_success'))
this.dialogVisible = false
this.search()
})
} else {
return false
}
})
},
editUserPassword(editPasswordForm) { editUserPassword(editPasswordForm) {
this.$refs[editPasswordForm].validate(valid => { this.$refs[editPasswordForm].validate(valid => {
if (valid) { if (valid) {
this.result = this.$post(this.editPasswordPath, this.ruleForm, () => { editPassword(this.ruleForm).then(res => {
this.$success(this.$t('commons.modify_success')) this.$success(this.$t('commons.modify_success'))
this.editPasswordVisible = false this.editPasswordVisible = false
this.search() this.search()
...@@ -377,13 +365,13 @@ export default { ...@@ -377,13 +365,13 @@ export default {
this.dialogVisible = false this.dialogVisible = false
}, },
changeSwitch(row) { changeSwitch(row) {
this.$post('/api/user/update_status', row, () => { const { userId, enabled } = row
const param = { userId: userId, enabled: enabled }
editStatus(param).then(res => {
this.$success(this.$t('commons.modify_success')) this.$success(this.$t('commons.modify_success'))
}) })
}, },
buildPagePath(path) {
return path + '/' + this.currentPage + '/' + this.pageSize
},
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val this.multipleSelection = val
}, },
...@@ -391,7 +379,7 @@ export default { ...@@ -391,7 +379,7 @@ export default {
loadDepts({ action, parentNode, callback }) { loadDepts({ action, parentNode, callback }) {
if (action === LOAD_ROOT_OPTIONS) { if (action === LOAD_ROOT_OPTIONS) {
const _self = this const _self = this
!this.depts && getMenusTree('0').then(res => { !this.depts && getDeptTree('0').then(res => {
_self.depts = res.data.data.map(node => _self.normalizer(node)) _self.depts = res.data.data.map(node => _self.normalizer(node))
callback() callback()
}) })
...@@ -399,7 +387,7 @@ export default { ...@@ -399,7 +387,7 @@ export default {
if (action === LOAD_CHILDREN_OPTIONS) { if (action === LOAD_CHILDREN_OPTIONS) {
const _self = this const _self = this
getMenusTree(parentNode.id).then(res => { getDeptTree(parentNode.id).then(res => {
parentNode.children = res.data.data.map(function(obj) { parentNode.children = res.data.data.map(function(obj) {
return _self.normalizer(obj) return _self.normalizer(obj)
}) })
...@@ -442,4 +430,5 @@ export default { ...@@ -442,4 +430,5 @@ export default {
</script> </script>
<style scoped> <style scoped>
@import "~@/metersphere/common/css/index.css";
</style> </style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论