zhengpengju 3 years ago
parent 77df9d7c01
commit 2690f60e11

@ -44,7 +44,7 @@ const handleAdd = async (fields: TableListItem) => {
*/ */
const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) => { const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) => {
const hide = message.loading('正在配置'); const hide = message.loading('正在配置');
console.log('fields',fields)
try { try {
await saveCourse({ await saveCourse({
...currentRow, ...currentRow,
@ -286,7 +286,7 @@ const CourseList: React.FC = () => {
hideInForm: true, hideInForm: true,
hideInSearch: true, hideInSearch: true,
width: 100, width: 100,
renderText: (val: string) => `${val}M`, renderText: (val: string) => `${val} 字节`,
formItemProps: { formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule // 参照 https://ant.design/components/form-cn/#Rule
rules: [ rules: [
@ -600,14 +600,18 @@ const CourseList: React.FC = () => {
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }} wrapperCol={{ span: 12 }}
onFinish={async (values) => { onFinish={async (values) => {
alert(0) console.log('values', values)
console.log('currentRow', currentRow) console.log('currentRow', currentRow)
//const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url;
//console.log('url', url)
await handleUpdate({ await handleUpdate({
...values, ...values,
attachment_filesize: attachment_json?.size || 0, // Bit 字节
course_id: currentRow?.course_id, course_id: currentRow?.course_id,
//attachment_json: `{"img":"", "name": "${values.attachment_json.file.name}", "url": "down/M3u8/${uuid?.substr(0, 2)}/${uuid}.m3u8"}` attachment_json: `{"img":"", "name": "${values.attachment_json?.name}", "url": "${values.attachment_json?.url}", "size": "${values.attachment_json?.size}"}`
}); });
handleUpdateModalVisible(false); // 隐藏编辑窗口 handleUpdateModalVisible(false); // 隐藏编辑窗口
actionRef.current?.reloadAndRest?.();
console.log(values); console.log(values);
}} }}
submitter={{ submitter={{

@ -17,7 +17,7 @@ import { queryQuestionById, queryQuestionList, queryQuestionType } from '@/pages
import ProForm, { ProFormSelect } from '@ant-design/pro-form'; import ProForm, { ProFormSelect } from '@ant-design/pro-form';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table'; import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
const labels = ['A','B','C','D','E','F','G','H','I','J']; // 默认10个
//const { Paragraph } = Typography; //const { Paragraph } = Typography;
const formItemLayout = { const formItemLayout = {
@ -41,12 +41,13 @@ const AnswersSelector = () => {
return ( return (
<Form.List <Form.List
initialValue={['','','','']}
name="names" name="names"
rules={[ rules={[
{ {
validator: async (_, names) => { validator: async (_, names) => {
if (!names || names.length < 2) { if (!names || names.length < 2) {
return Promise.reject(new Error('At least 2 passengers')); return Promise.reject(new Error('至少填写2个选项'));
} }
}, },
}, },
@ -56,24 +57,24 @@ const AnswersSelector = () => {
<> <>
{fields.map((field, index) => ( {fields.map((field, index) => (
<Form.Item <Form.Item
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)} label={labels[index]}
label={index === 0 ? 'Passengers' : ''}
required={false} required={false}
key={field.key} key={field.key}
> >
<Form.Item <Form.Item
{...field} {...field}
validateTrigger={['onChange', 'onBlur']} validateTrigger={['onChange', 'onBlur']}
rules={[ rules={[
{ {
required: true, required: true,
whitespace: true, whitespace: true,
message: "Please input passenger's name or delete this field.", message: "选项不能为空",
}, },
]} ]}
noStyle noStyle
> >
<Input placeholder="passenger name" style={{ width: '100%' }} /> <Input placeholder="" style={{ width: '80%' }} />
</Form.Item> </Form.Item>
{fields.length > 1 ? ( {fields.length > 1 ? (
<MinusCircleOutlined <MinusCircleOutlined
@ -87,20 +88,10 @@ const AnswersSelector = () => {
<Button <Button
type="dashed" type="dashed"
onClick={() => add()} onClick={() => add()}
style={{ width: '60%' }} style={{ marginLeft: 22, width: '60%' }}
icon={<PlusOutlined />}
>
Add field
</Button>
<Button
type="dashed"
onClick={() => {
add('The head item', 0);
}}
style={{ width: '60%', marginTop: '20px' }}
icon={<PlusOutlined />} icon={<PlusOutlined />}
> >
Add field at head
</Button> </Button>
<Form.ErrorList errors={errors} /> <Form.ErrorList errors={errors} />
</Form.Item> </Form.Item>

@ -1,4 +1,9 @@
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
:global {
.anticon.anticon-minus-circle.dynamic-delete-button{
padding: 10px;
}
}
.questionbank{ .questionbank{
:global { :global {
.ant-list-split.ant-list-something-after-last-item .ant-spin-container > .ant-list-items > .ant-list-item:last-child{ .ant-list-split.ant-list-something-after-last-item .ant-spin-container > .ant-list-items > .ant-list-item:last-child{

Loading…
Cancel
Save