完善文档管理

This commit is contained in:
龙运模 2024-07-27 17:04:28 +08:00
parent fdd217d680
commit 4389884309
9 changed files with 421 additions and 143 deletions

View File

@ -17,6 +17,13 @@ export default {
return await http.post(this.url, params); return await http.post(this.url, params);
}, },
}, },
rename:{
url: `${config.API_URL}/document.file.rename`,
name: "修改文件名",
post: async function (params) {
return await http.post(this.url, params);
},
},
list: { list: {
url: `${config.API_URL}/document.folder.list`, url: `${config.API_URL}/document.folder.list`,
name: "文件、文件夹列表", name: "文件、文件夹列表",
@ -38,10 +45,31 @@ export default {
return await http.post(this.url, params); return await http.post(this.url, params);
}, },
}, },
export:{
url: `${config.API_URL}/document.download`,
name: "多任务下载",
post: async function (params) {
return await http.post(this.url, params);
},
},
user:{
url: `${config.API_URL}/document.user.list.active`,
name: "用户列表下拉",
post: async function (params) {
return await http.post(this.url, params);
},
},
dept:{
url: `${config.API_URL}/document.dept.list.active`,
name: "部门列表下拉",
post: async function (params) {
return await http.post(this.url, params);
},
}
}, },
share:{ share:{
add: { add: {
url: `${config.API_URL}/document.file.delete`, url: `${config.API_URL}/document.share.add`,
name: "共享文件、文件夹", name: "共享文件、文件夹",
post: async function (params) { post: async function (params) {
return await http.post(this.url, params); return await http.post(this.url, params);

View File

@ -0,0 +1,13 @@
<template>
<svg t="1722058975340" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3630" width="200" height="200"><path d="M358.23999969 536.31999969c22.50666656 0 33.76000031 11.20000031 33.76000031 33.76000031v118.13333344c0 22.50666656-11.20000031 33.76000031-33.76000031 33.76000031-22.50666656 0-33.76000031-11.25333375-33.75999938-33.76000031V570.13333344c0-22.50666656 11.25333375-33.76000031 33.75999938-33.76000031zM512.10666688 302.02666625c22.50666656 0 33.76000031 11.20000031 33.75999937 33.76000031v352.42666688c0 22.50666656-11.25333375 33.76000031-33.75999937 33.76000031-22.50666656 0-33.76000031-11.25333375-33.76000032-33.76000031V335.78666656c0-22.50666656 11.25333375-33.76000031 33.76000032-33.76000031zM665.76000031 395.94666688c22.50666656 0 33.76000031 11.25333375 33.75999938 33.75999937v258.50666719c0 22.50666656-11.25333375 33.76000031-33.75999938 33.76000031-22.50666656 0-33.76000031-11.25333375-33.76000031-33.76000031V429.70666625c0-22.50666656 11.20000031-33.76000031 33.76000031-33.75999937z" p-id="3631"></path><path d="M980.79999969 666.50666656l-84.90666656-84.79999969a33.76000031 33.76000031 0 0 0-47.73333282 0l-84.90666656 84.79999969a33.76000031 33.76000031 0 1 0 47.73333281 47.73333375l27.19999969-27.20000062v121.81333406a29.17333312 29.17333312 0 0 1-29.17333312 29.17333312H214.82666656a29.22666656 29.22666656 0 0 1-29.17333312-29.17333312v-176.74666688a33.76000031 33.76000031 0 0 0-67.51999969 0v176.74666688a96.79999969 96.79999969 0 0 0 96.69333281 96.63999937H809.06666656a96.74666625 96.74666625 0 0 0 96.69333375-96.63999937V686.93333375l27.19999969 27.25333312a33.76000031 33.76000031 0 1 0 47.78666625-47.73333375zM151.83999969 453.86666656a33.76000031 33.76000031 0 0 0 23.84000062-9.86666625l84.79999969-84.80000062a33.76000031 33.76000031 0 0 0-47.68000031-47.73333281l-27.19999969 27.19999968V215.04000031a29.22666656 29.22666656 0 0 1 29.17333313-29.17333406H809.06666656a29.22666656 29.22666656 0 0 1 29.17333313 29.17333406V392a33.76000031 33.76000031 0 0 0 67.52000062 0V215.04000031A96.74666625 96.74666625 0 0 0 809.06666656 118.4H214.82666656a96.79999969 96.79999969 0 0 0-96.69333281 96.64000031V338.66666656l-27.25333406-27.19999969a33.76000031 33.76000031 0 1 0-47.73333281 47.73333282L128 444.00000031c6.34666687 6.40000031 14.93333344 9.86666625 23.89333313 9.86666625z" p-id="3632"></path></svg>
</template>
<script>
export default {
name: "ShareBtn"
}
</script>
<style scoped>
</style>

View File

@ -43,6 +43,7 @@ export { default as See } from './See.vue'
export { default as AbilityAuthorization } from './AbilityAuthorization.vue' export { default as AbilityAuthorization } from './AbilityAuthorization.vue'
export { default as DataAuthorization } from './DataAuthorization.vue' export { default as DataAuthorization } from './DataAuthorization.vue'
export { default as UserList } from './UserList.vue' export { default as UserList } from './UserList.vue'
export { default as ShareBtn } from './ShareBtn.vue'
export { default as Home } from './menu/Home.vue' export { default as Home } from './menu/Home.vue'

View File

@ -0,0 +1,125 @@
<template>
<el-popover
placement="bottom-end"
title=""
trigger="click"
content=""
width="300"
v-bind="$attrs"
:visible="show"
>
<template #reference>
<slot></slot>
</template>
<template #default>
<div v-for="(item,index) in list" :key="item">
<div :class="list.length-1==index?'':'exportItem'" v-if="list.length>0 && type == item.type">
<div class="exportHeader">
<div class="name">{{item.type_desc}}</div>
<div class="status" v-if="item.status==0">{{item.msg}}</div>
<div class="finish" v-if="item.status==1"><i class="icon"><sc-icon-Finish/></i> 文件生成完成</div>
</div>
<el-progress class="exportPopover" :text-inside="true" :stroke-width="12" :percentage="item.rate" />
</div>
</div>
</template>
</el-popover>
</template>
<script>
import {eventBus} from "@/utils/eventBus"
export default {
name: "exportList",
props:{
size:{type: String, default: "small" },
show:{type:Boolean, default: false},
type:{type: String, default: ""},
exportList:{type: Array},
},
watch:{
exportList: {
handler (v) {
this.list = v;
},
immediate:true,
deep:true,
}
},
data(){
return{
list:this.exportList,
}
},
setup(){
},
mounted() {
//
eventBus.$on('sockBack', this.getWsResult);
},
unmounted() {
eventBus.$off('sockBack', this.getWsResult);
},
methods:{
getWsResult(res){
if(res.data && (res.data.type == 14)){
this.list.forEach(item=>{
if(item.file_unique_id == res.data.file_unique_id){
item.type = res.data.type;
item.rate = res.data.rate;
item.type_desc = item.client_file_name;
item.status = res.data.rate!=100?0:1;
item.msg = res.data.msg;
}
})
let data = this.list.filter(em=>em.status!=1);
let params = {
type:res.data.type,
data: data
}
this.$emit('updateShow', params);
if(res.data.rate==100){
this.down(res.data);
}
}
},
down(item){
const link = document.createElement('a');
link.href = item.file_url;
link.setAttribute('download', '');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
},
exportClick(){
this.$emit('exportData');
},
}
}
</script>
<style scoped lang="scss">
.exportItem{
margin-bottom: 12px;
}
.exportHeader{
font-size: 12px;
display: flex;align-items: center;justify-content: space-around;
margin-bottom: 6px;
.name{width: 50%;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;}
.status{width: 50%;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;}
.finish{
display: flex;align-items: center;justify-content: flex-end;color: var(--el-color-success);
.icon{width: 14px;height: 14px;margin-right: 4px;}
}
}
.exportPopover :deep(.el-progress-bar__innerText){
height: 100%;
display: flex;align-items: center;justify-content: flex-end;
font-size: 10px;
}
</style>

View File

@ -27,6 +27,7 @@ import scInput from "./components/scInput";
import scVgInput from "./components/scInput/inputVague"; import scVgInput from "./components/scInput/inputVague";
import scSearch from "./components/scSearch"; import scSearch from "./components/scSearch";
import scExport from "./components/scExport"; import scExport from "./components/scExport";
import scExportList from "./components/scExport/exportList";
import scImport from "./components/scImport"; import scImport from "./components/scImport";
import scStatusIndicator from './components/scMini/scStatusIndicator' import scStatusIndicator from './components/scMini/scStatusIndicator'
@ -81,6 +82,7 @@ export default {
app.component('scVgInput', scVgInput); app.component('scVgInput', scVgInput);
app.component('scSearch', scSearch); app.component('scSearch', scSearch);
app.component('scExport', scExport); app.component('scExport', scExport);
app.component('scExportList', scExportList);
app.component('scImport', scImport); app.component('scImport', scImport);
//注册全局指令 //注册全局指令

View File

@ -32,7 +32,7 @@
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="add" icon="sc-icon-CreateFolder">创建文件夹</el-dropdown-item> <el-dropdown-item @click="add" icon="sc-icon-CreateFolder">创建文件夹</el-dropdown-item>
<el-dropdown-item @click="table_edit('edit')" icon="sc-icon-CreateShare">创建共享文件夹</el-dropdown-item> <el-dropdown-item @click="addShare" icon="sc-icon-CreateShare">创建共享文件夹</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
@ -50,13 +50,16 @@
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="batch_del" icon="sc-icon-Delete">删除</el-dropdown-item> <el-dropdown-item @click="batch_del" icon="sc-icon-Delete">删除</el-dropdown-item>
<el-dropdown-item @click="table_edit('edit')" icon="sc-icon-Edit">重命名</el-dropdown-item> <el-dropdown-item @click="table_edit('edit')" icon="sc-icon-Edit">重命名</el-dropdown-item>
<el-dropdown-item @click="share_edit('edit')" icon="sc-icon-ShareBtn">共享</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<el-button type="primary" plain :size="size" icon="el-icon-sort"></el-button> <el-button type="primary" plain :size="size" icon="el-icon-sort"></el-button>
</div> </div>
<div class="right-panel"> <div class="right-panel">
<scExportList :size="size" @updateShow="exportChangeShow" :exportList="exportList" :show="exportShow" type="14">
<el-button :size="size" icon="sc-icon-Download" @click="exportData">下载</el-button>
</scExportList>
</div> </div>
</el-header> </el-header>
<el-main class="nopadding"> <el-main class="nopadding">
@ -70,7 +73,7 @@
</div> </div>
<div class="nameBox" v-else> <div class="nameBox" v-else>
<el-icon size="large"><sc-icon-Excel/></el-icon> <el-icon size="large"><sc-icon-Excel/></el-icon>
<div class="text">{{scope.row.file_name}}</div> <div class="text">{{scope.row.client_file_name}}</div>
</div> </div>
</template> </template>
<template #size="scope"> <template #size="scope">
@ -92,18 +95,20 @@
<uploadFile ref="uploadFile" @uploadFileSuccess="uploadFileSuccess" title="上传附件"></uploadFile> <uploadFile ref="uploadFile" @uploadFileSuccess="uploadFileSuccess" title="上传附件"></uploadFile>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save=false"></save-dialog> <save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save=false"></save-dialog>
<shareSave v-if="dialog.shareSave" ref="shareSave" @success="handleSaveSuccess" @closed="dialog.shareSave=false"></shareSave>
</template> </template>
<script> <script>
import saveDialog from './save' import saveDialog from './save'
import uploadFile from './uploadFile' import uploadFile from './uploadFile'
import shareSave from './shareSave'
export default { export default {
name: 'document', name: 'document',
components: { components: {
saveDialog, saveDialog,
uploadFile uploadFile,
shareSave
}, },
data() { data() {
return { return {
@ -112,9 +117,12 @@ export default {
docsList:[], docsList:[],
docsNextShow:false, docsNextShow:false,
exportShow:false,
exportList:[],
dialog: { dialog: {
save: false, save: false,
permission: false shareSave: false
}, },
list:{ list:{
apiObj: this.$API.docs.manager.list, apiObj: this.$API.docs.manager.list,
@ -137,9 +145,41 @@ export default {
this.$refs.saveDialog.open('add').setData(this.params) this.$refs.saveDialog.open('add').setData(this.params)
}) })
}, },
addShare(){
this.dialog.shareSave = true
this.$nextTick(() => {
this.$refs.shareSave.open('add').setData(this.params)
})
},
share_edit(){
let data = this.$TOOL.objCopy(this.params);
let folderList = {
ids:[],
file_type:'folder'
};
let fileList = {
ids:[],
file_type:'file'
};
this.selection.forEach(item=>{
if(item.type == 'folder'){
folderList.ids.push(item.id)
}
if(item.type == 'file'){
fileList.ids.push(item.id)
}
})
data.share = [folderList,fileList];
this.dialog.shareSave = true;
this.$nextTick(() => {
this.$refs.shareSave.open('edit').setData(data)
})
},
// //
table_edit(){ table_edit(){
if(this.selection.length!=1){ if(this.selection.length!=1){
this.$message.warning('有且只能有单条数据编辑');
return return
} }
let row = this.selection[0]; let row = this.selection[0];
@ -158,21 +198,21 @@ export default {
async batch_del(){ async batch_del(){
const isFolder = this.selection.some(em=>em.type == "folder"); const isFolder = this.selection.some(em=>em.type == "folder");
const isFile = this.selection.some(em=>em.type == "file"); const isFile = this.selection.some(em=>em.type == "file");
if(isFolder && isFile){
this.$message.warning('只能删除同类型的文件,不能同时删除文件和文件夹');
return
}
this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', { this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', {
type: 'warning' type: 'warning'
}).then(async () => { }).then(async () => {
const loading = this.$loading(); const loading = this.$loading();
const params = {ids: this.selection.map(em => em.id)}; let folderList = this.selection.filter(em=>em.type!='file');
let fileList = this.selection.filter(em=>em.type=='file');
let res = {}; let res = {};
if(isFolder){ if(isFolder){
const params = {ids: folderList.map(em => em.id)};
res = await this.$API.docs.manager.deleteFolder.post(params); res = await this.$API.docs.manager.deleteFolder.post(params);
} }
if(isFile){ if(isFile){
const params = {ids: fileList.map(em => em.id)};
res = await this.$API.docs.manager.deleteFile.post(params); res = await this.$API.docs.manager.deleteFile.post(params);
} }
if (res.code == 200) { if (res.code == 200) {
@ -231,6 +271,25 @@ export default {
this.params.folder_id = row.id; this.params.folder_id = row.id;
this.$refs.table.upData(this.params); this.$refs.table.upData(this.params);
},
//
exportChangeShow(params){
if(params.type == 14){
this.exportShow = params.data.length>0? true:false;
}
},
async exportData() {
const isFolder = this.selection.some(em=>em.type == "folder");
if(isFolder){
this.$message.warning('只能下载文件');
return
}
let params = this.selection.map(em=>em.id);
const res = await this.$API.docs.manager.export.post({file_ids:params});
if(res.code == 200){
this.exportList = res.data;
this.$message.success('操作成功,马上导出');
}
} }
} }
} }

View File

@ -25,6 +25,7 @@ export default {
}, },
visible: false, visible: false,
isSave: false, isSave: false,
file_type:'',
// //
form: { form: {
parent_id:"", parent_id:"",
@ -71,6 +72,9 @@ export default {
if(this.mode == 'edit'){ if(this.mode == 'edit'){
this.form.parent_id = data.parent_id; this.form.parent_id = data.parent_id;
this.form.id = data.id; this.form.id = data.id;
if(data.type == 'file'){
this.form.name = data.client_file_name;
}
} }
} }
} }

View File

@ -19,7 +19,7 @@
</div> </div>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<el-input type="text" :size="size" prefix-icon="el-icon-Search" placeholder="搜索"></el-input> <el-input type="text" :size="size" v-model="params.keyword" @input="upSearch" prefix-icon="el-icon-Search" placeholder="搜索"></el-input>
</el-col> </el-col>
</el-row> </el-row>
</el-header> </el-header>
@ -29,25 +29,7 @@
<el-button type="primary" :size="size" style="margin-right: 12px;">新建文档 <el-icon class="el-icon--right"><el-icon-ArrowDown/></el-icon></el-button> <el-button type="primary" :size="size" style="margin-right: 12px;">新建文档 <el-icon class="el-icon--right"><el-icon-ArrowDown/></el-icon></el-button>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="add" icon="sc-icon-CreateFolder">创建文件夹</el-dropdown-item> <el-dropdown-item @click="addShare" icon="sc-icon-CreateShare">创建共享文件夹</el-dropdown-item>
<el-dropdown-item @click="table_edit('edit')" icon="sc-icon-CreateShare">创建共享文件夹</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-dropdown placement="bottom-start">
<el-button type="primary" plain :size="size" style="margin-right: 12px;">上传 <el-icon class="el-icon--right"><el-icon-ArrowDown/></el-icon></el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="uploadFile" icon="sc-icon-Upload">上传附件</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-dropdown placement="bottom-start">
<el-button type="primary" plain :size="size" style="margin-right: 12px;">操作 <el-icon class="el-icon--right"><el-icon-ArrowDown/></el-icon></el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="batch_del" icon="sc-icon-Delete">删除</el-dropdown-item>
<el-dropdown-item @click="table_edit('edit')" icon="sc-icon-Edit">重命名</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
@ -68,7 +50,7 @@
</div> </div>
<div class="nameBox" v-else> <div class="nameBox" v-else>
<el-icon size="large"><sc-icon-Excel/></el-icon> <el-icon size="large"><sc-icon-Excel/></el-icon>
<div class="text">{{scope.row.file_name}}</div> <div class="text">{{scope.row.client_file_name}}</div>
</div> </div>
</template> </template>
<template #size="scope"> <template #size="scope">
@ -88,144 +70,49 @@
</el-main> </el-main>
</el-container> </el-container>
<uploadFile ref="uploadFile" @uploadFileSuccess="uploadFileSuccess" title="上传附件"></uploadFile> <shareSave v-if="dialog.shareSave" ref="shareSave" @success="handleSaveSuccess" @closed="dialog.shareSave=false"></shareSave>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save=false"></save-dialog>
</template> </template>
<script> <script>
import saveDialog from './save' import shareSave from './shareSave'
import uploadFile from './uploadFile'
export default { export default {
name: 'share', name: 'share',
components: { components: {
saveDialog, shareSave
uploadFile
}, },
data() { data() {
return { return {
size:'small', size:'small',
dialog: { dialog: {
save: false, save: false,
permission: false shareSave: false
}, },
list:{ list:{
apiObj: this.$API.docs.share.list, apiObj: this.$API.docs.share.list,
column:[] column:[]
}, },
selection: [], selection: [],
search: { params: {
keyword: null keyword: null,
folder_id:"",
name:""
} }
} }
}, },
methods: { methods: {
//
add(){
this.dialog.save = true
this.$nextTick(() => {
this.$refs.saveDialog.open()
})
},
//
table_edit(row){
this.dialog.save = true
this.$nextTick(() => {
this.$refs.saveDialog.open('edit').setData(row)
})
},
//
table_show(row){
this.dialog.save = true
this.$nextTick(() => {
this.$refs.saveDialog.open('show').setData(row)
})
},
uploadFile(){
this.$nextTick(()=>{
this.$refs.uploadFile.importFile();
})
},
//
permission(){
this.dialog.permission = true
this.$nextTick(() => {
this.$refs.permissionDialog.open()
})
},
//
async table_del(row){
const reqData = {id: row.id};
const res = await this.$API.demo.post.post(reqData);
if(res.code == 200){
this.$refs.table.refresh()
this.$message.success("删除成功")
}
},
//
async batch_del(){
const isFolder = this.selection.some(em=>em.type == "folder");
const isFile = this.selection.some(em=>em.type == "file");
if(isFolder && isFile){
this.$message.warning('只能删除同类型的文件,不能同时删除文件和文件夹');
return
}
this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', {
type: 'warning'
}).then(async () => {
const loading = this.$loading();
const params = {ids: this.selection.map(em => em.id)};
let res = {};
if(isFolder){
res = await this.$API.docs.manager.deleteFolder.post(params);
}
if(isFile){
res = await this.$API.docs.manager.deleteFile.post(params);
}
if (res.code == 200) {
this.$refs.table.refresh();
this.$message.success("删除成功");
}
loading.close();
}).catch(() => {
})
},
// //
selectionChange(selection){ selectionChange(selection){
this.selection = selection; this.selection = selection;
}, },
// addShare(){
changeSwitch(val, row){ this.dialog.shareSave = true
row.status = row.status == '1'?'0':'1' this.$nextTick(() => {
row.$switch_status = true; this.$refs.shareSave.open('add').setData(this.params)
setTimeout(()=>{ })
delete row.$switch_status;
row.status = val;
this.$message.success("操作成功")
}, 500)
}, },
// //
upSearch(){ upSearch(){
this.$refs.table.upData(this.params);
},
//ID
filterTree(id){
let target = null;
function filter(tree){
tree.forEach(item => {
if(item.id == id){
target = item
}
if(item.children){
filter(item.children)
}
})
}
filter(this.$refs.table.tableData)
return target
}, },
// //
handleSaveSuccess(data, mode){ handleSaveSuccess(data, mode){
@ -235,7 +122,6 @@ export default {
this.$refs.table.refresh() this.$refs.table.refresh()
} }
}, },
uploadFileSuccess(){ uploadFileSuccess(){
this.$refs.table.refresh(); this.$refs.table.refresh();
}, },

View File

@ -0,0 +1,160 @@
<template>
<el-dialog :title="titleMap[mode]" v-model="visible" :width="460" draggable destroy-on-close @closed="$emit('closed')">
<el-form class="radioItem" :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="top">
<div v-if="mode == 'add'">
<div class="checkboxMain">
<el-radio-group v-model="form.share.share_type" @change="shareChange">
<el-radio label="team">部门共享</el-radio>
<el-radio label="user">用户共享</el-radio>
</el-radio-group>
</div>
<el-form-item label="请输入文件夹名称" prop="name" >
<el-input v-model="form.name" placeholder="请输入文件夹名称" clearable></el-input>
</el-form-item>
</div>
<div v-if="mode == 'edit'">
<el-form-item label="选择共享" prop="share_type">
<el-select style="width: 100%;" v-model="form.share_type" @change="shareChange">
<el-option label="部门共享" value="team"></el-option>
<el-option label="用户共享" value="user"></el-option>
</el-select>
</el-form-item>
</div>
<el-form-item label="选择要共享的部门" v-if="(mode!='edit' && form.share.share_type == 'team') || (mode=='edit' && form.share_type == 'team')">
<el-select placeholder="请选择部门" v-model="form.share.share_ids" style="width: 100%;" filterable multiple collapse-tags @visible-change="getTeam">
<el-option :label="item.name" :value="item.id" v-for="item in setMap.teamList" :key="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="选择要共享的用户" v-if="(mode!='edit' && form.share.share_type == 'user') || (mode=='edit' && form.share_type == 'user')">
<el-select placeholder="请选择用户" v-model="form.share.share_ids" style="width: 100%;" filterable multiple collapse-tags @visible-change="getUser">
<el-option :label="item.name" :value="item.id" v-for="item in setMap.userList" :key="item"></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="visible=false" > </el-button>
<el-button v-if="mode!='show'" type="primary" :loading="isSave" @click="submit()"> </el-button>
</template>
</el-dialog>
</template>
<script>
export default {
name:"shareSave",
emits: ['success', 'closed'],
data() {
return {
mode: "add",
titleMap: {
add: '新建共享文件夹',
edit: '共享文件',
},
visible: false,
isSave: false,
setMap:{
userList:[],
teamList:[]
},
//
shareParams:{},
//
form: {
share_type:"team",
parent_id:"",
name: "",
share:{
share_type:"team",
share_ids:[]
},
},
//
rules: {
name: [
{required: true, message: '请输入文件夹名称'}
],
}
}
},
mounted() {
},
methods: {
shareChange(){
this.form.share.share_ids = [];
},
async getUser() {
const res = await this.$API.docs.manager.user.post();
if(res.code == 200){
this.setMap.userList = res.data;
}
},
async getTeam() {
const res = await this.$API.docs.manager.dept.post();
if(res.code == 200){
this.setMap.teamList = res.data;
}
},
//
open(mode='add'){
this.mode = mode;
this.visible = true;
return this
},
//
submit(){
this.$refs.dialogForm.validate(async (valid) => {
if (valid) {
this.isSave = true;
let res;
if(this.mode == 'add'){
res = await this.$API.docs.manager.add.post(this.form);
}
if(this.mode == 'edit'){
let params = this.setList();
res = await this.$API.docs.share.add.post({share:params});
}
this.isSave = false;
if(res.code == 200){
this.$emit('success', this.form, this.mode)
this.visible = false;
this.$message.success("操作成功")
}
}
})
},
setList(){
let arr = new Array();
if(this.shareParams.share){
this.shareParams.share.forEach(em=>{
em.share_type = this.form.share_type;
em.share_ids = this.form.share.share_ids
})
let shareList = this.shareParams.share.filter(em=>em.ids.length!=0);
arr = shareList;
}
return arr
},
//
setData(data){
this.form.parent_id = data.folder_id;
this.form.name = data.name;
if(this.mode == 'edit'){
this.shareParams = data;
this.form.parent_id = data.parent_id;
this.form.id = data.id;
}
}
}
}
</script>
<style lang="scss" scoped>
.radioItem{
position: relative;
}
.checkboxMain{
position: absolute;right: 0;top: -4px;z-index: 10;
}
</style>