系统菜单下工作空间的创建和修改

This commit is contained in:
shiziyuan9527 2020-03-02 10:49:09 +08:00
parent cecebc6fb9
commit 9e11452ebd
6 changed files with 85 additions and 8 deletions

View File

@ -30,6 +30,12 @@ public class WorkspaceController {
return workspaceService.saveWorkspace(workspace); return workspaceService.saveWorkspace(workspace);
} }
@PostMapping("special/add")
@RequiresRoles(RoleConstants.ADMIN)
public void addWorkspaceByAdmin(@RequestBody Workspace workspace) {
workspaceService.addWorkspaceByAdmin(workspace);
}
@PostMapping("update") @PostMapping("update")
@RequiresRoles(RoleConstants.ORG_ADMIN) @RequiresRoles(RoleConstants.ORG_ADMIN)
public Workspace updateWorkspace(@RequestBody Workspace workspace) { public Workspace updateWorkspace(@RequestBody Workspace workspace) {
@ -37,6 +43,12 @@ public class WorkspaceController {
return workspaceService.saveWorkspace(workspace); return workspaceService.saveWorkspace(workspace);
} }
@PostMapping("special/update")
@RequiresRoles(RoleConstants.ADMIN)
public void updateWorkspacebyAdmin(@RequestBody Workspace workspace) {
workspaceService.updateWorkspacebyAdmin(workspace);
}
@GetMapping("delete/{workspaceId}") @GetMapping("delete/{workspaceId}")
@RequiresRoles(RoleConstants.ORG_ADMIN) @RequiresRoles(RoleConstants.ORG_ADMIN)
public void deleteWorkspace(@PathVariable String workspaceId) { public void deleteWorkspace(@PathVariable String workspaceId) {

View File

@ -177,4 +177,16 @@ public class WorkspaceService {
public Integer checkSourceRole(String orgId, String userId, String roleId) { public Integer checkSourceRole(String orgId, String userId, String roleId) {
return extOrganizationMapper.checkSourceRole(orgId, userId, roleId); return extOrganizationMapper.checkSourceRole(orgId, userId, roleId);
} }
public void updateWorkspacebyAdmin(Workspace workspace) {
workspace.setUpdateTime(System.currentTimeMillis());
workspaceMapper.updateByPrimaryKeySelective(workspace);
}
public void addWorkspaceByAdmin(Workspace workspace) {
workspace.setId(UUID.randomUUID().toString());
workspace.setCreateTime(System.currentTimeMillis());
workspace.setUpdateTime(System.currentTimeMillis());
workspaceMapper.insertSelective(workspace);
}
} }

View File

@ -25,9 +25,11 @@ export default {
'create_time': 'Created Time', 'create_time': 'Created Time',
'update_time': 'Updated Time', 'update_time': 'Updated Time',
'add': 'Add', 'add': 'Add',
'member': 'Member'
}, },
workspace: { workspace: {
'create': 'Create Workspace', 'create': 'Create Workspace',
'update': 'Update Workspace',
'delete_confirm': 'Are you sure you want to delete this workspace?', 'delete_confirm': 'Are you sure you want to delete this workspace?',
'add': 'Add Workspace', 'add': 'Add Workspace',
'input_name': 'Please enter a workspace name', 'input_name': 'Please enter a workspace name',
@ -40,6 +42,7 @@ export default {
'modify': 'Modify', 'modify': 'Modify',
'delete_confirm': 'Are you sure you want to delete this workspace?', 'delete_confirm': 'Are you sure you want to delete this workspace?',
'input_name': 'Please enter a organization name', 'input_name': 'Please enter a organization name',
'select_organization': 'Please select organization',
'search_by_name': 'Search by name', 'search_by_name': 'Search by name',
'special_characters_are_not_supported': 'Special characters are not supported', 'special_characters_are_not_supported': 'Special characters are not supported',
}, },

View File

@ -25,9 +25,11 @@ export default {
'create_time': '创建时间', 'create_time': '创建时间',
'update_time': '更新时间', 'update_time': '更新时间',
'add': '添加', 'add': '添加',
'member': '成员'
}, },
workspace: { workspace: {
'create': '创建工作空间', 'create': '创建工作空间',
'update': '修改工作空间',
'delete_confirm': '这个工作空间确定要删除吗?', 'delete_confirm': '这个工作空间确定要删除吗?',
'add': '添加工作空间', 'add': '添加工作空间',
'input_name': '请输入工作空间名称', 'input_name': '请输入工作空间名称',
@ -40,6 +42,7 @@ export default {
'modify': '修改组织', 'modify': '修改组织',
'delete_confirm': '这个组织确定要删除吗?', 'delete_confirm': '这个组织确定要删除吗?',
'input_name': '请输入组织名称', 'input_name': '请输入组织名称',
'select_organization': '请选择组织',
'search_by_name': '根据名称搜索', 'search_by_name': '根据名称搜索',
'special_characters_are_not_supported': '不支持特殊字符', 'special_characters_are_not_supported': '不支持特殊字符',
}, },

View File

@ -13,10 +13,11 @@
</span> </span>
</el-row> </el-row>
</div> </div>
<el-table :data="tableData" style="width: 100%"> <el-table :data="tableData" style="width: 100%" @cell-click="cellClick">
<el-table-column type="selection" width="55"/> <el-table-column type="selection" width="55"/>
<el-table-column prop="name" :label="$t('commons.name')"/> <el-table-column prop="name" :label="$t('commons.name')"/>
<el-table-column prop="description" :label="$t('commons.description')"/> <el-table-column prop="description" :label="$t('commons.description')"/>
<el-table-column prop="member" :label="$t('commons.member')"> 123 </el-table-column>
<el-table-column :label="$t('commons.operating')"> <el-table-column :label="$t('commons.operating')">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/> <el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
@ -127,6 +128,9 @@
this.updateVisible = true; this.updateVisible = true;
this.form = row; this.form = row;
}, },
cellClick(){
alert(1)
},
del(row) { del(row) {
this.$confirm(this.$t('organization.delete_confirm'), '', { this.$confirm(this.$t('organization.delete_confirm'), '', {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),

View File

@ -52,8 +52,8 @@
<el-form-item :label="$t('commons.description')"> <el-form-item :label="$t('commons.description')">
<el-input type="textarea" v-model="form.description"></el-input> <el-input type="textarea" v-model="form.description"></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('workspace.organization_name')" prop="orgIds"> <el-form-item :label="$t('workspace.organization_name')" prop="organizationId">
<el-select v-model="form.organizationId" placeholder="请选择组织" class="select-width"> <el-select v-model="form.organizationId" :placeholder="$t('organization.select_organization')" class="select-width">
<el-option <el-option
v-for="item in form.orgList" v-for="item in form.orgList"
:key="item.id" :key="item.id"
@ -67,6 +67,30 @@
<el-button type="primary" @click="submit('form')" size="medium">{{$t('commons.save')}}</el-button> <el-button type="primary" @click="submit('form')" size="medium">{{$t('commons.save')}}</el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog :title="$t('workspace.update')" :visible.sync="updateVisible" width="30%">
<el-form :model="form" :rules="rules" ref="updateForm" label-position="left" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/>
</el-form-item>
<el-form-item :label="$t('commons.description')">
<el-input type="textarea" v-model="form.description"></el-input>
</el-form-item>
<el-form-item :label="$t('workspace.organization_name')" prop="organizationId">
<el-select v-model="form.organizationId" :placeholder="$t('organization.select_organization')" class="select-width">
<el-option
v-for="item in form.orgList1"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="updateWorkspace('updateForm')" size="medium">{{$t('commons.save')}}</el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
@ -85,13 +109,13 @@
this.createVisible = true; this.createVisible = true;
this.form = {}; this.form = {};
this.$get("/organization/list", response => { this.$get("/organization/list", response => {
this.form = { orgList: response.data } this.$set(this.form, "orgList", response.data);
}) })
}, },
submit(formName) { submit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
let saveType = 'add'; let saveType = 'special/add';
if (this.form.id) { if (this.form.id) {
saveType = 'update' saveType = 'update'
} }
@ -106,10 +130,12 @@
}); });
}, },
edit(row) { edit(row) {
this.createVisible = true; this.updateVisible = true;
// copy user // copy user
this.form = Object.assign({}, row); this.form = Object.assign({}, row);
this.$get("/organization/list", response => {
this.$set(this.form, "orgList1", response.data);
})
// let self = this; // let self = this;
// let getUser1 = this.$get("/test/user"); // let getUser1 = this.$get("/test/user");
// let getUser2 = this.$get("/test/sleep"); // let getUser2 = this.$get("/test/sleep");
@ -118,6 +144,22 @@
// self.loading = false; // self.loading = false;
// }); // });
}, },
updateWorkspace(updateForm) {
this.$refs[updateForm].validate(valide => {
if (valide) {
this.result = this.$post("/workspace/special/update", this.form,() => {
this.$message({
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateVisible = false;
this.list();
});
} else {
return false;
}
})
},
del(row) { del(row) {
this.$confirm(this.$t('workspace.delete_confirm'), this.$t('commons.prompt'), { this.$confirm(this.$t('workspace.delete_confirm'), this.$t('commons.prompt'), {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),
@ -154,6 +196,7 @@
result: {}, result: {},
loading: false, loading: false,
createVisible: false, createVisible: false,
updateVisible: false,
btnTips: this.$t('workspace.add'), btnTips: this.$t('workspace.add'),
condition: "", condition: "",
items: [], items: [],
@ -169,7 +212,7 @@
{required: true, message: this.$t('workspace.input_name'), trigger: 'blur'}, {required: true, message: this.$t('workspace.input_name'), trigger: 'blur'},
{min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'} {min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'}
], ],
orgIds: [ organizationId: [
{required: true, message: '请选择组织', trigger: ['blur']} {required: true, message: '请选择组织', trigger: ['blur']}
] ]
}, },