crud.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. import * as api from './api';
  2. import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
  3. import { dictionary } from '/@/utils/dictionary';
  4. import { successMessage } from '/@/utils/message';
  5. import { auth } from '/@/utils/authFunction';
  6. import tableSelector from '/@/components/tableSelector/index.vue';
  7. import { shallowRef } from 'vue';
  8. import { useRouter } from 'vue-router';
  9. export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  10. const router = useRouter();
  11. const pageRequest = async (query: UserPageQuery) => {
  12. return await api.GetList(query);
  13. };
  14. const editRequest = async ({ form, row }: EditReq) => {
  15. form.id = row.id;
  16. return await api.UpdateObj(form);
  17. };
  18. const delRequest = async ({ row }: DelReq) => {
  19. return await api.DelObj(row.id);
  20. };
  21. const addRequest = async ({ form }: AddReq) => {
  22. return await api.AddObj(form);
  23. };
  24. /**
  25. * 懒加载
  26. * @param row
  27. * @returns {Promise<unknown>}
  28. */
  29. const loadContentMethod = (tree: any, treeNode: any, resolve: Function) => {
  30. pageRequest({ pcode: tree.code }).then((res: APIResponseData) => {
  31. resolve(res.data);
  32. });
  33. };
  34. return {
  35. crudOptions: {
  36. request: {
  37. pageRequest,
  38. addRequest,
  39. editRequest,
  40. delRequest,
  41. },
  42. actionbar: {
  43. buttons: {
  44. add: {
  45. show: false,//auth('area:Create'),
  46. },
  47. },
  48. },
  49. rowHandle: {
  50. //固定右侧
  51. fixed: 'right',
  52. width: 200,
  53. buttons: {
  54. view: {
  55. iconRight: 'view',
  56. show: true,
  57. type: 'text',
  58. click: ({ row }) => {
  59. // 在新窗口中打开报告详情页面,确保使用正确的哈希路由格式
  60. const baseUrl = window.location.origin;
  61. const url = `${baseUrl}/#/report?id=${row.id}`;
  62. window.open(url, '_blank');
  63. }
  64. },
  65. edit: {
  66. iconRight: 'Edit',
  67. type: 'text',
  68. show: false,//auth('area:Update'),
  69. },
  70. remove: {
  71. iconRight: 'Delete',
  72. type: 'text',
  73. show: false,//auth('area:Delete'),
  74. },
  75. },
  76. },
  77. pagination: {
  78. show: true,
  79. },
  80. table: {
  81. rowKey: 'id',
  82. },
  83. search: {
  84. show: true,
  85. layout: 'auto',
  86. },
  87. columns: {
  88. _index: {
  89. title: '序号',
  90. form: { show: false },
  91. column: {
  92. type: 'index',
  93. align: 'center',
  94. width: '70px',
  95. columnSetDisabled: true, //禁止在列设置中选择
  96. },
  97. },
  98. report_id: {
  99. title: '报告编号',
  100. search: {
  101. show: true,
  102. component: {
  103. placeholder: '请输入报告编号',
  104. },
  105. },
  106. type: 'input',
  107. column: {
  108. minWidth: 150,
  109. },
  110. form: {
  111. rules: [
  112. { required: true, message: '报告编号必填项' },
  113. ],
  114. },
  115. },
  116. applicant_name: {
  117. title: '申请人姓名',
  118. search: {
  119. show: true,
  120. component: {
  121. placeholder: '请输入申请人姓名',
  122. },
  123. },
  124. type: 'input',
  125. column: {
  126. minWidth: 120,
  127. },
  128. form: {
  129. rules: [
  130. { required: true, message: '申请人姓名必填项' },
  131. ],
  132. },
  133. },
  134. applicant_phone: {
  135. title: '申请人电话',
  136. search: {
  137. show: true,
  138. component: {
  139. placeholder: '请输入申请人电话',
  140. },
  141. },
  142. type: 'input',
  143. column: {
  144. minWidth: 130,
  145. },
  146. form: {
  147. rules: [
  148. { required: true, message: '申请人电话必填项' },
  149. ],
  150. },
  151. },
  152. position_title: {
  153. title: '申请职位',
  154. search: {
  155. show: true,
  156. component: {
  157. placeholder: '请输入申请职位',
  158. },
  159. },
  160. type: 'input',
  161. column: {
  162. minWidth: 120,
  163. },
  164. form: {
  165. rules: [
  166. { required: true, message: '申请职位必填项' },
  167. ],
  168. },
  169. },
  170. status: {
  171. title: '申请状态',
  172. search: {
  173. show: true,
  174. component: {
  175. name: 'el-select',
  176. placeholder: '请选择申请状态',
  177. },
  178. },
  179. type: 'dict-select',
  180. column: {
  181. minWidth: 100,
  182. },
  183. dict: dict({
  184. data: [
  185. { value: 1, label: '待面试' },
  186. { value: 2, label: '已面试' },
  187. { value: 3, label: '已录用' },
  188. { value: 4, label: '已拒绝' },
  189. ],
  190. }),
  191. },
  192. comprehensive_score: {
  193. title: '综合评分',
  194. type: 'number',
  195. column: {
  196. minWidth: 100,
  197. },
  198. },
  199. hire_recommendation: {
  200. title: '录用建议',
  201. type: 'textarea',
  202. column: {
  203. minWidth: 150,
  204. showOverflowTooltip: true,
  205. },
  206. },
  207. /* resume_url: {
  208. title: '简历链接',
  209. type: 'link',
  210. column: {
  211. minWidth: 100,
  212. component: {
  213. name: 'fs-button',
  214. type: 'primary',
  215. link: true,
  216. text: '查看简历',
  217. click: compute(({ row }) => {
  218. return () => {
  219. if (row.resume_url) {
  220. window.open(row.resume_url);
  221. }
  222. };
  223. }),
  224. },
  225. show: compute(({ row }) => {
  226. return !!row.resume_url;
  227. }),
  228. },
  229. }, */
  230. create_datetime: {
  231. title: '创建时间',
  232. type: 'datetime',
  233. column: {
  234. minWidth: 160,
  235. },
  236. form: {
  237. show: false,
  238. },
  239. },
  240. update_datetime: {
  241. title: '更新时间',
  242. type: 'datetime',
  243. column: {
  244. minWidth: 160,
  245. },
  246. form: {
  247. show: false,
  248. },
  249. },
  250. },
  251. },
  252. };
  253. };