buttons.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /**
  2. * 按钮
  3. */
  4. const buttons = {
  5. 'search': {
  6. label: '查询',
  7. type: 'primary',
  8. icon: 'ibps-icon-search',
  9. scope: ['toolbar', 'search']
  10. },
  11. 'resetSearch': {
  12. label: '重置',
  13. type: 'primary',
  14. icon: 'ibps-icon-undo',
  15. scope: ['toolbar', 'search']
  16. },
  17. 'moreSearch': {
  18. label: '更多',
  19. type: 'primary',
  20. icon: 'ibps-icon-ellipsis-h',
  21. scope: ['toolbar', 'search']
  22. },
  23. 'add': {
  24. label: '添加',
  25. type: 'success',
  26. icon: 'ibps-icon-add',
  27. scope: ['toolbar', 'contextmenu'],
  28. contextmenu: 'all'
  29. },
  30. 'remove': {
  31. label: '删除',
  32. type: 'danger',
  33. icon: 'ibps-icon-remove',
  34. scope: ['toolbar'],
  35. contextmenu: 'sub'
  36. },
  37. 'edit': {
  38. label: '编辑',
  39. type: 'primary',
  40. icon: 'ibps-icon-edit',
  41. scope: ['manage'],
  42. contextmenu: 'sub'
  43. },
  44. // 原明细
  45. // 'detail': {
  46. // label: '明细',
  47. // type: 'info',
  48. // icon: 'ibps-icon-detail',
  49. // scope: ['manage'],
  50. // contextmenu: 'sub'
  51. // },
  52. 'detail': {
  53. label: '查阅',
  54. type: 'primary',
  55. icon: 'ibps-icon-detail',
  56. scope: ['manage'],
  57. contextmenu: 'sub'
  58. },
  59. 'batchModify': {
  60. label: '批量修改',
  61. type: 'primary',
  62. icon: 'ibps-icon-check-square-o',
  63. scope: ['toolbar']
  64. },
  65. 'import': {
  66. label: '导入',
  67. type: 'primary',
  68. icon: 'ibps-icon-import',
  69. scope: ['toolbar']
  70. },
  71. 'export': {
  72. label: '导出',
  73. type: 'primary',
  74. icon: 'ibps-icon-export',
  75. scope: ['toolbar'],
  76. menus: [
  77. {
  78. label: '导出模板',
  79. key: 'exportTemplate'
  80. },
  81. {
  82. label: '导出选中',
  83. key: 'exportSelected'
  84. }, {
  85. label: '导出所有',
  86. key: 'exportAll'
  87. }, {
  88. label: '导出当前页',
  89. key: 'exportCurPage'
  90. }]
  91. },
  92. // 导出字段需要在导出按钮那里设置
  93. 'exportMuBan': {
  94. label: '导出模板',
  95. type: 'primary',
  96. icon: 'ibps-icon-export',
  97. scope: ['toolbar']
  98. },
  99. 'openTask': {
  100. label: '编制',
  101. type: 'success',
  102. icon: 'ibps-icon-add',
  103. scope: ['toolbar'],
  104. contextmenu: 'all'
  105. },
  106. 'consult': {
  107. label: '表单',
  108. type: 'primary',
  109. icon: 'ibps-icon-table',
  110. scope: ['manage'],
  111. contextmenu: 'sub'
  112. },
  113. 'download': {
  114. label: '下载记录',
  115. type: 'primary',
  116. icon: 'ibps-icon-download',
  117. scope: ['manage'],
  118. contextmenu: 'sub'
  119. },
  120. 'close': {
  121. label: '关闭',
  122. type: 'default',
  123. icon: 'ibps-icon-close',
  124. scope: ['edit', 'detail']
  125. },
  126. 'save': {
  127. label: '保存',
  128. type: 'primary',
  129. icon: 'ibps-icon-save',
  130. scope: ['edit']
  131. },
  132. 'print': {
  133. label: '打印',
  134. type: 'primary',
  135. icon: 'ibps-icon-print',
  136. scope: ['toolbar', 'manage', 'edit', 'detail']
  137. },
  138. 'custom': {
  139. label: '自定义',
  140. type: 'primary',
  141. icon: 'ibps-icon-cog',
  142. scope: ['toolbar', 'manage', 'edit', 'detail', 'dialog']
  143. },
  144. 'ok': {
  145. label: '确定',
  146. type: 'primary',
  147. icon: 'ibps-icon-ok',
  148. scope: ['dialog']
  149. },
  150. 'confirm': {
  151. label: '确定',
  152. type: 'primary',
  153. icon: 'ibps-icon-ok',
  154. scope: ['dialog']
  155. },
  156. 'clean': {
  157. label: '清空',
  158. type: 'info',
  159. icon: 'ibps-icon-clean',
  160. scope: ['dialog']
  161. },
  162. 'cleanClose': {
  163. label: '清空并关闭',
  164. type: 'warning',
  165. icon: 'ibps-icon-times-circle-o',
  166. scope: ['dialog']
  167. },
  168. 'cancel': {
  169. label: '取消',
  170. type: 'default',
  171. icon: 'ibps-icon-cancel',
  172. scope: ['dialog']
  173. },
  174. 'refresh': {
  175. label: '刷新',
  176. type: 'primary',
  177. icon: 'ibps-icon-refresh',
  178. scope: ['toolbar']
  179. },
  180. 'expand': {
  181. label: '展开',
  182. type: 'primary',
  183. icon: 'ibps-icon-expand',
  184. scope: ['toolbar']
  185. },
  186. 'compress': {
  187. label: '收缩',
  188. type: 'primary',
  189. icon: 'ibps-icon-compress',
  190. scope: ['toolbar']
  191. },
  192. 'more': {
  193. label: '更多',
  194. type: 'primary',
  195. icon: 'ibps-icon-list-alt',
  196. scope: ['toolbar']
  197. },
  198. 'collapse': {
  199. label: '收缩',
  200. icon: 'ibps-icon-angle-up',
  201. scope: ['toolbar']
  202. },
  203. 'expansion': {
  204. label: '展开',
  205. icon: 'ibps-icon-angle-down',
  206. scope: ['toolbar']
  207. },
  208. 'sefStartFlow': {
  209. label: '启动自定义流程',
  210. icon: 'ibps-icon-cog',
  211. scope: ['toolbar', 'manage', 'edit']
  212. }
  213. }
  214. export default buttons
  215. function hasButtonPermission (type, action) {
  216. var positions = buttons[type]['scope']
  217. if (!positions) { return false }
  218. return positions.indexOf(action) > -1
  219. }
  220. /**
  221. * 是否有权限
  222. */
  223. export const hasPermission = hasButtonPermission
  224. /*
  225. * 是否有按钮
  226. */
  227. export const hasButton = function (type, action, position) {
  228. var hasPermission = hasButtonPermission(type, action)
  229. if (!hasPermission) { return false }// 没有权限
  230. if (!position || position === 'all' || position === action) { return true }
  231. return false
  232. }
  233. /**
  234. * 是否有右键菜单权限
  235. */
  236. export const hasContextmenuButton = function (type, action, p) {
  237. var hasPermission = hasButtonPermission(type, action)
  238. if (!hasPermission) { return false }// 没有权限
  239. var contextmenu = buttons[type]['contextmenu']
  240. if (contextmenu === 'all' || contextmenu === p) { return true }
  241. return false
  242. }
  243. /**
  244. * 是否有搜索权限
  245. * @param {*} type
  246. */
  247. export const hasSearchPermission = function (type) {
  248. return hasButtonPermission(type, 'search')
  249. }