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'; const TEMPLATE_URL = 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/bom/635/%E5%90%88%E5%90%8C%E6%96%87%E4%BB%B6/%E6%8A%95%E6%A0%87%E6%A8%A1%E6%9D%BF.xlsx'; const TEMPLATE_URL2 = 'https://water-service-test.oss-cn-hangzhou.aliyuncs.com/public/bom/psr.xlsx'; function Index(props) { const { versionId = 2376 } = props; const sheetRef = useRef(); const luckysheetRef = useRef(); const uploadExcelByUrl = type => { LuckyExcel.transformExcelToLuckyByUrl( type == 1 ? TEMPLATE_URL : TEMPLATE_URL2, '模板.xlsx', async (exportJson, luckysheetfile) => { // if (type == 2) initData(exportJson.sheets); let [record] = await getExcel(versionId); let len = exportJson.sheets.length; record.order = len - 1; record.index = len; record.status = '0'; const data = [...exportJson.sheets, record]; console.log(data); 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; }; const initData = sheets => { let r = 5, c = 12; // let dateCell = sheets[3].celldata.find(item => item.r == 1 && item.c == 3); let timer = sheets[3].celldata.filter(item => item.r == r && item.c >= c); timer.forEach((item, index) => { const cell = item.v; cell.f = `=EDATE(D2,${index})`; }); console.log(timer); }; return (