|
|
|
@ -9,8 +9,9 @@ import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
|
|
|
|
|
import ProDescriptions from '@ant-design/pro-descriptions';
|
|
|
|
|
import type { FormValueType } from './components/UpdateForm';
|
|
|
|
|
import UpdateForm from './components/UpdateForm';
|
|
|
|
|
import { queryTrainList, saveTrain, removeTrain } from './service';
|
|
|
|
|
import { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey } from './service';
|
|
|
|
|
import type { TableListItem, TableListPagination } from './data';
|
|
|
|
|
import { useRequest } from 'umi';
|
|
|
|
|
/**
|
|
|
|
|
* 添加培训
|
|
|
|
|
*
|
|
|
|
@ -77,7 +78,51 @@ const handleRemove = async (selectedRows: TableListItem[]) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface OrgTreeForOaItem {
|
|
|
|
|
id?: number;
|
|
|
|
|
pId?: number;
|
|
|
|
|
|
|
|
|
|
name?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface children {
|
|
|
|
|
title?: string;
|
|
|
|
|
value?: number;
|
|
|
|
|
children?: children[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 递归方法 生成 json tree 数据
|
|
|
|
|
const getJsonTree = (data: [], pId: number) => {
|
|
|
|
|
//console.log('getJsonTree..', data)
|
|
|
|
|
const itemArr = [];
|
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
|
const node: OrgTreeForOaItem = data[i];
|
|
|
|
|
//console.log('f')
|
|
|
|
|
//console.log('node?.pId',node?.pId)
|
|
|
|
|
//console.log('pId',pId)
|
|
|
|
|
if (node?.pId === pId) {
|
|
|
|
|
console.log('if')
|
|
|
|
|
const treeNode: children = {};
|
|
|
|
|
treeNode.value = node?.id;
|
|
|
|
|
treeNode.title = node?.name;
|
|
|
|
|
//treeNode.url = node.url;
|
|
|
|
|
//treeNode.icon = node.icon;
|
|
|
|
|
|
|
|
|
|
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
treeNode.children = getJsonTree(data, node?.id || 0);
|
|
|
|
|
itemArr.push(treeNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return itemArr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableList: React.FC = () => {
|
|
|
|
|
|
|
|
|
|
const { data, loading } = useRequest(() => {
|
|
|
|
|
return queryValueByKey({});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** 新建窗口的弹窗 */
|
|
|
|
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
|
|
|
|
|
|
|
|
@ -108,10 +153,21 @@ const TableList: React.FC = () => {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '培训对象',
|
|
|
|
|
valueType: 'treeSelect',
|
|
|
|
|
dataIndex: 'org_names',
|
|
|
|
|
request: async () => {
|
|
|
|
|
const Value = await queryValueByKey({});
|
|
|
|
|
const orgId = Value['common.org.id'] ? Value['common.org.id'] : 0; // 平台全局设置
|
|
|
|
|
const tree = await queryOrgTree({
|
|
|
|
|
org_id: orgId,
|
|
|
|
|
org_type: 2,
|
|
|
|
|
school_type:1,
|
|
|
|
|
})
|
|
|
|
|
return getJsonTree(tree.table_List, orgId)
|
|
|
|
|
},
|
|
|
|
|
sorter: false,
|
|
|
|
|
hideInForm: false,
|
|
|
|
|
renderText: (val: string) => `${val}`,
|
|
|
|
|
//renderText: (val: string) => `${val}`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '开始时间',
|
|
|
|
@ -127,6 +183,14 @@ const TableList: React.FC = () => {
|
|
|
|
|
hideInForm: true,
|
|
|
|
|
renderText: (val: string) => `${val}`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '培训时间',
|
|
|
|
|
valueType: 'dateTimeRange',
|
|
|
|
|
dataIndex: 'datetime',
|
|
|
|
|
sorter: false,
|
|
|
|
|
hideInForm: false,
|
|
|
|
|
renderText: (val: string) => `${val}`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '学时安排',
|
|
|
|
|
sorter: false,
|
|
|
|
@ -239,7 +303,7 @@ const TableList: React.FC = () => {
|
|
|
|
|
}}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
|
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
|
|
<BetaSchemaForm
|
|
|
|
|
layout="horizontal"
|
|
|
|
|
layoutType="Form"
|
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
|