feat:知识管理页面接口对接完成

This commit is contained in:
李想 2025-03-19 17:21:23 +08:00
parent 29ce087f99
commit 2fb5713f65
7 changed files with 116 additions and 69 deletions

View File

@ -0,0 +1,15 @@
import request from '@/utils/axios';
/**
* @Title: 上传图片
*/
export function CommonUpload(data, params) {
return request({
url: `/upload`,
method: 'POST',
apisType: 'upload',
uploadType: 'multipart/form-data',
data,
params,
});
}

View File

@ -7,7 +7,7 @@
--> -->
<template> <template>
<section class="rich-editor"> <section class="rich-editor">
<Toolbar class="rich-editor-toolbar" :editor="refEditor" :default-config="options.toolbarConfig" :mode="mode" /> <Toolbar v-show="toolbarShow" class="rich-editor-toolbar" :editor="refEditor" :default-config="options.toolbarConfig" :mode="mode" />
<Editor <Editor
v-model="valueHtml" v-model="valueHtml"
class="rich-editor-toolbar" class="rich-editor-toolbar"
@ -29,6 +29,7 @@ import { shallowRef, ref, computed, nextTick, onBeforeUnmount, onMounted } from
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'; import { Editor, Toolbar } from '@wangeditor/editor-for-vue';
import { isEmpty } from '@/utils'; import { isEmpty } from '@/utils';
// import { CommonUpload, UploadImageFromEditor } from '@/apis/common'; // import { CommonUpload, UploadImageFromEditor } from '@/apis/common';
import { imageUpload } from './upFile';
const { VITE_APP_OSS_URL } = import.meta.env; const { VITE_APP_OSS_URL } = import.meta.env;
@ -63,29 +64,17 @@ export default {
maxFileSize: 10 * 1024 * 1024, //10M maxFileSize: 10 * 1024 * 1024, //10M
maxNumberOfFiles: 10, maxNumberOfFiles: 10,
allowedFileTypes: ['image/*'], allowedFileTypes: ['image/*'],
async customUpload(file, insertFn) { customUpload: imageUpload,
// if (isEmpty(file.name)) return;
// const data = {
// key: file.name,
// size: file.size,
// contentType: file.type,
// expiresInSecond: 3600,
// };
// const res = await UploadImageFromEditor(data);
// if (res.code === 200) {
// await CommonUpload({
// url: res.data.url,
// file,
// });
// insertFn(VITE_APP_OSS_URL + res.data.key, file.name, res.data.key);
// }
},
}, },
}, },
}, },
}; };
}, },
}, },
toolbarShow: {
type: Boolean,
default: true,
},
}, },
emits: ['focus', 'blur', 'change', 'update:value'], emits: ['focus', 'blur', 'change', 'update:value'],
setup(props, cxt) { setup(props, cxt) {

View File

@ -0,0 +1,10 @@
import { CommonUpload } from '../../apis/common';
export async function imageUpload(file, insertFn) {
let formData = new FormData();
formData.append('file', file);
let res = await CommonUpload(formData);
if (res.code == 200) {
insertFn(res.data.url, file.name, res.data.key);
}
}

View File

@ -1,6 +1,6 @@
import * as redBlackApi from './redAndBlank'; import * as redBlackApi from './redAndBlank';
import * as materialApi from './material'; import * as materialApi from './material';
import * as knowledgeApi from './common'; import * as knowledgeApi from './knowledge';
export default { export default {
...materialApi, ...materialApi,

View File

@ -1,7 +1,14 @@
import request from '@/utils/axios'; import request from '@/utils/axios';
function getQuestionList(params) { export function getQuestionList(params) {
return request('/knowledge/page', { return request('/input/knowledge/page', {
params, params,
}); });
} }
export function getQuestionReply(data) {
return request('/input/knowledge/reply', {
data,
method: 'PUT',
});
}

View File

@ -2,8 +2,7 @@ import request from '@/utils/axios';
/* 获取物资类型 */ /* 获取物资类型 */
export function getMaterailTypes(params) { export function getMaterailTypes(params) {
return request({ return request('/input/common/getList', {
url: '/input/common/getList',
params, params,
}); });
} }

View File

@ -7,6 +7,7 @@
:data="data" :data="data"
:option="option" :option="option"
:table-loading="_loading" :table-loading="_loading"
:before-close="handleDialogClose"
@search-change="handleSearch" @search-change="handleSearch"
@search-reset="handleSearchReset" @search-reset="handleSearchReset"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
@ -17,8 +18,14 @@
<template #menu="scope"> <template #menu="scope">
<custom-table-operate :actions="actions" :data="scope" /> <custom-table-operate :actions="actions" :data="scope" />
</template> </template>
<template #replyContent-form> <template #replyContent-form="{ type }">
<custom-rich-editor v-model:value="richText" :read-only="true" /> <custom-rich-editor
v-show="richText || type != 'view'"
v-model:value="richText"
:toolbar-show="type != 'view'"
:read-only="type == 'view'"
:style="{ margin: `${type != 'view' ? '0' : 14}px 0` }"
/>
</template> </template>
</avue-crud> </avue-crud>
</CustomCard> </CustomCard>
@ -28,6 +35,8 @@
import { ref, reactive, onMounted, h } from 'vue'; import { ref, reactive, onMounted, h } from 'vue';
import CustomCard from '@/components/CustomCard.vue'; import CustomCard from '@/components/CustomCard.vue';
import { CRUD_OPTIONS } from '@/config'; import { CRUD_OPTIONS } from '@/config';
import inputSuppliesApi from '@/apis/inputSuppliesApi';
import { ElMessage } from 'element-plus';
onMounted(getData); onMounted(getData);
/* --------------- data --------------- */ /* --------------- data --------------- */
@ -36,19 +45,19 @@ const curdRef = ref();
const _loading = ref(false); const _loading = ref(false);
const data = ref([]); const data = ref([]);
const searchCondition = ref({ const searchCondition = ref({
keywords: '', problemName: '',
status: '', status: '',
}); });
const option = reactive({ const option = reactive({
...CRUD_OPTIONS, ...CRUD_OPTIONS,
addBtn: false, addBtn: false,
selection: false, selection: false,
dialogWidth: 800, dialogWidth: '60%',
editTitle: '回复', editTitle: '回复',
column: [ column: [
{ {
label: '关键词', label: '关键词',
prop: 'keywords', prop: 'problemName',
hide: true, hide: true,
search: true, search: true,
editDisplay: false, editDisplay: false,
@ -69,47 +78,46 @@ const option = reactive({
}, },
{ {
label: '名称', label: '名称',
prop: 'question', prop: 'problemName',
renderForm: ({ row }) => { renderForm: ({ row }) => {
console.log('row ---', row); return h('span', {}, row.problemName);
return h('span', {}, row.question);
}, },
span: 24, span: 24,
}, },
{ {
label: '提问时间', label: '提问时间',
prop: 'questionDate', prop: 'createTime',
viewDisplay: false, viewDisplay: false,
renderForm: ({ row }) => { renderForm: ({ row }) => {
return h('span', {}, row.questionDate); return h('span', {}, row.createTime);
}, },
span: 24, span: 24,
}, },
{
hide: true,
label: '回复内容',
prop: 'replyContent',
span: 24,
},
{ {
label: '专家姓名', label: '专家姓名',
prop: 'expertName', prop: 'expertName',
editDisplay: false, editDisplay: false,
viewDisplay: false, span: 24,
}, },
{ {
label: '回复时间', label: '回复时间',
prop: 'replyDate', prop: 'updateTime',
editDisplay: false, editDisplay: false,
viewDisplay: false,
},
{
label: '回复内容Text',
prop: 'replyContentText',
editDisplay: false,
viewDisplay: false,
},
{
hide: true,
label: '回复内容',
prop: 'replyContent',
viewDisplay: false,
span: 24, span: 24,
}, },
// {
// label: 'Text',
// prop: 'replyContentText',
// editDisplay: false,
// viewDisplay: false,
// render: ({ row }) => row.replyContent,
// },
], ],
}); });
const pageData = reactive({ const pageData = reactive({
@ -136,7 +144,8 @@ const richText = ref();
/* --------------- methods --------------- */ /* --------------- methods --------------- */
// #region // #region
function getData() { async function getData() {
_loading.value = true;
let params = Object.assign( let params = Object.assign(
{ {
currentPage: pageData.currentPage, currentPage: pageData.currentPage,
@ -144,19 +153,23 @@ function getData() {
}, },
searchCondition.value searchCondition.value
); );
console.log('params', params); let res = await inputSuppliesApi.getQuestionList(params);
_loading.value = false;
for (let i = 0; i < 13; i++) { if (res.code == 200) {
data.value.push({ data.value = res.data.records;
id: i + Date.now(), pageData.total = res.data.total;
question: '我是问题' + i,
questionDate: '2022-01-01',
expertName: '专家' + i,
replyDate: '2022-01-01',
replyContent: `<ol><li>${i}${i}${i}${i}${i}</li></ol><ul><li>😂😂</li></ul><p><strong>333</strong></p><p><span style="color: rgb(9, 109, 217);">4534</span></p>`,
status: !(i % 2) ? '0' : '1',
});
} }
// for (let i = 0; i < 13; i++) {
// data.value.push({
// id: i + Date.now(),
// problemName: '' + i,
// createTime: '2022-01-01',
// expertName: '' + i,
// updateTime: '2022-01-01',
// replyContent: `<ol><li>${i}${i}${i}${i}${i}</li></ol><ul><li>😂😂</li></ul><p><strong>333</strong></p><p><span style="color: rgb(9, 109, 217);">4534</span></p>`,
// status: !(i % 2) ? '0' : '1',
// });
// }
} }
function handleSearch(form, done) { function handleSearch(form, done) {
resetGet(); resetGet();
@ -166,31 +179,45 @@ function handleSearchReset() {
resetGet(); resetGet();
} }
function handleCurrentChange(val) { function handleCurrentChange(val) {
console.log(val); pageData.currentPage = val;
getData();
} }
function handleSizeChange(val) { function handleSizeChange(val) {
console.log(val); pageData.size = val;
resetGet();
} }
function handleRowUpdate(form, done, loading) { async function handleRowUpdate(form, index, done, loading) {
console.log('rich', richText.value); let data = {
console.log('update ', form); id: form.id,
replyContent: richText.value,
};
let res = await inputSuppliesApi.getQuestionReply(data);
loading(); loading();
if (res.code == 200) {
ElMessage.success('回复成功!');
getData();
done();
}
} }
function handleRowSave(form, done, loading) { function handleRowSave(form, done, loading) {
loading(); loading();
} }
function resetGet() { function resetGet() {
pageData.currentPage = 1; pageData.currentPage = 1;
getData; getData();
} }
function handleReply({ row }) { function handleReply({ row }) {
console.log('reply', row);
curdRef.value.rowEdit(row); curdRef.value.rowEdit(row);
} }
function handleInfo({ row }) { function handleInfo({ row }) {
console.log('info', row); richText.value = row.replyContent;
curdRef.value.rowView(row); curdRef.value.rowView(row);
} }
function handleDialogClose(done) {
richText.value = '';
done();
}
// #endregion // #endregion
</script> </script>