zhengpengju 3 years ago
commit 41820147b2

@ -247,6 +247,9 @@ const TableList: React.FC = () => {
key="update"
onClick={() => {
handleUpdateModalVisible(true);
const idsArr = record.org_ids.split(",")
record.org_names = idsArr
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 (
<PageContainer>
@ -347,29 +362,43 @@ const TableList: React.FC = () => {
console.log('values1:', values, orgTree);
//return false;
// 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) => {
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(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.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={{
render: (props, doms) => (
@ -385,26 +414,40 @@ const TableList: React.FC = () => {
columns={columns}
/>
</Modal>
<UpdateForm
onSubmit={async (value) => {
const success = await handleUpdate(value, currentRow);
if (success) {
handleUpdateModalVisible(false);
setCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
<Modal
title="编辑"
width="60%"
visible={updateModalVisible}
destroyOnClose
onCancel={() => {
handleUpdateModalVisible(false);
setCurrentRow(undefined);
}}
updateModalVisible={updateModalVisible}
values={currentRow || {}}
/>
footer={null}
>
{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
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', {
data,
method: 'POST',
requestType: "form",
...(options || {}),
});
}

Loading…
Cancel
Save