|
@@ -11,7 +11,12 @@
|
|
|
<div class="c_top adfacjb">
|
|
|
<div class="ct_l adfac">
|
|
|
<p>文件</p>
|
|
|
- <el-input placeholder="搜索" suffix-icon="el-icon-search" v-model="queryParams.filename"></el-input>
|
|
|
+ <el-input placeholder="搜索" suffix-icon="el-icon-search" v-model="queryParams.fileName" style="width: 300px;" @keyup.enter.native="getList"></el-input>
|
|
|
+ <el-select v-model="queryParams.status" placeholder="状态" style="width: 200px;margin-left: 20px;" @keyup.enter.native="getList">
|
|
|
+ <el-option label="解析失败" :value="-1"></el-option>
|
|
|
+ <el-option label="解析中" :value="0"></el-option>
|
|
|
+ <el-option label="解析完成" :value="1"></el-option>
|
|
|
+ </el-select>
|
|
|
</div>
|
|
|
<div class="ct_r">
|
|
|
<el-button type="primary" icon="el-icon-plus" @click="handleAddFile">添加文件</el-button>
|
|
@@ -24,18 +29,21 @@
|
|
|
{{ scope.$index + 1 }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="文件名称" prop="aaa"></el-table-column>
|
|
|
- <el-table-column label="字符数" prop="bbb"></el-table-column>
|
|
|
- <el-table-column label="上传时间" prop="ccc"></el-table-column>
|
|
|
+ <el-table-column label="文件名称" prop="fileName"></el-table-column>
|
|
|
+ <el-table-column label="文件格式" prop="fileFormat"></el-table-column>
|
|
|
+ <!-- <el-table-column label="字符数" prop="bbb"></el-table-column> -->
|
|
|
+ <el-table-column label="上传时间" prop="createDate"></el-table-column>
|
|
|
<el-table-column label="状态" prop="ddd">
|
|
|
<template #default="scope">
|
|
|
- <el-switch v-model="value" active-color="#833478" inactive-color="#833478" active-text="可用" inactive-text="已禁用"></el-switch>
|
|
|
+ <div class="sdiv adfac">
|
|
|
+ <div class="sdian" :class="{'jxsb':scope.row.status===-1,'jxz':scope.row.status===0,'jxwc':scope.row.status===1}"></div>
|
|
|
+ <div class="stext">{{ statuscfg[scope.row.status]||'' }}</div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="200">
|
|
|
+ <el-table-column label="操作" width="100">
|
|
|
<template #default="scope">
|
|
|
- <el-button link type="text" size="mini" @click="handleSetName(scope.row)">重命名</el-button>
|
|
|
- <el-button link type="text" size="mini" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
+ <el-button link type="text" size="mini" @click="handleDelete(scope.row)" v-hasPermi="['core:knowledgedata:delete']">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -66,8 +74,11 @@
|
|
|
<el-upload
|
|
|
class="upload-demo"
|
|
|
drag
|
|
|
- action=""
|
|
|
- multiple>
|
|
|
+ :action="uploadUrl"
|
|
|
+ :headers="uploadHeaders"
|
|
|
+ :on-success="uploadFileSuccess"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :limit="1">
|
|
|
<i class="el-icon-upload"></i>
|
|
|
<div class="el-upload__text">点击或拖拽文件上传</div>
|
|
|
<div class="el-upload__text" style="font-size: 12px;color: #C1C7D2;line-height: 20px;margin-top: 8px;">
|
|
@@ -76,50 +87,73 @@
|
|
|
</el-upload>
|
|
|
</div>
|
|
|
<div class="demo-drawer__footer" style="display: flex;justify-content: end;">
|
|
|
- <el-button :loading="buttonLoading" type="primary" @click="submitForm">确认</el-button>
|
|
|
+ <el-button :loading="buttonLoading" type="primary" @click="submitForm" v-hasPermi="['core:knowledgedata:save']">确认</el-button>
|
|
|
<el-button @click="cancel" style="margin-right: 5%;">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
- <el-dialog width="579px" :visible.sync="setShow" title="知识库设置" @close="cancel2">
|
|
|
- <el-form ref="setRef" :model="zskForm" :rules="zskRules" label-width="120px" style="width: 90%;margin: 0 auto;" label-position="top">
|
|
|
- <el-form-item label="知识库名称" prop="aaa">
|
|
|
- <el-input v-model="zskForm.aaa" placeholder="请输入知识库名称"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <div class="demo-drawer__footer" style="display: flex;justify-content: end;">
|
|
|
- <el-button :loading="buttonLoading2" type="primary" @click="submitForm2">保存</el-button>
|
|
|
- <el-button @click="cancel2" style="margin-right: 5%;">取 消</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="">
|
|
|
- import { ref, getCurrentInstance, onMounted } from 'vue'
|
|
|
+ import Cookies from "js-cookie";
|
|
|
+ import { ref, getCurrentInstance, onMounted, nextTick } from 'vue'
|
|
|
+ import {getKnowledgeFileList,addKnowledgeFile,deleteKnowledgeFile} from '@/api/agent/index.js'
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
+ const uploadUrl = `${window.SITE_CONFIG["apiURL"]}/sys/oss/uploadFile`
|
|
|
+ const uploadHeaders = {token:Cookies.get("token")};
|
|
|
|
|
|
+ const statuscfg = {
|
|
|
+ '-1':'解析失败',
|
|
|
+ '0':'解析中',
|
|
|
+ '1':'解析完成'
|
|
|
+ }
|
|
|
const title = ref('')
|
|
|
const list = ref([])
|
|
|
const show = ref(false)
|
|
|
const buttonLoading = ref(false)
|
|
|
const queryParams = ref({
|
|
|
+ baseId:'',
|
|
|
page: 1,
|
|
|
limit: 10,
|
|
|
- filename:''
|
|
|
+ fileName:'',
|
|
|
+ status:''
|
|
|
})
|
|
|
const total = ref(0)
|
|
|
const loading = ref(false)
|
|
|
- const setShow = ref(false)
|
|
|
- const buttonLoading2 = ref(false)
|
|
|
- const setRef = ref(null)
|
|
|
- const zskForm = ref({
|
|
|
- aaa: ''
|
|
|
- })
|
|
|
- const zskRules = ref({
|
|
|
- aaa: [
|
|
|
- { required: true, message: '请输入知识库名称', trigger: 'blur' }
|
|
|
- ]
|
|
|
+ const fileDto = ref({
|
|
|
+ baseId:'',
|
|
|
+ fileData:'',
|
|
|
+ fileFormat:'',
|
|
|
+ fileName:''
|
|
|
})
|
|
|
+
|
|
|
+ const uploadFileSuccess = e =>{
|
|
|
+ fileDto.value.fileData = e.data;
|
|
|
+ proxy?.$modal.msgSuccess('上传成功');
|
|
|
+ }
|
|
|
+ const beforeAvatarUpload = (e) => {
|
|
|
+ let name = e.name.split('.')[0];
|
|
|
+ let type = e.name.split('.')[e.name.split('.').length-1];
|
|
|
+ let isTxt = e.type === 'text/plain';
|
|
|
+ let isPdf = e.type === 'application/pdf';
|
|
|
+ let isHtml = e.type === 'text/html';
|
|
|
+ let isExcel = e.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
|
+ let isDocx = e.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
|
+ if((type.toLowerCase() === 'xlsx' || type.toLowerCase() === 'xls' && isExcel)
|
|
|
+ || (type.toLowerCase() === 'docx' && isDocx)
|
|
|
+ || (type.toLowerCase() === 'txt' && isTxt)
|
|
|
+ || (type.toLowerCase() === 'pdf' && isPdf)
|
|
|
+ || (type.toLowerCase() === 'html' && isHtml)
|
|
|
+ && e.size <= 1024*1024*15){
|
|
|
+ fileDto.value.fileName = name;
|
|
|
+ fileDto.value.fileFormat = type;
|
|
|
+ }else{
|
|
|
+ proxy?.$modal.msgError('请上传txt、pdf、html、xlsx、xls或docx格式的文件!且文件大小不超过15MB!');
|
|
|
+ fileDto.value.fileName = '';
|
|
|
+ fileDto.value.fileFormat = '';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const handleBack = () => {
|
|
|
proxy.$router.go(-1)
|
|
@@ -135,19 +169,22 @@
|
|
|
|
|
|
const submitForm = () => {
|
|
|
buttonLoading.value = true;
|
|
|
- setTimeout(() => {
|
|
|
+ addKnowledgeFile(fileDto.value).then((res) => {
|
|
|
+ if(res.code!==0) return proxy?.$modal.msgError(res.msg);
|
|
|
+ proxy?.$modal.msgSuccess("上传成功");
|
|
|
show.value = false;
|
|
|
buttonLoading.value = false;
|
|
|
- list.value = [...list.value, {id: 1}]
|
|
|
- }, 2000)
|
|
|
+ getList();
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const getList = () => {
|
|
|
loading.value = true;
|
|
|
- setTimeout(() => {
|
|
|
- total.value = list.value.length
|
|
|
+ getKnowledgeFileList(queryParams.value).then((res) => {
|
|
|
loading.value = false;
|
|
|
- }, 1000)
|
|
|
+ list.value = res.data || [];
|
|
|
+ total.value = res.data.total;
|
|
|
+ })
|
|
|
}
|
|
|
const handleSizeChange = (val) => {
|
|
|
queryParams.value.limit = val;
|
|
@@ -159,42 +196,21 @@
|
|
|
getList()
|
|
|
}
|
|
|
|
|
|
- const handleSetName = (item) => {
|
|
|
- setShow.value = true;
|
|
|
- }
|
|
|
async function handleDelete(row) {
|
|
|
- await proxy?.$modal.confirm('确认删除文件【' + row.realName + '】吗?').finally(() => loading.value = false);
|
|
|
- // let res = await deleteCoach([row.id]);
|
|
|
- // if (res.code === 0) proxy?.$modal.msgSuccess("删除成功");
|
|
|
- // else return proxy?.$modal.msgError(res.msg);
|
|
|
- // await getList();
|
|
|
- }
|
|
|
-
|
|
|
- const submitForm2 = () => {
|
|
|
- proxy.$refs.setRef.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- buttonLoading2.value = true;
|
|
|
- setTimeout(() => {
|
|
|
- setShow.value = false;
|
|
|
- buttonLoading2.value = false;
|
|
|
- }, 2000)
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- const cancel2 = () => {
|
|
|
- setShow.value = false;
|
|
|
- zskForm.value = {
|
|
|
- aaa: ''
|
|
|
- }
|
|
|
- proxy.$refs.setRef.resetFields();
|
|
|
+ await proxy?.$modal.confirm('确认删除文件【' + row.fileName + '】吗?').finally(() => loading.value = false);
|
|
|
+ let res = await deleteKnowledgeFile([row.id]);
|
|
|
+ if (res.code === 0) proxy?.$modal.msgSuccess("删除成功");
|
|
|
+ else return proxy?.$modal.msgError(res.msg);
|
|
|
+ await getList();
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
title.value = proxy.$route.query.title;
|
|
|
- getList()
|
|
|
+ queryParams.value.baseId = proxy.$route.query.id;
|
|
|
+ fileDto.value.baseId = proxy.$route.query.id;
|
|
|
+ nextTick(() => {
|
|
|
+ getList()
|
|
|
+ })
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -278,6 +294,31 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .sdiv{
|
|
|
+ .sdian{
|
|
|
+ width: 8px;
|
|
|
+ height: 8px;
|
|
|
+ border-radius: 50%;
|
|
|
+ &.jxsb{
|
|
|
+ background: rgb(196, 33, 33);
|
|
|
+ }
|
|
|
+ &.jxz{
|
|
|
+ background: #FFd750;
|
|
|
+ }
|
|
|
+ &.jxwc{
|
|
|
+ background: #22C55D;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .stext{
|
|
|
+ font-family: PingFangSC, PingFang SC;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #393939;
|
|
|
+ line-height: 20px;
|
|
|
+ margin-left: 6px;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.cs_upload{
|