crud.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import * as api from './api';
  2. import { UserPageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
  3. export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  4. const pageRequest = async (query: UserPageQuery) => {
  5. return await api.GetList(query);
  6. };
  7. const editRequest = async ({ form, row }: EditReq) => {
  8. form.id = row.id;
  9. return await api.UpdateObj(form);
  10. };
  11. const delRequest = async ({ row }: DelReq) => {
  12. return await api.DelObj(row.id);
  13. };
  14. const addRequest = async ({ form }: AddReq) => {
  15. return await api.AddObj(form);
  16. };
  17. return {
  18. crudOptions: {
  19. toolbar:{
  20. buttons:{
  21. search:{show:false},
  22. // 刷新按钮
  23. refresh:{show:false},
  24. // 紧凑模式
  25. compact:{show:false},
  26. // 导出按钮
  27. export:{
  28. text: '导出',
  29. type: 'primary',
  30. size: 'small',
  31. icon: 'upload',
  32. circle: false,
  33. display: true,
  34. show:false
  35. },
  36. // 列设置按钮
  37. columns:{
  38. show:false
  39. },
  40. }
  41. },
  42. request: {
  43. pageRequest,
  44. addRequest,
  45. editRequest,
  46. delRequest,
  47. },
  48. actionbar: {
  49. buttons: {
  50. add: {
  51. show: false,
  52. },
  53. },
  54. },
  55. rowHandle: {
  56. fixed:'right',
  57. width: 100,
  58. buttons: {
  59. view: {
  60. type: 'text',
  61. },
  62. edit: {
  63. show: false,
  64. },
  65. remove: {
  66. show: false,
  67. },
  68. },
  69. },
  70. columns: {
  71. _index: {
  72. title: '序号',
  73. form: { show: false },
  74. column: {
  75. //type: 'index',
  76. align: 'center',
  77. width: '70px',
  78. columnSetDisabled: true, //禁止在列设置中选择
  79. formatter: (context) => {
  80. //计算序号,你可以自定义计算规则,此处为翻页累加
  81. let index = context.index ?? 1;
  82. let pagination = crudExpose!.crudBinding.value.pagination;
  83. return ((pagination!.currentPage ?? 1) - 1) * pagination!.pageSize + index + 1;
  84. },
  85. },
  86. },
  87. search: {
  88. title: '关键词',
  89. column: {
  90. show: false,
  91. },
  92. search: {
  93. show: true,
  94. component: {
  95. props: {
  96. clearable: true,
  97. },
  98. placeholder: '请输入关键词',
  99. },
  100. },
  101. form: {
  102. show: false,
  103. component: {
  104. props: {
  105. clearable: true,
  106. },
  107. },
  108. },
  109. },
  110. request_modular: {
  111. title: '请求模块',
  112. search: {
  113. disabled: false,
  114. },
  115. type: 'input',
  116. column:{
  117. minWidth: 100,
  118. },
  119. form: {
  120. disabled: true,
  121. component: {
  122. placeholder: '请输入请求模块',
  123. },
  124. },
  125. },
  126. request_path: {
  127. title: '请求地址',
  128. search: {
  129. disabled: false,
  130. },
  131. type: 'input',
  132. column:{
  133. minWidth: 200,
  134. },
  135. form: {
  136. disabled: true,
  137. component: {
  138. placeholder: '请输入请求地址',
  139. },
  140. },
  141. },
  142. request_body: {
  143. column: {
  144. showOverflowTooltip: true,
  145. width: 200, //列宽
  146. minWidth: 100, //最小列宽
  147. },
  148. title: '请求参数',
  149. search: {
  150. disabled: true,
  151. },
  152. disabled: true,
  153. type: 'textarea',
  154. form: {
  155. component: {
  156. props: {
  157. type: 'textarea',
  158. },
  159. autosize: {
  160. minRows: 2,
  161. maxRows: 8,
  162. },
  163. placeholder: '请输入关键词',
  164. },
  165. },
  166. },
  167. request_method: {
  168. title: '请求方法',
  169. type: 'input',
  170. search: {
  171. disabled: false,
  172. },
  173. column:{
  174. minWidth: 100,
  175. },
  176. form: {
  177. disabled: true,
  178. component: {
  179. placeholder: '请输入请求方法',
  180. },
  181. },
  182. component: { props: { color: 'auto' } }, // 自动染色
  183. },
  184. request_msg: {
  185. title: '操作说明',
  186. disabled: true,
  187. form: {
  188. component: {
  189. span: 12,
  190. },
  191. },
  192. },
  193. request_ip: {
  194. title: 'IP地址',
  195. search: {
  196. disabled: false,
  197. },
  198. type: 'input',
  199. column:{
  200. minWidth: 100,
  201. },
  202. form: {
  203. disabled: true,
  204. component: {
  205. placeholder: '请输入IP地址',
  206. },
  207. },
  208. component: { props: { color: 'auto' } }, // 自动染色
  209. },
  210. request_browser: {
  211. title: '请求浏览器',
  212. type: 'input',
  213. column:{
  214. minWidth: 120,
  215. },
  216. form: {
  217. disabled: true,
  218. },
  219. component: { props: { color: 'auto' } }, // 自动染色
  220. },
  221. response_code: {
  222. title: '响应码',
  223. search: {
  224. disabled: true,
  225. },
  226. type: 'input',
  227. column:{
  228. minWidth: 100,
  229. },
  230. form: {
  231. disabled: true,
  232. },
  233. component: { props: { color: 'auto' } }, // 自动染色
  234. },
  235. request_os: {
  236. title: '操作系统',
  237. disabled: true,
  238. search: {
  239. disabled: true,
  240. },
  241. type: 'input',
  242. column:{
  243. minWidth: 120,
  244. },
  245. form: {
  246. disabled: true,
  247. },
  248. component: { props: { color: 'auto' } }, // 自动染色
  249. },
  250. json_result: {
  251. title: '返回信息',
  252. search: {
  253. disabled: true,
  254. },
  255. type: 'input',
  256. column:{
  257. minWidth: 150,
  258. },
  259. form: {
  260. disabled: true,
  261. },
  262. component: { props: { color: 'auto' } }, // 自动染色
  263. },
  264. creator_name: {
  265. title: '操作人',
  266. column:{
  267. minWidth: 100,
  268. },
  269. form: {
  270. disabled: true,
  271. },
  272. },
  273. },
  274. },
  275. };
  276. };