浏览代码

fix: 信息价保存ai填值bug

vian 7 月之前
父节点
当前提交
059a29fab6
共有 2 个文件被更改,包括 19 次插入6 次删除
  1. 9 0
      web/maintain/price_info_lib/js/common.js
  2. 10 6
      web/maintain/price_info_lib/js/priceEmpty.js

+ 9 - 0
web/maintain/price_info_lib/js/common.js

@@ -73,6 +73,15 @@ function getRowDiffData(curRowData, cacheRowData, headers) {
   return item;
 }
 
+function getRowAllData(curRowData, headers) {
+  let item = {};
+  headers.forEach(({ dataCode }) => {
+    const curValue = curRowData[dataCode];
+    item[dataCode] = curValue || '';
+  });
+  return item;
+}
+
 const TIME_OUT = 1000 * 20;
 const libID = window.location.search.match(/libID=([^&]+)/)[1];
 

+ 10 - 6
web/maintain/price_info_lib/js/priceEmpty.js

@@ -115,7 +115,7 @@ const EMPTY_BOOK = (() => {
   }
 
   // 编辑处理
-  async function handleEdit(changedCells, diffMap, needRefresh) {
+  async function handleEdit(changedCells, diffMap, needRefresh, saveAll) {
     const postData = []; // 请求用
     // 更新缓存用
     const updateData = [];
@@ -130,7 +130,7 @@ const EMPTY_BOOK = (() => {
             if (diffMap) {
               diffData = diffMap[row];
             } else {
-              diffData = getRowDiffData(rowData, cache[row], setting.header);
+              diffData = saveAll ? getRowAllData(rowData, setting.header) : getRowDiffData(rowData, cache[row], setting.header);
             }
             if (diffData) {
               // 改一行, 实际可能是改多行,表格一行数据是多行合并显示的
@@ -158,7 +158,9 @@ const EMPTY_BOOK = (() => {
         }
       });
       if (postData.length) {
-        $.bootstrapLoading.start();
+        if (!saveAll) {
+          $.bootstrapLoading.start();
+        }
         await ajaxPost('/priceInfo/editPriceData', { postData }, TIME_OUT);
         // 更新缓存,先更新然后删除,最后再新增,防止先新增后缓存数据的下标与更新、删除数据的下标对应不上
         updateData.forEach(item => {
@@ -198,7 +200,9 @@ const EMPTY_BOOK = (() => {
         if (deleteData.length || insertData.length || needRefresh) {
           showData(workBookObj.sheet, cache, setting.header);
         }
-        $.bootstrapLoading.end();
+        if (!saveAll) {
+          $.bootstrapLoading.end();
+        }
         CLASS_BOOK.reload();
       }
     } catch (err) {
@@ -364,7 +368,7 @@ const EMPTY_BOOK = (() => {
 
       // 分块进行ai匹配
       const step = 100 / (chunks.length || 1);
-      for (const chunk of chunks) {
+      for (const chunk of [chunks[0]]) {
         const listA = [];
         const listB = [];
         const summaryData = [];
@@ -472,7 +476,7 @@ const EMPTY_BOOK = (() => {
       let percent = 0;
       const step = 100 / (chunks.length || 1);
       for (const chunk of chunks) {
-        await handleEdit(chunk);
+        await handleEdit(chunk, undefined, undefined, true);
         percent += parseInt(`${step}`);
         $("#progress_modal_bar").css('width', `${percent}%`);
         await setTimeoutSync(200);