buttons.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. 'detail': {
  45. label: '明细',
  46. type: 'primary',
  47. icon: 'ibps-icon-detail',
  48. scope: ['toolbar', 'manage'],
  49. contextmenu: 'sub'
  50. },
  51. 'batchModify': {
  52. label: '批量修改',
  53. type: 'primary',
  54. icon: 'ibps-icon-check-square-o',
  55. scope: ['toolbar']
  56. },
  57. 'import': {
  58. label: '导入',
  59. type: 'primary',
  60. icon: 'ibps-icon-import',
  61. scope: ['toolbar']
  62. },
  63. 'export': {
  64. label: '导出',
  65. type: 'primary',
  66. icon: 'ibps-icon-export',
  67. scope: ['toolbar'],
  68. menus: [
  69. {
  70. label: '导出选中',
  71. key: 'exportSelected'
  72. }, {
  73. label: '导出所有',
  74. key: 'exportAll'
  75. }, {
  76. label: '导出当前页',
  77. key: 'exportCurPage'
  78. }, {
  79. label: '导出模板',
  80. key: 'exportMuBan'
  81. }]
  82. },
  83. // 导出字段需要在导出按钮那里设置
  84. 'exportMuBan': {
  85. label: '导出模板',
  86. type: 'primary',
  87. icon: 'ibps-icon-export',
  88. scope: ['toolbar'],
  89. },
  90. 'close': {
  91. label: '关闭',
  92. type: 'default',
  93. icon: 'ibps-icon-close',
  94. scope: ['edit', 'detail']
  95. },
  96. 'save': {
  97. label: '保存',
  98. type: 'primary',
  99. icon: 'ibps-icon-save',
  100. scope: ['edit']
  101. },
  102. 'print': {
  103. label: '打印',
  104. type: 'primary',
  105. icon: 'ibps-icon-print',
  106. scope: ['toolbar', 'manage', 'edit', 'detail']
  107. },
  108. 'custom': {
  109. label: '自定义',
  110. type: 'primary',
  111. icon: 'ibps-icon-cog',
  112. scope: ['toolbar', 'manage', 'edit', 'detail', 'dialog']
  113. },
  114. 'ok': {
  115. label: '确定',
  116. type: 'primary',
  117. icon: 'ibps-icon-ok',
  118. scope: ['dialog']
  119. },
  120. 'confirm': {
  121. label: '确定',
  122. type: 'primary',
  123. icon: 'ibps-icon-ok',
  124. scope: ['dialog']
  125. },
  126. 'clean': {
  127. label: '清空',
  128. type: 'info',
  129. icon: 'ibps-icon-clean',
  130. scope: ['dialog']
  131. },
  132. 'cleanClose': {
  133. label: '清空并关闭',
  134. type: 'warning',
  135. icon: 'ibps-icon-times-circle-o',
  136. scope: ['dialog']
  137. },
  138. 'cancel': {
  139. label: '取消',
  140. type: 'default',
  141. icon: 'ibps-icon-cancel',
  142. scope: ['dialog']
  143. },
  144. 'refresh': {
  145. label: '刷新',
  146. type: 'primary',
  147. icon: 'ibps-icon-refresh',
  148. scope: ['toolbar']
  149. },
  150. 'expand': {
  151. label: '展开',
  152. type: 'primary',
  153. icon: 'ibps-icon-expand',
  154. scope: ['toolbar']
  155. },
  156. 'compress': {
  157. label: '收缩',
  158. type: 'primary',
  159. icon: 'ibps-icon-compress',
  160. scope: ['toolbar']
  161. },
  162. 'more': {
  163. label: '更多',
  164. type: 'primary',
  165. icon: 'ibps-icon-list-alt',
  166. scope: ['toolbar']
  167. },
  168. 'collapse': {
  169. label: '收缩',
  170. icon: 'ibps-icon-angle-up',
  171. scope: ['toolbar']
  172. },
  173. 'expansion': {
  174. label: '展开',
  175. icon: 'ibps-icon-angle-down',
  176. scope: ['toolbar']
  177. },
  178. 'sefStartFlow': {
  179. label: '启动自定义流程',
  180. icon: 'ibps-icon-cog',
  181. scope: ['toolbar', 'manage', 'edit']
  182. }
  183. }
  184. export default buttons
  185. function hasButtonPermission(type, action) {
  186. var positions = buttons[type]['scope']
  187. if (!positions) { return false }
  188. return positions.indexOf(action) > -1
  189. }
  190. /**
  191. * 是否有权限
  192. */
  193. export const hasPermission = hasButtonPermission
  194. /*
  195. * 是否有按钮
  196. */
  197. export const hasButton = function (type, action, position) {
  198. var hasPermission = hasButtonPermission(type, action)
  199. if (!hasPermission) { return false }// 没有权限
  200. if (!position || position === 'all' || position === action) { return true }
  201. return false
  202. }
  203. /**
  204. * 是否有右键菜单权限
  205. */
  206. export const hasContextmenuButton = function (type, action, p) {
  207. var hasPermission = hasButtonPermission(type, action)
  208. if (!hasPermission) { return false }// 没有权限
  209. var contextmenu = buttons[type]['contextmenu']
  210. if (contextmenu === 'all' || contextmenu === p) { return true }
  211. return false
  212. }
  213. /**
  214. * 是否有搜索权限
  215. * @param {*} type
  216. */
  217. export const hasSearchPermission = function (type) {
  218. return hasButtonPermission(type, 'search')
  219. }