Commit 5200368d authored by rockyl's avatar rockyl

修改权限管理的表现形式

parent 93afec2d
......@@ -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);
const options = {
......
......@@ -25,6 +25,7 @@
"Behavior": "行为",
"Search": "搜索",
"Only mine": "仅我的",
"Creator": "创建人",
"Add": "添加",
"Delete": "删除",
"Delete all": "删除全部",
......@@ -392,5 +393,10 @@
"customCmds": {
"z-for": "循环",
"z-if": "存在"
}
},
"project-conflicts-resolve-steps": [
"查看冲突",
"手动合并",
"完成"
]
}
\ No newline at end of file
......@@ -100,8 +100,8 @@ export const projectStore = {
state.id = id;
state.name = name;
state.creator = creator;
state.operators = operators;
state.operator = operator;
state.operators = operators;
state.update_time = update_time;
const localData = state.data;
......@@ -156,8 +156,8 @@ export const projectStore = {
},
modifyDependencies(state, value) {
state.data.dependencies = value;
},
modifyOperators(state, value) {
},
modifyOperators(state, value) {
state.operators = value;
},
/**
......@@ -477,12 +477,13 @@ export const projectStore = {
},
getters: {
project(state) {
const {id, name, creator, data, update_time} = state;
const {id, name, creator, data, update_time, operator, operators,} = state;
let newData = clonePureObj(data);
delete newData['dependencies'];
deleteDesignConfig(newData.processes);
deleteAssetsDepConfig(newData);
return {
id, name, creator, update_time,
id, name, creator, update_time, operator, operators,
data: JSON.stringify(newData),
};
},
......
......@@ -7,9 +7,7 @@
>
<div class="wrapper">
<el-steps :active="step" finish-status="success" align-center>
<el-step title="查看冲突"></el-step>
<el-step title="手动合并"></el-step>
<el-step title="完成"></el-step>
<el-step v-for="item in steps" :title="item"></el-step>
</el-steps>
<div class="container">
<monaco-editor
......@@ -57,6 +55,7 @@
step: 0,
remoteData: '',
localData: '',
steps: this.$t('project-conflicts-resolve-steps'),
}
},
mounted() {
......@@ -110,6 +109,7 @@
cancelButtonText: this.$t('Cancel'),
type: 'warning'
}).then(() => {
this.step++;
this.visible = false;
this.$emit('resolved', this.localData);
}).catch((e) => {
......
<template>
<div class="project-auth-manager">
<el-card shadow="hover">
<h3 class="title">当前权限用户列表</h3>
<div class="user-list" v-if="operatorsData.length > 0">
<el-tag
:key="tag"
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"
:disabled="operatorsData.includes(item.name)"
></el-checkbox>
</el-checkbox-group>
<br />
<el-button type="primary" size="small" @click="onAdd">添加</el-button>
</el-card>
</div>
<div class="project-auth-manager">
<p><b>{{$t('Creator')}}</b>:{{project.creator}}</p>
<el-select style="width: 100%;" size="mini" v-model="operators" filterable multiple :disabled="!editable">
<el-option v-for="(item, index) in devPersons"
:key="index"
:disabled="item.name === project.creator || item.name === currentOperator"
:label="item.name"
:value="item.name">
</el-option>
</el-select>
</div>
</template>
<script>
import { mapState, mapGetters, mapMutations } from "vuex";
import { playWaiting } from "../../../../utils";
import { getDevPersons } from "../../../../api/editor";
import { updateOperators } from "../../../../api/project";
// updateOperators
export default {
name: "AuthManagerEditor",
data() {
return {
checkList: [],
devPersons: [],
addDivShow: false,
};
},
computed: {
...mapState({
operatorsData: (state) => state.project.operators && state.project.operators.split(","),
projectId: (state) => state.project.id,
currentOperator: (state) => state.editor.operator,
}),
},
methods: {
...mapMutations(["modifyOperators"]),
async edit() {
this.devPersons = await getDevPersons();
},
onAdd() {
if(!this.operatorsData.includes(this.currentOperator)) {
this.$message({ message: this.$t('No permission'), type: "error" });
return false;
}
let mergeData = [...this.operatorsData, ...this.checkList].join(",");
this.onUpdate(mergeData);
},
async onUpdate(mergeData) {
updateOperators(this.projectId, mergeData)
.then(() => {
this.$message({
message: this.$t("Operate success"),
type: "success",
});
this.modifyOperators(mergeData);
this.checkList = [];
this.addDivShow = false;
})
.catch((e) => {
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) => {});
},
},
};
import {mapState, mapGetters, mapMutations} from "vuex";
import {playWaiting} from "../../../../utils";
import {getDevPersons} from "../../../../api/editor";
import {updateOperators} from "../../../../api/project";
export default {
name: "AuthManagerEditor",
data() {
return {
devPersons: [],
operators: [],
};
},
computed: {
editable(){
return this.operators.includes(this.currentOperator);
},
...mapState({
projectId: (state) => state.project.id,
currentOperator: (state) => state.editor.operator,
}),
...mapState(['project']),
},
methods: {
...mapMutations(["modifyOperators"]),
async edit() {
this.devPersons = await getDevPersons();
this.operators = this.project.operators.split(',');
this.operatorsOrigin = this.operators.concat().sort().join(',');
},
async save() {
let operatorsNew = this.operators.concat().sort().join(',');
if (operatorsNew === this.operatorsOrigin) {
return;
}
let operatorsStr = this.operators.join(',');
updateOperators(this.projectId, operatorsStr)
.then(() => {
this.$message({
message: this.$t("Operate success"),
type: "success",
});
this.modifyOperators(operatorsStr);
})
.catch((e) => {
this.$message({message: e.message, type: "error"});
});
},
},
};
</script>
<style lang="scss" scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
</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