UNPKG

7.58 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = void 0;
7
8var _react = _interopRequireDefault(require("react"));
9
10var _propTypes = _interopRequireDefault(require("prop-types"));
11
12var _reactLifecyclesCompat = require("react-lifecycles-compat");
13
14var _ReferComponents = _interopRequireDefault(require("./ReferComponents"));
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
18function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
20function _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; }
21
22function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
24function _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); } }
25
26function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27
28function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
29
30function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
32function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
34function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
36function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37
38var FixedComponents =
39/*#__PURE__*/
40function (_React$Component) {
41 _inherits(FixedComponents, _React$Component);
42
43 function FixedComponents(props) {
44 var _this;
45
46 _classCallCheck(this, FixedComponents);
47
48 _this = _possibleConstructorReturn(this, _getPrototypeOf(FixedComponents).call(this, props));
49 _this.onChange = _this.onChange.bind(_assertThisInitialized(_this));
50 _this.state = {
51 record: {},
52 record2: {},
53 recordValue: {}
54 };
55 return _this;
56 }
57
58 _createClass(FixedComponents, [{
59 key: "onChange",
60 value: function onChange(type, value) {
61 var _this2 = this;
62
63 // console.log([type,value])
64 this.setState(_defineProperty({}, type, value), function () {
65 if (type === 'record') {
66 _this2.setState({
67 record2: {},
68 recordValue: {}
69 });
70 }
71
72 if (type === 'record2') {
73 _this2.setState({
74 recordValue: {}
75 });
76 }
77
78 if (type === 'recordValue' && value.id) {
79 _this2.props.onInsertValue(' getID("' + _this2.state.record.code + '","' + value.title + '","' + value.id + '") ');
80
81 _this2.props.onDesc('getID');
82 }
83 });
84 }
85 }, {
86 key: "render",
87 value: function render() {
88 var _this$props = this.props,
89 ReferDataUrl = _this$props.ReferDataUrl,
90 fixedData = _this$props.fixedData;
91 return _react["default"].createElement("div", {
92 className: "yy-tab-content"
93 }, _react["default"].createElement("form", {
94 className: "form-horizontal"
95 }, _react["default"].createElement("div", {
96 className: "form-group"
97 }, _react["default"].createElement("label", {
98 className: "col-sm-2 control-label"
99 }, this.props.item.showName1), _react["default"].createElement("div", {
100 className: "col-sm-10"
101 }, _react["default"].createElement(_ReferComponents["default"], {
102 url: ReferDataUrl,
103 fixedData: fixedData,
104 value: this.state.record,
105 placeholder: this.props.item.placeholder,
106 notFoundContent: this.props.item.notFoundContent,
107 onChange: this.onChange.bind(this, 'record')
108 }))), _react["default"].createElement("div", {
109 className: "form-group"
110 }, _react["default"].createElement("label", {
111 className: "col-sm-2 control-label"
112 }, this.props.item.showName2), _react["default"].createElement("div", {
113 className: "col-sm-10"
114 }, this.state.record.code === 'accsubject' ? _react["default"].createElement("div", null, _react["default"].createElement(_ReferComponents["default"], {
115 url: ReferDataUrl,
116 isCode: true,
117 fixedData: _extends({}, fixedData, {
118 refCode: 'accsubjectchart',
119 refType: 'table',
120 fields: ['id', 'code', 'name'],
121 orderby: 'code asc',
122 displayFields: ['id', 'code', 'name']
123 }),
124 disabled: !this.state.record.code,
125 value: this.state.record2,
126 placeholder: this.props.item.placeholder,
127 notFoundContent: this.props.item.notFoundContent,
128 onChange: this.onChange.bind(this, 'record2')
129 }), _react["default"].createElement(_ReferComponents["default"], {
130 url: ReferDataUrl,
131 isCode: true,
132 fixedData: _extends({}, fixedData, {
133 refCode: this.state.record.code,
134 filterCondition: '{"accsubjectchart":"' + this.state.record2.id + '"}',
135 refType: 'table',
136 fields: ['id', 'code', 'name'],
137 orderby: 'code asc',
138 displayFields: ['id', 'code', 'name']
139 }),
140 disabled: !this.state.record2.code,
141 value: this.state.recordValue,
142 placeholder: this.props.item.placeholder,
143 notFoundContent: this.props.item.notFoundContent,
144 onChange: this.onChange.bind(this, 'recordValue')
145 })) : _react["default"].createElement(_ReferComponents["default"], {
146 url: ReferDataUrl,
147 fixedData: _extends({}, fixedData, {
148 refCode: this.state.record.code
149 }),
150 disabled: !this.state.record.code,
151 value: this.state.recordValue,
152 placeholder: this.props.item.placeholder,
153 notFoundContent: this.props.item.notFoundContent,
154 onChange: this.onChange.bind(this, 'recordValue')
155 })))));
156 }
157 }]);
158
159 return FixedComponents;
160}(_react["default"].Component);
161
162FixedComponents.propTypes = {
163 item: _propTypes["default"].object,
164 ReferDataUrl: _propTypes["default"].string,
165 fixedData: _propTypes["default"].object
166};
167FixedComponents.defaultProps = {
168 item: {},
169 ReferDataUrl: '',
170 fixedData: {}
171};
172(0, _reactLifecyclesCompat.polyfill)(FixedComponents);
173var _default = FixedComponents;
174exports["default"] = _default;
\No newline at end of file