zhengpengju 3 years ago
commit 41820147b2

@ -247,6 +247,9 @@ const TableList: React.FC = () => {
key="update" key="update"
onClick={() => { onClick={() => {
handleUpdateModalVisible(true); handleUpdateModalVisible(true);
const idsArr = record.org_ids.split(",")
record.org_names = idsArr
setCurrentRow(record); setCurrentRow(record);
}} }}
> >
@ -258,6 +261,18 @@ const TableList: React.FC = () => {
], ],
}, },
]; ];
/** 获取列数据初始值 */
const getInitialValues = (cols: any[], vals: any) => {
console.log('getInitialValues-columns', columns);
console.log('getInitialValues-values', vals);
const initialValues: any[] = [];
cols.forEach((column: { dataIndex: string }) => {
const key: any = column?.dataIndex || '';
initialValues.push({ ...column, initialValue: key ? vals[key] : '' });
});
console.log('initialValues::', initialValues);
return initialValues || [];
};
return ( return (
<PageContainer> <PageContainer>
@ -347,29 +362,43 @@ const TableList: React.FC = () => {
console.log('values1:', values, orgTree); console.log('values1:', values, orgTree);
//return false; //return false;
// values.attachment_json.response.file.response.url // values.attachment_json.response.file.response.url
const params = {
...values,
end_time: values.datetime[1],
start_time: values.datetime[0],
}
delete params.datetime
console.log(123);
const tree = orgTree.filter((item, idx, self) => { const tree = orgTree.filter((item, idx, self) => {
console.log(item.id);
return (values.org_names.find(item.id) >= 0) return (values.org_names.indexOf(item.id) !== -1)
}); });
tree.map((e, i) => {
tree[i].org_id = e.id
tree[i].org_name = e.name
delete tree[i].id
delete tree[i].name
delete tree[i].pId
})
console.log(321); console.log(321);
console.log(tree, 'tree'); console.log(tree, 'tree');
const _data = {
...values,
end_time: values.datetime[1],
start_time: values.datetime[0],
target_list_json: JSON.stringify(tree)
}
delete _data.datetime
delete _data.org_names
// delete params.course_time // delete params.course_time
// delete params.examination_time // delete params.examination_time
console.log(_data, '_data');
const res = await saveTrain(_data);
// console.log(res, 'ressss');
if (res.code === 2000) {
handleModalVisible(false);
actionRef.current?.reloadAndRest?.();
}
// await handleUpdate(params);
// handleCreateModalVisible(false);
// actionRef.current?.reloadAndRest?.();
}} }}
submitter={{ submitter={{
render: (props, doms) => ( render: (props, doms) => (
@ -385,26 +414,40 @@ const TableList: React.FC = () => {
columns={columns} columns={columns}
/> />
</Modal> </Modal>
<UpdateForm <Modal
onSubmit={async (value) => { title="编辑"
const success = await handleUpdate(value, currentRow); width="60%"
visible={updateModalVisible}
if (success) { destroyOnClose
handleUpdateModalVisible(false);
setCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => { onCancel={() => {
handleUpdateModalVisible(false); handleUpdateModalVisible(false);
setCurrentRow(undefined);
}} }}
updateModalVisible={updateModalVisible} footer={null}
values={currentRow || {}} >
/> {currentRow?.train_id && (
<BetaSchemaForm<DataItem>
layout="horizontal"
layoutType="Form"
labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }}
onFinish={async (values) => {
console.log(values);
}}
submitter={{
render: (props, doms) => (
<Row>
<Col span={12} offset={8}>
<Space>{doms}</Space>
</Col>
</Row>
),
}}
// action = ''
title="编辑"
columns={getInitialValues(columns, currentRow)}
/>
)}
</Modal>
<Drawer <Drawer
width={600} width={600}

@ -34,6 +34,7 @@ export async function saveTrain(data: Record<string, any>, options?: Record<stri
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/train/save', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/train/save', {
data, data,
method: 'POST', method: 'POST',
requestType: "form",
...(options || {}), ...(options || {}),
}); });
} }

Loading…
Cancel
Save