| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- import store from '@/store';
- const userId = store.state.user.info.userId
- const userName = store.state.user.info.name
- export function isCreateUserId(row) {
- return userId == row?.createUserId
- }
- export function isPower(data = {}, power, selection = []) {
- 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
- }
- 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 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(fileType, status, lcyStatus) {
- if (fileType == 2) {
- return status == 1 ? '已发布' : '未发布';
- }
- if (fileType === 0) {
- if (lcyStatus == 2) {
- return '已归档'
- }
- if (lcyStatus == 3) {
- return '已发布'
- }
- if (lcyStatus == 4) {
- return '已废止'
- }
- }
- }
|