PsrControl.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Button, Input, InputNumber, Select, Spin } from 'antd';
  2. import React, { useState } from 'react';
  3. const { Option } = Select;
  4. function PsrControl(props) {
  5. const { sheetRef } = props;
  6. const [value1, setValue1] = useState(0.15);
  7. const [value2, setValue2] = useState(0.25);
  8. const [value3, setValue3] = useState(14096800);
  9. const [loading, setLoading] = useState(false);
  10. const changeProjectType = type => {
  11. sheetRef.current.luckysheet.setCellValue(101, 1, type, {
  12. order: 0,
  13. });
  14. sheetRef.current.luckysheet.setCellFormat(101, 1, 'ct', { fa: 'General', t: 'g' });
  15. sheetRef.current.luckysheet.refreshFormula();
  16. };
  17. const changeBiddingType = type => {
  18. sheetRef.current.luckysheet.setCellValue(102, 1, type, {
  19. order: 0,
  20. });
  21. sheetRef.current.luckysheet.setCellFormat(102, 1, 'ct', { fa: 'General', t: 'g' });
  22. sheetRef.current.luckysheet.refreshFormula();
  23. };
  24. const goalSeek = (type, value) => {
  25. setLoading(true);
  26. try {
  27. sheetRef.current.goalSeek(type, value);
  28. } catch (error) {}
  29. setLoading(false);
  30. };
  31. return (
  32. <div style={{ marginBottom: 20 }}>
  33. <Spin spinning={loading}>
  34. <Input
  35. value={value1}
  36. style={{ width: 160, marginRight: 20 }}
  37. onChange={e => setValue1(e.target.value)}
  38. addonAfter={<a onClick={() => goalSeek(1, value1)}>净利率</a>}
  39. />
  40. <Input
  41. value={value2}
  42. style={{ width: 160, marginRight: 20 }}
  43. onChange={e => setValue2(e.target.value)}
  44. addonAfter={<a onClick={() => goalSeek(2, value2)}>毛利率</a>}
  45. />
  46. <Input
  47. value={value3}
  48. style={{ width: 220, marginRight: 20 }}
  49. onChange={e => setValue3(e.target.value)}
  50. addonAfter={<a onClick={() => goalSeek(3, value3)}>合同总价</a>}
  51. />
  52. <Select
  53. placeholder="项目类别"
  54. onChange={changeProjectType}
  55. style={{ width: 120, marginRight: 20 }}
  56. >
  57. <Option value="UF">UF</Option>
  58. <Option value="RO/NF">RO/NF</Option>
  59. <Option value="UF&RO/NF">UF+RO/NF</Option>
  60. <Option value="MBR">MBR</Option>
  61. <Option value="其他">其他</Option>
  62. </Select>
  63. <Select placeholder="招标类型" onChange={changeBiddingType} style={{ width: 120 }}>
  64. <Option value="货物招标">货物招标</Option>
  65. <Option value="服务招标">服务招标</Option>
  66. <Option value="工程招标">工程招标</Option>
  67. </Select>
  68. </Spin>
  69. </div>
  70. );
  71. }
  72. export default PsrControl;