sz-mx-cabin-yjb
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -18,2 +18,3 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import React, { useEffect } from 'react'; | ||
import moment from 'moment'; | ||
import { Form, Row } from 'dw-mx'; | ||
@@ -72,2 +73,16 @@ import { Form as Form_m } from 'antd-mobile'; | ||
function isDate(value) { | ||
// 将值转换为日期对象 | ||
var date = new Date(value); // 判断日期对象是否是有效的 | ||
if (isNaN(date.getTime())) { | ||
return false; | ||
} // 判断日期对象的年份是否与原始值相同 | ||
var year = date.getFullYear(); | ||
var originalYear = new Date(value).getFullYear(); | ||
return year === originalYear; | ||
} | ||
useEffect(function () { | ||
@@ -86,3 +101,3 @@ if (!data) { | ||
for (var formkey in data[key]) { | ||
if (data[key][formkey] && data[key][formkey]._isAMomentObject) { | ||
if (!isMobile() && data[key][formkey] && data[key][formkey]._isAMomentObject) { | ||
var gs = void 0; | ||
@@ -112,2 +127,12 @@ var format = attrs[key][formkey] ? attrs[key][formkey].format : ''; | ||
} | ||
if (isMobile() && data[key][formkey] && isDate(data[key][formkey])) { | ||
var _gs = void 0; | ||
var _format = attrs[key][formkey] ? attrs[key][formkey].format : 'YYYY-MM-DD'; | ||
formdata[formkey] = moment(data[key][formkey]).format(_gs); | ||
} else { | ||
formdata[formkey] = data[key][formkey]; | ||
} | ||
} | ||
@@ -127,3 +152,3 @@ | ||
for (var key in values) { | ||
if (values[key] && values[key]._isAMomentObject) { | ||
if (!isMobile() && values[key] && values[key]._isAMomentObject) { | ||
var gs = void 0; | ||
@@ -151,2 +176,10 @@ var format = attrs[name][key] ? attrs[name][key].format : ''; | ||
} | ||
if (isMobile() && values[key] && isDate(values[key])) { | ||
var _gs2 = void 0; | ||
var _format2 = attrs[name][key] ? attrs[name][key].format : 'YYYY-MM-DD'; | ||
values[key] = values[key].format(_gs2); | ||
} | ||
} | ||
@@ -171,22 +204,22 @@ | ||
for (var formkey in newData[_key]) { | ||
if (newData[_key][formkey] && newData[_key][formkey]._isAMomentObject) { | ||
var _gs = void 0; | ||
if (!isMobile() && newData[_key][formkey] && newData[_key][formkey]._isAMomentObject) { | ||
var _gs3 = void 0; | ||
var _format = attrs[_key][formkey] ? attrs[_key][formkey].format : ''; | ||
var _format3 = attrs[_key][formkey] ? attrs[_key][formkey].format : ''; | ||
var _picker = attrs[_key][formkey] ? attrs[_key][formkey].picker : ''; | ||
if (_format) { | ||
_gs = _format; | ||
if (_format3) { | ||
_gs3 = _format3; | ||
} else { | ||
if (_picker == 'month') { | ||
_gs = 'YYYY-MM'; | ||
_gs3 = 'YYYY-MM'; | ||
} else if (_picker == 'week') { | ||
_gs = 'YYYY-wo'; | ||
_gs3 = 'YYYY-wo'; | ||
} else if (_picker == 'quarter') { | ||
_gs = 'YYYY-\\QQ'; | ||
_gs3 = 'YYYY-\\QQ'; | ||
} else if (_picker == 'year') { | ||
_gs = 'YYYY'; | ||
_gs3 = 'YYYY'; | ||
} else { | ||
_gs = 'YYYY-MM-DD'; | ||
_gs3 = 'YYYY-MM-DD'; | ||
} | ||
@@ -196,6 +229,16 @@ } | ||
formdata; | ||
formdata[formkey] = newData[_key][formkey].format(_gs); | ||
formdata[formkey] = newData[_key][formkey].format(_gs3); | ||
} else { | ||
formdata[formkey] = newData[_key][formkey]; | ||
} | ||
if (isMobile() && data[_key][formkey] && isDate(data[_key][formkey])) { | ||
var _gs4 = void 0; | ||
var _format4 = attrs[_key][formkey] ? attrs[_key][formkey].format : 'YYYY-MM-DD'; | ||
formdata[formkey] = moment(data[_key][formkey]).format(_gs4); | ||
} else { | ||
formdata[formkey] = data[_key][formkey]; | ||
} | ||
} | ||
@@ -202,0 +245,0 @@ |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _moment = _interopRequireDefault(require("moment")); | ||
var _dwMx = require("dw-mx"); | ||
@@ -23,2 +25,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -91,2 +95,16 @@ | ||
function isDate(value) { | ||
// 将值转换为日期对象 | ||
var date = new Date(value); // 判断日期对象是否是有效的 | ||
if (isNaN(date.getTime())) { | ||
return false; | ||
} // 判断日期对象的年份是否与原始值相同 | ||
var year = date.getFullYear(); | ||
var originalYear = new Date(value).getFullYear(); | ||
return year === originalYear; | ||
} | ||
(0, _react.useEffect)(function () { | ||
@@ -105,3 +123,3 @@ if (!data) { | ||
for (var formkey in data[key]) { | ||
if (data[key][formkey] && data[key][formkey]._isAMomentObject) { | ||
if (!(0, _NumberUtil.isMobile)() && data[key][formkey] && data[key][formkey]._isAMomentObject) { | ||
var gs = void 0; | ||
@@ -131,2 +149,12 @@ var format = attrs[key][formkey] ? attrs[key][formkey].format : ''; | ||
} | ||
if ((0, _NumberUtil.isMobile)() && data[key][formkey] && isDate(data[key][formkey])) { | ||
var _gs = void 0; | ||
var _format = attrs[key][formkey] ? attrs[key][formkey].format : 'YYYY-MM-DD'; | ||
formdata[formkey] = (0, _moment["default"])(data[key][formkey]).format(_gs); | ||
} else { | ||
formdata[formkey] = data[key][formkey]; | ||
} | ||
} | ||
@@ -146,3 +174,3 @@ | ||
for (var key in values) { | ||
if (values[key] && values[key]._isAMomentObject) { | ||
if (!(0, _NumberUtil.isMobile)() && values[key] && values[key]._isAMomentObject) { | ||
var gs = void 0; | ||
@@ -170,2 +198,10 @@ var format = attrs[name][key] ? attrs[name][key].format : ''; | ||
} | ||
if ((0, _NumberUtil.isMobile)() && values[key] && isDate(values[key])) { | ||
var _gs2 = void 0; | ||
var _format2 = attrs[name][key] ? attrs[name][key].format : 'YYYY-MM-DD'; | ||
values[key] = values[key].format(_gs2); | ||
} | ||
} | ||
@@ -190,22 +226,22 @@ | ||
for (var formkey in newData[_key]) { | ||
if (newData[_key][formkey] && newData[_key][formkey]._isAMomentObject) { | ||
var _gs = void 0; | ||
if (!(0, _NumberUtil.isMobile)() && newData[_key][formkey] && newData[_key][formkey]._isAMomentObject) { | ||
var _gs3 = void 0; | ||
var _format = attrs[_key][formkey] ? attrs[_key][formkey].format : ''; | ||
var _format3 = attrs[_key][formkey] ? attrs[_key][formkey].format : ''; | ||
var _picker = attrs[_key][formkey] ? attrs[_key][formkey].picker : ''; | ||
if (_format) { | ||
_gs = _format; | ||
if (_format3) { | ||
_gs3 = _format3; | ||
} else { | ||
if (_picker == 'month') { | ||
_gs = 'YYYY-MM'; | ||
_gs3 = 'YYYY-MM'; | ||
} else if (_picker == 'week') { | ||
_gs = 'YYYY-wo'; | ||
_gs3 = 'YYYY-wo'; | ||
} else if (_picker == 'quarter') { | ||
_gs = 'YYYY-\\QQ'; | ||
_gs3 = 'YYYY-\\QQ'; | ||
} else if (_picker == 'year') { | ||
_gs = 'YYYY'; | ||
_gs3 = 'YYYY'; | ||
} else { | ||
_gs = 'YYYY-MM-DD'; | ||
_gs3 = 'YYYY-MM-DD'; | ||
} | ||
@@ -215,6 +251,16 @@ } | ||
formdata; | ||
formdata[formkey] = newData[_key][formkey].format(_gs); | ||
formdata[formkey] = newData[_key][formkey].format(_gs3); | ||
} else { | ||
formdata[formkey] = newData[_key][formkey]; | ||
} | ||
if ((0, _NumberUtil.isMobile)() && data[_key][formkey] && isDate(data[_key][formkey])) { | ||
var _gs4 = void 0; | ||
var _format4 = attrs[_key][formkey] ? attrs[_key][formkey].format : 'YYYY-MM-DD'; | ||
formdata[formkey] = (0, _moment["default"])(data[_key][formkey]).format(_gs4); | ||
} else { | ||
formdata[formkey] = data[_key][formkey]; | ||
} | ||
} | ||
@@ -221,0 +267,0 @@ |
{ | ||
"name": "sz-mx-cabin-yjb", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "reactCabin", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
1213380
26187