暂无描述

index.js 4.6KB

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