import store from '@/store'; import vue from 'vue'; const userId = store.state.user.info.userId; const userName = store.state.user.info.name; export function isCreateUserId(row) { if (vue.prototype.$hasPermission('fm:doc:viewAll')) { return true; } return userId == row?.createUserId; } export function isPower(data = {}, power, selection = []) { if (!data.id && selection.length == 0) { return false; } if ( //文件查看浏览权限 vue.prototype.$hasPermission('fm:doc:viewAll') ) { return true; } if (power == 'add' && data.userAuthority.length == 0) { return true; } if (power == 'checkEnter' && data?.checkOutUserId != userId) { //检入特殊处理 return false; } if (selection.length > 0) { //多选情况处理 let _isPower = true; let userAuthorityS = []; let createUserIdS = selection .map((item) => item.createUserId) .filter((createUserId) => createUserId == userId); if (createUserIdS.length == selection.length || userName == 'admin') { //创建人/admin所有权限 return true; } selection.forEach((val) => { const powerObj = val.userAuthority.find((item) => item.id == userId); if (powerObj) { userAuthorityS.push(powerObj); } }); if (userAuthorityS.length == 0) { _isPower = false; } userAuthorityS.forEach((item) => { if (item[power] != '1') { _isPower = false; } }); return _isPower; } if (data.createUserId == userId || userName == 'admin') { //创建人/admin所有权限 return true; } if (!power) { return false; } const powerObj = data.userAuthority?.find((item) => item.id == userId); if (powerObj) { return powerObj[power] == '1'; } } export function isCheckOut(data = {}) { //检出判断 if (data?.checkOutStatus == 1 && userId != data.checkOutUserId) { return true; } } export function setFolderList(data) { //递归过滤文件夹权限 data.forEach((item) => { item['disabled'] = !isPower(item, 'add'); if (item.sonDirectoryList && item.sonDirectoryList.length > 0) { setFolderList(item.sonDirectoryList); } }); } export function setFileUrl(row) { let file = row.storagePath[0]; let fileNames = file.storePath.split('/'); let url = window.location.origin + '/api/main/file/getFile?objectName=' + file.storePath + '&fullfilename=' + fileNames[fileNames.length - 1]; return '/kkfile/onlinePreview?url=' + btoa(url); } export function getFileType() { return [ 'par', 'asm', 'psm', 'dft', 'sldprt', 'sldasm', 'ipt', ' iam', 'prt', '3dxml', 'CATPart', 'CATProduct', 'cgr', 'model', 'exp', 'session', 'x_t', 'xmt_txt', 'x_b', 'xmp_bin', 'xmp_txt', 'sat', '.sab', '.igs', 'iges', 'stp', 'step', 'jt', 'xcgm', '3dm', 'stl', 'obj', '3mf', 'fbx', 'vda', 'dxf', 'dwg', 'idf', 'idb', 'emn', 'brd' ]; } export function fileStatus(status) { return status == 1 ? '发布中' : status == 2 ? '已发布' : status == 3 ? '已归档' : status == 4 ? '已废止' : ''; // if (fileType == 2) { // return status == 1 ? '已发布' : '未发布'; // } // if (fileType === 0) { // if (lcyStatus == 2) { // return '已归档' // } // if (lcyStatus == 3) { // return '已发布' // } // if (lcyStatus == 4) { // return '已废止' // } // } }