feat: modify routing to nested mode and rename document (#52)

* feat: modify routing to nested mode

* feat: rename document
This commit is contained in:
balibabu
2024-02-02 18:49:54 +08:00
committed by GitHub
parent 503735cd1d
commit 7b71fb2db6
33 changed files with 681 additions and 175 deletions

View File

@@ -1,14 +1,19 @@
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
import kbService from '@/services/kbService';
import { message } from 'antd';
import omit from 'lodash/omit';
import pick from 'lodash/pick';
import { Nullable } from 'typings';
import { DvaModel } from 'umi';
export interface KFModelState {
isShowCEFwModal: boolean;
isShowTntModal: boolean;
isShowSegmentSetModal: boolean;
isShowRenameModal: boolean;
tenantIfo: any;
data: any[];
data: IKnowledgeFile[];
currentRecord: Nullable<IKnowledgeFile>;
}
const model: DvaModel<KFModelState> = {
@@ -17,8 +22,10 @@ const model: DvaModel<KFModelState> = {
isShowCEFwModal: false,
isShowTntModal: false,
isShowSegmentSetModal: false,
isShowRenameModal: false,
tenantIfo: {},
data: [],
currentRecord: null,
},
reducers: {
updateState(state, { payload }) {
@@ -27,6 +34,12 @@ const model: DvaModel<KFModelState> = {
...payload,
};
},
setIsShowRenameModal(state, { payload }) {
return { ...state, isShowRenameModal: payload };
},
setCurrentRecord(state, { payload }) {
return { ...state, currentRecord: payload };
},
},
subscriptions: {
setup({ dispatch, history }) {
@@ -99,6 +112,26 @@ const model: DvaModel<KFModelState> = {
});
}
},
*document_rename({ payload = {} }, { call, put }) {
const { data } = yield call(
kbService.document_rename,
omit(payload, ['kb_id']),
);
const { retcode, data: res, retmsg } = data;
if (retcode === 0) {
message.success('rename success');
yield put({
type: 'setIsShowRenameModal',
payload: false,
});
yield put({
type: 'getKfList',
payload: { kb_id: payload.kb_id },
});
}
return retcode;
},
*document_create({ payload = {} }, { call, put }) {
const { data, response } = yield call(kbService.document_create, payload);
const { retcode, data: res, retmsg } = data;