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 hide = message.loading('正在配置');
console.log('fields',fields)
try {
await saveCourse({
...currentRow,
@ -286,7 +286,7 @@ const CourseList: React.FC = () => {
hideInForm: true,
hideInSearch: true,
width: 100,
renderText: (val: string) => `${val}M`,
renderText: (val: string) => `${val} 字节`,
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
@ -600,14 +600,18 @@ const CourseList: React.FC = () => {
labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }}
onFinish={async (values) => {
alert(0)
console.log('values', values)
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({
...values,
attachment_filesize: attachment_json?.size || 0, // Bit 字节
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); // 隐藏编辑窗口
actionRef.current?.reloadAndRest?.();
console.log(values);
}}
submitter={{

@ -17,7 +17,7 @@ import { queryQuestionById, queryQuestionList, queryQuestionType } from '@/pages
import ProForm, { ProFormSelect } from '@ant-design/pro-form';
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 formItemLayout = {
@ -40,13 +40,14 @@ console.log('first');
const AnswersSelector = () => {
return (
<Form.List
<Form.List
initialValue={['','','','']}
name="names"
rules={[
{
validator: async (_, names) => {
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) => (
<Form.Item
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
label={index === 0 ? 'Passengers' : ''}
label={labels[index]}
required={false}
key={field.key}
>
<Form.Item
{...field}
validateTrigger={['onChange', 'onBlur']}
rules={[
{
required: true,
whitespace: true,
message: "Please input passenger's name or delete this field.",
message: "选项不能为空",
},
]}
noStyle
>
<Input placeholder="passenger name" style={{ width: '100%' }} />
<Input placeholder="" style={{ width: '80%' }} />
</Form.Item>
{fields.length > 1 ? (
<MinusCircleOutlined
@ -87,20 +88,10 @@ const AnswersSelector = () => {
<Button
type="dashed"
onClick={() => add()}
style={{ width: '60%' }}
icon={<PlusOutlined />}
>
Add field
</Button>
<Button
type="dashed"
onClick={() => {
add('The head item', 0);
}}
style={{ width: '60%', marginTop: '20px' }}
style={{ marginLeft: 22, width: '60%' }}
icon={<PlusOutlined />}
>
Add field at head
</Button>
<Form.ErrorList errors={errors} />
</Form.Item>

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

Loading…
Cancel
Save