buttons.js 5.4 KB

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