No Description

index.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import { a as _inherits, b as _classCallCheck, c as _possibleConstructorReturn, d as _getPrototypeOf, e as _createClass } from '../inherits-6cb67931.js';
  2. import React, { Component } from 'react';
  3. import 'react-dom';
  4. import Modal from '../Modal/index.js';
  5. import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
  6. import '../defineProperty-18999f8e.js';
  7. import '../_commonjsHelpers-97e6d7b1.js';
  8. import '../index-c9837619.js';
  9. import 'antd';
  10. import WantedPublishView from '../WantedPublishView/index.js';
  11. 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";
  12. var styles = {
  13. "modalBg": "WantedPublishModal_modalBg__3OlNh"
  14. };
  15. styleInject(css);
  16. var WantedPublishModal =
  17. /*#__PURE__*/
  18. function (_Component) {
  19. _inherits(WantedPublishModal, _Component);
  20. function WantedPublishModal(props) {
  21. var _this;
  22. _classCallCheck(this, WantedPublishModal);
  23. _this = _possibleConstructorReturn(this, _getPrototypeOf(WantedPublishModal).call(this, props));
  24. _this.handleModalShow = function () {};
  25. _this.handleClose = function () {
  26. var handleConfirm = _this.props.handleConfirm;
  27. if (handleConfirm) {
  28. _this.handleUpdateCurrentWanted(_this.state.current_wanted, function (value) {
  29. handleConfirm(Number(value).toFixed(2));
  30. });
  31. }
  32. _this.setState({
  33. modalVisible: false
  34. });
  35. };
  36. _this.handleUpdateCurrentWanted = function (value, afterUpdate) {
  37. if (!value) return;
  38. var result;
  39. result = value;
  40. if (parseInt("".concat(value), 10) === value) {
  41. result = Number(value);
  42. }
  43. if (!result) return;
  44. if (result > 10000) result = 10000;
  45. if (result < 5) result = 5;
  46. _this.setState({
  47. current_wanted: result
  48. }, function () {
  49. return afterUpdate && afterUpdate(result);
  50. });
  51. };
  52. _this.clearCurrentWanted = function (cb) {
  53. _this.setState({
  54. current_wanted: null
  55. }, function () {
  56. return cb();
  57. });
  58. };
  59. _this.state = {
  60. modalVisible: false,
  61. current_wanted: null
  62. };
  63. return _this;
  64. }
  65. _createClass(WantedPublishModal, [{
  66. key: "renderMain",
  67. value: function renderMain() {
  68. var _this2 = this;
  69. var current_wanted = this.state.current_wanted;
  70. return React.createElement(WantedPublishView, {
  71. wrapperClass: styles.modalBg,
  72. current_wanted: current_wanted,
  73. InputWantedValueChange: function InputWantedValueChange(v) {
  74. return _this2.setState({
  75. current_wanted: v
  76. });
  77. },
  78. InputWantedPressEnter: function InputWantedPressEnter(v) {
  79. return _this2.handleUpdateCurrentWanted(v, _this2.handleClose);
  80. },
  81. InputWantedOnBlur: function InputWantedOnBlur(v) {
  82. return _this2.handleUpdateCurrentWanted(v);
  83. },
  84. InputWantedClear: function InputWantedClear() {
  85. return _this2.clearCurrentWanted(_this2.handleClose);
  86. },
  87. CloseFunction: this.handleClose
  88. });
  89. }
  90. }, {
  91. key: "render",
  92. value: function render() {
  93. var _this3 = this;
  94. return React.createElement(React.Fragment, null, React.createElement("div", {
  95. onClick: function onClick() {
  96. return _this3.setState({
  97. modalVisible: true
  98. });
  99. }
  100. }, this.props.children), React.createElement(Modal, Object.assign({
  101. visible: this.state.modalVisible,
  102. onCancel: this.handleClose
  103. }, this.props.modalConfig), this.renderMain()));
  104. }
  105. }]);
  106. return WantedPublishModal;
  107. }(Component);
  108. export default WantedPublishModal;
  109. export { WantedPublishModal };
  110. //# sourceMappingURL=index.js.map