提交 c7d27b64 authored 作者: 钟是志's avatar 钟是志

移动端代码优化

上级 31d1a691
......@@ -21,6 +21,7 @@ export default class MobileDate extends Component {
}
triggerChange = changedValue => {
console.log(changedValue);
// Should provide an event to pass value to Form.
const onChange = this.props.onChange;
// console.log(changedValue);
......@@ -57,9 +58,9 @@ export default class MobileDate extends Component {
}
this.triggerChange(dates);
};
handelEndChange = date => {
const { dates } = this.state;
if (dates.length === 0) {
dates.push(null);
dates.push(moment(date.valueOf()));
......@@ -68,7 +69,6 @@ export default class MobileDate extends Component {
Toast.fail('结束时间必须在开始时间之后', 1);
return false;
}
dates.push(moment(date.valueOf()));
} else {
if (dates[0].isAfter(moment(date.valueOf()), 'second')) {
......@@ -95,7 +95,7 @@ export default class MobileDate extends Component {
formatDateShow = (v) => {
}
};
render() {
let { dates } = this.state;
......@@ -107,12 +107,11 @@ export default class MobileDate extends Component {
if (!showTime) {
mode = 'date';
}
console.log(formatDiy);
const startTime = dates.length > 0 ? dates[0] && dates[0].valueOf() : null;
const endTime = dates.length > 1 ? dates[1] && dates[1].valueOf() : null;
const MustSpan = this.MustSpan();
// console.log(startTime, endTime, dates);
// return null;
// console.log(startTime, endTime);
return (
<div>
......
import { EditorState, convertFromRaw, convertToRaw, CompositeDecorator } from 'draft-js';
import { stateToHTML } from 'draft-js-export-html';
import moment from 'moment';
import React from "react";
import React from 'react';
function findLinkEntities(contentBlock, callback, contentState) {
contentBlock.findEntityRanges(
(character) => {
character => {
const entityKey = character.getEntity();
return entityKey !== null && contentState.getEntity(entityKey).getType() === 'LINK';
},
function () {
function() {
console.log(arguments);
callback(...arguments);
},
);
}
const Link = (props) => {
const Link = props => {
const { url } = props.contentState.getEntity(props.entityKey).getData();
return (
......@@ -68,7 +68,10 @@ export function changeFromDraftState(editorState) {
const blocks = JSON.stringify(convertToRaw(x));
const content = stateToHTML(x);
return { content, blocks };
return {
content,
blocks,
};
}
export function changeToDraftState2(blocks) {
......@@ -115,11 +118,9 @@ export function preHandle(values) {
for (let j in childObj) {
// 我写的代码
if (j.indexOf('$') > -1 && Array.isArray(childObj[j]) && childObj[j].length === 2) {
j.split('$').map((g,index) => {
if(moment.isMoment(childObj[j][index])){
j.split('$').map((g, index) => {
if (moment.isMoment(childObj[j][index])) {
childObj[g] = childObj[j][index].valueOf();
// childObj[j][index] = childObj[j][index].valueOf();
}
});
delete childObj[j];
......@@ -146,9 +147,6 @@ export function preHandle(values) {
}
}
}
}
}
}
......@@ -157,7 +155,6 @@ export function preHandle(values) {
}
}
/**
* 深拷贝函数 一站式使用
* */
......@@ -195,7 +192,8 @@ export function deepCopy(obj, parent = null) {
temp = obj[key];
if (temp && moment.isMoment(temp)) {
result[key] = temp.clone();
} else if (temp && typeof temp === 'object') { // 如果字段的值也是一个对象
} else if (temp && typeof temp === 'object') {
// 如果字段的值也是一个对象
// 递归执行深拷贝 将同级的待拷贝对象与新对象传递给 parent 方便追溯循环引用
result[key] = deepCopy(temp, {
originalParent: obj,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论