51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
|
|
import React, { useState } from 'react';
|
||
|
|
import { Form, Col } from 'antd'
|
||
|
|
import { extendInclude, extendRule, initFilter } from "../../utils/common";
|
||
|
|
import moment from 'moment'
|
||
|
|
import BraftEditor from 'braft-editor';
|
||
|
|
import 'braft-editor/dist/index.css';
|
||
|
|
/**
|
||
|
|
* @return {string}
|
||
|
|
*/
|
||
|
|
|
||
|
|
export default {
|
||
|
|
onBeforeEdit: ({ isNew, login, stateData }) => {
|
||
|
|
if (isNew) {
|
||
|
|
stateData.STATUS = 0
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onBeforeSaveHandleRecord(params) {
|
||
|
|
params.record.STATUS = params.customParams
|
||
|
|
},
|
||
|
|
|
||
|
|
handleRenderHeadControl(params) {
|
||
|
|
if (params.colConfig.field == 'TITLE') {
|
||
|
|
const initialEditorState = BraftEditor.createEditorState(params.record.TITLE || '');
|
||
|
|
const formItemLayout = {
|
||
|
|
labelCol: { span: 24 },
|
||
|
|
wrapperCol: { span: 24 }
|
||
|
|
};
|
||
|
|
const customOrResponse = {
|
||
|
|
lg: 24, xxl: 24
|
||
|
|
}
|
||
|
|
const placeholder = '请输入' + params.colConfig.label + '...'
|
||
|
|
return <>
|
||
|
|
<Col key={params.colConfig.field} {...customOrResponse}>
|
||
|
|
<Form.Item {...formItemLayout} label={params.colConfig.label} >
|
||
|
|
<BraftEditor style={{ border: "1px solid #d9d9d9", width: "98%", height: "300px" }}
|
||
|
|
contentStyle={{ zIndex: 'auto' }}
|
||
|
|
value={initialEditorState}
|
||
|
|
onBlur={(editorState) => {
|
||
|
|
const htmlContent = editorState.toHTML();
|
||
|
|
if (params.record.TITLE != htmlContent) {
|
||
|
|
params.setFieldValue('TITLE', htmlContent);
|
||
|
|
}
|
||
|
|
}}
|
||
|
|
placeholder={placeholder}
|
||
|
|
/>
|
||
|
|
</Form.Item>
|
||
|
|
</Col>
|
||
|
|
</>
|
||
|
|
}
|
||
|
|
},
|
||
|
|
};
|