columns.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { BasicColumn } from '@/components/Table';
  2. import { FormSchema } from '@/components/Form';
  3. import { h } from 'vue';
  4. import { NButton } from 'naive-ui';
  5. import router from '@/router';
  6. import { formatToDate } from '@/utils/dateUtil';
  7. export const columns: BasicColumn[] = [
  8. {
  9. title: '知识库名称',
  10. key: 'name',
  11. align: 'center',
  12. width: 300,
  13. render(row: any) {
  14. return h(
  15. NButton,
  16. {
  17. text: true,
  18. tag: 'a',
  19. type: 'primary',
  20. onClick: () => {
  21. router.push({ name: 'knowledge_info', params: { id: row.id } });
  22. },
  23. },
  24. {
  25. default: () => row.name,
  26. }
  27. );
  28. },
  29. },
  30. {
  31. title: '知识库描述',
  32. key: 'des',
  33. align: 'center',
  34. },
  35. {
  36. title: '创建时间',
  37. key: 'createTime',
  38. align: 'center',
  39. width: 120,
  40. render(row: any) {
  41. return h('span', {}, formatToDate(new Date(Number(row.createTime))));
  42. },
  43. },
  44. ];
  45. export const searchSchemas: FormSchema[] = [
  46. {
  47. field: 'name',
  48. component: 'NInput',
  49. label: '知识库名称',
  50. componentProps: {
  51. placeholder: '请输入知识库名称',
  52. },
  53. },
  54. ];
  55. export const formSchemas: FormSchema[] = [
  56. {
  57. field: 'id',
  58. label: 'ID',
  59. component: 'NInput',
  60. isHidden: true,
  61. },
  62. {
  63. field: 'name',
  64. component: 'NInput',
  65. label: '知识库名称',
  66. componentProps: {
  67. placeholder: '请输入知识库名称',
  68. },
  69. rules: [{ required: true, message: '请输入知识库名称', trigger: ['blur'] }],
  70. },
  71. {
  72. field: 'isStruct',
  73. component: 'NRadioGroup',
  74. label: '结构化文档',
  75. labelMessage: '是否填充的结构化文档数据',
  76. defaultValue: false,
  77. componentProps: {
  78. options: [
  79. {
  80. label: '非结构化数据',
  81. value: false,
  82. },
  83. {
  84. label: '是结构化数据',
  85. value: true,
  86. },
  87. ],
  88. },
  89. },
  90. {
  91. field: 'des',
  92. component: 'NInput',
  93. label: '知识库描述',
  94. componentProps: {
  95. placeholder: '请输入知识库描述',
  96. type: 'textarea',
  97. autosize: {
  98. minRows: 5,
  99. maxRows: 8,
  100. },
  101. },
  102. },
  103. ];