Commit 27b19f3e authored by 罗超's avatar 罗超

修改分享

parent b18678d0
......@@ -143,5 +143,19 @@ class ConfigService{
static async SetShareAsync(params:{ShareFileId:number,ShareList:{ShareType:number,ShareTargetIds:string,EditType:string}[]}):Promise<HttpResponse>{
return Api.Post("triptemplate_SetTripShare",params)
}
static async GetShareAsync(FileId:number):Promise<HttpResponse>{
let msg = {FileId}
return Api.Post("triptemplate_GetTripShareDetails",msg)
}
static async RemoveShareAsync(ShareId:number):Promise<HttpResponse>{
let msg = {ShareId}
return Api.Post("triptemplate_RemoveTripShare",msg)
}
static async UpdateShareAsync(params:{ShareId:number,ShareTargetIds:string,EditType:string}):Promise<HttpResponse>{
return Api.Post("triptemplate_EditTripShare",params)
}
}
export default ConfigService;
\ No newline at end of file
<template>
<el-dialog v-model="show" v-loading="loading" :show-close="false" :close-on-press-escape="false" :close-on-click-modal="false" style="max-width:550px;">
<template #header>
<div class="text-title">分享设置</div>
<div class="text-title" ref="headDom">分享设置</div>
</template>
<div>
<div class="row items-center">
......@@ -36,97 +36,57 @@
<el-button class="q-ml-md" @click="saveShareHandler">添加</el-button>
</div>
<el-scrollbar height="300px" class="q-mt-lg">
<div class="row items-center q-mb-md">
<el-avatar icon="OfficeBuilding" size="36" shape="square" class="bg-primary"></el-avatar>
<div class="row items-center q-mb-md" v-for="x in shareList">
<el-avatar icon="OfficeBuilding" size="36" shape="square" class="bg-primary" v-if="x.ShareType==0"></el-avatar>
<el-avatar icon="HomeFilled" size="36" shape="square" class="bg-secony" v-else-if="x.ShareType==1"></el-avatar>
<el-avatar icon="Menu" size="36" shape="square" class="bg-waring" v-else-if="x.ShareType==2"></el-avatar>
<el-avatar icon="UserFilled" size="36" shape="square" v-else-if="x.ShareType==4"></el-avatar>
<div class="q-mx-md col">
<div class="text-subtitle2">所有人</div>
<div class="text-small text-info">所有在职员工均适用于此规则</div>
</div>
<div class="cusor-pointer" style="margin-top: 8px;">
<el-tooltip effect="dark" content="可以查看">
<el-icon size="16"><View /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以修改">
<el-icon size="16" color="#f89c53" class="q-mx-md"><EditPen /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以下载">
<el-icon size="16" color="#0b40fe"><Download /></el-icon>
</el-tooltip>
</div>
<el-divider direction="vertical" class="q-mx-md" />
<el-tooltip effect="dark" content="删除规则">
<el-button link><el-icon size="16" color="#FF4B86"><Delete /></el-icon></el-button>
</el-tooltip>
</div>
<div class="row items-center q-mb-md">
<el-avatar icon="HomeFilled" size="36" shape="square" class="bg-secony"></el-avatar>
<div class="q-mx-md col">
<div class="text-subtitle2 cusor-pointer">成都印象等12家公司</div>
<div class="text-small text-info">分公司权限</div>
</div>
<div class="cusor-pointer" style="margin-top: 8px;">
<el-tooltip effect="dark" content="可以查看">
<el-icon size="16"><View /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以修改">
<el-icon size="16" color="#f89c53" class="q-mx-md"><EditPen /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以下载">
<el-icon size="16" color="#0b40fe"><Download /></el-icon>
</el-tooltip>
<div class="text-subtitle2">
<span v-if="x.ShareType==0">所有人</span>
<span v-else>
{{ x.ShareTargetName.split(':')[1].split(',')[0] }}
<span class="q-mr-md" v-if="x.ShareTargetIds.split(',').length>0"></span>
<el-popover :width="300" trigger="click">
<template #reference>
<el-tag size="small" v-if="x.ShareTargetIds.split(',').length>0" effect="light" class="cusor-pointer">
{{ x.ShareTargetIds.split(',').length }}{{ x.ShareType==1?'公司':(x.ShareType==2?'部门':'人员') }}
</el-tag>
</template>
<div class="row wrap">
<el-tag v-for="(item,i) in x.ShareTargetName.split(':')[1].split(',')" :key="i" type="success" class="q-mr-md q-mb-md" effect="plain">
{{ item }}
</el-tag>
</div>
</el-popover>
</span>
</div>
<div class="text-small text-info">
<span v-if="x.ShareType==0">所有在职员工均适用于此规则</span>
<span v-else>{{ x.ShareTargetName.split(':')[0] }}权限</span>
</div>
</div>
<el-popover :width="275" trigger="click">
<template #reference>
<div class="cusor-pointer" style="margin-top: 8px;">
<el-icon size="16" class="q-ml-md" title="可以查看" v-if="x.EditTypeList.indexOf(1)!=-1"><View /></el-icon>
<el-icon size="16" color="#f89c53" class="q-ml-md" title="可以修改" v-if="x.EditTypeList.indexOf(2)!=-1"><EditPen /></el-icon>
<el-icon size="16" color="#0b40fe" class="q-ml-md" title="可以下载" v-if="x.EditTypeList.indexOf(3)!=-1"><Download /></el-icon>
</div>
</template>
<el-checkbox-group v-model="x.copyEditor">
<el-checkbox v-for="city in permissions" :key="city.value" :label="city.value">{{ city.label }}</el-checkbox>
</el-checkbox-group>
<div class="text-right q-mt-md">
<el-button size="mini" type="primary" @click="updateShareRuleAsync(x)">确认修改</el-button>
</div>
</el-popover>
<el-divider direction="vertical" class="q-mx-md" />
<el-tooltip effect="dark" content="删除规则">
<el-button link><el-icon size="16" color="#FF4B86"><Delete /></el-icon></el-button>
</el-tooltip>
</div>
<div class="row items-center q-mb-md">
<el-avatar icon="Menu" size="36" shape="square" class="bg-waring"></el-avatar>
<div class="q-mx-md col">
<div class="text-subtitle2 cusor-pointer">成都印象等12家公司</div>
<div class="text-small text-info">部门权限</div>
</div>
<div class="cusor-pointer" style="margin-top: 8px;">
<el-tooltip effect="dark" content="可以查看">
<el-icon size="16"><View /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以修改">
<el-icon size="16" color="#f89c53" class="q-mx-md"><EditPen /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以下载">
<el-icon size="16" color="#0b40fe"><Download /></el-icon>
</el-tooltip>
</div>
<el-divider direction="vertical" class="q-mx-md" />
<el-tooltip effect="dark" content="删除规则">
<el-button link><el-icon size="16" color="#FF4B86"><Delete /></el-icon></el-button>
</el-tooltip>
</div>
<div class="row items-center q-mb-md">
<el-avatar icon="UserFilled" size="36" shape="square"></el-avatar>
<div class="q-mx-md col">
<div class="text-subtitle2 cusor-pointer">成都印象等12家公司</div>
<div class="text-small text-info">部门权限</div>
</div>
<div class="cusor-pointer" style="margin-top: 8px;">
<el-tooltip effect="dark" content="可以查看">
<el-icon size="16"><View /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以修改">
<el-icon size="16" color="#f89c53" class="q-mx-md"><EditPen /></el-icon>
</el-tooltip>
<el-tooltip effect="dark" content="可以下载">
<el-icon size="16" color="#0b40fe"><Download /></el-icon>
</el-tooltip>
</div>
<el-divider direction="vertical" class="q-mx-md" />
<el-tooltip effect="dark" content="删除规则">
<el-button link><el-icon size="16" color="#FF4B86"><Delete /></el-icon></el-button>
<el-button link @click="removeShareRuleAsync(x.ShareId)"><el-icon size="16" color="#FF4B86"><Delete /></el-icon></el-button>
</el-tooltip>
</div>
<el-empty :image-size="100" v-if="!shareList || shareList.length==0" description="未设置分享信息" />
</el-scrollbar>
</div>
<template #footer>
......@@ -142,7 +102,7 @@ import { ApiResult } from '@/configs/axios';
import OrgService from '@/services/OrgService';
import { ref } from 'vue';
import { View,Download,EditPen,Delete } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';
import { ElDialog, ElMessage, ElMessageBox } from 'element-plus';
import ConfigService from '@/services/ConfigService';
const props = defineProps({
......@@ -160,6 +120,7 @@ const defaultProps = {
label: 'DepartmentName'
}
const show=ref(true)
const headDom = ref()
const shareTypeItems = ref<{label:string,value:number}[]>([])
const permissions = ref<{label:string,value:number}[]>([])
const loading = ref(true)
......@@ -170,10 +131,11 @@ const selectedPermission = ref<number[]>([])
const allBranchs = ref<any[]>([])
const allOrgs = ref<any[]>([])
const allPeoples = ref<any[]>([])
const shareList = ref<any[]>([])
shareTypeItems.value.push({label:'所有人',value:0})
shareTypeItems.value.push({label:'公司',value:1})
shareTypeItems.value.push({label:'部门',value:2})
shareTypeItems.value.push({label:'员工',value:3})
shareTypeItems.value.push({label:'员工',value:4})
permissions.value.push({label:'查看',value:1})
permissions.value.push({label:'编辑',value:2})
permissions.value.push({label:'导出',value:3})
......@@ -215,6 +177,78 @@ const getAllPeople = async ()=>{
loading.value=false
})
}
const getShareAsync = () => {
ConfigService.GetShareAsync(props.id).then((res)=>{
if(res.data.resultCode == ApiResult.SUCCESS && res.data.data.length>0){
shareList.value=res.data.data
shareList.value.forEach((x)=>{
x.copyEditor = JSON.parse(JSON.stringify(x.EditTypeList))
})
}
loading.value=false
}).catch(()=>{
loading.value=false
})
}
const removeShareRuleAsync=(id:number)=>{
ElMessageBox.confirm('你确定要删除这条分享规则吗?','删除提醒',{
confirmButtonText: '确定删除',
cancelButtonText: '取消'
})
.then(() => {
loading.value=true
ConfigService.RemoveShareAsync(id).then((res)=>{
if(res.data.resultCode == ApiResult.SUCCESS){
ElMessage.success({
message:'操作成功'
})
getShareAsync()
}else{
ElMessage.error({
message:'操作执行失败,请刷新页面重试'
})
}
loading.value=false
}).catch(()=>{
ElMessage.error({
message:'操作执行失败,请刷新页面重试'
})
loading.value=false
})
})
.catch(() => { })
}
const updateShareRuleAsync=async (x:any)=>{
if(loading.value) return
loading.value=true
let errmsg=''
if(!x.copyEditor || x.copyEditor.length==0) errmsg='请选择权限'
if(errmsg==''){
try {
let response = await ConfigService.UpdateShareAsync({
ShareId:x.ShareId,
ShareTargetIds:x.ShareTargetIds,
EditType:x.copyEditor.join(',')
})
if(response.data.resultCode==ApiResult.SUCCESS){
ElMessage.success({
message:'设置成功'
})
headDom.value.click()
getShareAsync()
} else errmsg='修改权限失败,请刷新重试'
} catch (error) {
errmsg = '修改权限失败,请刷新重试'
}
}
if(errmsg!='') {
ElMessage.error({
message:errmsg
})
}
loading.value=false
}
const saveShareHandler = async ()=>{
if(loading.value) return
loading.value=true
......@@ -242,6 +276,7 @@ const saveShareHandler = async ()=>{
ElMessage.success({
message:'分享成功'
})
getShareAsync()
} else errmsg='保存分享配置失败,请重试'
} catch (error) {
errmsg = '保存分享配置失败,请重试'
......@@ -257,6 +292,7 @@ const saveShareHandler = async ()=>{
getDepartments()
getAllBranch()
getAllPeople()
getShareAsync()
</script>
<style>
.share-item{}
......
......@@ -177,7 +177,7 @@
</div>
<el-divider
class="no-bg q-mt-lg"
v-if="queryObj.pageCount == queryObj.pageIndex && !loading"
v-if="queryObj.pageCount == queryObj.pageIndex && !loading && queryObj.pageCount != 1"
>
<span
class="text-small bg-white"
......
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