diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx index e08ea8f..3d16f2a 100644 --- a/admin/src/pages/training/option/index.tsx +++ b/admin/src/pages/training/option/index.tsx @@ -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 ( @@ -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} /> - { - const success = await handleUpdate(value, currentRow); - - if (success) { - handleUpdateModalVisible(false); - setCurrentRow(undefined); - - if (actionRef.current) { - actionRef.current.reload(); - } - } - }} + { handleUpdateModalVisible(false); - setCurrentRow(undefined); }} - updateModalVisible={updateModalVisible} - values={currentRow || {}} - /> + footer={null} + > + {currentRow?.train_id && ( + + layout="horizontal" + layoutType="Form" + labelCol={{ span: 8 }} + wrapperCol={{ span: 12 }} + onFinish={async (values) => { + console.log(values); + }} + submitter={{ + render: (props, doms) => ( + + + {doms} + + + ), + }} + // action = '' + title="编辑" + columns={getInitialValues(columns, currentRow)} + /> + )} + , options?: Record('/dsideal_yy/ypt/careerTraining/train/save', { data, method: 'POST', + requestType: "form", ...(options || {}), }); }