columns.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
  3. *
  4. * Licensed under the GNU Affero General Public License, Version 3 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * https://www.gnu.org/licenses/agpl-3.0.html
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import { BasicColumn } from '@/components/Table';
  17. import { FormSchema } from '@/components/Form';
  18. import { h } from 'vue';
  19. import { NTag } from 'naive-ui';
  20. export const columns: BasicColumn[] = [
  21. {
  22. title: '文档名称',
  23. key: 'name',
  24. },
  25. {
  26. title: '文档内容/链接',
  27. key: 'content',
  28. },
  29. {
  30. title: '文档来源',
  31. key: 'sliceNum',
  32. width: 90,
  33. align: 'center',
  34. render(row) {
  35. return h(
  36. NTag,
  37. {
  38. size: 'small',
  39. type: row.type == 'UPLOAD' ? 'success' : 'info',
  40. },
  41. {
  42. default: () => (row.type == 'UPLOAD' ? '上传' : '录入'),
  43. }
  44. );
  45. },
  46. },
  47. {
  48. title: '切片数量',
  49. key: 'sliceNum',
  50. width: 90,
  51. align: 'center',
  52. },
  53. {
  54. title: '切片状态',
  55. key: 'status',
  56. width: 100,
  57. align: 'center',
  58. render(row) {
  59. return h(
  60. NTag,
  61. {
  62. size: 'small',
  63. type: row.sliceStatus == true ? 'success' : 'info',
  64. },
  65. {
  66. default: () => (row.sliceStatus == true ? '已训练' : '未训练'),
  67. }
  68. );
  69. },
  70. },
  71. {
  72. title: '文件大小',
  73. key: 'size',
  74. width: 100,
  75. align: 'center',
  76. render(rowData) {
  77. return (Number(rowData.size) / 1000000).toFixed(2) + ' MB';
  78. },
  79. },
  80. ];
  81. export const searchSchemas: FormSchema[] = [
  82. {
  83. field: 'name',
  84. component: 'NInput',
  85. label: '文档名称',
  86. componentProps: {
  87. placeholder: '请输入文档名称',
  88. },
  89. },
  90. ];
  91. export const formSchemas: FormSchema[] = [
  92. {
  93. field: 'id',
  94. label: 'ID',
  95. component: 'NInput',
  96. isHidden: true,
  97. },
  98. {
  99. field: 'name',
  100. component: 'NInput',
  101. label: '文档名称',
  102. componentProps: {
  103. placeholder: '请输入文档名称',
  104. },
  105. rules: [{ required: true, message: '请输入文档名称', trigger: ['blur'] }],
  106. },
  107. {
  108. field: 'content',
  109. component: 'NInput',
  110. label: '文档内容',
  111. componentProps: {
  112. placeholder: '请输入文档内容',
  113. type: 'textarea',
  114. autosize: {
  115. minRows: 8,
  116. maxRows: 12,
  117. },
  118. },
  119. },
  120. ];