zck 1 year ago
parent
commit
5167514846

+ 30 - 7
src/view/performance/09-workOrderVerification/index.vue

@@ -2144,20 +2144,43 @@ const handleDelete = () => {
 }
 
 // 导出
-const exportExcel = ()=>{
+const exportExcel = () => {
   const el = document.getElementById('table');
-  // 文件名
   const filename = '导出核验单EXCEL.xlsx';
-  const wb = XLSX.utils.table_to_book(el, { raw: true });
-  const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
+  
+  // 获取表格数据
+  const ws = XLSX.utils.table_to_sheet(el);
+  
+  // 找出需要保留为数字的列(假设'sl'列是数字)
+  const numCols = ['qczl_fp']; // 添加其他需要保留数字的列名
+  
+  // 遍历工作表数据,将指定列转换为数字
+  for (const cell in ws) {
+    if (cell[0] === '!') continue; // 跳过特殊属性
+    
+    const colName = cell.replace(/[0-9]/g, ''); // 获取列字母
+    const header = ws[colName + '1']; // 获取表头
+    
+    if (header && numCols.includes(header.v)) {
+      // 如果是数字列,尝试转换为数字
+      const value = ws[cell].v;
+      if (!isNaN(value) && value !== '') {
+        ws[cell].t = 'n'; // 设置为数字类型
+        ws[cell].v = Number(value); // 转换为数字
+      }
+    }
+  }
+  
+  // 创建工作簿并导出
+  const wb = XLSX.utils.book_new();
+  XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
+  
   try {
-    FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
+    XLSX.writeFile(wb, filename);
   } catch (e) {
     console.log(e);
   }
-  return wbout;
 }
-
 </script>
 
 <style>

+ 21 - 6
src/view/performance/12-orderAccounting/componets/hjfpfb.vue

@@ -165,17 +165,32 @@ const tableData = ref([])
 const isLoading = ref(false)
 
 const handleExcel = () => {
-  const el = document.getElementById('table');
-  // 文件名
   const filename = '导出核检废品EXCEL.xlsx';
-  const wb = XLSX.utils.table_to_book(el, { raw: true });
-  const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
+  
+  // 准备表头映射关系
+  const headers = tableColumns.value.map(col => col.label);
+  
+  // 准备数据 - 将 prop 映射为 label
+  const data = tableData.value.map(row => {
+    const newRow = {};
+    tableColumns.value.forEach(col => {
+      newRow[col.label] = row[col.prop];
+    });
+    return newRow;
+  });
+  
+  // 创建工作表
+  const ws = XLSX.utils.json_to_sheet(data, { header: headers });
+  
+  // 创建工作簿并导出
+  const wb = XLSX.utils.book_new();
+  XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
+  
   try {
-    FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
+    XLSX.writeFile(wb, filename);
   } catch (e) {
     console.log(e);
   }
-  return wbout;
 }
 
 const handleSearch = async() => {

+ 3 - 3
src/view/yunyin/shengchanguanli/components/print.vue

@@ -28,17 +28,17 @@
     </el-row>
     <el-row>
       <el-form-item label="印件名称:" prop="currentProcess" class="mab" >
-        <el-input v-model="form['yjmc']" placeholder="" style="width: 480px;" />
+        <el-input v-model="form['yjmc']" placeholder="" style="width: 360px;" />
       </el-form-item>
     </el-row>
     <el-row>
       <el-form-item label="制单:" prop="currentProcess" class="mab" label-width="70">
-        <el-input v-model="form['zd']" placeholder="" style="width: 480px;" />
+        <el-input v-model="form['zd']" placeholder="" style="width: 360px;" />
       </el-form-item>
     </el-row>
     <el-row>
       <el-form-item label="审核:" prop="currentProcess" class="mab" label-width="70">
-        <el-input v-model="form['sh']" placeholder="" style="width: 480px;"/>
+        <el-input v-model="form['sh']" placeholder="" style="width: 360px;"/>
       </el-form-item>
     </el-row>
     <div class="dialog-footer" style="text-align: right; margin-top: 30px;">