|
@@ -1,13 +1,14 @@
|
|
|
-import React, { useEffect, useState } from 'react';
|
|
|
-import { Button, message, Modal } from 'antd';
|
|
|
+import React, {useEffect, useState} from 'react';
|
|
|
+import {Button, message, Modal} from 'antd';
|
|
|
import Quill from '@/pages/Memory/components/Quill';
|
|
|
import service from '@/pages/Memory/service';
|
|
|
-import { useSingleState } from 'nice-hooks';
|
|
|
-import { getTextFromHtml } from '@/utils/utils';
|
|
|
-import { TableListItem } from '../../MemoryList/data.d';
|
|
|
+import {useSingleState} from 'nice-hooks';
|
|
|
+import {getTextFromHtml} from '@/utils/utils';
|
|
|
+import {TableListItem} from '../../MemoryList/data.d';
|
|
|
|
|
|
// 表单特殊字段
|
|
|
-export interface FormValueType extends Partial<TableListItem> {}
|
|
|
+export interface FormValueType extends Partial<TableListItem> {
|
|
|
+}
|
|
|
|
|
|
export interface UpdateFormProps {
|
|
|
onCancel: (fresh?: boolean) => void;
|
|
@@ -67,7 +68,7 @@ const dealHtml = (html: string, callBack: Function) => {
|
|
|
const htmlDoc = new DOMParser().parseFromString(html, 'text/html');
|
|
|
const imgs = htmlDoc.querySelectorAll('img');
|
|
|
for (let i = 0; i < imgs.length; i += 1) {
|
|
|
- const { src } = imgs[i];
|
|
|
+ const {src} = imgs[i];
|
|
|
if (src.startsWith('data')) {
|
|
|
dealImage(src, 500, 150, (base64: string) => {
|
|
|
imgs[i].src = base64;
|
|
@@ -93,7 +94,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
...props.values,
|
|
|
});
|
|
|
|
|
|
- const { onCancel: hideModal, modalVisible } = props;
|
|
|
+ const {onCancel: hideModal, modalVisible} = props;
|
|
|
|
|
|
const addHandle = async () => {
|
|
|
/**
|
|
@@ -121,7 +122,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
if (formValues.id !== undefined) {
|
|
|
hideModal(true);
|
|
|
} else {
|
|
|
- setFormValues({ front: '', back: '' });
|
|
|
+ setFormValues({front: '', back: ''});
|
|
|
}
|
|
|
} else {
|
|
|
message.info(`操作失败: ${res.message}`);
|
|
@@ -141,8 +142,9 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
|
return (
|
|
|
<Modal
|
|
|
+ maskClosable={false}
|
|
|
width={640}
|
|
|
- bodyStyle={{ padding: '15px 15px 15px' }}
|
|
|
+ bodyStyle={{padding: '15px 15px 15px'}}
|
|
|
destroyOnClose
|
|
|
title="配置模型"
|
|
|
visible={modalVisible}
|
|
@@ -156,25 +158,25 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
readonly={false}
|
|
|
onChange={(value) => {
|
|
|
dealHtml(value, (html: string) => {
|
|
|
- setFormValues({ front: html });
|
|
|
+ setFormValues({front: html});
|
|
|
});
|
|
|
}}
|
|
|
value={formValues.front}
|
|
|
/>
|
|
|
|
|
|
- <p />
|
|
|
+ <p/>
|
|
|
<h4>反面</h4>
|
|
|
<Quill
|
|
|
theme={"snow"}
|
|
|
readonly={false}
|
|
|
onChange={(value) => {
|
|
|
dealHtml(value, (html: string) => {
|
|
|
- setFormValues({ back: html });
|
|
|
+ setFormValues({back: html});
|
|
|
});
|
|
|
}}
|
|
|
value={formValues.back}
|
|
|
/>
|
|
|
- <p />
|
|
|
+ <p/>
|
|
|
<Button type="primary" disabled={btnDisable} onClick={addHandle}>
|
|
|
确定
|
|
|
</Button>
|