|
@@ -1,94 +1,155 @@
|
|
|
import store from '@/store';
|
|
import store from '@/store';
|
|
|
-const userId = store.state.user.info.userId
|
|
|
|
|
-const userName = store.state.user.info.name
|
|
|
|
|
|
|
+import vue from 'vue';
|
|
|
|
|
+const userId = store.state.user.info.userId;
|
|
|
|
|
+const userName = store.state.user.info.name;
|
|
|
|
|
|
|
|
export function isCreateUserId(row) {
|
|
export function isCreateUserId(row) {
|
|
|
- return userId == row?.createUserId
|
|
|
|
|
|
|
+ return userId == row?.createUserId;
|
|
|
}
|
|
}
|
|
|
export function isPower(data = {}, power, selection = []) {
|
|
export function isPower(data = {}, power, selection = []) {
|
|
|
|
|
+ if (!data.id && selection.length == 0) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (
|
|
|
|
|
+ //文件查看浏览权限
|
|
|
|
|
+ vue.prototype.$hasPermission('fm:doc:viewAll') &&
|
|
|
|
|
+ ['check', 'browse'].includes(power)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (!data.id && selection.length == 0) {
|
|
|
|
|
- return false
|
|
|
|
|
|
|
+ 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;
|
|
|
}
|
|
}
|
|
|
- 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
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ selection.forEach((val) => {
|
|
|
|
|
+ const powerObj = val.userAuthority.find((item) => item.id == userId);
|
|
|
|
|
+ if (powerObj) {
|
|
|
|
|
+ userAuthorityS.push(powerObj);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- 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'
|
|
|
|
|
|
|
+ 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 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 setFolderList(data) {
|
|
|
|
|
+ //递归过滤文件夹权限
|
|
|
|
|
+ data.forEach((item) => {
|
|
|
|
|
+ item['disabled'] = !isPower(item, 'add');
|
|
|
|
|
+ if (item.sonDirectoryList && item.sonDirectoryList.length > 0) {
|
|
|
|
|
+ setFolderList(item.sonDirectoryList);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function getFileType() {
|
|
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'
|
|
|
|
|
- ]
|
|
|
|
|
|
|
+ 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) {
|
|
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 '已废止'
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ 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 '已废止'
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+}
|