UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

116 lines (93 loc) 5.71 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _button = require('antd-mobile/lib/button'); var _button2 = _interopRequireDefault(_button); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); require('antd-mobile/lib/button/style/css'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _index = require('../../../index'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var data1 = [{ value: "340000", label: "安徽省", children: [{ value: "341500", label: "六安市", children: [{ value: "341522", label: "霍邱县" }, { value: "341525", label: "霍山县" }, { value: "341502", label: "金安区" }, { value: "341524", label: "金寨县" }] }, { value: "340500", label: "马鞍山市" }, { value: "341800", label: "宣城市" }] }, { value: "820000", label: "澳门特别行政区" }, { value: "110000", label: "北京" }, { value: "450000", label: "广西壮族自治区" }, { value: "810000", label: "香港特别行政区" }, { value: "330000", label: "浙江省" }]; var data2 = [{ value: "340000", label: "安徽省" }, { value: "820000", label: "澳门特别行政区" }, { value: "110000", label: "北京" }, { value: "450000", label: "广西壮族自治区" }, { value: "810000", label: "香港特别行政区" }, { value: "330000", label: "浙江省" }]; var grade = [[{ label: '2017界', value: '2017' }, { label: '2018界', value: '2018' }], [{ label: '物理系', value: '001' }, { label: '数学系', value: '002' }]]; var YYDatePickerDemo = function (_React$Component) { _inherits(YYDatePickerDemo, _React$Component); function YYDatePickerDemo(props) { _classCallCheck(this, YYDatePickerDemo); var _this = _possibleConstructorReturn(this, (YYDatePickerDemo.__proto__ || Object.getPrototypeOf(YYDatePickerDemo)).call(this, props)); _this.onOk = function (value) { console.log(value); }; _this.submit = function () { _this.props.form.validateFields(['picker1', 'picker2', 'picker3'], function (err, value) { if (!err) { _index.YYToast.success('提交成功', 1); console.log(value); } else { var arr = []; for (var i in err) { arr.push(err[i]); } _index.YYToast.info(arr[0].errors[0].message, 1.5); console.log(err); } }); }; _this.state = { data1: data1, data2: data2 }; return _this; } _createClass(YYDatePickerDemo, [{ key: 'render', value: function render() { var form = this.props.form; return _react2.default.createElement( 'div', null, _react2.default.createElement( _index.YYForm, null, _react2.default.createElement(_index.YYPicker, { data: this.state.data1, value: ["340000", "341500", "341502"], form: form, cols: 3, label: '\u8054\u52A8\u9009\u62E9', field: 'picker1', onOk: this.onOk, required: true, onPickerChange: function onPickerChange(v) { return console.log(v); } }), _react2.default.createElement(_index.YYPicker, { data: grade, form: form, cols: 2, label: '\u65E0\u8054\u52A8\u591A\u9009', cascade: false, field: 'picker2', onOk: this.onOk, required: true }), _react2.default.createElement(_index.YYPicker, { data: this.state.data2, form: form, cols: 1, label: '\u5355\u9009', field: 'picker3', onOk: this.onOk, required: true }), _react2.default.createElement( _button2.default, { onClick: this.submit }, '\u63D0\u4EA4' ) ) ); } }]); return YYDatePickerDemo; }(_react2.default.Component); exports.default = _index.YYForm.create()(YYDatePickerDemo);