Browse Source

导入Excel预算价

chenshilong 3 years atrás
parent
commit
0cc49a3886
1 changed files with 34 additions and 10 deletions
  1. 34 10
      web/building_saas/main/js/views/project_glj_view.js

+ 34 - 10
web/building_saas/main/js/views/project_glj_view.js

@@ -1420,6 +1420,24 @@ projectGljObject = {
     if ($("#freight_ration").is(":visible") && materialCalcObj.freightRationSpread) materialCalcObj.freightRationSpread.refresh();
     if ($("#price_ration").is(":visible") && materialCalcObj.priceRationSpread) materialCalcObj.priceRationSpread.refresh();
   },
+  getColIndex: function (colName) {
+    const headerArr = this.projectGljSetting.header;
+    for (let index = 0; index < headerArr.length; index++) {
+      const e = headerArr[index];
+      if (e.headerName === colName) return index;
+    }
+    return -1;
+  },
+  getSheetDataRowAndPrice: function (gljIndex) {
+    const pGlj = projectObj.project.projectGLJ.datas.gljMap[gljIndex];
+    if (!pGlj) return null;
+    const sheetDataArr = this.projectGljSheetData;
+    for (let index = 0; index < sheetDataArr.length; index++) {
+      const e = sheetDataArr[index];
+      if (e.id === pGlj.id) return { row: index, price: e.unit_price.market_price };
+    }
+    return null;
+  },
 };
 
 function getProjectResizeEles() {
@@ -1784,7 +1802,8 @@ $(function () {
       sheetData[0][1].value === "名称" &&
       sheetData[0][2].value === "规格" &&
       sheetData[0][3].value === "单位" &&
-      sheetData[0][4].value === "预算价";
+      sheetData[0][4].value === "类型" &&
+      sheetData[0][5].value === "预算价";
     if (!isRightHead) throw err;
 
     let rst = [];
@@ -1794,7 +1813,8 @@ $(function () {
         name: sheetData[row][1].value,
         specs: sheetData[row][2].value,
         unit: sheetData[row][3].value,
-        unitPrice: sheetData[row][4].value,
+        type: sheetData[row][4].value,
+        unitPrice: sheetData[row][5].value,
       };
       rst.push(rowData);
     }
@@ -1859,20 +1879,24 @@ $(function () {
       }
 
       showAlert("正在导入预算价...", true);
-      //
-      const gljList = projectObj.project.projectGLJ.datas.gljList;
-      const priceCol = 5;
-      console.log(gljList);
-      console.log(projectGljObject.projectGljSetting);
+      debugger;
+      const priceCol = projectGljObject.getColIndex("预算价");
+      console.log(projectGljObject.projectGljSheetData);
       const changeInfo = [];
       for (const pd of priceData) {
         const idx = gljUtil.getIndex(pd, gljKeyArray);
-        const pGlj = projectObj.project.projectGLJ.selected;
-        if (pGlj.unit_price.market_price !== pd.unitPrice) {
-          changeInfo.push({ row: 6, col: priceCol, value: pd.unitPrice });
+        const pGlj = projectGljObject.getSheetDataRowAndPrice(idx);
+        if (pGlj && pGlj.price !== pd.unitPrice) {
+          changeInfo.push({ row: pGlj.row, col: priceCol, value: pd.unitPrice });
         }
       }
       if (changeInfo.length > 0) projectGljObject.batchUpdateProjectGLJ(changeInfo, "projectGljSheet");
+      $("#showAlert").hide();
+      $(me).removeClass("disabled");
+      $("#importPriceForm").modal("hide");
+      if ($.bootstrapLoading.isLoading()) {
+        $.bootstrapLoading.end();
+      }
     } catch (err) {
       console.log(err);
       showAlert(err);