Browse Source

fix: 知识库,工单bug fix commit

master
AaronWu 4 weeks ago
parent
commit
d4be0b8b83
  1. 4
      .env.development
  2. 109
      src/views/client/knowledgeBase/index.vue
  3. 25
      src/views/question/commom/tools.ts
  4. 10
      src/views/question/issue/index.vue
  5. 10
      src/views/question/knowledge/index.vue

4
.env.development

@ -9,8 +9,8 @@
# 只在开发模式中被载入 # 只在开发模式中被载入
# 网站前缀 # 网站前缀
VITE_BASE_API_URL = http://192.168.2.33:8089/server/
# VITE_BASE_API_URL = http://43.137.2.78:8085/server/
# VITE_BASE_API_URL = http://192.168.2.33:8089/server/
VITE_BASE_API_URL = http://43.137.2.78:8085/server/
# base api # base api
VITE_BASE_API = '/server/' VITE_BASE_API = '/server/'

109
src/views/client/knowledgeBase/index.vue

@ -48,6 +48,9 @@
> >
</div> </div>
</div> </div>
<div class="description" v-if="curRowDetail.description">
{{ curRowDetail.description }}
</div>
<div class="tags"> <div class="tags">
<template v-if="curRowDetail.tags"> <template v-if="curRowDetail.tags">
<a-tag v-for="tag in curRowDetail.tags.split(',')" :key="tag" color="blue"> <a-tag v-for="tag in curRowDetail.tags.split(',')" :key="tag" color="blue">
@ -58,6 +61,26 @@
</div> </div>
<div class="content-divider"></div> <div class="content-divider"></div>
<div class="content-body markdown-body" v-html="curRowDetail.solution"></div> <div class="content-body markdown-body" v-html="curRowDetail.solution"></div>
<!-- 添加附件展示区域 -->
<div class="attachments" v-if="curRowDetail.files && curRowDetail.files.length">
<div class="attachments-header">
<paper-clip-outlined />
<span>附件列表</span>
</div>
<div class="attachments-list">
<a-card
v-for="file in curRowDetail.files"
:key="file.id"
class="file-card"
@click="handleDownload(file)"
>
<template #cover>
<file-outlined class="file-icon" />
</template>
<a-card-meta :title="file.originalFilename" />
</a-card>
</div>
</div>
</div> </div>
</template> </template>
<template v-else> <template v-else>
@ -84,11 +107,16 @@
DeleteOutlined, DeleteOutlined,
ExportOutlined, ExportOutlined,
LeftOutlined, LeftOutlined,
PaperClipOutlined,
FileOutlined,
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import { fetchKnowledgeBaseList, findOneById, addReadCount } from '@/api/knowledgeBase'; import { fetchKnowledgeBaseList, findOneById, addReadCount } from '@/api/knowledgeBase';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useUserStore } from '@/store/modules/user'; import { useUserStore } from '@/store/modules/user';
//
const handleDownload = (file) => {
window.open(file.url, '_blank');
};
const userStore = useUserStore(); const userStore = useUserStore();
const isAdmin = userStore.userInfo.isAdmin; const isAdmin = userStore.userInfo.isAdmin;
@ -108,12 +136,20 @@
solution: string; solution: string;
createTime: string; createTime: string;
readCount: any; readCount: any;
description: string;
files: Array<{
id: string;
originalFilename: string;
url: string;
}>;
}>({ }>({
title: '', title: '',
tags: '', tags: '',
solution: '', solution: '',
createTime: '', createTime: '',
readCount: 0, readCount: 0,
description: '',
files: [],
}); });
const goBack = () => { const goBack = () => {
@ -184,6 +220,62 @@
border-radius: 8px; border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
.attachments {
margin-top: 32px;
padding-top: 24px;
border-top: 1px solid #e2e8f0;
.attachments-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 16px;
color: #1e293b;
font-size: 16px;
font-weight: 500;
.anticon {
color: #3b82f6;
}
}
.attachments-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 16px;
.file-card {
cursor: pointer;
transition: all 0.3s ease;
border-radius: 8px;
overflow: hidden;
&:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.file-icon {
font-size: 40px;
color: #3b82f6;
display: flex;
justify-content: center;
align-items: center;
padding: 24px 0;
background: #f8fafc;
}
:deep(.ant-card-meta-title) {
font-size: 14px;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
}
.card-title { .card-title {
display: flex; display: flex;
align-items: center; align-items: center;
@ -221,6 +313,16 @@
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
.content-header { .content-header {
.description {
margin: 16px 0;
padding: 12px 16px;
background: #f8fafc;
border-left: 4px solid #3b82f6;
border-radius: 0 8px 8px 0;
color: #475569;
font-size: 15px;
line-height: 1.6;
}
.header-main { .header-main {
margin-bottom: 16px; margin-bottom: 16px;
@ -329,10 +431,7 @@
:deep(blockquote) { :deep(blockquote) {
margin: 20px 0; margin: 20px 0;
padding: 16px 24px; padding: 16px 24px;
background: #f8fafc;
border-left: 4px solid #3b82f6;
border-radius: 0 8px 8px 0;
color: #475569;
font-style: italic; font-style: italic;
} }

25
src/views/question/commom/tools.ts

@ -6,6 +6,22 @@ const quillEditor = ref<InstanceType<typeof QuillEditor> | null>(null);
export const quillImageUploadCustom = (quill) => { export const quillImageUploadCustom = (quill) => {
quillEditor.value = quill; quillEditor.value = quill;
console.log('quillEditor.value: ', quillEditor.value);
const editor = quillEditor.value?.getEditor();
editor?.addEventListener('drop', function (event: any) {
event.preventDefault(); // 防止默认行为
event.stopPropagation();
// 获取拖拽的文件
var files = event.dataTransfer.files;
// 处理文件上传逻辑,比如调用接口上传附件
if (files.length > 0) {
// 自定义处理上传的逻辑
console.log('上传的文件:', files);
customUploadAjax(files[0]);
}
});
const toolbar = quillEditor.value?.getToolbar(); const toolbar = quillEditor.value?.getToolbar();
const formats = toolbar?.querySelectorAll('.ql-formats'); const formats = toolbar?.querySelectorAll('.ql-formats');
@ -38,9 +54,14 @@ const handleCustomImageUpload = () => {
input.onchange = async (e: any) => { input.onchange = async (e: any) => {
const file = e?.target?.files[0]; const file = e?.target?.files[0];
if (file) { if (file) {
customUploadAjax(file);
}
};
};
const customUploadAjax = async (file) => {
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
// 发送文件到服务器进行上传 // 发送文件到服务器进行上传
try { try {
const res = await commonUpload(formData); const res = await commonUpload(formData);
@ -53,8 +74,6 @@ const handleCustomImageUpload = () => {
} catch (error) { } catch (error) {
console.error('文件上传失败', error); console.error('文件上传失败', error);
} }
}
};
}; };
// 插入图片到 Quill 编辑器 // 插入图片到 Quill 编辑器

10
src/views/question/issue/index.vue

@ -189,10 +189,10 @@
(newVal) => { (newVal) => {
if (newVal) { if (newVal) {
nextTick(() => { nextTick(() => {
if (time.value === 0) {
// if (time.value === 0) {
quillImageUploadCustom(quillEditor.value); quillImageUploadCustom(quillEditor.value);
time.value++;
}
// time.value++;
// }
}); });
} }
}, },
@ -223,6 +223,8 @@
}; };
}); });
values.fileIds = values.files.map((e) => e.id).join(','); values.fileIds = values.files.map((e) => e.id).join(',');
} else {
values.fileIds = '';
} }
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { if (values?.tags && Array.isArray(values.tags) && values.tags.length) {
@ -396,6 +398,8 @@
}; };
}); });
values.fileIds = values.files.map((e) => e.id).join(','); values.fileIds = values.files.map((e) => e.id).join(',');
} else {
values.fileIds = '';
} }
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { if (values?.tags && Array.isArray(values.tags) && values.tags.length) {

10
src/views/question/knowledge/index.vue

@ -156,10 +156,10 @@
(newVal) => { (newVal) => {
if (newVal) { if (newVal) {
nextTick(() => { nextTick(() => {
if (time.value === 0) {
// if (time.value === 0) {
quillImageUploadCustom(quillEditor.value); quillImageUploadCustom(quillEditor.value);
time.value++;
}
// time.value++;
// }
}); });
} }
}, },
@ -190,6 +190,8 @@
}; };
}); });
values.fileIds = values.files.map((e) => e.id).join(','); values.fileIds = values.files.map((e) => e.id).join(',');
} else {
values.fileIds = '';
} }
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { if (values?.tags && Array.isArray(values.tags) && values.tags.length) {
@ -291,6 +293,8 @@
}; };
}); });
values.fileIds = values.files.map((e) => e.id).join(','); values.fileIds = values.files.map((e) => e.id).join(',');
} else {
values.fileIds = '';
} }
await (record.id ? updateKnowledgeBase : createKnowledgeBase)(values); await (record.id ? updateKnowledgeBase : createKnowledgeBase)(values);

Loading…
Cancel
Save