Commit 5200368d authored by rockyl's avatar rockyl

修改权限管理的表现形式

parent 93afec2d
...@@ -24,7 +24,7 @@ class ApiError extends Error { ...@@ -24,7 +24,7 @@ class ApiError extends Error {
} }
} }
export async function fetchApi(uri, {host = '', params, method = 'get', auth = true, judgeSuccess = true, contentType = 'json', dataField = 'data', errMessage}) { export async function fetchApi(uri, {host = '', params, method = 'get', auth = true, judgeSuccess = true, contentType = 'json', dataField = 'data', errMessage} = {}) {
let url = host + (uri.startsWith('http') || uri.startsWith('//') ? uri : API_HOST + uri); let url = host + (uri.startsWith('http') || uri.startsWith('//') ? uri : API_HOST + uri);
const options = { const options = {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
"Behavior": "行为", "Behavior": "行为",
"Search": "搜索", "Search": "搜索",
"Only mine": "仅我的", "Only mine": "仅我的",
"Creator": "创建人",
"Add": "添加", "Add": "添加",
"Delete": "删除", "Delete": "删除",
"Delete all": "删除全部", "Delete all": "删除全部",
...@@ -392,5 +393,10 @@ ...@@ -392,5 +393,10 @@
"customCmds": { "customCmds": {
"z-for": "循环", "z-for": "循环",
"z-if": "存在" "z-if": "存在"
} },
"project-conflicts-resolve-steps": [
"查看冲突",
"手动合并",
"完成"
]
} }
\ No newline at end of file
...@@ -100,8 +100,8 @@ export const projectStore = { ...@@ -100,8 +100,8 @@ export const projectStore = {
state.id = id; state.id = id;
state.name = name; state.name = name;
state.creator = creator; state.creator = creator;
state.operators = operators;
state.operator = operator; state.operator = operator;
state.operators = operators;
state.update_time = update_time; state.update_time = update_time;
const localData = state.data; const localData = state.data;
...@@ -477,12 +477,13 @@ export const projectStore = { ...@@ -477,12 +477,13 @@ export const projectStore = {
}, },
getters: { getters: {
project(state) { project(state) {
const {id, name, creator, data, update_time} = state; const {id, name, creator, data, update_time, operator, operators,} = state;
let newData = clonePureObj(data); let newData = clonePureObj(data);
delete newData['dependencies'];
deleteDesignConfig(newData.processes); deleteDesignConfig(newData.processes);
deleteAssetsDepConfig(newData); deleteAssetsDepConfig(newData);
return { return {
id, name, creator, update_time, id, name, creator, update_time, operator, operators,
data: JSON.stringify(newData), data: JSON.stringify(newData),
}; };
}, },
......
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
> >
<div class="wrapper"> <div class="wrapper">
<el-steps :active="step" finish-status="success" align-center> <el-steps :active="step" finish-status="success" align-center>
<el-step title="查看冲突"></el-step> <el-step v-for="item in steps" :title="item"></el-step>
<el-step title="手动合并"></el-step>
<el-step title="完成"></el-step>
</el-steps> </el-steps>
<div class="container"> <div class="container">
<monaco-editor <monaco-editor
...@@ -57,6 +55,7 @@ ...@@ -57,6 +55,7 @@
step: 0, step: 0,
remoteData: '', remoteData: '',
localData: '', localData: '',
steps: this.$t('project-conflicts-resolve-steps'),
} }
}, },
mounted() { mounted() {
...@@ -110,6 +109,7 @@ ...@@ -110,6 +109,7 @@
cancelButtonText: this.$t('Cancel'), cancelButtonText: this.$t('Cancel'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.step++;
this.visible = false; this.visible = false;
this.$emit('resolved', this.localData); this.$emit('resolved', this.localData);
}).catch((e) => { }).catch((e) => {
......
<template> <template>
<div class="project-auth-manager"> <div class="project-auth-manager">
<el-card shadow="hover"> <p><b>{{$t('Creator')}}</b>:{{project.creator}}</p>
<h3 class="title">当前权限用户列表</h3> <el-select style="width: 100%;" size="mini" v-model="operators" filterable multiple :disabled="!editable">
<div class="user-list" v-if="operatorsData.length > 0"> <el-option v-for="(item, index) in devPersons"
<el-tag :key="index"
:key="tag" :disabled="item.name === project.creator || item.name === currentOperator"
v-for="tag in operatorsData"
closable
:disable-transitions="false"
@close="deleteAuth(tag)"
>
{{ tag }}
</el-tag>
</div>
<p v-else></p>
<el-divider></el-divider>
<el-button type="primary" size="small" @click="addDivShow = true"
>增加权限</el-button
>
</el-card>
<br />
<el-card shadow="hover" v-show="addDivShow">
<p>请先勾选后,点击添加按钮</p>
<el-checkbox-group v-model="checkList">
<el-checkbox
v-for="item in devPersons"
:key="'dev-' + item.id"
:label="item.name" :label="item.name"
:disabled="operatorsData.includes(item.name)" :value="item.name">
></el-checkbox> </el-option>
</el-checkbox-group> </el-select>
<br />
<el-button type="primary" size="small" @click="onAdd">添加</el-button>
</el-card>
</div> </div>
</template> </template>
<script> <script>
import { mapState, mapGetters, mapMutations } from "vuex"; import {mapState, mapGetters, mapMutations} from "vuex";
import { playWaiting } from "../../../../utils"; import {playWaiting} from "../../../../utils";
import { getDevPersons } from "../../../../api/editor"; import {getDevPersons} from "../../../../api/editor";
import { updateOperators } from "../../../../api/project"; import {updateOperators} from "../../../../api/project";
// updateOperators
export default { export default {
name: "AuthManagerEditor", name: "AuthManagerEditor",
data() { data() {
return { return {
checkList: [],
devPersons: [], devPersons: [],
addDivShow: false, operators: [],
}; };
}, },
computed: { computed: {
editable(){
return this.operators.includes(this.currentOperator);
},
...mapState({ ...mapState({
operatorsData: (state) => state.project.operators && state.project.operators.split(","),
projectId: (state) => state.project.id, projectId: (state) => state.project.id,
currentOperator: (state) => state.editor.operator, currentOperator: (state) => state.editor.operator,
}), }),
...mapState(['project']),
}, },
methods: { methods: {
...mapMutations(["modifyOperators"]), ...mapMutations(["modifyOperators"]),
async edit() { async edit() {
this.devPersons = await getDevPersons(); this.devPersons = await getDevPersons();
this.operators = this.project.operators.split(',');
this.operatorsOrigin = this.operators.concat().sort().join(',');
}, },
onAdd() { async save() {
if(!this.operatorsData.includes(this.currentOperator)) { let operatorsNew = this.operators.concat().sort().join(',');
this.$message({ message: this.$t('No permission'), type: "error" }); if (operatorsNew === this.operatorsOrigin) {
return false; return;
} }
let mergeData = [...this.operatorsData, ...this.checkList].join(",");
this.onUpdate(mergeData); let operatorsStr = this.operators.join(',');
}, updateOperators(this.projectId, operatorsStr)
async onUpdate(mergeData) {
updateOperators(this.projectId, mergeData)
.then(() => { .then(() => {
this.$message({ this.$message({
message: this.$t("Operate success"), message: this.$t("Operate success"),
type: "success", type: "success",
}); });
this.modifyOperators(mergeData); this.modifyOperators(operatorsStr);
this.checkList = [];
this.addDivShow = false;
}) })
.catch((e) => { .catch((e) => {
this.$message({ message: e.message, type: "error" }); this.$message({message: e.message, type: "error"});
}); });
}, },
deleteAuth(tag) {
if(this.currentOperator === tag) {
this.$message({ message: this.$t('Error delete self'), type: "error" });
return false;
}
if(!this.operatorsData.includes(this.currentOperator)) {
this.$message({ message: this.$t('No permission'), type: "error" });
return false;
}
this.$confirm(this.$t("Are you sure to delete this user auth") + tag, {
confirmButtonText: this.$t("Confirm"),
cancelButtonText: this.$t("Cancel"),
type: "warning",
})
.then(() => {
let mergeData = this.operatorsData
.filter((item) => item !== tag)
.join(",");
this.onUpdate(mergeData);
})
.catch((e) => {});
}, },
}, };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment