添加权限分发到组织和项目

This commit is contained in:
dong 2023-01-13 15:54:06 +08:00
parent dca3d00d50
commit b0d80ac49e
8 changed files with 257 additions and 9 deletions

View File

@ -144,3 +144,10 @@ export function setDeviceConfig(data) {
data: data
});
}
/** 获取所有项目 */
export function getAllProject() {
return request({
url: `/api/project/all `,
method: 'get'
});
}

View File

@ -276,6 +276,11 @@ export default {
{ value: 'user', label: '个人'},
{ value: 'org', label: '组织'}
],
permissionSubTypeList: [ // 权限分发主体类型
{ value: 'user', label: '个人'},
{ value: 'org', label: '组织'},
{ value: 'project', label: '项目'}
],
trainingType: [
// 实训类型
{ enlabel: 'single operation', label: '单操', value: 'SINGLE' },

View File

@ -0,0 +1,110 @@
<template>
<el-dialog title="权限分发到指定组织" :visible.sync="dialogVisible" width="1000px" :before-close="doClose" center :close-on-click-modal="false">
<QueryListPage ref="queryListPage1" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</el-dialog>
</template>
<script>
import { setDistributeToSubject } from '@/api/authorityTransfer';
import { getCompanyList } from '@/api/company';
export default {
name:'DistributeOrg',
data() {
return {
packageId:'',
dialogVisible:false,
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '80px',
reset: true,
columnNum: 5,
queryObject: {
name: {
type: 'text',
label: this.$t('system.name')
}
}
},
queryList: {
query: this.getTableData,
selectCheckShow: false,
paginationHiden: true,
height: '420',
indexShow: true,
columns: [
{
title: this.$t('system.name'),
prop: 'name'
},
{
title: '创建时间',
prop: 'createTime',
width: '160'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '90',
buttons: [
{
name: '选择',
handleClick: this.distributePackage
}
]
}
]
}
};
},
created() {
},
methods:{
getTableData(obj) {
return new Promise((resolve, reject) => {
getCompanyList().then(resp => {
const list = [];
resp.data && resp.data.forEach(item => {
if (item.name.includes(obj.name || '')) {
list.push(item);
}
});
resolve({
code: 200,
message: '成功',
data: list
});
}).catch((error) => {
console.error(error);
reject();
});
});
},
doShow(data) {
this.packageId = data.id;
this.dialogVisible = true;
},
doClose() {
this.dialogVisible = false;
},
distributePackage(index, row) {
if (this.packageId) {
const accountId = row.id;
const subjectType = 'org'; //
setDistributeToSubject(this.packageId, subjectType, accountId).then(resp=> {
this.$message.success('权限分发给指定组织成功!');
this.$emit('reloadTable');
this.doClose();
}).catch(() => {
this.$messageBox('权限分发给指定组织失败');
});
}
}
}
};
</script>

View File

