Lijy пре 5 месеци
родитељ
комит
13b9416dcf

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/business/addEditor.vue

@@ -42,6 +42,7 @@ import CustomerForm from '@components/common/formForm/formView.vue'
 import FoldingPanel from '@components/common/foldingPanel.vue';
 import NewAndModifiedRelatedProducts from '@pages/pageComponents/product/newAndModifiedRelatedProducts.vue'
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 const props = defineProps({
@@ -81,7 +82,7 @@ function onSubmit() {
       businessItemProductList: newList ? JSON.stringify(newList) : []
     }
     toastLoading('保存中', 0)
-    requests.post(NEW_BUSINESS_OPPORTUNITY_EDITING, { ...newForm }).then(() => {
+    requests.post(NEW_BUSINESS_OPPORTUNITY_EDITING, { ...commonUtil.getFromValue({ ...newForm }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/contacts/addEditor.vue

@@ -19,6 +19,7 @@ import requests from "@common/requests";
 import useToast from "@hooks/useToast"
 import { CONTACT_PERSON_ADDITION_EDITOR, CUSTOMER_ADDED_EDITOR } from "@hooks/useApi"
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 const router = useRouterStore()
 
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
@@ -38,7 +39,7 @@ function onSubmit() {
     }
     toastLoading('保存中', 0)
     const url = props.formValue.id ? '/contacts/updateContacts' : CONTACT_PERSON_ADDITION_EDITOR
-    requests.post(url, { ...props.formValue, ...res.data }).then(() => {
+    requests.post(url, { ...commonUtil.getFromValue({ ...props.formValue, ...res.data }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/contract/addEditor.vue

@@ -58,6 +58,7 @@ import { CONTRACT_ADDITION_EDITING, CONTRACT_EDITING, OBTAIN_THE_CONTRACT_REMITT
 import useRouterStore from "@store/useRouterStore.js";
 import FoldingPanel from '@components/common/foldingPanel.vue';
 import dayjs from 'dayjs';
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
@@ -106,7 +107,7 @@ function onSubmit() {
     }
 
     toastLoading('保存中', 0)
-    requests.post(props.formValue?.id ? CONTRACT_EDITING : CONTRACT_ADDITION_EDITING, { ...props.formValue, ...res.data, paymentListStr: JSON.stringify(paymentPlanList.value) }).then(() => {
+    requests.post(props.formValue?.id ? CONTRACT_EDITING : CONTRACT_ADDITION_EDITING, { ...commonUtil.getFromValue({ ...props.formValue, ...res.data, paymentListStr: JSON.stringify(paymentPlanList.value) }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/customer/addEditor.vue

@@ -19,6 +19,7 @@ import requests from "@common/requests";
 import useToast from "@hooks/useToast"
 import { CUSTOMER_ADDED_EDITOR } from "@hooks/useApi"
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
@@ -37,7 +38,7 @@ function onSubmit() {
       return
     }
     toastLoading('保存中', 0)
-    requests.post(CUSTOMER_ADDED_EDITOR, { ...props.formValue, ...res.data }).then(() => {
+    requests.post(CUSTOMER_ADDED_EDITOR, { ...commonUtil.getFromValue({ ...props.formValue, ...res.data }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/order/addEditor.vue

@@ -47,6 +47,7 @@ import FoldingPanel from '@components/common/foldingPanel.vue';
 import CustomerForm from '@components/common/formForm/formView.vue'
 import NewAndModifiedRelatedProducts from '@pages/pageComponents/product/newAndModifiedRelatedProducts.vue'
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 
@@ -81,7 +82,7 @@ function onSubmit() {
       orderProductDetailString: JSON.stringify(newList),
     }
     toastLoading('保存中', 0)
-    requests.post(ORDER_ADDITION_EDITING, { ...formVal }).then(() => {
+    requests.post(ORDER_ADDITION_EDITING, { ...commonUtil.getFromValue({ ...formVal }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/product/addEditor.vue

@@ -19,6 +19,7 @@ import requests from "@common/requests";
 import useToast from "@hooks/useToast"
 import { PRODUCT_ADD_EDITOR } from "@hooks/useApi"
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
@@ -37,7 +38,7 @@ function onSubmit() {
       return
     }
     toastLoading('保存中', 0)
-    requests.post(PRODUCT_ADD_EDITOR, { ...props.formValue, ...res.data }).then(() => {
+    requests.post(PRODUCT_ADD_EDITOR, { ...commonUtil.getFromValue({ ...props.formValue, ...res.data }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/tasks/addEditor.vue

@@ -194,6 +194,7 @@ import PullDownSelector from '@components/common/pullDownSelector.vue'
 import CustomerForm from '@components/common/formForm/formView.vue'
 import TranslationComponent from '@components/common/translationComponent.vue';
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
@@ -258,7 +259,7 @@ function onSubmit() {
     console.log('formValue', formValue)
     toastLoading('保存中')
     const url = formValue.id ? MODIFY_TASK : TASK_ADD_EDIT
-    requests.post(url, { ...formValue }).then(() => {
+    requests.post(url, { ...commonUtil.getFromValue({ ...formValue }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 2 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/thread/addEditor.vue

@@ -19,6 +19,7 @@ import requests from "@common/requests";
 import useToast from "@hooks/useToast"
 import { NEW_CLUE_EDITING } from "@hooks/useApi"
 import useRouterStore from "@store/useRouterStore.js";
+import commonUtil from "@utility/commonUtil"
 
 const router = useRouterStore()
 const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
@@ -37,7 +38,7 @@ function onSubmit() {
       return
     }
     toastLoading('保存中', 0)
-    requests.post(NEW_CLUE_EDITING, { ...props.formValue, ...res.data }).then(() => {
+    requests.post(NEW_CLUE_EDITING, { ...commonUtil.getFromValue({ ...props.formValue, ...res.data }) }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {
         router.navigateBack({

+ 43 - 0
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/utility/commonUtil.js

@@ -77,4 +77,47 @@ commonUtil.isJsonStr = (str) => {
     }
 };
 
+/**
+ * 判断值是否为空
+ * @param value 值
+ * @returns {boolean}
+ */
+commonUtil.isValueEmpty = (value) => {
+    if (value === null || value === undefined) {
+        return true;
+    }
+    if (typeof value === "string" && value.trim() === "") {
+        return true;
+    }
+    if (Array.isArray(value) && value.length === 0) {
+        return true;
+    }
+    if (
+        typeof value === "object" &&
+        !Array.isArray(value) &&
+        Object.keys(value).length === 0
+    ) {
+        return true;
+    }
+    if (typeof value === "symbol" && value.toString() === "Symbol()") {
+        return true;
+    }
+    return false;
+}
+
+/**
+ * 获取表单数据中有值的数据
+ * @param formData 表单数据
+ * @returns {T}
+ */
+commonUtil.getFromValue = (formData) => {
+    const result = {};
+    for (const key in formData) {
+        if (!commonUtil.isValueEmpty(formData[key])) {
+            result[key] = formData[key];
+        }
+    }
+    return result;
+}
+
 export default commonUtil;