No Description

index.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var inherits = require('../inherits-c86d64c1.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. require('react-dom');
  8. var Modal = require('../Modal/index.js');
  9. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  10. require('../defineProperty-ba7cd53d.js');
  11. require('../_commonjsHelpers-72d386ba.js');
  12. require('../index-44e17595.js');
  13. require('antd');
  14. var WantedPublishView = require('../WantedPublishView/index.js');
  15. var css = ".WantedPublishModal_modalBg__3OlNh {\n background: white;\n display: flex;\n justify-content: center;\n flex-direction: column;\n align-items: center;\n padding: 16px;\n text-align: center;\n border-radius: 4px;\n}\n";
  16. var styles = {
  17. "modalBg": "WantedPublishModal_modalBg__3OlNh"
  18. };
  19. styleInject_es.styleInject(css);
  20. var WantedPublishModal =
  21. /*#__PURE__*/
  22. function (_Component) {
  23. inherits._inherits(WantedPublishModal, _Component);
  24. function WantedPublishModal(props) {
  25. var _this;
  26. inherits._classCallCheck(this, WantedPublishModal);
  27. _this = inherits._possibleConstructorReturn(this, inherits._getPrototypeOf(WantedPublishModal).call(this, props));
  28. _this.handleModalShow = function () {};
  29. _this.handleClose = function () {
  30. var handleConfirm = _this.props.handleConfirm;
  31. if (handleConfirm) {
  32. _this.handleUpdateCurrentWanted(_this.state.current_wanted, function (value) {
  33. handleConfirm(Number(value).toFixed(2));
  34. });
  35. }
  36. _this.setState({
  37. modalVisible: false
  38. });
  39. };
  40. _this.handleUpdateCurrentWanted = function (value, afterUpdate) {
  41. if (!value) return;
  42. var result;
  43. result = value;
  44. if (parseInt("".concat(value), 10) === value) {
  45. result = Number(value);
  46. }
  47. if (!result) return;
  48. if (result > 10000) result = 10000;
  49. if (result < 5) result = 5;
  50. _this.setState({
  51. current_wanted: result
  52. }, function () {
  53. return afterUpdate && afterUpdate(result);
  54. });
  55. };
  56. _this.clearCurrentWanted = function (cb) {
  57. _this.setState({
  58. current_wanted: null
  59. }, function () {
  60. return cb();
  61. });
  62. };
  63. _this.state = {
  64. modalVisible: false,
  65. current_wanted: null
  66. };
  67. return _this;
  68. }
  69. inherits._createClass(WantedPublishModal, [{
  70. key: "renderMain",
  71. value: function renderMain() {
  72. var _this2 = this;
  73. var current_wanted = this.state.current_wanted;
  74. return React__default.createElement(WantedPublishView.default, {
  75. wrapperClass: styles.modalBg,
  76. current_wanted: current_wanted,
  77. InputWantedValueChange: function InputWantedValueChange(v) {
  78. return _this2.setState({
  79. current_wanted: v
  80. });
  81. },
  82. InputWantedPressEnter: function InputWantedPressEnter(v) {
  83. return _this2.handleUpdateCurrentWanted(v, _this2.handleClose);
  84. },
  85. InputWantedOnBlur: function InputWantedOnBlur(v) {
  86. return _this2.handleUpdateCurrentWanted(v);
  87. },
  88. InputWantedClear: function InputWantedClear() {
  89. return _this2.clearCurrentWanted(_this2.handleClose);
  90. },
  91. CloseFunction: this.handleClose
  92. });
  93. }
  94. }, {
  95. key: "render",
  96. value: function render() {
  97. var _this3 = this;
  98. return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
  99. onClick: function onClick() {
  100. return _this3.setState({
  101. modalVisible: true
  102. });
  103. }
  104. }, this.props.children), React__default.createElement(Modal.default, Object.assign({
  105. visible: this.state.modalVisible,
  106. onCancel: this.handleClose
  107. }, this.props.modalConfig), this.renderMain()));
  108. }
  109. }]);
  110. return WantedPublishModal;
  111. }(React.Component);
  112. exports.WantedPublishModal = WantedPublishModal;
  113. exports.default = WantedPublishModal;
  114. //# sourceMappingURL=index.js.map