| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632 |
- <template>
- <div class="container">
- <Breadcrumb :items="['大模型', '知识库管理']" />
- <div class="main-container">
- <div class="lf-container">
- <div class="lf-container-top">
- <a-input-search
- :placeholder="$t('cardList.searchInput.placeholder')"
- style="width: 130px;"
- />
- <addKnow></addKnow>
- </div>
- <div class="lf-container-down">
- <div class="tabs">
- <div
- class="tab"
- v-for="(tab, index) in tabs"
- :key="index"
- @click="selectTab(index)"
- :class="{ 'active': selectedTab === index }"
- >
- {{ tab }}
- </div>
- </div>
- </div>
- </div>
- <div class="rt-container">
- <a-tabs default-active-key="1">
- <a-tab-pane key="1" title="数据集">
- <div class="rt-container-main">
- <a-card ref="account" class="general-card" :title="$t('')" style="padding-top: 20px">
- <a-row>
- <a-col :flex="1" :span="12">
- <a-form
- :model="formModel"
- :label-col-props="{ span: 6 }"
- :wrapper-col-props="{ span: 18 }"
- label-align="left"
- >
- <a-row :gutter="16">
- <a-col :span="24" style="margin-bottom: 10px;display: flex;justify-content: right">
- <a-input-search
- :placeholder="$t('cardList.searchInput.placeholder')"
- style="width: 200px;margin-right: 10px"
- />
- <!-- 新建-->
- <add />
- </a-col>
- <!-- <a-col :span="8">-->
- <!-- <a-form-item field="name" :label="$t('searchTable.form.name')">-->
- <!-- <a-input-->
- <!-- v-model="formModel.name"-->
- <!-- :placeholder="$t('searchTable.form.name.placeholder')"-->
- <!-- />-->
- <!-- </a-form-item>-->
- <!-- </a-col>-->
- <!-- <a-col :span="8">-->
- <!-- <a-form-item-->
- <!-- field="contentType"-->
- <!-- :label="$t('searchTable.form.contentType')"-->
- <!-- >-->
- <!-- <a-select-->
- <!-- v-model="formModel.contentType"-->
- <!-- :options="contentTypeOptions"-->
- <!-- :placeholder="$t('searchTable.form.selectDefault')"-->
- <!-- />-->
- <!-- </a-form-item>-->
- <!-- </a-col>-->
- <!-- <a-col :span="8">-->
- <!-- <a-form-item-->
- <!-- field="filterType"-->
- <!-- :label="$t('searchTable.form.filterType')"-->
- <!-- >-->
- <!-- <a-select-->
- <!-- v-model="formModel.filterType"-->
- <!-- :options="filterTypeOptions"-->
- <!-- :placeholder="$t('searchTable.form.selectDefault')"-->
- <!-- />-->
- <!-- </a-form-item>-->
- <!-- </a-col>-->
- <!-- <a-col :span="8">-->
- <!-- <a-form-item-->
- <!-- field="createdTime"-->
- <!-- :label="$t('searchTable.form.createdTime')"-->
- <!-- >-->
- <!-- <a-range-picker-->
- <!-- v-model="formModel.createdTime"-->
- <!-- style="width: 100%"-->
- <!-- />-->
- <!-- </a-form-item>-->
- <!-- </a-col>-->
- <!-- <a-col :span="8">-->
- <!-- <a-form-item-->
- <!-- field="status"-->
- <!-- :label="$t('searchTable.form.status')"-->
- <!-- >-->
- <!-- <a-select-->
- <!-- v-model="formModel.status"-->
- <!-- :options="statusOptions"-->
- <!-- :placeholder="$t('searchTable.form.selectDefault')"-->
- <!-- />-->
- <!-- </a-form-item>-->
- <!-- </a-col>-->
- </a-row>
- </a-form>
- </a-col>
- <!-- <a-divider style="height: 40px" direction="vertical" />-->
- <!-- <a-col :flex="'200px'" style="text-align: right">-->
- <!-- <a-button @click="reset" style="margin-right: 20px">-->
- <!-- <template #icon>-->
- <!-- <icon-refresh />-->
- <!-- </template>-->
- <!-- {{ $t('searchTable.form.reset') }}-->
- <!-- </a-button>-->
- <!-- <a-button type="primary" @click="search">-->
- <!-- <template #icon>-->
- <!-- <icon-search />-->
- <!-- </template>-->
- <!-- {{ $t('searchTable.form.search') }}-->
- <!-- </a-button>-->
- <!-- </a-col>-->
- </a-row>
- <a-divider style="margin-top: 0" />
- <a-row style="margin-bottom: 16px">
- <a-col :span="12">
- <a-space>
- <!-- <a-button type="primary" @click="handleClick">-->
- <!-- <template #icon>-->
- <!-- <icon-plus />-->
- <!-- </template>-->
- <!-- {{ $t('searchTable.operation.create') }}-->
- <!-- </a-button>-->
- <!-- <a-upload action="/">-->
- <!-- <template #upload-button>-->
- <!-- <a-button>-->
- <!-- {{ $t('searchTable.operation.import') }}-->
- <!-- </a-button>-->
- <!-- </template>-->
- <!-- </a-upload>-->
- </a-space>
- </a-col>
- <a-col
- :span="12"
- style="display: flex; align-items: center; justify-content: end"
- >
- <!-- <a-button>-->
- <!-- <template #icon>-->
- <!-- <icon-download />-->
- <!-- </template>-->
- <!-- {{ $t('searchTable.operation.download') }}-->
- <!-- </a-button>-->
- <a-tooltip :content="$t('searchTable.actions.refresh')">
- <div class="action-icon" @click="search"
- ><icon-refresh size="18"
- /></div>
- </a-tooltip>
- <a-dropdown @select="handleSelectDensity">
- <a-tooltip :content="$t('searchTable.actions.density')">
- <div class="action-icon"><icon-line-height size="18" /></div>
- </a-tooltip>
- <template #content>
- <a-doption
- v-for="item in densityList"
- :key="item.value"
- :value="item.value"
- :class="{ active: item.value === size }"
- >
- <span>{{ item.name }}</span>
- </a-doption>
- </template>
- </a-dropdown>
- <!-- <a-tooltip :content="$t('searchTable.actions.columnSetting')">-->
- <!-- <a-popover-->
- <!-- trigger="click"-->
- <!-- position="bl"-->
- <!-- @popup-visible-change="popupVisibleChange"-->
- <!-- >-->
- <!-- <div class="action-icon"><icon-settings size="18" /></div>-->
- <!-- <template #content>-->
- <!-- <div id="tableSetting">-->
- <!-- <div-->
- <!-- v-for="(item, index) in showColumns"-->
- <!-- :key="item.dataIndex"-->
- <!-- class="setting"-->
- <!-- >-->
- <!-- <div style="margin-right: 4px; cursor: move">-->
- <!-- <icon-drag-arrow />-->
- <!-- </div>-->
- <!-- <div>-->
- <!-- <a-checkbox-->
- <!-- v-model="item.checked"-->
- <!-- @change="-->
- <!-- handleChange($event, item as TableColumnData, index)-->
- <!-- "-->
- <!-- >-->
- <!-- </a-checkbox>-->
- <!-- </div>-->
- <!-- <div class="title">-->
- <!-- {{ item.title === '#' ? '序列号' : item.title }}-->
- <!-- </div>-->
- <!-- </div>-->
- <!-- </div>-->
- <!-- </template>-->
- <!-- </a-popover>-->
- <!-- </a-tooltip>-->
- </a-col>
- </a-row>
- <a-table
- row-key="id"
- :loading="loading"
- :pagination="pagination"
- :columns="cloneColumns"
- :data="renderData"
- :bordered="false"
- :size="size"
- @page-change="onPageChange"
- :scroll="{ y: 580 }"
- >
- <template #contentType="{ record }">
- <a-space>
- <a-avatar
- v-if="record.contentType === 'img'"
- :size="16"
- shape="square"
- >
- <img
- alt="avatar"
- src="//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/581b17753093199839f2e327e726b157.svg~tplv-49unhts6dw-image.image"
- />
- </a-avatar>
- <a-avatar
- v-else-if="record.contentType === 'horizontalVideo'"
- :size="16"
- shape="square"
- >
- <img
- alt="avatar"
- src="//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/77721e365eb2ab786c889682cbc721c1.svg~tplv-49unhts6dw-image.image"
- />
- </a-avatar>
- <a-avatar v-else :size="16" shape="square">
- <img
- alt="avatar"
- src="//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/ea8b09190046da0ea7e070d83c5d1731.svg~tplv-49unhts6dw-image.image"
- />
- </a-avatar>
- {{ $t(`searchTable.form.contentType.${record.contentType}`) }}
- </a-space>
- </template>
- <template #filterType="{ record }">
- {{ $t(`searchTable.form.filterType.${record.filterType}`) }}
- </template>
- <template #status="{ record }">
- <span v-if="record.status === 'offline'" class="circle"></span>
- <span v-else class="circle pass"></span>
- {{ $t(`searchTable.form.status.${record.status}`) }}
- </template>
- <template #operations="{ record }">
- <a-popconfirm content="确定删除吗?" type="warning" @ok="deleteItem(record)">
- <a-button v-permission="['admin']" type="text" size="small">
- {{ $t('删除') }}
- </a-button>
- </a-popconfirm>
- </template>
- </a-table>
- </a-card>
- </div>
- </a-tab-pane>
- <a-tab-pane key="2" title="测试">
- <div class="rt-container-main">
- <test ></test>
- </div>
- </a-tab-pane>
- <a-tab-pane key="3" title="配置">
- <div class="rt-container-main">
- <config ></config>
- </div>
- </a-tab-pane>
- </a-tabs>
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { computed, ref, reactive, watch, nextTick } from 'vue';
- import { useI18n } from 'vue-i18n';
- import useLoading from '@/hooks/loading';
- import { queryPolicyList, PolicyRecord, PolicyParams } from '@/api/list';
- import { Pagination } from '@/types/global';
- import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
- import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
- import cloneDeep from 'lodash/cloneDeep';
- import Sortable from 'sortablejs';
- import add from '@/views/dmx/knowledgeLib/add.vue'
- import addKnow from '@/views/dmx/knowledgeLib/addKnow.vue'
- import config from '@/views/dmx/knowledgeLib/config.vue'
- import test from '@/views/dmx/knowledgeLib/test.vue'
- import { deleteAccount } from "@/api/account";
- type SizeProps = 'mini' | 'small' | 'medium' | 'large';
- type Column = TableColumnData & { checked?: true };
- const account = ref(null)
- const generateFormModel = () => {
- return {
- number: '',
- name: '',
- contentType: '',
- filterType: '',
- createdTime: [],
- status: '',
- };
- };
- const { loading, setLoading } = useLoading(true);
- const { t } = useI18n();
- const renderData = ref<PolicyRecord[]>([]);
- const formModel = ref(generateFormModel());
- const cloneColumns = ref<Column[]>([]);
- const showColumns = ref<Column[]>([]);
- const edit = ref('add');
- const size = ref<SizeProps>('medium');
- let visible = ref(false)
- let selectedTab = ref(0)
- let tabs = reactive(['法律知识库', '政务知识库', '医学知识库', '其他知识库'])
- const selectTab = (index) => {
- selectedTab.value= index;
- }
- const basePagination: Pagination = {
- current: 1,
- pageSize: 20,
- };
- const pagination = reactive({
- ...basePagination,
- });
- const densityList = computed(() => [
- {
- name: t('searchTable.size.mini'),
- value: 'mini',
- },
- {
- name: t('searchTable.size.small'),
- value: 'small',
- },
- {
- name: t('searchTable.size.medium'),
- value: 'medium',
- },
- {
- name: t('searchTable.size.large'),
- value: 'large',
- },
- ]);
- const columns = computed<TableColumnData[]>(() => [
- // {
- // title: t('序号'),
- // dataIndex: 'index',
- // slotName: 'index',
- // },
- {
- title: t('名称'),
- dataIndex: 'name',
- },
- {
- title: t('分快数'),
- dataIndex: 'contentType',
- slotName: 'contentType',
- },
- {
- title: t('上传时间'),
- dataIndex: 'filterType',
- },
- {
- title: t('创建人'),
- dataIndex: 'count',
- },
- {
- title: t('解析状态'),
- dataIndex: 'createdTime',
- },
- {
- title: t('操作'),
- dataIndex: 'operations',
- slotName: 'operations',
- },
- ]);
- const contentTypeOptions = computed<SelectOptionData[]>(() => [
- {
- label: t('searchTable.form.contentType.img'),
- value: 'img',
- },
- {
- label: t('searchTable.form.contentType.horizontalVideo'),
- value: 'horizontalVideo',
- },
- {
- label: t('searchTable.form.contentType.verticalVideo'),
- value: 'verticalVideo',
- },
- ]);
- const filterTypeOptions = computed<SelectOptionData[]>(() => [
- {
- label: t('searchTable.form.filterType.artificial'),
- value: 'artificial',
- },
- {
- label: t('searchTable.form.filterType.rules'),
- value: 'rules',
- },
- ]);
- const statusOptions = computed<SelectOptionData[]>(() => [
- {
- label: t('searchTable.form.status.online'),
- value: 'online',
- },
- {
- label: t('searchTable.form.status.offline'),
- value: 'offline',
- },
- ]);
- const fetchData = async (
- params: PolicyParams = { current: 1, pageSize: 20 }
- ) => {
- setLoading(true);
- try {
- const { data } = await queryPolicyList(params);
- renderData.value = data.list;
- console.log(renderData);
- pagination.current = params.current;
- pagination.total = data.total;
- } catch (err) {
- // you can report use errorHandler or other
- } finally {
- setLoading(false);
- }
- };
- const search = () => {
- fetchData({
- ...basePagination,
- ...formModel.value,
- } as unknown as PolicyParams);
- };
- const handleClick = ()=>{
- visible.value = true;
- }
- const onPageChange = (current: number) => {
- fetchData({ ...basePagination, current });
- };
- fetchData();
- const reset = () => {
- formModel.value = generateFormModel();
- };
- const handleSelectDensity = (
- val: string | number | Record<string, any> | undefined,
- e: Event
- ) => {
- size.value = val as SizeProps;
- };
- const handleChange = (
- checked: boolean | (string | boolean | number)[],
- column: Column,
- index: number
- ) => {
- if (!checked) {
- cloneColumns.value = showColumns.value.filter(
- (item) => item.dataIndex !== column.dataIndex
- );
- } else {
- cloneColumns.value.splice(index, 0, column);
- }
- };
- const exchangeArray = <T extends Array<any>>(
- array: T,
- beforeIdx: number,
- newIdx: number,
- isDeep = false
- ): T => {
- const newArray = isDeep ? cloneDeep(array) : array;
- if (beforeIdx > -1 && newIdx > -1) {
- // 先替换后面的,然后拿到替换的结果替换前面的
- newArray.splice(
- beforeIdx,
- 1,
- newArray.splice(newIdx, 1, newArray[beforeIdx]).pop()
- );
- }
- return newArray;
- };
- const popupVisibleChange = (val: boolean) => {
- if (val) {
- nextTick(() => {
- const el = document.getElementById('tableSetting') as HTMLElement;
- const sortable = new Sortable(el, {
- onEnd(e: any) {
- const { oldIndex, newIndex } = e;
- exchangeArray(cloneColumns.value, oldIndex, newIndex);
- exchangeArray(showColumns.value, oldIndex, newIndex);
- },
- });
- });
- }
- };
- const deleteItem = async (row)=>{
- console.log(row);
- // let data = await deleteAccount({id: row.number})
- account.value.$messageSuccess('删除成功')
- //
- // if(data.code == 200){
- // this.$messageSuccess('删除成功')
- // }
- }
- watch(
- () => columns.value,
- (val) => {
- // alert(columns.value)
- cloneColumns.value = cloneDeep(val);
- cloneColumns.value.forEach((item, index) => {
- item.checked = true;
- });
- showColumns.value = cloneDeep(cloneColumns.value);
- },
- { deep: true, immediate: true }
- );
- </script>
- <script lang="ts">
- export default {
- name: 'SearchTable',
- methods: {
- }
- };
- </script>
- <style scoped lang="less">
- .container {
- padding: 0 20px 20px 20px;
- .main-container{
- display: flex;
- .lf-container{
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: space-evenly;
- background: #ffffff;
- width: 200px;
- .lf-container-top{
- display: flex;
- }
- .lf-container-down{
- display: flex;
- flex-direction: column;
- width: 90%;
- height: calc(100% - 5rem);
- border: 1px solid #eeeeee;
- overflow: auto;
- padding: 10px;
- .tabs .tab {
- cursor: pointer;
- box-sizing: border-box;
- margin: 10px 0;
- padding:0 10px;
- color: rgba(0, 0, 0, 0.88);
- font-size: 14px;
- height: 40px;
- line-height: 40px;
- list-style: none;
- position: relative;
- background: #ffffff;
- border: 1px solid #f0f0f0;
- border-radius: 8px;
- }
- .tabs .tab:hover {
- border: 1px solid #ffffff;
- background: #e8e8ea;
- box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
- }
- .tabs .tab.active {
- border: 1px solid #e8e8ea;
- background: #e8e8ea;
- cursor: pointer;
- }
- }
- }
- .rt-container{
- //background: #626aea;
- margin-left: 20px;
- width: calc(100% - 200px);
- height: calc(100% - 5rem);
- .rt-container-main{
- height: 76vh;
- }
- }
- }
- }
- :deep(.arco-table-th) {
- &:last-child {
- .arco-table-th-item-title {
- margin-left: 16px;
- }
- }
- }
- .action-icon {
- margin-left: 12px;
- cursor: pointer;
- }
- .active {
- color: #0960bd;
- background-color: #e3f4fc;
- }
- .setting {
- display: flex;
- align-items: center;
- width: 200px;
- .title {
- margin-left: 12px;
- cursor: pointer;
- }
- }
- </style>
|