util.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import store from '@/store';
  2. const userId = store.state.user.info.userId
  3. const userName = store.state.user.info.name
  4. export function isCreateUserId(row) {
  5. return userId == row?.createUserId
  6. }
  7. export function isPower(data = {}, power, selection = []) {
  8. if (!data.id && selection.length == 0) {
  9. return false
  10. }
  11. if (power == 'add' && data.userAuthority.length == 0) { //文件夹默认开放新增权限
  12. return true
  13. }
  14. if (power == 'checkEnter' && data?.checkOutUserId != userId) { //检入特殊处理
  15. return false
  16. }
  17. if (selection.length > 0) { //多选情况处理
  18. let _isPower = true
  19. let userAuthorityS = []
  20. let createUserIdS = selection.map(item => item.createUserId).filter(createUserId => createUserId == userId)
  21. if (createUserIdS.length == selection.length || userName == 'admin') { //创建人/admin所有权限
  22. return true
  23. }
  24. selection.forEach(val => {
  25. const powerObj = val.userAuthority.find(item => item.id == userId)
  26. if (powerObj) {
  27. userAuthorityS.push(powerObj)
  28. }
  29. })
  30. if (userAuthorityS.length == 0) {
  31. _isPower = false
  32. }
  33. userAuthorityS.forEach(item => {
  34. if (item[power] != '1') {
  35. _isPower = false
  36. }
  37. })
  38. return _isPower
  39. }
  40. if (data.createUserId == userId || userName == 'admin') { //创建人/admin所有权限
  41. return true
  42. }
  43. if (!power) {
  44. return false
  45. }
  46. const powerObj = data.userAuthority?.find(item => item.id == userId)
  47. if (powerObj) {
  48. return powerObj[power] == '1'
  49. }
  50. }
  51. export function isCheckOut(data = {}) { //检出判断
  52. if (data?.checkOutStatus == 1&&userId!=data.checkOutUserId) {
  53. return true
  54. }
  55. }
  56. export function setFolderList(data) { //递归过滤文件夹权限
  57. data.forEach((item) => {
  58. item['disabled'] = !isPower(item, 'add');
  59. if (item.sonDirectoryList && item.sonDirectoryList.length > 0) {
  60. setFolderList(item.sonDirectoryList);
  61. }
  62. });
  63. }
  64. export function getFileType() {
  65. return ['par', 'asm', 'psm', 'dft', 'sldprt',
  66. 'sldasm', 'ipt', ' iam',
  67. 'prt', '3dxml', 'CATPart', 'CATProduct', 'cgr',
  68. 'model', 'exp', 'session', 'x_t', 'xmt_txt',
  69. 'x_b', 'xmp_bin', 'xmp_txt', 'sat', '.sab', '.igs',
  70. 'iges', 'stp', 'step', 'jt', 'xcgm', '3dm', 'stl', 'obj', '3mf', 'fbx', 'vda', 'dxf', 'dwg', 'idf', 'idb', 'emn', 'brd'
  71. ]
  72. }
  73. export function fileStatus(fileType, status, lcyStatus) {
  74. if (fileType == 2) {
  75. return status == 1 ? '已发布' : '未发布';
  76. }
  77. if (fileType === 0) {
  78. if (lcyStatus == 2) {
  79. return '已归档'
  80. }
  81. if (lcyStatus == 3) {
  82. return '已发布'
  83. }
  84. if (lcyStatus == 4) {
  85. return '已废止'
  86. }
  87. }
  88. }