buttons.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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-eye',
  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. {
  86. label: '导出所有',
  87. key: 'exportAll'
  88. },
  89. {
  90. label: '导出当前页',
  91. key: 'exportCurPage'
  92. }
  93. ]
  94. },
  95. 'openTask': {
  96. label: '编制',
  97. type: 'success',
  98. icon: 'ibps-icon-add',
  99. scope: ['toolbar'],
  100. contextmenu: 'all'
  101. },
  102. 'consult': {
  103. label: '表单',
  104. type: 'primary',
  105. icon: 'ibps-icon-table',
  106. scope: ['manage'],
  107. contextmenu: 'sub'
  108. },
  109. 'download': {
  110. label: '下载记录',
  111. type: 'primary',
  112. icon: 'ibps-icon-download',
  113. scope: ['manage'],
  114. contextmenu: 'sub'
  115. },
  116. 'close': {
  117. label: '关闭',
  118. type: 'default',
  119. icon: 'ibps-icon-close',
  120. scope: ['edit', 'detail']
  121. },
  122. 'save': {
  123. label: '保存',
  124. type: 'primary',
  125. icon: 'ibps-icon-save',
  126. scope: ['edit']
  127. },
  128. 'print': {
  129. label: '打印',
  130. type: 'primary',
  131. icon: 'ibps-icon-print',
  132. scope: ['toolbar', 'manage', 'edit', 'detail']
  133. },
  134. 'custom': {
  135. label: '自定义',
  136. type: 'primary',
  137. icon: 'ibps-icon-cog',
  138. scope: ['toolbar', 'manage', 'edit', 'detail', 'dialog']
  139. },
  140. 'ok': {
  141. label: '确定',
  142. type: 'primary',
  143. icon: 'ibps-icon-ok',
  144. scope: ['dialog']
  145. },
  146. 'confirm': {
  147. label: '确定',
  148. type: 'primary',
  149. icon: 'ibps-icon-ok',
  150. scope: ['dialog']
  151. },
  152. 'clean': {
  153. label: '清空',
  154. type: 'info',
  155. icon: 'ibps-icon-clean',
  156. scope: ['dialog']
  157. },
  158. 'cleanClose': {
  159. label: '清空并关闭',
  160. type: 'warning',
  161. icon: 'ibps-icon-times-circle-o',
  162. scope: ['dialog']
  163. },
  164. 'cancel': {
  165. label: '取消',
  166. type: 'default',
  167. icon: 'ibps-icon-cancel',
  168. scope: ['dialog']
  169. },
  170. 'refresh': {
  171. label: '刷新',
  172. type: 'primary',
  173. icon: 'ibps-icon-refresh',
  174. scope: ['toolbar']
  175. },
  176. 'expand': {
  177. label: '展开',
  178. type: 'primary',
  179. icon: 'ibps-icon-expand',
  180. scope: ['toolbar']
  181. },
  182. 'compress': {
  183. label: '收缩',
  184. type: 'primary',
  185. icon: 'ibps-icon-compress',
  186. scope: ['toolbar']
  187. },
  188. 'more': {
  189. label: '更多',
  190. type: 'primary',
  191. icon: 'ibps-icon-list-alt',
  192. scope: ['toolbar']
  193. },
  194. 'collapse': {
  195. label: '收缩',
  196. icon: 'ibps-icon-angle-up',
  197. scope: ['toolbar']
  198. },
  199. 'expansion': {
  200. label: '展开',
  201. icon: 'ibps-icon-angle-down',
  202. scope: ['toolbar']
  203. },
  204. 'sefStartFlow': {
  205. label: '启动自定义流程',
  206. icon: 'ibps-icon-cog',
  207. scope: ['toolbar', 'manage', 'edit']
  208. }
  209. }
  210. export default buttons
  211. function hasButtonPermission (type, action) {
  212. var positions = buttons[type]['scope']
  213. if (!positions) { return false }
  214. return positions.indexOf(action) > -1
  215. }
  216. /**
  217. * 是否有权限
  218. */
  219. export const hasPermission = hasButtonPermission
  220. /*
  221. * 是否有按钮
  222. */
  223. export const hasButton = function (type, action, position) {
  224. var hasPermission = hasButtonPermission(type, action)
  225. if (!hasPermission) { return false }// 没有权限
  226. if (!position || position === 'all' || position === action) { return true }
  227. return false
  228. }
  229. /**
  230. * 是否有右键菜单权限
  231. */
  232. export const hasContextmenuButton = function (type, action, p) {
  233. var hasPermission = hasButtonPermission(type, action)
  234. if (!hasPermission) { return false }// 没有权限
  235. var contextmenu = buttons[type]['contextmenu']
  236. if (contextmenu === 'all' || contextmenu === p) { return true }
  237. return false
  238. }
  239. /**
  240. * 是否有搜索权限
  241. * @param {*} type
  242. */
  243. export const hasSearchPermission = function (type) {
  244. return hasButtonPermission(type, 'search')
  245. }