index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="bm-main-box">
  3. <div class="flex items-center">
  4. <div class="bm-main-box-title">文档</div>
  5. </div>
  6. <CzrContent
  7. v-model:tableHead="state.query.tableHead"
  8. @handleReset="onReset"
  9. @handleSearch="onSearch"
  10. v-model:full="state.query.isFull"
  11. >
  12. <template #tableTitle>
  13. <div class="flex gap-[var(--czr-gap)]">
  14. <CzrButton type="add" title="添加文件"/>
  15. <CzrButton title="迁移" icon="move"/>
  16. <CzrButton title="归档" icon="cloud"/>
  17. <CzrButton title="删除" icon="czr_del"/>
  18. </div>
  19. </template>
  20. <template #buttons>
  21. <div class="flex items-center gap-[var(--czr-gap)]">
  22. <div class="__hover text-[0.88rem] text-[#576275] flex items-center gap-[0.3rem]" @click="state.query.form.isCreate = !state.query.form.isCreate">
  23. <SvgIcon name="czr_add1" size="14" :active="state.query.form.isCreate"/>我的创建
  24. </div>
  25. <div class="__hover text-[0.88rem] text-[#576275] flex items-center gap-[0.3rem]" @click="state.query.form.isStar = !state.query.form.isStar">
  26. <SvgIcon name="star" size="15" class="mb-[2px]" :active="state.query.form.isStar"/>我的收藏
  27. </div>
  28. <CzrForm class="bm-filter" label-width="0px" @handleEnter="onSearch">
  29. <CzrFormColumn
  30. width="6.68rem"
  31. class="__czr-table-form-column"
  32. :span="24"
  33. label-width="0px"
  34. v-model:param="state.query.form.group"
  35. link="select"
  36. :options="DictionaryStore.knowledgeGroups.list"
  37. placeholder="全部分组"
  38. />
  39. <CzrFormColumn
  40. width="6.68rem"
  41. class="__czr-table-form-column"
  42. :span="24"
  43. label-width="0px"
  44. v-model:param="state.query.form.tag"
  45. link="select"
  46. :options="DictionaryStore.knowledgeTags.list"
  47. placeholder="全部标签"
  48. />
  49. <CzrFormColumn
  50. width="15.63rem"
  51. class="__czr-table-form-column"
  52. :span="24"
  53. label-width="0px"
  54. v-model:param="state.text"
  55. placeholder="按名称搜索"
  56. :prefix-icon="Search"
  57. />
  58. </CzrForm>
  59. </div>
  60. </template>
  61. <template #table>
  62. <CzrTable
  63. v-loading="state.query.loading"
  64. ref="ref_cusTable"
  65. :data="state.query.result.data"
  66. :head="state.query.head"
  67. :total="state.query.result.total"
  68. :page="state.query.page.pageNum"
  69. :pageSize="state.query.page.pageSize"
  70. @handlePage="onPage"
  71. v-model:selected="state.query.selected"
  72. >
  73. <template #importAndExportType-column-value="{ scope }">
  74. <!-- <dict-tag :options="import_and_export_type" :value="scope.row.importAndExportType"/>-->
  75. </template>
  76. <template #caozuo-column-value="{ scope }">
  77. <div class="__czr-table-operations">
  78. <CzrButton type="table" title="重命名"/>
  79. <CzrButton type="table" title="迁移"/>
  80. <CzrButton type="table" title="归档"/>
  81. <CzrButton type="table-del"/>
  82. </div>
  83. </template>
  84. </CzrTable>
  85. </template>
  86. </CzrContent>
  87. </div>
  88. </template>
  89. <script setup lang="ts">
  90. import {getCurrentInstance, onMounted, reactive, ref, watch} from "vue";
  91. import { Search } from '@element-plus/icons-vue'
  92. import {debounce} from "lodash";
  93. import {useDialogStore, useDictionaryStore} from "@/stores";
  94. import {ElMessage} from "element-plus";
  95. const DialogStore = useDialogStore();
  96. const DictionaryStore = useDictionaryStore();
  97. const emits = defineEmits([])
  98. const props = defineProps({
  99. knowledge: <any>{}
  100. })
  101. const {proxy}: any = getCurrentInstance()
  102. const state: any = reactive({
  103. text: '',
  104. query: {
  105. loading: false,
  106. head: [
  107. {value: 'p1', label: '文件名称', show: true},
  108. {value: 'p1', label: '字符数', show: true},
  109. {value: 'p1', label: '状态', show: true},
  110. {value: 'p1', label: '召回次数', show: true},
  111. {value: 'p1', label: '启用/停用', show: true},
  112. {value: 'p1', label: '审核状态', show: true},
  113. {value: 'p1', label: '关联应用', show: true},
  114. {value: 'p1', label: '创建时间', show: true},
  115. {value: 'p1', label: '更新时间', show: true},
  116. {value: 'caozuo', label: '操作', show: true, width: 300, fixed: 'right', popover: false},
  117. ],
  118. page: {
  119. pageNum: 1,
  120. pageSize: 20
  121. },
  122. form: {},
  123. formReal: {},
  124. result: {
  125. total: 0,
  126. data: []
  127. },
  128. selected: []
  129. },
  130. detail: {
  131. show: false,
  132. transfer: {}
  133. },
  134. })
  135. const setText = debounce((v) => {
  136. state.query.form.name = v
  137. }, 1000)
  138. watch(() => state.text, (n) => {
  139. setText(n)
  140. })
  141. watch(() => state.query.form, (n) => {
  142. onSearch()
  143. }, {deep: true})
  144. const onPage = (pageNum, pageSize) => {
  145. state.query.page = {
  146. pageNum: pageNum,
  147. pageSize: pageSize,
  148. }
  149. const params = {
  150. pageNum: state.query.page.pageNum,
  151. pageSize: state.query.page.pageSize,
  152. }
  153. // 添加表单参数
  154. for (const [k, v] of Object.entries(state.query.formReal)) {
  155. if (proxy.$czrUtil.isValue(v)) {
  156. params[k] = v
  157. }
  158. }
  159. state.query.loading = true
  160. setTimeout(() => {
  161. state.query.result.total = 100
  162. const arr: any = []
  163. for (let i = 1; i <= params.pageSize; i++) {
  164. const n = (params.pageNum - 1) * params.pageSize + i
  165. arr.push({
  166. p1: '部门知识库-部门知识库-部门知识库-' + n,
  167. p2: '王一鸣',
  168. p3: '只是一个政务服务事项办事指南',
  169. p4: n,
  170. p5: '2980k',
  171. p6: n % 4,
  172. p7: n % 2,
  173. tags: n % 2 ? '1,2,3,41,2,3,41,2,3,41,2,3,41,2,3,4' : ''
  174. })
  175. }
  176. state.query.result.data = arr
  177. state.query.loading = false
  178. }, 1000)
  179. // state.query.loading = true
  180. // listRuleLogisticsDataSubscribeInfo(params).then(res => {
  181. // if (res.code == 200) {
  182. // state.query.result.total = res.total
  183. // state.query.result.data = res.rows
  184. // state.query.loading = false
  185. // } else {
  186. // ElMessage.error(res.msg)
  187. // }
  188. // }).catch(() => {
  189. // state.query.loading = false
  190. // })
  191. }
  192. const onSearch = () => {
  193. state.query.formReal = JSON.parse(JSON.stringify(state.query.form))
  194. onPage(1, state.query.page.pageSize)
  195. }
  196. const onReset = () => {
  197. state.query.page = {
  198. pageNum: 1,
  199. pageSize: 20
  200. }
  201. state.query.form = {}
  202. onSearch()
  203. }
  204. const onAdd = () => {
  205. state.detail.transfer = {
  206. mode: 'add'
  207. }
  208. state.detail.show = true
  209. }
  210. const onEdit = (row) => {
  211. state.detail.transfer = {
  212. mode: 'edit',
  213. id: row.id
  214. }
  215. state.detail.show = true
  216. }
  217. const onDel = (row: any) => {
  218. DialogStore.confirm({
  219. title: '删除确认',
  220. content: `${row.p6}个应用正在使用该大模型,请确认是否删除`,
  221. onSubmit: () => {
  222. ElMessage.success('删除成功!')
  223. }
  224. })
  225. }
  226. const onChangeTag = (row, tags) => {
  227. row.tags = tags
  228. // onSearch()
  229. }
  230. const initDictionary = () => {
  231. DictionaryStore.initKnowledgeGroups()
  232. }
  233. onMounted(() => {
  234. console.log(props.knowledge)
  235. initDictionary()
  236. onReset()
  237. })
  238. </script>
  239. <style lang="scss" scoped>
  240. .knowledge {
  241. width: 100%;
  242. height: 11.81rem;
  243. background-image: url("@/assets/images/knowledge-item-bg.png");
  244. background-repeat: no-repeat;
  245. background-size: 100% 100%;
  246. padding: 1rem 1.5rem;
  247. }
  248. </style>