Browse Source

提交客户相关代码

Lijy 11 months ago
parent
commit
1f9631ccda

+ 37 - 3
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/relatedProducts/relatedProducts.vue

@@ -1,5 +1,5 @@
 <template>
-    <div>
+    <div class="pt-2">
         <el-table ref="productTableRef" :data="productTable" border :row-class-name="tableRowClassName"
             @row-click="tableRowItem" :style="{ width: '100%', height: heightClass }">
             <el-table-column label="序号" width="60" align="center">
@@ -55,11 +55,22 @@
                 </template>
             </el-table-column>
         </el-table>
+
+        <div class="flex w-full justify-between pt-2 pb-1">
+            <div>整单折扣率(%)</div>
+            <div class="flex">
+                <div>已选中产品:<span class="text-[red] pr-2">{{ selectedQuantity }}</span>个</div>
+                <div class="pl-4">
+                    总金额:<span class="pr-1">{{ totalAmount }}</span> 元
+                </div>
+            </div>
+        </div>
     </div>
 </template>
   
 <script lang="ts" setup>
-import { ref, reactive, onMounted, inject, watchEffect } from "vue";
+import { ElNotification } from "element-plus";
+import { ref, reactive, onMounted, inject, watchEffect, computed } from "vue";
 
 const props = defineProps<{
     productTableList: any,
@@ -118,12 +129,35 @@ function returnData() {
     if (jsonstr == json) {
         return false
     }
+
+    const list = productTable.value.filter((item: any) => item.productId)
+    const incompleteProduct = list.find((item: any) => !item.sellingPrice || !item.quantity || !item.discount);
+    if (incompleteProduct) {
+        ElNotification.closeAll();
+        ElNotification({
+            title: '提示',
+            message: `相关产品【${incompleteProduct.productName}】请填写完整`,
+            type: 'warning',
+        });
+        return false;
+    }
+
     productTable.value.forEach((item: any) => {
         delete item.index
     });
-    return productTable.value
+    return productTable.value || []
 }
 
+const selectedQuantity = computed(() => {
+    return productTable.value.filter((item: any) => item.productId).length
+})
+
+const totalAmount = computed(() => {
+    return productTable.value.filter((item: any) => item.productId).reduce((pre: number, cur: any) => {
+        return pre + (cur.totalPrice || 0)
+    }, 0)
+})
+
 watchEffect(() => {
     const { productTableList, height, productTableListValue = [] } = props
     console.log(productTableListValue, '<==== 数据')

+ 3 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/component/products.vue

@@ -78,6 +78,9 @@ const allLoading = reactive({
 
 function editProduct() {
     let productTableListData = relatedProductsRef?.value?.returnData()
+    if(!productTableListData) {
+      return
+    }
     productTableListData.forEach((item: any) => {
         delete item.id
     })

+ 4 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/index.vue

@@ -252,7 +252,10 @@ const productTableListValue = ref([])
 
 function editBusiness(visibles: boolean) {
   businessTemplateRef.value?.getData().then((res: any) => {
-    let productTableListData = relatedProductsRef?.value?.returnData() || []
+    let productTableListData = relatedProductsRef?.value?.returnData()
+    if(!productTableListData) {
+      return
+    }
     productTableListData.forEach((item: any) => {
       delete item.id
     })

+ 3 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/contacts/component/relatedBusiness.vue

@@ -95,6 +95,9 @@ function toBusDetal(row: any) {
 function editBusiness() {
     businessTemplateRef.value?.getData().then((res: any) => {
         let productTableListData = relatedProductsRef?.value?.returnData()
+        if(!productTableListData) {
+            return
+        }
         let newForm = {
             ...res,
             expectedTransactionDate: res.expectedTransactionDate ? formatDateTime(new Date(res.expectedTransactionDate)) : '',

+ 4 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/customer/component/relatedBusiness.vue

@@ -86,7 +86,10 @@ const allLoading = reactive({
 
 function editBusiness(visibles: boolean) {
     businessTemplateRef.value?.getData().then((res: any) => {
-        let productTableListData = relatedProductsRef?.value?.returnData() || []
+        let productTableListData = relatedProductsRef?.value?.returnData()
+        if(!productTableListData) {
+            return
+        }
         productTableListData.forEach((item: any) => {
             delete item.id
         })

+ 3 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/thread/detail/components/information.vue

@@ -202,6 +202,9 @@ const transferOptions = ref<personnelInterface[]>([]) // 转移人员列表
 function transferBusiness() {
     generateFormDataRef.value?.getData().then((res: any) => {
         let productTableListData = relatedProductsRef?.value?.returnData()
+        if(!productTableListData) {
+            return
+        }
         let newForm = {
             ...res,
             expectedTransactionDate: res.expectedTransactionDate ? formatDateTime(new Date(res.expectedTransactionDate)) : '',