1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { queryRecordSheet } from '@/services/boom';
- import LuckySheet from '../Detail/LuckySheet';
- import react, { useRef } from 'react';
- import LuckyExcel from 'luckyexcel';
- import { Button, message } from 'antd';
- import { getToken } from '@/utils/utils';
- import moment from 'moment';
- import uploadExcelByUrl from '@/utils/uploadExcelByUrl';
- const TEMPLATE_URL =
- 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/doc/contract/2023-06-29/ed0d5dcd-6ce0-40df-9d17-a1f69245dbb9.xlsx';
- const TEMPLATE_URL2 =
- 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/ContractTemplate.xlsx';
- function Index(props) {
- const { versionId = 2554 } = props;
- const sheetRef = useRef();
- const luckysheetRef = useRef();
- const onClick = async type => {
- let data = await uploadExcelByUrl(type, versionId, {
- project_name: 'test水厂',
- project_full_code: 'TESTCODE',
- });
- luckysheetRef.current.destroy();
- luckysheetRef.current.create({
- data,
- lang: 'zh',
- showinfobar: false,
- showstatisticBar: false,
- hook: {
- cellMousedown: (cell, position, sheet) => {
- console.log(cell, position, sheet);
- },
- cellUpdated: () => {
- luckysheetRef.current.refreshFormula();
- },
- },
- });
- };
- const handleLoad = () => {
- let contentWindow = sheetRef.current.contentWindow;
- luckysheetRef.current = contentWindow.luckysheet;
- };
- return (
- <div>
- <Button type="primary" style={{ marginRight: 20 }} onClick={() => onClick(3)}>
- 导入投标投标
- </Button>
- <Button type="primary" onClick={() => onClick(4)}>
- 导入合同模板
- </Button>
- <iframe
- style={{
- width: '100%',
- height: '80vh',
- }}
- ref={sheetRef}
- onLoad={handleLoad}
- src="/luckysheet.html"
- ></iframe>
- </div>
- );
- }
- export default Index;
|