buttons.js 5.6 KB

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