flat: 暂存
This commit is contained in:
@@ -23,29 +23,28 @@ export type ListFormProps = {
|
|||||||
educationEnum: DictValueEnumObj;
|
educationEnum: DictValueEnumObj;
|
||||||
experienceEnum: DictValueEnumObj;
|
experienceEnum: DictValueEnumObj;
|
||||||
areaEnum: DictValueEnumObj;
|
areaEnum: DictValueEnumObj;
|
||||||
|
isExplainOptions: any;
|
||||||
mode?: 'view' | 'edit' | 'create';
|
mode?: 'view' | 'edit' | 'create';
|
||||||
};
|
};
|
||||||
|
|
||||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
const listEdit: React.FC<ListFormProps> = (props) => {
|
||||||
const [form] = Form.useForm<API.ManagementList.Manage>();
|
const [form] = Form.useForm<API.ManagementList.Manage>();
|
||||||
const { educationEnum, experienceEnum, areaEnum } = props;
|
const { educationEnum, experienceEnum, areaEnum, isExplainOptions } = props;
|
||||||
const { mode = props.values ? 'edit' : 'create' } = props;
|
const { mode = props.values ? 'edit' : 'create' } = props;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.open) {
|
if (props.open) {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
setTimeout(() => {
|
||||||
if (props.values) {
|
if (props.values) {
|
||||||
console.log('Setting form values:', props.values);
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
...props.values,
|
...props.values,
|
||||||
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
||||||
isExplain: Number(props.values.isExplain ?? 0),
|
isExplain: Number(props.values.isExplain) || 0, // 确保是数字
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// console.log('Setting default form values');
|
form.setFieldsValue({ isExplain: 0 });
|
||||||
// form.setFieldsValue({
|
|
||||||
// isExplain: 0,
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
}, [form, props.values, props.open]);
|
}, [form, props.values, props.open]);
|
||||||
|
|
||||||
@@ -107,6 +106,7 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
|||||||
onError(new Error(errorMessage));
|
onError(new Error(errorMessage));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mode === 'view') {
|
if (mode === 'view') {
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
@@ -142,7 +142,7 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
|||||||
<ProDescriptions.Item dataIndex="cover" label="视频帧封面图" />
|
<ProDescriptions.Item dataIndex="cover" label="视频帧封面图" />
|
||||||
<ProDescriptions.Item
|
<ProDescriptions.Item
|
||||||
dataIndex="isExplain"
|
dataIndex="isExplain"
|
||||||
label="视频显示方式"
|
label="是否显示讲解视频"
|
||||||
valueType="select"
|
valueType="select"
|
||||||
valueEnum={{
|
valueEnum={{
|
||||||
0: '关闭显示',
|
0: '关闭显示',
|
||||||
@@ -263,13 +263,10 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
|||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormRadio.Group
|
<ProFormRadio.Group
|
||||||
name="isExplain"
|
name="isExplain"
|
||||||
label={'视频显示方式'}
|
label={'是否显示讲解视频'}
|
||||||
colProps={{ md: 24 }}
|
colProps={{ md: 24 }}
|
||||||
placeholder="请选择视频显示方式"
|
placeholder="请选择是否显示讲解视频"
|
||||||
valueEnum={{
|
options={isExplainOptions}
|
||||||
0: '关闭显示',
|
|
||||||
1: '显示视频',
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
|
|||||||
@@ -67,6 +67,17 @@ function ManagementList() {
|
|||||||
const [currentRow, setCurrentRow] = useState<API.ManagementList.Manage>();
|
const [currentRow, setCurrentRow] = useState<API.ManagementList.Manage>();
|
||||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||||
const [mode, setMode] = useState<'view' | 'edit' | 'create'>('create');
|
const [mode, setMode] = useState<'view' | 'edit' | 'create'>('create');
|
||||||
|
const isExplainOptions = [
|
||||||
|
{
|
||||||
|
label: '关闭显示',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '显示视频',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDictValueEnum('education', true, true).then((data) => {
|
getDictValueEnum('education', true, true).then((data) => {
|
||||||
setEducationEnum(data);
|
setEducationEnum(data);
|
||||||
@@ -177,6 +188,15 @@ function ManagementList() {
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '讲解视频',
|
||||||
|
dataIndex: 'isExplain',
|
||||||
|
valueType: 'text',
|
||||||
|
valueEnum: isPublishEnum,
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
render: (text, record) => (record.cover ? '有' : '无'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
@@ -255,6 +275,7 @@ function ManagementList() {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div style={{ width: '100%', float: 'right' }}>
|
<div style={{ width: '100%', float: 'right' }}>
|
||||||
@@ -333,6 +354,7 @@ function ManagementList() {
|
|||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
setCurrentRow(undefined);
|
setCurrentRow(undefined);
|
||||||
}}
|
}}
|
||||||
|
isExplainOptions={isExplainOptions}
|
||||||
educationEnum={educationEnum}
|
educationEnum={educationEnum}
|
||||||
experienceEnum={experienceEnum}
|
experienceEnum={experienceEnum}
|
||||||
areaEnum={areaEnum}
|
areaEnum={areaEnum}
|
||||||
|
|||||||
Reference in New Issue
Block a user