|
|
@@ -1503,53 +1503,53 @@ import LuckyExcel from 'luckyexcel';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //导出到Excel按钮
|
|
|
- const jcToExcel = () => {
|
|
|
- const el = document.getElementById('Exceltable');
|
|
|
- if (!el) {
|
|
|
- console.error('Table element not found!');
|
|
|
- return;
|
|
|
- }
|
|
|
- const filename = '工序大废品.xlsx';
|
|
|
- const wb = XLSX.utils.table_to_book(el, { raw: true });
|
|
|
- const ws = wb.Sheets[wb.SheetNames[0]]; // 获取第一个工作表
|
|
|
-
|
|
|
- // 获取工作表的范围
|
|
|
- const range = XLSX.utils.decode_range(ws['!ref']);
|
|
|
-
|
|
|
- // 遍历每一行(从第二行开始)
|
|
|
- for (let R = range.s.r + 1; R <= range.e.r + 1; ++R) {
|
|
|
- // 直接通过单元格地址访问F列和H列的单元格
|
|
|
- const cellF = ws[`F${R}`];
|
|
|
- const cellH = ws[`H${R}`];
|
|
|
-
|
|
|
- // 检查F列的单元格是否存在且其值是字符串类型
|
|
|
- if (cellF && typeof cellF.v === 'string') {
|
|
|
- const numF = Number(cellF.v);
|
|
|
- if (!isNaN(numF)) {
|
|
|
- // 修改单元格类型为数字,并更新值
|
|
|
- cellF.t = 'n';
|
|
|
- cellF.v = numF;
|
|
|
- }
|
|
|
- }
|
|
|
- // 检查H列的单元格是否存在且其值是字符串类型
|
|
|
- if (cellH && typeof cellH.v === 'string') {
|
|
|
- console.log(`H${R}: ${cellH.v}, Type before: ${cellH.t}`);
|
|
|
- const numH = Number(cellH.v);
|
|
|
- if (!isNaN(numH)) {
|
|
|
- // 修改单元格类型为数字,并更新值
|
|
|
- cellH.t = 'n';
|
|
|
- cellH.v = numH;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
|
|
|
- try {
|
|
|
- FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
|
|
|
- } catch (e) {
|
|
|
- console.error('Error saving file:', e);
|
|
|
- }
|
|
|
- };
|
|
|
+ //导出到Excel按钮
|
|
|
+ const jcToExcel = () => {
|
|
|
+ const el = document.getElementById('Exceltable');
|
|
|
+ if (!el) {
|
|
|
+ console.error('Table element not found!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const filename = '工序大废品.xlsx';
|
|
|
+ const wb = XLSX.utils.table_to_book(el, { raw: true });
|
|
|
+ const ws = wb.Sheets[wb.SheetNames[0]]; // 获取第一个工作表
|
|
|
+
|
|
|
+ // 获取工作表的范围
|
|
|
+ const range = XLSX.utils.decode_range(ws['!ref']);
|
|
|
+
|
|
|
+ // 遍历每一行(从第二行开始)
|
|
|
+ for (let R = range.s.r + 1; R <= range.e.r + 1; ++R) {
|
|
|
+ // 直接通过单元格地址访问F列和H列的单元格
|
|
|
+ const cellF = ws[`F${R}`];
|
|
|
+ const cellH = ws[`H${R}`];
|
|
|
+
|
|
|
+ // 检查F列的单元格是否存在且其值是字符串类型
|
|
|
+ if (cellF && typeof cellF.v === 'string') {
|
|
|
+ const numF = Number(cellF.v);
|
|
|
+ if (!isNaN(numF)) {
|
|
|
+ // 修改单元格类型为数字,并更新值
|
|
|
+ cellF.t = 'n';
|
|
|
+ cellF.v = numF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 检查H列的单元格是否存在且其值是字符串类型
|
|
|
+ if (cellH && typeof cellH.v === 'string') {
|
|
|
+ console.log(`H${R}: ${cellH.v}, Type before: ${cellH.t}`);
|
|
|
+ const numH = Number(cellH.v);
|
|
|
+ if (!isNaN(numH)) {
|
|
|
+ // 修改单元格类型为数字,并更新值
|
|
|
+ cellH.t = 'n';
|
|
|
+ cellH.v = numH;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
|
|
|
+ try {
|
|
|
+ FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
|
|
|
+ } catch (e) {
|
|
|
+ console.error('Error saving file:', e);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
//日报表上传
|
|
|
const SubmitDailyProduction = async () => {
|