refactor: 优化项目创建相关代码
This commit is contained in:
parent
5df76a9e8b
commit
decc06d27c
|
@ -2,7 +2,8 @@
|
||||||
<div>
|
<div>
|
||||||
<el-card class="table-card" v-loading="result.loading">
|
<el-card class="table-card" v-loading="result.loading">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<ms-table-header :create-permission="['SYSTEM_WORKSPACE:READ+CREATE']" :condition.sync="condition" @search="list" @create="create"
|
<ms-table-header :create-permission="['SYSTEM_WORKSPACE:READ+CREATE']" :condition.sync="condition"
|
||||||
|
@search="list" @create="create"
|
||||||
:create-tip="$t('workspace.create')" :title="$t('commons.workspace')"/>
|
:create-tip="$t('workspace.create')" :title="$t('commons.workspace')"/>
|
||||||
</template>
|
</template>
|
||||||
<!-- workspace table -->
|
<!-- workspace table -->
|
||||||
|
@ -24,7 +25,9 @@
|
||||||
<div>
|
<div>
|
||||||
<ms-table-operator :edit-permission="['SYSTEM_WORKSPACE:READ+EDIT']"
|
<ms-table-operator :edit-permission="['SYSTEM_WORKSPACE:READ+EDIT']"
|
||||||
:delete-permission="['SYSTEM_WORKSPACE:READ+DELETE']"
|
:delete-permission="['SYSTEM_WORKSPACE:READ+DELETE']"
|
||||||
@editClick="edit(scope.row)" @deleteClick="handleDelete(scope.row)"/>
|
:show-delete="workspaceId !== scope.row.id"
|
||||||
|
@editClick="edit(scope.row)"
|
||||||
|
@deleteClick="handleDelete(scope.row)"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
@ -206,23 +209,25 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsCreateBox from "../CreateBox";
|
import MsCreateBox from "../CreateBox";
|
||||||
import {Message} from "element-ui";
|
import {Message} from "element-ui";
|
||||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||||
import {
|
import {
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
getCurrentWorkspaceId, listenGoBack,
|
getCurrentWorkspaceId,
|
||||||
refreshSessionAndCookies, removeGoBackListener
|
listenGoBack,
|
||||||
} from "@/common/js/utils";
|
refreshSessionAndCookies,
|
||||||
import {DEFAULT, GROUP_ORGANIZATION, GROUP_WORKSPACE, WORKSPACE} from "@/common/js/constants";
|
removeGoBackListener
|
||||||
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
|
} from "@/common/js/utils";
|
||||||
|
import {DEFAULT, GROUP_WORKSPACE, WORKSPACE} from "@/common/js/constants";
|
||||||
|
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsSystemWorkspace",
|
name: "MsSystemWorkspace",
|
||||||
components: {
|
components: {
|
||||||
MsDeleteConfirm,
|
MsDeleteConfirm,
|
||||||
|
@ -243,16 +248,16 @@
|
||||||
this.form = {};
|
this.form = {};
|
||||||
this.$get("/organization/list", response => {
|
this.$get("/organization/list", response => {
|
||||||
this.$set(this.form, "orgList", response.data);
|
this.$set(this.form, "orgList", response.data);
|
||||||
})
|
});
|
||||||
listenGoBack(this.close);
|
listenGoBack(this.close);
|
||||||
},
|
},
|
||||||
dataFilter(val) {
|
dataFilter(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.memberForm.userList = this.memberForm.copyUserList.filter((item) => {
|
this.memberForm.userList = this.memberForm.copyUserList.filter((item) => {
|
||||||
if (!!~item.id.indexOf(val) || !!~item.id.toUpperCase().indexOf(val.toUpperCase())) {
|
if (!!~item.id.indexOf(val) || !!~item.id.toUpperCase().indexOf(val.toUpperCase())) {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
this.memberForm.userList = this.memberForm.copyUserList;
|
this.memberForm.userList = this.memberForm.copyUserList;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +267,7 @@
|
||||||
if (valid) {
|
if (valid) {
|
||||||
let saveType = 'special/add';
|
let saveType = 'special/add';
|
||||||
if (this.form.id) {
|
if (this.form.id) {
|
||||||
saveType = 'update'
|
saveType = 'update';
|
||||||
}
|
}
|
||||||
this.result = this.$post("/workspace/" + saveType, this.form, () => {
|
this.result = this.$post("/workspace/" + saveType, this.form, () => {
|
||||||
this.dialogWsAddVisible = false;
|
this.dialogWsAddVisible = false;
|
||||||
|
@ -282,7 +287,7 @@
|
||||||
});
|
});
|
||||||
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
|
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
|
||||||
this.$set(this.memberForm, "groups", response.data);
|
this.$set(this.memberForm, "groups", response.data);
|
||||||
})
|
});
|
||||||
|
|
||||||
listenGoBack(this.handleClose);
|
listenGoBack(this.handleClose);
|
||||||
},
|
},
|
||||||
|
@ -305,7 +310,7 @@
|
||||||
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
|
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
|
||||||
let groups = response.data;
|
let groups = response.data;
|
||||||
this.$set(this.memberLineData[i], "groups", groups);
|
this.$set(this.memberLineData[i], "groups", groups);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
this.dialogTotal = data.itemCount;
|
this.dialogTotal = data.itemCount;
|
||||||
});
|
});
|
||||||
|
@ -326,7 +331,7 @@
|
||||||
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
|
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
|
||||||
let groups = response.data;
|
let groups = response.data;
|
||||||
this.$set(this.memberLineData[i], "groups", groups);
|
this.$set(this.memberLineData[i], "groups", groups);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
this.dialogTotal = data.itemCount;
|
this.dialogTotal = data.itemCount;
|
||||||
});
|
});
|
||||||
|
@ -337,7 +342,7 @@
|
||||||
this.form = Object.assign({}, row);
|
this.form = Object.assign({}, row);
|
||||||
this.$get("/organization/list", response => {
|
this.$get("/organization/list", response => {
|
||||||
this.$set(this.form, "orgList1", response.data);
|
this.$set(this.form, "orgList1", response.data);
|
||||||
})
|
});
|
||||||
listenGoBack(this.close);
|
listenGoBack(this.close);
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
|
@ -356,7 +361,7 @@
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.memberForm = {};
|
this.memberForm = {};
|
||||||
|
@ -379,12 +384,12 @@
|
||||||
let param = {
|
let param = {
|
||||||
name: '',
|
name: '',
|
||||||
workspaceId: this.items[i].id
|
workspaceId: this.items[i].id
|
||||||
}
|
};
|
||||||
let path = "user/special/ws/member/list/all";
|
let path = "user/special/ws/member/list/all";
|
||||||
this.$post(path, param, res => {
|
this.$post(path, param, res => {
|
||||||
let member = res.data;
|
let member = res.data;
|
||||||
this.$set(this.items[i], "memberSize", member.length);
|
this.$set(this.items[i], "memberSize", member.length);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
this.total = data.itemCount;
|
this.total = data.itemCount;
|
||||||
});
|
});
|
||||||
|
@ -400,7 +405,7 @@
|
||||||
this.result = this.$post("user/special/ws/member/add", param, () => {
|
this.result = this.$post("user/special/ws/member/add", param, () => {
|
||||||
this.cellClick(this.currentWorkspaceRow);
|
this.cellClick(this.currentWorkspaceRow);
|
||||||
this.dialogWsMemberAddVisible = false;
|
this.dialogWsMemberAddVisible = false;
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +418,7 @@
|
||||||
let groupIds = this.memberForm.groups.map(r => r.id);
|
let groupIds = this.memberForm.groups.map(r => r.id);
|
||||||
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
|
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
|
||||||
this.$set(this.memberForm, "allgroups", response.data);
|
this.$set(this.memberForm, "allgroups", response.data);
|
||||||
})
|
});
|
||||||
// console.log(this.memberForm)
|
// console.log(this.memberForm)
|
||||||
// 编辑时填充角色信息
|
// 编辑时填充角色信息
|
||||||
this.$set(this.memberForm, 'groupIds', groupIds);
|
this.$set(this.memberForm, 'groupIds', groupIds);
|
||||||
|
@ -474,7 +479,7 @@
|
||||||
phone: this.memberForm.phone,
|
phone: this.memberForm.phone,
|
||||||
groupIds: this.memberForm.groupIds,
|
groupIds: this.memberForm.groupIds,
|
||||||
workspaceId: this.currentWorkspaceRow.id
|
workspaceId: this.currentWorkspaceRow.id
|
||||||
}
|
};
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.result = this.$post("/workspace/member/update", param, () => {
|
this.result = this.$post("/workspace/member/update", param, () => {
|
||||||
|
@ -486,6 +491,11 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
workspaceId() {
|
||||||
|
return getCurrentWorkspaceId();
|
||||||
|
}
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
result: {},
|
result: {},
|
||||||
|
@ -538,39 +548,39 @@
|
||||||
},
|
},
|
||||||
currentWorkspaceRow: {},
|
currentWorkspaceRow: {},
|
||||||
wsId: ""
|
wsId: ""
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.el-table__row:hover .edit {
|
.el-table__row:hover .edit {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.member-size {
|
.member-size {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ws-member-id {
|
.ws-member-id {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ws-member-email {
|
.ws-member-email {
|
||||||
float: right;
|
float: right;
|
||||||
color: #8492a6;
|
color: #8492a6;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-width {
|
.select-width {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-css >>> .el-dialog__header {
|
.dialog-css >>> .el-dialog__header {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue