123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <template>
- <div class="auxiliary-knowledge-lexicon-container layout-pd">
- <el-card shadow="never">
- <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent>
- <el-form-item label="关键词" prop="Tag">
- <el-input v-model="state.queryParams.Tag" placeholder="请输入关键词" clearable @keyup.enter="handleQuery" class="keyword-input" />
- </el-form-item>
- <el-form-item label="分类" prop="Classify">
- <el-select v-model="state.queryParams.Classify" placeholder="请选择分类" @change="handleQuery">
- <el-option v-for="item in knowledgeWordClassify" :value="item.dicDataValue" :key="item.dicDataValue" :label="item.dicDataName" />
- </el-select>
- </el-form-item>
- <el-form-item label="近义词" prop="Synonym">
- <el-input v-model="state.queryParams.Synonym" placeholder="请输入近义词" clearable @keyup.enter="handleQuery" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
- <el-button @click="resetQuery(ruleFormRef)" class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
- </el-form-item>
- </el-form>
- </el-card>
- <el-card shadow="never">
- <ProTable
- ref="proTableRef"
- :columns="columns"
- :data="state.tableData"
- @updateTable="queryList"
- :loading="state.loading"
- :total="state.total"
- v-model:page-index="state.queryParams.PageIndex"
- v-model:page-size="state.queryParams.PageSize"
- >
- <!-- 表格 header 按钮 -->
- <template #tableHeader="scope">
- <el-button type="primary" @click="addParameter" v-auth="'auxiliary:knowledgeLexicon:add'">
- <SvgIcon name="ele-Plus" class="mr5" />新增
- </el-button>
- <el-button type="primary" @click="businessTagRemove" v-auth="'auxiliary:knowledgeLexicon:delete'" :disabled="!scope.isSelected">
- <SvgIcon name="ele-Delete" class="mr5" />删除
- </el-button>
- </template>
- <!-- 表格操作 -->
- <template #operation="{ row }">
- <el-button link type="primary" @click="updateLexicon(row)" v-auth="'auxiliary:knowledgeLexicon:edit'" title="编辑知识库词库">
- 编辑
- </el-button>
- </template>
- </ProTable>
- </el-card>
- <!-- 新增知识库词库 -->
- <knowledge-lexicon-add ref="knowledgeLexiconAddRef" @updateList="queryList" :knowledgeWordClassify="knowledgeWordClassify" />
- <!-- 编辑知识库词库 -->
- <knowledge-lexicon-edit ref="knowledgeLexiconEditRef" @updateList="queryList" :knowledgeWordClassify="knowledgeWordClassify" />
- </div>
- </template>
- <script lang="tsx" setup name="auxiliaryKnowledgeLexicon">
- import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
- import { ElButton, ElMessage, ElMessageBox, FormInstance } from 'element-plus';
- import { formatDate } from '@/utils/formatTime';
- import { knowledgeLexiconDelete, knowledgeLexiconList, orderKnowledgeBaseData } from '@/api/auxiliary/knowledgeLexicon';
- // 引入组件
- const KnowledgeLexiconAdd = defineAsyncComponent(() => import('@/views/auxiliary/knowledgeLexicon/components/Knowledge-lexicon-add.vue')); // 新增知识库词库
- const KnowledgeLexiconEdit = defineAsyncComponent(() => import('@/views/auxiliary/knowledgeLexicon/components/Knowledge-lexicon-edit.vue')); // 编辑知识库词库
- const proTableRef = ref<RefType>(); // 表格ref
- // 表格配置项
- const columns = ref<any[]>([
- { type: 'selection', fixed: 'left', width: 55 },
- { prop: 'classify', label: '词性分类', showOverflowTooltip: true },
- { prop: 'tag', label: '关键词', width: 130 },
- { prop: 'synonym', label: '同义词', width: 130 },
- {
- prop: 'isEnable',
- label: '是否启用',
- render: (scope: any) => {
- return scope.row.isEnable === 1 ? '启用' : '禁用';
- },
- },
- { prop: 'creatorName', label: '创建人', showOverflowTooltip: true },
- {
- prop: 'creationTime',
- label: '创建时间',
- width: 170,
- render: (scope: any) => {
- return formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS');
- },
- },
- { prop: 'lastModificationName', label: '更新人', showOverflowTooltip: true },
- {
- prop: 'lastModificationTime',
- label: '更新时间',
- width: 170,
- render: (scope: any) => {
- return formatDate(scope.row.lastModificationTime, 'YYYY-mm-dd HH:MM:SS');
- },
- },
- { prop: 'operation', label: '操作', fixed: 'right', width: 100, align: 'center' },
- ]);
- // 定义变量内容
- const state = reactive<any>({
- loading: false, // 加载状态
- queryParams: {
- // 查询参数
- PageIndex: 1,
- PageSize: 10,
- Tag: null, // 标签
- Classify: null, // 标签类型
- Synonym: null, // 近义词
- },
- total: 0, // 总条数
- tableData: [], // 表格数据
- });
- const ruleFormRef = ref<any>(null); // 表单ref
- const knowledgeWordClassify = ref<EmptyArrayType>(); // 标签类型
- // 获取基础数据
- const getBaseData = async () => {
- try {
- const res = await orderKnowledgeBaseData();
- knowledgeWordClassify.value = res.result?.knowledgeWordClassify ?? [];
- } catch (error) {
- console.log(error);
- }
- };
- /** 搜索按钮操作 */
- const handleQuery = () => {
- state.queryParams.PageIndex = 1;
- queryList();
- };
- // 获取列表
- const queryList = () => {
- state.loading = true;
- knowledgeLexiconList(state.queryParams)
- .then((res) => {
- state.loading = false;
- state.tableData = res.result.items ?? [];
- state.total = res.result.total ?? 0;
- })
- .finally(() => {
- state.loading = false;
- });
- };
- // 重置表单
- const resetQuery = (formEl: FormInstance | undefined) => {
- if (!formEl) return;
- formEl.resetFields();
- queryList();
- };
- // 新增词库
- const knowledgeLexiconAddRef = ref<RefType>();
- const addParameter = () => {
- knowledgeLexiconAddRef.value.openDialog();
- };
- // 编辑知识库词库
- const knowledgeLexiconEditRef = ref<RefType>();
- const updateLexicon = (row: any) => {
- knowledgeLexiconEditRef.value.openDialog(row.id);
- };
- // 删除词库
- const businessTagRemove = () => {
- const ids = proTableRef.value.selectedList.map((item: any) => item.id);
- const names = proTableRef.value.selectedList.map((item: any) => item.tag);
- ElMessageBox.confirm(`您确定要删除:【${names}】,是否继续?`, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- draggable: true,
- cancelButtonClass: 'default-button',
- autofocus: false,
- })
- .then(() => {
- knowledgeLexiconDelete({ ids }).then(() => {
- ElMessage.success('操作成功');
- queryList();
- });
- })
- .catch(() => {});
- };
- // 页面加载时
- onMounted(() => {
- getBaseData();
- queryList();
- });
- </script>
|