Преглед изворни кода

feat:导出接口增加自检

vian пре 5 година
родитељ
комит
c3ac2af7eb

+ 1 - 0
public/scHintBox.html

@@ -187,6 +187,7 @@
     };
 
     $('#hintBox_form').on('hide.bs.modal', function() {
+        $('#hintBox_caption').removeClass('export-check');
         if($.bootstrapLoading) $.bootstrapLoading.end();
         return;
     });

+ 5 - 0
web/building_saas/css/custom.css

@@ -594,4 +594,9 @@ input.text-right {
   100% {
     transform: translateX(420px);
   }
+}
+
+.export-check{
+  overflow: auto;
+  height: 400px;
 }

+ 1 - 1
web/building_saas/standard_interface/export/anhui_maanshan.js

@@ -48,7 +48,7 @@ INTERFACE_EXPORT = (() => {
     // 节点定义--------------------------------
 
     const subArea = areaKey.split('@')[1];
-
+    
     // 建设项目基本信息
     function JingJiBiao(projectName, information) {
       const taxModeMap = {

+ 26 - 1
web/building_saas/standard_interface/export/base.js

@@ -57,6 +57,8 @@ const INTERFACE_EXPORT_BASE = (() => {
 
   // 缓存项 不需要的时候需要清空
   const _cache = {
+    // 错误提示列表
+    failList: [],
     // 项目数据(不包含详细数据,项目管理数据)
     projectData: {},
     // 当前导出类型,默认投标
@@ -79,6 +81,7 @@ const INTERFACE_EXPORT_BASE = (() => {
   }
   // 清空缓存项
   function clear() {
+    _cache.failList = [];
     _cache.projectData = {};
     _cache.exportKind = EXPORT_KIND.BID_SUBMISSION;
     _cache.tenderDetailMap = {};
@@ -155,6 +158,10 @@ const INTERFACE_EXPORT_BASE = (() => {
    * */
   function check(datas) {
     for (const data of datas) {
+      // 错误提示
+      if (data.fail && data.fail.hint) {
+        _cache.failList.push(data.fail);
+      }
       const isHasValue = hasValue(data.value);
       // 值统一转换成String,并且处理各类型属性空值时的默认取值
       data.value = !isHasValue ?
@@ -643,6 +650,23 @@ const INTERFACE_EXPORT_BASE = (() => {
       .join('');
   }
 
+  // 将错误提示数据进行分类处理
+  function transformFailList(failList) {
+    const grouped = _.groupBy(failList, 'type');
+    const rst = [];
+    Object
+      .entries(grouped)
+      .forEach(([type, items]) => {
+        if (type) {
+          rst.push(`<span style="font-weight: bold">${type}:</span>`);
+        }
+        items.forEach(({ hint }) => {
+          rst.push(hint);
+        });
+      });
+    return rst;
+  }
+
   const UTIL = Object.freeze({
     hasValue,
     setTimeoutSync,
@@ -668,7 +692,8 @@ const INTERFACE_EXPORT_BASE = (() => {
     getParsedData,
     setupCode,
     getHan,
-    getNowFormatTime
+    getNowFormatTime,
+    transformFailList,
   });
 
   // 开始标签

+ 16 - 1
web/building_saas/standard_interface/export/view.js

@@ -5,11 +5,13 @@
  * @date 2019/6/5
  * @version
  */
-//导出接口相关
+
+// 导出接口相关
 const EXPORT_VIEW = (() => {
   'use strict';
 
   const _base = INTERFACE_EXPORT_BASE;
+  const _util = _base.UTIL;
   const _cache = _base.CACHE;
   // 导出数据缓存,为了自检完后,再导出的时候不需要重新运行相关提取程序。(暂时取消了自检,但还是留着这个缓存机制)
   let _exportCache = [];
@@ -23,6 +25,12 @@ const EXPORT_VIEW = (() => {
     _exportCache = [];
     _cache.clear();
   }
+  // 设置提示高度样式
+  function setHeightByInfo(infos) {
+    if (infos.length > 20) {
+      $('#hintBox_caption').addClass('export-check');
+    }
+  }
   //事件监听
   function exportListener() {
     // 导出接口
@@ -52,6 +60,12 @@ const EXPORT_VIEW = (() => {
             const requestForSummaryInfo = INTERFACE_EXPORT.requestForSummaryInfo || null;
             const projectID = projectObj.project.ID();
             const exportData = await _base.extractExportData(INTERFACE_EXPORT.entry, requestForSummaryInfo, boqType, areaKey, projectID, userID);
+            const failList = _util.transformFailList(_cache.getItem('failList'));
+            if (failList.length) {
+              // 自检提示错误,打断导出
+              setHeightByInfo(failList);
+              throw failList.join('<br/>');
+            }
             _exportCache.push(...exportData);
           }
         }
@@ -64,6 +78,7 @@ const EXPORT_VIEW = (() => {
         console.log(err);
         alert(err);
       } finally {
+        _cache.setItem('failList', []);
         pr.end();
         setTimeout(() => {
           STATE.exporting = false;