提交 ea471e45 authored 作者: chscls@163.com's avatar chscls@163.com

富文本组件

上级 5ff844f8
...@@ -27,6 +27,8 @@ import { ...@@ -27,6 +27,8 @@ import {
notification, notification,
} from 'antd'; } from 'antd';
import QRCode from 'qrcode.react'; import QRCode from 'qrcode.react';
import {EditorState,Editor} from 'draft-js';
import MyBlockRenderer from '../App/MyBlockRender'
import { import {
InputItem as MobileInputItem, InputItem as MobileInputItem,
ImagePicker as MobileImagePicker, ImagePicker as MobileImagePicker,
...@@ -62,12 +64,14 @@ import { date } from '../libs/formList/config'; ...@@ -62,12 +64,14 @@ import { date } from '../libs/formList/config';
import Highlighter from 'react-highlight-words'; import Highlighter from 'react-highlight-words';
import Signature from '../Signature'; import Signature from '../Signature';
import baseX from 'base-x'; import baseX from 'base-x';
import {changeToDraftState} from '../utils/myutils'
const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const base64 = baseX(Bs64); const base64 = baseX(Bs64);
import { Base16Encode } from '../Base16/index'; import { Base16Encode } from '../Base16/index';
import { getToken } from '../utils/token'; import { getToken } from '../utils/token';
import { formulaList } from '../excelInitFuc/functionList'; import { formulaList } from '../excelInitFuc/functionList';
import FilePreview from '../filePreview'; import FilePreview from '../filePreview';
import DraftEditor from '../App/DraftEditor';
const Item = MobileList.Item; const Item = MobileList.Item;
const Brief = Item.Brief; const Brief = Item.Brief;
function getBase64(value) { function getBase64(value) {
...@@ -1236,44 +1240,7 @@ export default class tableCom extends Component { ...@@ -1236,44 +1240,7 @@ export default class tableCom extends Component {
: bindObj; : bindObj;
if (this.props.fatherCode == null && dataColumn == null) if (this.props.fatherCode == null && dataColumn == null)
dataColumn = { base52: this.props.uuid }; dataColumn = { base52: this.props.uuid };
/* if (this.props.fatherCode != null) {
dataColumn = { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
} else {
dataColumn = { base52: this.props.uuid }
if (Object.keys(mapData).length > 0) {
const columnIds = json.columnIds;
const bindObj = this.getColumn('c1');
let dataColumn = this.props.fatherCode != null ? (bindObj ? { ...bindObj, base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}` } :
{ base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` })
: bindObj;
if (this.props.fatherCode == null && dataColumn == null) dataColumn = { base52: this.props.uuid }
/* if (this.props.fatherCode != null) {
dataColumn = { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
} else {
dataColumn = { base52: this.props.uuid }
if (Object.keys(mapData).length > 0) {
const columnIds = json.columnIds;
if (columnIds && columnIds['c1']) {
const columnId = columnIds['c1'][columnIds['c1'].length - 1];
if (mapData[columnId] != null) {
dataColumn = mapData[columnId]
}
}
}
} */
// if (!this.props.isEdit && this.props.fatherCode) {
// if (bindObj != null) {
// dataColumn.base52 = bindObj.base52
// } else {
// dataColumn.base52 = this.props.uuid
// }
// }
if (!this.props.isEdit && this.props.fatherCode) { if (!this.props.isEdit && this.props.fatherCode) {
if (bindObj != null) { if (bindObj != null) {
dataColumn.base52 = bindObj.base52; dataColumn.base52 = bindObj.base52;
...@@ -1866,6 +1833,13 @@ export default class tableCom extends Component { ...@@ -1866,6 +1833,13 @@ export default class tableCom extends Component {
// case 'Signature': // case 'Signature':
// cm = <img src={queryApiActionPath()+obj[dataColumn.base52]} /> // cm = <img src={queryApiActionPath()+obj[dataColumn.base52]} />
// break; // break;
case 'RichText':
cm = <Editor key={dataColumn.base52}
readOnly={true}
blockRendererFn={MyBlockRenderer.bind(this, true,null,null,null)}
editorState={changeToDraftState(obj[dataColumn.base52])}
/>;
break;
case 'TextArea': case 'TextArea':
cm = ( cm = (
<span <span
...@@ -2858,6 +2832,24 @@ export default class tableCom extends Component { ...@@ -2858,6 +2832,24 @@ export default class tableCom extends Component {
); );
} }
break; break;
case 'RichText':
cm = getFieldDecorator(dataColumn.base52, {
initialValue:{editorState:changeToDraftState(initValue)},
})(
<DraftEditor placeholder={json.placeholder}/>,
);
if (get === 'mobile' && json.isLabel && title) {
cm = (
<Form.Item
labelCol={{ span: json.labelSpan }}
wrapperCol={{ span: json.wrapperSpan }}
label={title}
>
{cm}
</Form.Item>
);
}
break;
case 'LocationCom': case 'LocationCom':
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: {}, initialValue: {},
......
...@@ -4,8 +4,8 @@ import { ...@@ -4,8 +4,8 @@ import {
} from 'draft-js'; } from 'draft-js';
import { message } from 'antd' import { message } from 'antd'
import { stateToHTML } from 'draft-js-export-html'; import { stateToHTML } from 'draft-js-export-html';
import moment from 'moment'; import moment from 'moment';
function findLinkEntities(contentBlock, callback, contentState) { function findLinkEntities(contentBlock, callback, contentState) {
contentBlock.findEntityRanges( contentBlock.findEntityRanges(
(character) => { (character) => {
...@@ -104,7 +104,10 @@ export function preHandle(values) { ...@@ -104,7 +104,10 @@ export function preHandle(values) {
} else { } else {
if (values[key] != null) { if (values[key] != null) {
if (values[key] instanceof moment) { if (values[key].editorState) {
values[key] = changeFromDraftState(values[key].editorState).blocks
}else if (values[key] instanceof moment) {
values[key] = values[key].valueOf() values[key] = values[key].valueOf()
}else if (values[key] instanceof Date) { }else if (values[key] instanceof Date) {
values[key] = values[key].valueOf() values[key] = values[key].valueOf()
...@@ -119,7 +122,10 @@ export function preHandle(values) { ...@@ -119,7 +122,10 @@ export function preHandle(values) {
let childObj = objValues[k]; let childObj = objValues[k];
for(let j in childObj){ for(let j in childObj){
if(childObj[j]!=null){ if(childObj[j]!=null){
if (childObj[j] instanceof moment) { if (childObj[j].editorState) {
values[key][k][j]= changeFromDraftState(values[key][k][j].editorState).blocks
}else if (childObj[j] instanceof moment) {
values[key][k][j] = values[key][k][j].valueOf() values[key][k][j] = values[key][k][j].valueOf()
}else if (childObj[j] instanceof Date) { }else if (childObj[j] instanceof Date) {
values[key][k][j] = values[key][k][j].valueOf() values[key][k][j] = values[key][k][j].valueOf()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论