Browse Source

feat: 上传参数调整

zhangjie 6 months ago
parent
commit
51a7da68a6
2 changed files with 6 additions and 1 deletions
  1. 2 1
      src/modules/card/api.js
  2. 4 0
      src/plugins/utils.js

+ 2 - 1
src/modules/card/api.js

@@ -1,5 +1,6 @@
 import { $postParam, $post } from "@/plugins/axios";
 import { fileMD5 } from "@/plugins/md5";
+import { isNull } from "@/plugins/utils";
 
 export const cardConfigInfos = (id) => {
   return $postParam("/api/admin/basic/card_rule/get_one", { id });
@@ -31,7 +32,7 @@ export const saveCard = async (datas, config = {}) => {
       const md5 = await fileMD5(file);
       formData.append(`${key}Md5`, md5);
     } else {
-      formData.append(key, val);
+      if (!isNull(val)) formData.append(key, val);
     }
   }
 

+ 4 - 0
src/plugins/utils.js

@@ -424,6 +424,10 @@ export function parseHrefParam(urlStr, paramName = null) {
   return params;
 }
 
+export function isNull(val) {
+  return val === null || val === "null" || val === "";
+}
+
 export function objFilterNull(obj) {
   let nobj = {};
   Object.entries(obj).forEach(([key, val]) => {