menu.data.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import { BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Table';
  3. import { h } from 'vue';
  4. import { Tag } from 'ant-design-vue';
  5. import { Icon } from '/@/components/Icon';
  6. export const columns: BasicColumn[] = [
  7. {
  8. title: '菜单名称',
  9. dataIndex: 'menuName',
  10. width: 200,
  11. align: 'left',
  12. },
  13. {
  14. title: '图标',
  15. dataIndex: 'icon',
  16. width: 50,
  17. customRender: ({ record }) => {
  18. return h(Icon, { icon: record.icon });
  19. },
  20. },
  21. {
  22. title: '权限标识',
  23. dataIndex: 'permission',
  24. width: 180,
  25. },
  26. {
  27. title: '组件',
  28. dataIndex: 'component',
  29. },
  30. {
  31. title: '排序',
  32. dataIndex: 'orderNo',
  33. width: 50,
  34. },
  35. {
  36. title: '状态',
  37. dataIndex: 'status',
  38. width: 80,
  39. customRender: ({ record }) => {
  40. const status = record.status;
  41. const enable = ~~status === 0;
  42. const color = enable ? 'green' : 'red';
  43. const text = enable ? '启用' : '停用';
  44. return h(Tag, { color: color }, () => text);
  45. },
  46. },
  47. {
  48. title: '创建时间',
  49. dataIndex: 'createTime',
  50. width: 180,
  51. },
  52. ];
  53. const isDir = (type: string) => type === '0';
  54. const isMenu = (type: string) => type === '1';
  55. const isButton = (type: string) => type === '2';
  56. export const searchFormSchema: FormSchema[] = [
  57. {
  58. field: 'menuName',
  59. label: '菜单名称',
  60. component: 'Input',
  61. colProps: { span: 8 },
  62. },
  63. {
  64. field: 'status',
  65. label: '状态',
  66. component: 'Select',
  67. componentProps: {
  68. options: [
  69. { label: '启用', value: '0' },
  70. { label: '停用', value: '1' },
  71. ],
  72. },
  73. colProps: { span: 8 },
  74. },
  75. ];
  76. export const formSchema: FormSchema[] = [
  77. {
  78. field: 'type',
  79. label: '菜单类型',
  80. component: 'RadioButtonGroup',
  81. defaultValue: '0',
  82. componentProps: {
  83. options: [
  84. { label: '目录', value: '0' },
  85. { label: '菜单', value: '1' },
  86. { label: '按钮', value: '2' },
  87. ],
  88. },
  89. colProps: { lg: 24, md: 24 },
  90. },
  91. {
  92. field: 'menuName',
  93. label: '菜单名称',
  94. component: 'Input',
  95. required: true,
  96. },
  97. {
  98. field: 'parentMenu',
  99. label: '上级菜单',
  100. component: 'TreeSelect',
  101. componentProps: {
  102. fieldNames: {
  103. label: 'menuName',
  104. key: 'id',
  105. value: 'id',
  106. },
  107. getPopupContainer: () => document.body,
  108. },
  109. },
  110. {
  111. field: 'orderNo',
  112. label: '排序',
  113. component: 'InputNumber',
  114. required: true,
  115. },
  116. {
  117. field: 'icon',
  118. label: '图标',
  119. component: 'IconPicker',
  120. required: true,
  121. ifShow: ({ values }) => !isButton(values.type),
  122. },
  123. {
  124. field: 'routePath',
  125. label: '路由地址',
  126. component: 'Input',
  127. required: true,
  128. ifShow: ({ values }) => !isButton(values.type),
  129. },
  130. {
  131. field: 'component',
  132. label: '组件路径',
  133. component: 'Input',
  134. ifShow: ({ values }) => isMenu(values.type),
  135. },
  136. {
  137. field: 'permission',
  138. label: '权限标识',
  139. component: 'Input',
  140. ifShow: ({ values }) => !isDir(values.type),
  141. },
  142. {
  143. field: 'status',
  144. label: '状态',
  145. component: 'RadioButtonGroup',
  146. defaultValue: '0',
  147. componentProps: {
  148. options: [
  149. { label: '启用', value: '0' },
  150. { label: '禁用', value: '1' },
  151. ],
  152. },
  153. },
  154. {
  155. field: 'isExt',
  156. label: '是否外链',
  157. component: 'RadioButtonGroup',
  158. defaultValue: '0',
  159. componentProps: {
  160. options: [
  161. { label: '否', value: '0' },
  162. { label: '是', value: '1' },
  163. ],
  164. },
  165. ifShow: ({ values }) => !isButton(values.type),
  166. },
  167. {
  168. field: 'keepalive',
  169. label: '是否缓存',
  170. component: 'RadioButtonGroup',
  171. defaultValue: '0',
  172. componentProps: {
  173. options: [
  174. { label: '否', value: '0' },
  175. { label: '是', value: '1' },
  176. ],
  177. },
  178. ifShow: ({ values }) => isMenu(values.type),
  179. },
  180. {
  181. field: 'show',
  182. label: '是否显示',
  183. component: 'RadioButtonGroup',
  184. defaultValue: '0',
  185. componentProps: {
  186. options: [
  187. { label: '是', value: '0' },
  188. { label: '否', value: '1' },
  189. ],
  190. },
  191. ifShow: ({ values }) => !isButton(values.type),
  192. },
  193. ];