menu.data.ts 4.1 KB

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