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>
<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
v-model="valueHtml"
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 { isEmpty } from '@/utils';
// import { CommonUpload, UploadImageFromEditor } from '@/apis/common';
import { imageUpload } from './upFile';
const { VITE_APP_OSS_URL } = import.meta.env;
@ -63,29 +64,17 @@ export default {
maxFileSize: 10 * 1024 * 1024, //10M
maxNumberOfFiles: 10,
allowedFileTypes: ['image/*'],
async customUpload(file, insertFn) {
// 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);
// }
},
customUpload: imageUpload,
},
},
},
};
},
},
toolbarShow: {
type: Boolean,
default: true,
},
},
emits: ['focus', 'blur', 'change', 'update:value'],
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 materialApi from './material';
import * as knowledgeApi from './common';
import * as knowledgeApi from './knowledge';
export default {
...materialApi,

View File

@ -1,7 +1,14 @@
import request from '@/utils/axios';
function getQuestionList(params) {
return request('/knowledge/page', {
export function getQuestionList(params) {
return request('/input/knowledge/page', {
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) {
return request({
url: '/input/common/getList',
return request('/input/common/getList', {
params,
});
}

View File

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