Browse Source

feat: 导出自检增加必须非空值属性处理

vian 5 years atrás
parent
commit
8aaaeb3157

+ 9 - 2
web/building_saas/standard_interface/export/base.js

@@ -103,7 +103,7 @@ const INTERFACE_EXPORT_BASE = (() => {
   function Element(name, attrs = []) {
     this.name = name;
     this.attrs = attrs;
-    check(this.attrs);
+    this.attrs = check(this.attrs);
     handleXMLEntity(this.attrs);
     this.children = [];
   }
@@ -154,15 +154,21 @@ const INTERFACE_EXPORT_BASE = (() => {
    * 检查
    * 创建节点时检查节点的数据(原本是用于自检,现在来处理默认值)
    * @param {Array}datas 需要检查的属性数据
-   * @return {void}
+   * @return {Array}
    * */
   function check(datas) {
+    const rst = [];
     for (const data of datas) {
       // 错误提示
       if (data.fail && data.fail.hint) {
         _cache.failList.push(data.fail);
       }
       const isHasValue = hasValue(data.value);
+      // 设置了mustHasValue,意味着必须要有值才输出该属性
+      if (data.mustHasValue && !isHasValue) {
+        continue;
+      }
+      rst.push(data);
       // 值统一转换成String,并且处理各类型属性空值时的默认取值
       data.value = !isHasValue ?
         DEFAULT_VALUE[data.type] ?
@@ -199,6 +205,7 @@ const INTERFACE_EXPORT_BASE = (() => {
         data.value = DEFAULT_VALUE[TYPE.BOOL];
       }
     }
+    return rst;
   }
   // 等待一段时间
   function setTimeoutSync(handle, time) {

+ 0 - 1
web/building_saas/standard_interface/import/anhui_chizhou.js

@@ -18,7 +18,6 @@ INTERFACE_IMPORT = (() => {
       UTIL: {
         getValue,
         arrayValue,
-        getBool,
         extractItemsRecur,
       }
     } = INTERFACE_EXPORT_BASE;