@ -171,14 +171,13 @@ export default {
distributePackage(index, row) {
if (this.packageId) {
const accountId = row.id;
// const subjectType = row.type == '1' ? 'user' : 'org';
const subjectType = 'user'; //
const subjectType = 'user'; //
setDistributeToSubject(this.packageId, subjectType, accountId).then(resp=> {
this.$message.success('权限分发给指定户成功!');
this.$message.success('权限分发给指定户成功!');
this.$emit('reloadTable');
this.doClose();
}).catch(() => {
this.$messageBox('权限分发给指定户失败');
this.$messageBox('权限分发给指定户失败');
});
}
}

View File

@ -0,0 +1,105 @@
<template>
<el-dialog title="权限分发到指定项目" :visible.sync="dialogVisible" width="1000px" :before-close="doClose" center :close-on-click-modal="false">
<QueryListPage ref="queryListPage1" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</el-dialog>
</template>
<script>
import { setDistributeToSubject } from '@/api/authorityTransfer';
import { getAllProject } from '@/api/project';
export default {
name:'DistributeProject',
data() {
return {
packageId:'',
dialogVisible:false,
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '80px',
reset: true,
columnNum: 5,
queryObject: {
name: {
type: 'text',
label: this.$t('system.name')
}
}
},
queryList: {
query: this.getTableData,
selectCheckShow: false,
paginationHiden: true,
height: '420',
indexShow: true,
columns: [
{
title: this.$t('system.name'),
prop: 'name'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '90',
buttons: [
{
name: '选择',
handleClick: this.distributePackage
}
]
}
]
}
};
},
created() {
},
methods:{
getTableData(obj) {
return new Promise((resolve, reject) => {
getAllProject().then(resp => {
const list = [];
resp.data && resp.data.forEach(item => {
if (item.name.includes(obj.name || '')) {
list.push(item);
}
});
resolve({
code: 200,
message: '成功',
data: list
});
}).catch((error) => {
console.error(error);
reject();
});
});
},
doShow(data) {
this.packageId = data.id;
this.dialogVisible = true;
},
doClose() {
this.dialogVisible = false;
},
distributePackage(index, row) {
if (this.packageId) {
const accountId = row.id;
const subjectType = 'project'; //
setDistributeToSubject(this.packageId, subjectType, accountId).then(resp=> {
this.$message.success('权限分发给指定项目成功!');
this.$emit('reloadTable');
this.doClose();
}).catch(() => {
this.$messageBox('权限分发给指定项目失败');
});
}
}
}
};
</script>

View File

@ -3,6 +3,8 @@
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<qr-code ref="qrCode" />
<distribute-package ref="distributePackage" @reloadTable="reloadTable" />
<distribute-org ref="distributeOrg" @reloadTable="reloadTable" />
<distributeProject ref="distributeProject" @reloadTable="reloadTable" />
<Detail ref="detail" />
</div>
</template>
@ -12,6 +14,8 @@ import { admin } from '@/router/index';
import { getDistributeList, getDistributeQrCode } from '@/api/authorityTransfer';
import QrCode from '@/components/QrCode';
import DistributePackage from './distributePackage';
import DistributeOrg from './distributeOrg';
import DistributeProject from './distributeProject';
import Detail from './detail';
export default {
@ -19,7 +23,9 @@ export default {
components: {
QrCode,
Detail,
DistributePackage
DistributePackage,
DistributeOrg,
DistributeProject
},
data() {
return {
@ -106,9 +112,19 @@ export default {
type: ''
},
{
name: '领取到',
name: '领取到用户',
handleClick: this.distributePackage,
type: ''
},
{
name: '领取到组织',
handleClick: this.distributeOrg,
type: ''
},
{
name: '领取到项目',
handleClick: this.distributeProject,
type: ''
}
]
}
@ -146,6 +162,12 @@ export default {
},
distributePackage(index, row) {
this.$refs.distributePackage.doShow(row);
},
distributeOrg(index, row) {
this.$refs.distributeOrg.doShow(row);
},
distributeProject(index, row) {
this.$refs.distributeProject.doShow(row);
}
}
};

View File

@ -69,7 +69,7 @@ export default {
prop: 'subjectType',
width: '80',
type: 'tag',
columnValue: (row) => { return this.$ConstSelect.translate(row.subjectType, 'subTypeList'); },
columnValue: (row) => { return this.$ConstSelect.translate(row.subjectType, 'permissionSubTypeList'); },
tagType: (row) => { return ''; }
},
{
@ -166,7 +166,7 @@ export default {
this.$ConstSelect.EffectiveTypeList.forEach(elem => {
this.queryForm.queryObject.status.config.data.push(elem);
});
this.$ConstSelect.subTypeList.forEach(elem => {
this.$ConstSelect.permissionSubTypeList.forEach(elem => {
this.queryForm.queryObject.subType.config.data.push(elem);
});
},

View File

@ -56,7 +56,7 @@ export default {
prop: 'subjectType',
width: '80',
type: 'tag',
columnValue: (row) => { return this.$ConstSelect.translate(row.subjectType, 'subTypeList'); },
columnValue: (row) => { return this.$ConstSelect.translate(row.subjectType, 'permissionSubTypeList'); },
tagType: (row) => { return ''; }
},
{