index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { queryRecordSheet } from '@/services/boom';
  2. import LuckySheet from '../Detail/LuckySheet';
  3. import react, { useRef } from 'react';
  4. import LuckyExcel from 'luckyexcel';
  5. import { Button, message } from 'antd';
  6. import { getToken } from '@/utils/utils';
  7. import moment from 'moment';
  8. import uploadExcelByUrl from '@/utils/uploadExcelByUrl';
  9. const TEMPLATE_URL =
  10. 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/doc/contract/2023-06-29/ed0d5dcd-6ce0-40df-9d17-a1f69245dbb9.xlsx';
  11. const TEMPLATE_URL2 =
  12. 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/ContractTemplate.xlsx';
  13. function Index(props) {
  14. const { versionId = 2554 } = props;
  15. const sheetRef = useRef();
  16. const luckysheetRef = useRef();
  17. const onClick = async type => {
  18. let data = await uploadExcelByUrl(type, versionId, 'test水厂');
  19. luckysheetRef.current.destroy();
  20. luckysheetRef.current.create({
  21. data,
  22. lang: 'zh',
  23. showinfobar: false,
  24. showstatisticBar: false,
  25. hook: {
  26. cellMousedown: (cell, position, sheet) => {
  27. console.log(cell, position, sheet);
  28. },
  29. cellUpdated: () => {
  30. luckysheetRef.current.refreshFormula();
  31. },
  32. },
  33. });
  34. };
  35. const handleLoad = () => {
  36. let contentWindow = sheetRef.current.contentWindow;
  37. luckysheetRef.current = contentWindow.luckysheet;
  38. };
  39. return (
  40. <div>
  41. <Button type="primary" style={{ marginRight: 20 }} onClick={() => onClick(3)}>
  42. 导入投标投标
  43. </Button>
  44. <Button type="primary" onClick={() => onClick(4)}>
  45. 导入合同模板
  46. </Button>
  47. <iframe
  48. style={{
  49. width: '100%',
  50. height: '80vh',
  51. }}
  52. ref={sheetRef}
  53. onLoad={handleLoad}
  54. src="/luckysheet.html"
  55. ></iframe>
  56. </div>
  57. );
  58. }
  59. export default Index;