Commit 80dffd56 authored by 罗林杰's avatar 罗林杰

修改知识库

parent 524d1cc9
......@@ -97,14 +97,14 @@ export const formSchema: FormSchema[] = [
required: true,
},
{
field: 'deptName',
field: 'deptId',
label: '权属机构',
component: 'TreeSelect',
colProps: { lg: 24, md: 24 },
componentProps: {
fieldNames: {
label: 'deptName',
value: 'deptName',
value: 'businessId',
},
getPopupContainer: () => document.body,
},
......@@ -121,14 +121,14 @@ export const formSchema: FormSchema[] = [
export const importFormSchema: FormSchema[] = [
{
field: 'deptName',
field: 'deptId',
label: '导入至',
component: 'TreeSelect',
colProps: { lg: 24, md: 24 },
componentProps: {
fieldNames: {
label: 'deptName',
value: 'deptName',
value: 'businessId',
},
getPopupContainer: () => document.body,
},
......
......@@ -14,7 +14,6 @@
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { getDeptList } from '@/api/system/dept/dept';
import { UserDetailApi } from '@/api/system/user/user';
import { importFormSchema } from '@/views/knowledgeBase/data';
defineOptions({ name: 'AccountModal' });
......
......@@ -67,7 +67,8 @@ export const knowledgeData: any[] = [
fileType: 'test',
createDate: '2024-10-24 10:04:04',
createBy: 'admin',
deptName: '财务部门',
deptId: '102',
deptName: '研发部门',
updateDate: '2024-10-24 10:04:04',
updateBy: 'admin',
},
......@@ -80,7 +81,8 @@ export const knowledgeData: any[] = [
fileType: 'test',
createDate: '2024-10-24 10:04:04',
createBy: 'admin',
deptName: '财务部门',
deptId: '102',
deptName: '研发部门',
updateDate: '2024-10-24 10:04:04',
updateBy: 'admin',
},
......@@ -93,7 +95,8 @@ export const knowledgeData: any[] = [
fileType: 'test',
createDate: '2024-10-24 10:04:04',
createBy: 'admin',
deptName: '研发部门',
deptId: '103',
deptName: '市场部门',
updateDate: '2024-10-24 10:04:04',
updateBy: 'admin',
},
......@@ -106,7 +109,8 @@ export const knowledgeData: any[] = [
fileType: 'test',
createDate: '2024-10-24 10:04:04',
createBy: 'admin',
deptName: '研发部门',
deptId: '103',
deptName: '市场部门',
updateDate: '2024-10-24 10:04:04',
updateBy: 'admin',
},
......
......@@ -13,10 +13,10 @@
import { ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { getDeptList } from '@/api/system/dept/dept';
import { useMessage } from '@/hooks/web/useMessage';
import { formSchema } from '@/views/knowledgeBase/data';
import { knowledgeData } from '@/views/knowledgeBase/knowledgeBaseData';
import { getDeptList } from '@/api/system/dept/dept';
defineOptions({ name: 'KnowledgeModal' });
......@@ -27,7 +27,7 @@
const tableData = ref([]);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, resetFields }] = useForm({
const [registerForm, { setFieldsValue, updateSchema, resetFields }] = useForm({
labelWidth: 100,
baseColProps: { lg: 12, md: 24 },
schemas: formSchema,
......@@ -50,10 +50,59 @@
userData = tableData.value.filter((item) => item.businessId === rowId.value);
setFieldsValue(userData[0]);
}
const treeData = await getDeptList();
const treeList = handleTree(treeData.data, 'businessId', undefined, undefined, undefined);
updateSchema([
{
field: 'username',
show: !unref(isUpdate),
},
{
field: 'password',
show: !unref(isUpdate),
},
{
field: 'flag',
show: !unref(isUpdate),
},
{
field: 'deptId',
componentProps: {
treeData: treeList,
},
},
]);
});
const getTitle = computed(() => (!unref(isUpdate) ? '新增文件' : '编辑文件'));
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id';
parentId = parentId || 'parentId';
children = children || 'children';
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
// 返回第一层
return father[parentId] === rootId;
});
return treeData !== '' ? treeData : data;
}
async function handleSubmit() {
closeModal();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment