<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-row>
|
</a-form>
|
</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 #name="{ record }">
|
<icon-file style="color: #0960bd;margin-right: 4px;" />
|
<span style="color: #0960bd;cursor: pointer" @click="fileClick">
|
{{record.name}}
|
</span>
|
</template>
|
<template #staue="{ record }">
|
<a-switch :model-value="record.staue"/>
|
</template>
|
<template #status="{ record }">
|
<div style="display: flex;align-items: center;">
|
<div style="width: 100px">
|
<a-popover title="Title">
|
<a-tag :color="'blue'" border>成功</a-tag>
|
<template #content>
|
<p>Here is the text content</p>
|
</template>
|
</a-popover>
|
<a-popover title="Title">
|
<a-tag :color="'gold'" border>取消</a-tag>
|
<template #content>
|
<p>Here is the text content</p>
|
</template>
|
</a-popover>
|
<a-popover title="Title">
|
<a-tag :color="'green'" border>未启动</a-tag>
|
<template #content>
|
<p>Here is the text content</p>
|
</template>
|
</a-popover>
|
</div>
|
<div>
|
<a-button type="text" size="large">
|
<template #icon>
|
<icon-sync />
|
</template>
|
</a-button>
|
<a-button type="text" size="large">
|
<template #icon>
|
<icon-sync style="color: green" />
|
</template>
|
</a-button>
|
<a-button type="text" size="large">
|
<template #icon>
|
<icon-play-circle style="color: green" />
|
</template>
|
</a-button>
|
</div>
|
</div>
|
</template>
|
<template #operations="{ record }" >
|
<tool/>
|
<edit/>
|
<a-popconfirm content="确定删除吗?" type="warning" @ok="deleteItem(record)">
|
<a-button v-permission="['admin']" type="text" size="small">
|
<template #icon>
|
<icon-delete />
|
</template>
|
</a-button>
|
</a-popconfirm>
|
<a-button type="text" size="small">
|
<template #icon>
|
<icon-download />
|
</template>
|
</a-button>
|
</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 v-if="detailsShow" class="details">
|
<div class="details-header">
|
<div style="display: flex;align-items: center">
|
<span><icon-arrow-left size="20px" style="cursor: pointer;color: #0960bd;margin: 10px" @click="goBackClick" /></span>
|
<icon-file style="color: #0960bd;margin-right: 4px;" />
|
<span style="">123.docx</span>
|
</div>
|
<div style="display: flex; align-items: center;">
|
<a-radio-group v-model="position" type="button" style="margin-right: 10px">
|
<a-radio value="top">全文</a-radio>
|
<a-radio value="right">省略</a-radio>
|
</a-radio-group>
|
<a-popover position="bottom">
|
<a-button type="outline" class="button" style="margin-right: 10px">批量 <icon-down style="margin-left: 4px" /></a-button>
|
<template #content>
|
<p>Here is the text content</p>
|
<p>Here is the text content</p>
|
</template>
|
</a-popover>
|
<a-button type="outline" class="button" style="margin-right: 10px">
|
<template #icon>
|
<icon-search />
|
</template>
|
</a-button>
|
<a-popover position="bottom">
|
<a-button type="outline" class="button" style="margin-right: 10px"><icon-sort /></a-button>
|
<template #content>
|
<p>Here is the text content</p>
|
<p>Here is the text content</p>
|
</template>
|
</a-popover>
|
<addDetails></addDetails>
|
</div>
|
</div>
|
<a-divider style="margin-top: 10px" />
|
</div>
|
</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 edit from '@/views/dmx/knowledgeLib/edit.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 tool from '@/views/dmx/knowledgeLib/tool.vue'
|
import addDetails from '@/views/dmx/knowledgeLib/addDetails.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 size = ref<SizeProps>('medium');
|
let visible = ref(false)
|
let detailsShow = 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: 'name',
|
slotName: 'name',
|
},
|
{
|
title: t('分快数'),
|
dataIndex: 'contentType',
|
},
|
{
|
title: t('上传时间'),
|
dataIndex: 'filterType',
|
},
|
{
|
title: t('创建人'),
|
dataIndex: 'count',
|
},
|
{
|
title: t('解析状态'),
|
dataIndex: 'createdTime',
|
},
|
{
|
title: t('启用'),
|
dataIndex: 'staue',
|
slotName: 'staue',
|
},
|
{
|
title: t('解析状态'),
|
dataIndex: 'status',
|
slotName: 'status',
|
},
|
{
|
title: t('操作'),
|
dataIndex: 'operations',
|
slotName: 'operations',
|
width: 150,
|
minWidth: 100,
|
},
|
]);
|
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, '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 fileClick = ()=>{
|
detailsShow.value = true
|
|
}
|
|
const goBackClick = ()=>{
|
detailsShow.value = false
|
|
}
|
|
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{
|
position: relative;
|
//background: #626aea;
|
margin-left: 20px;
|
width: calc(100% - 200px);
|
height: calc(100% - 5rem);
|
.rt-container-main{
|
height: 76vh;
|
}
|
.details{
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
background: #ffffff;
|
.details-header{
|
display: flex;
|
justify-content: space-between;
|
margin-top: 10px;
|
padding-right: 20px;
|
}
|
}
|
}
|
}
|
}
|
: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>
|