crud.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import { CreateCrudOptionsProps, CreateCrudOptionsRet, dict, compute } from '@fast-crud/fast-crud';
  2. import * as api from '../../api';
  3. import { ElMessage } from 'element-plus';
  4. import { Session } from '/@/utils/storage';
  5. export const createAsideCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  6. const pageRequest = async (query: any) => {
  7. const params = {
  8. ...query,
  9. tenant_id: Session.get('tenant_id'),
  10. job_id: query.form?.job_id || ''
  11. };
  12. return api.GetDocumentList(params);
  13. };
  14. return {
  15. crudOptions: {
  16. request: {
  17. pageRequest
  18. },
  19. actionbar: {
  20. buttons: {
  21. add: {
  22. show: true,
  23. click: () => {
  24. // 打开添加问题对话框
  25. crudExpose.openAdd();
  26. }
  27. }
  28. }
  29. },
  30. rowHandle: {
  31. width: 300,
  32. buttons: {
  33. view: {
  34. size: 'small',
  35. icon: "View",
  36. type: 'text',
  37. click: ({ row }: any) => {
  38. const event = new CustomEvent('viewDocumentDetail', { detail: row });
  39. window.dispatchEvent(event);
  40. }
  41. },
  42. uploadVideo: {
  43. text: '上传视频',
  44. type: 'text',
  45. icon: "upload",
  46. size: 'small',
  47. click: ({ row }: any) => {
  48. const event = new CustomEvent('openVideoUploadDialog', { detail: row });
  49. window.dispatchEvent(event);
  50. }
  51. },
  52. edit: {
  53. type: 'text',
  54. icon: "Edit",
  55. size: 'small',
  56. },
  57. remove: {
  58. type: 'text',
  59. icon: "Delete",
  60. size: 'small',
  61. },
  62. sort: {
  63. type: 'text',
  64. icon: "sort",
  65. size: 'small',
  66. text: '修改排序',
  67. click: ({ row }: any) => {
  68. const event = new CustomEvent('openSortDialog', { detail: row });
  69. window.dispatchEvent(event);
  70. }
  71. }
  72. }
  73. },
  74. columns: {
  75. id: {
  76. title: 'ID',
  77. column: { show: true, width: 80 },
  78. search: { show: false },
  79. form: { show: false },
  80. },
  81. question: {
  82. title: '题目内容',
  83. search: { show: true },
  84. column: {
  85. sortable: 'custom',
  86. showOverflowTooltip: true,
  87. width: 300
  88. },
  89. form: {
  90. rules: [{ required: true, message: '题目内容必填' }],
  91. component: {
  92. placeholder: '请输入题目内容',
  93. }
  94. },
  95. },
  96. question_type: {
  97. title: '问题类型',
  98. search: { show: true },
  99. type: 'dict-select',
  100. column: {
  101. minWidth: 100,
  102. },
  103. dict: dict({
  104. data: [
  105. { value: 1, label: '专业技能' },
  106. { value: 2, label: '通用能力' },
  107. { value: 3, label: '个人特质' }
  108. ]
  109. }),
  110. form: {
  111. rules: [{ required: true, message: '问题类型必填' }],
  112. component: {
  113. placeholder: '请选择问题类型',
  114. },
  115. helper: '选择问题的类型分类'
  116. },
  117. },
  118. difficulty: {
  119. title: '难度等级',
  120. search: { show: true },
  121. type: 'dict-select',
  122. column: {
  123. minWidth: 80,
  124. },
  125. dict: dict({
  126. data: [
  127. { value: 1, label: '初级' },
  128. { value: 2, label: '中级' },
  129. { value: 3, label: '高级' }
  130. ]
  131. }),
  132. form: {
  133. rules: [{ required: true, message: '难度等级必填' }],
  134. helper: '选择题目的难度级别'
  135. },
  136. },
  137. sequence_number: {
  138. title: '排序',
  139. search: { show: false },
  140. column: { show: true },
  141. form: { show: true },
  142. },
  143. digital_human_video_url: {
  144. title: '视频链接',
  145. search: { show: false },
  146. column: {
  147. show: true,
  148. width: 120,
  149. formatter: ({ row }: any) => {
  150. return row.digital_human_video_url ? '已上传' : '未上传';
  151. }
  152. },
  153. form: { show: false },
  154. },
  155. digital_human_video_subtitle: {
  156. title: '字幕',
  157. search: { show: false },
  158. column: {
  159. show: true,
  160. width: 120,
  161. formatter: ({ row }: any) => {
  162. return row.digital_human_video_subtitle ? '已上传' : '未上传';
  163. }
  164. },
  165. form: { show: false },
  166. },
  167. }
  168. }
  169. };
  170. };