crud.tsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, dict, UserPageQuery } from '@fast-crud/fast-crud';
  2. import * as api from './api';
  3. import { auth } from '/@/utils/authFunction';
  4. export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  5. const pageRequest = async (query: UserPageQuery) => {
  6. return await api.GetList(query);
  7. };
  8. const getDetail = async ({ row }: InfoReq) => {
  9. return await api.GetObj(row.id);
  10. };
  11. const editRequest = async ({ form, row }: EditReq) => {
  12. form.id = row.id;
  13. return await api.UpdateObj(form);
  14. };
  15. const delRequest = async ({ row }: DelReq) => {
  16. return await api.DelObj(row.id);
  17. };
  18. const addRequest = async ({ form }: AddReq) => {
  19. return await api.AddObj(form);
  20. };
  21. return {
  22. crudOptions: {
  23. request: {
  24. pageRequest,
  25. editRequest,
  26. delRequest,
  27. addRequest,
  28. getDetail,
  29. },
  30. form:{
  31. wrapper: {
  32. buttons: {
  33. ok:{
  34. text:'提交'
  35. }
  36. }
  37. }
  38. },
  39. actionbar: {
  40. buttons: {
  41. add: {
  42. show: auth('area:Create'),
  43. },
  44. },
  45. },
  46. pagination: {
  47. show: false,
  48. },
  49. columns: {
  50. _index: {
  51. title: '序号',
  52. form: { show: false },
  53. column: {
  54. type: 'index',
  55. align: 'center',
  56. width: '70px',
  57. columnSetDisabled: true, //禁止在列设置中选择
  58. },
  59. },
  60. user_code:{
  61. title:'学号',
  62. type:'input',
  63. column: {
  64. minWidth: 120,
  65. },
  66. form: {
  67. component: { placeholder: '请填写学号' },
  68. rules: [{ required: true, message: '请填写学号' }],
  69. },
  70. },
  71. username:{
  72. title:'昵称',
  73. type:'input',
  74. column: {
  75. show: false,
  76. minWidth: 120,
  77. },
  78. form: {
  79. component: { placeholder: '请填写昵称' },
  80. rules: [{ required: true, message: '请填写昵称' }],
  81. },
  82. viewForm:{
  83. component: { placeholder: '' },
  84. }
  85. },
  86. name: {
  87. title: '名称',
  88. search: {
  89. show: true,
  90. },
  91. treeNode: true,
  92. type: 'input',
  93. column: {
  94. minWidth: 120,
  95. },
  96. form: {
  97. rules: [
  98. // 表单校验规则
  99. { required: true, message: '名称必填项' },
  100. ],
  101. component: {
  102. placeholder: '请输入名称',
  103. },
  104. },
  105. },
  106. password:{
  107. title: '密码',
  108. type: 'input',
  109. column: {
  110. minWidth: 120,
  111. show: false,
  112. },
  113. form: {
  114. component: { placeholder: '请填写密码' },
  115. rules: [{ required: true, message: '请填写密码' }],
  116. },
  117. editForm:{
  118. show:false,
  119. },
  120. viewForm:{
  121. show:false,
  122. }
  123. },
  124. email:{
  125. title: '邮箱',
  126. type: 'input',
  127. column: {
  128. show: false,
  129. minWidth: 120,
  130. },
  131. form: {
  132. component: { placeholder: '请填写邮箱' },
  133. rules: [{ required: false, message: '请填写邮箱' }],
  134. },
  135. viewForm:{
  136. component: { placeholder: '' },
  137. }
  138. },
  139. mobile:{
  140. title: '手机号',
  141. type: 'input',
  142. column: {
  143. show: false,
  144. minWidth: 120,
  145. },
  146. form: {
  147. component: { placeholder: '请填写手机号' },
  148. rules: [{ required: true, message: '请填写手机号' }],
  149. },
  150. viewForm:{
  151. component: { placeholder: '' },
  152. }
  153. },
  154. gender:{
  155. title: '性别',
  156. type: 'dict-select',
  157. column: {
  158. show: false,
  159. minWidth: 120,
  160. },
  161. dict: dict({
  162. data: [
  163. { label: '男', value: 1 },
  164. { label: '女', value: 2 },
  165. ],
  166. }),
  167. form: {
  168. component: { placeholder: '请选择性别' },
  169. rules: [{ required: true, message: '请选择性别' }],
  170. },
  171. viewForm:{
  172. component: { placeholder: '' },
  173. }
  174. },
  175. user_type:{
  176. title: '用户类型',
  177. type: 'dict-select',
  178. column: {
  179. minWidth: 120,
  180. },
  181. dict: dict({
  182. data: [
  183. { label: '学生', value: 0 },
  184. { label: '教师', value: 1 },
  185. { label: '校外团体', value: 2 },
  186. { label: '学院领导', value: 3 },
  187. ],
  188. }),
  189. form: {
  190. value:1,
  191. component: { placeholder: '请填写租户' },
  192. rules: [{ required: false, message: '请填写租户' }],
  193. },
  194. },
  195. organization:{
  196. title: '学院',
  197. type: 'input',
  198. column: {
  199. show: true,
  200. minWidth: 120,
  201. },
  202. form: {
  203. component: { placeholder: '请填写学院' },
  204. rules: [{ required: false, message: '请填写学院' }],
  205. },
  206. viewForm:{
  207. component: { placeholder: '' },
  208. }
  209. },
  210. sub_organization:{
  211. title: '专业',
  212. type: 'input',
  213. column: {
  214. show: true,
  215. minWidth: 120,
  216. },
  217. form: {
  218. component: { placeholder: '请填写专业' },
  219. rules: [{ required: false, message: '请填写专业' }],
  220. },
  221. viewForm:{
  222. component: { placeholder: '' },
  223. }
  224. },
  225. grade_or_level:{
  226. title: '年级',
  227. type: 'input',
  228. column: {
  229. show: false,
  230. minWidth: 120,
  231. },
  232. form: {
  233. component: { placeholder: '请填写年级' },
  234. rules: [{ required: false, message: '请填写年级' }],
  235. },
  236. viewForm:{
  237. component: { placeholder: '' },
  238. }
  239. },
  240. class_or_group:{
  241. title: '班级',
  242. type: 'input',
  243. column: {
  244. show: false,
  245. minWidth: 120,
  246. },
  247. form: {
  248. component: { placeholder: '请填写班级' },
  249. rules: [{ required: false, message: '请填写班级' }],
  250. },
  251. viewForm:{
  252. component: { placeholder: '' },
  253. }
  254. },
  255. },
  256. },
  257. };
  258. };