Procházet zdrojové kódy

导出材料预算价Excel。

chenshilong před 3 roky
rodič
revize
374ca83263

+ 1 - 0
web/building_saas/glj/html/project_glj.html

@@ -60,6 +60,7 @@
       <div class="main-content col p-0 " id="project-glj-main" style="overflow: hidden">
             <div class="top-content" id="projectGljTop" style="overflow: hidden;">
             <div class="main-data-top left" id="project_glj_sheet"></div>
+            <div id="project_glj_sheet_Temp" style="display: none"></div>
          </div>
          <div class="resize-y" id="projectGljResize"></div>
             <div class="bottom-content" id="projectGljBottom">

+ 56 - 3
web/building_saas/main/js/views/project_glj_view.js

@@ -1281,7 +1281,7 @@ projectGljObject = {
             return compilationName === "四川养护(2013)" || compilationName === "部颁2018计价标准";
           },
           callback: function (key, opt) {
-            $("#electrovalenceDiv").modal("show");
+            me.ExportExcelFile();
           },
         },
         importPriceFromExcel: {
@@ -1438,6 +1438,59 @@ projectGljObject = {
     }
     return null;
   },
+  ExportExcelFile: function () {
+    const excelIO = new GC.Spread.Excel.IO();
+    console.log(projectGljObject.projectGljSheetData);
+    let workbook = new GC.Spread.Sheets.Workbook(document.getElementById("#project_glj_sheet_Temp"));
+    let sheet = workbook.sheets[0];
+    workbook.commandManager().execute({ cmd: "renameSheet", sheetName: "Sheet1", name: "材料预算价" });
+    sheet.getCell(0, 0).value("编号");
+    sheet.getCell(0, 1).value("名称");
+    sheet.getCell(0, 2).value("规格");
+    sheet.getCell(0, 3).value("单位");
+    sheet.getCell(0, 4).value("类型");
+    sheet.getCell(0, 5).value("预算价");
+    let style = new GC.Spread.Sheets.Style();
+    style.font = "bold 15px Arial";
+    sheet.setStyle(0, -1, style, GC.Spread.Sheets.SheetArea.viewport);
+
+    sheet.setColumnWidth(0, 100);
+    sheet.setColumnWidth(1, 200);
+    sheet.setColumnWidth(2, 150);
+    sheet.setColumnWidth(3, 80);
+    sheet.setColumnWidth(4, 80);
+    sheet.setColumnWidth(5, 90);
+
+    sheet.getRange(-1, 0, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign.center); // 第1列居中对齐
+    sheet.getRange(-1, 3, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+    sheet.getRange(-1, 4, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+    sheet.getRange(-1, 5, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
+    sheet.getRange(0, -1, 1, -1).hAlign(GC.Spread.Sheets.HorizontalAlign.center); // 标题行居中对齐
+
+    for (let i = 0; i < projectGljObject.projectGljSheetData.length; i++) {
+      const e = projectGljObject.projectGljSheetData[i];
+      sheet.getCell(i + 1, 0).value(e.code);
+      sheet.getCell(i + 1, 1).value(e.name);
+      sheet.getCell(i + 1, 2).value(e.specs);
+      sheet.getCell(i + 1, 3).value(e.unit);
+      sheet.getCell(i + 1, 4).value(e.type);
+      sheet.getCell(i + 1, 5).value(e.unit_price.market_price);
+    }
+
+    let json = JSON.stringify(workbook.toJSON());
+    excelIO.save(
+      json,
+      function (blob) {
+        const fileName = "汇总工料机预算价.xlsx";
+        saveAs(blob, fileName);
+      },
+      function (e) {
+        if (e.errorCode === 1) {
+          alert(e.errorMessage);
+        }
+      }
+    );
+  },
 };
 
 function getProjectResizeEles() {
@@ -1792,6 +1845,7 @@ $(function () {
   }
 
   function getExcelData(sheets) {
+    debugger;
     const err = "当前Excel文件格式不正确,请参考导出Excel材料预算价文件!";
     const sheet = sheets["材料预算价"];
     if (!sheet) throw err;
@@ -1807,7 +1861,7 @@ $(function () {
     if (!isRightHead) throw err;
 
     let rst = [];
-    for (let row = 1; row < sheet.rowCount; row++) {
+    for (let row = 1; row < sheet.rows.length; row++) {
       const rowData = {
         code: sheetData[row][0].value,
         name: sheetData[row][1].value,
@@ -1879,7 +1933,6 @@ $(function () {
       }
 
       showAlert("正在导入预算价...", true);
-      debugger;
       const priceCol = projectGljObject.getColIndex("预算价");
       console.log(projectGljObject.projectGljSheetData);
       const changeInfo = [];

+ 4 - 4
web/common/html/header.html

@@ -73,11 +73,11 @@
                     <!--<a class="dropdown-item" href="/web/common/html/pdfViewer.html?type=userGuide" target="_blank">用户手册</a>
                     <a class="dropdown-item" href="/web/common/html/pdfViewer.html?type=upgradeGuide" target="_blank">升级说明</a>-->
                     <% if (compilationName === '公路造价(2018)') { %>
-                        <a class="dropdown-item" href="http://doc.zhzdwd.com/docs/glyyhsc" target="_blank">用户手册</a>
-                        <a class="dropdown-item" href="http://doc.zhzdwd.com/docs/glyun/glyun-1cfge2jui6nh9" target="_blank">升级说明</a>
+                        <a class="dropdown-item" href="https://doc.zhzdwd.com/docs/glyyhsc" target="_blank">用户手册</a>
+                        <a class="dropdown-item" href="https://doc.zhzdwd.com/docs/glyun/glyun-1cfge2jui6nh9" target="_blank">升级说明</a>
                     <% } else { %>
-                        <a class="dropdown-item" href="http://doc.zhzdwd.com/docs/yh_yhsc/yh_yhsc-1bup3dm7iacsg" target="_blank">用户手册</a>
-                        <a class="dropdown-item" href="http://doc.zhzdwd.com/docs/yanghuUpdate" target="_blank">升级说明</a>
+                        <a class="dropdown-item" href="https://doc.zhzdwd.com/docs/yh_yhsc/yh_yhsc-1bup3dm7iacsg" target="_blank">用户手册</a>
+                        <a class="dropdown-item" href="https://doc.zhzdwd.com/docs/yanghuUpdate" target="_blank">升级说明</a>
                     <% } %>
                     <a class="dropdown-item" href="https://smartcost.com.cn/" target="_blank">纵横官网</a>
                     <!--  <a class="dropdown-item" href="#">动画教程</a>-->