From 23d80c1b64f23ede237ab8e89ebc2ee2aaf43f26 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 19 七月 2023 19:32:10 +0800
Subject: [PATCH] 销售模块接口联调

---
 src/views/service/serviceContract/AddServiceContractDialog.vue |  119 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 90 insertions(+), 29 deletions(-)

diff --git a/src/views/service/serviceContract/AddServiceContractDialog.vue b/src/views/service/serviceContract/AddServiceContractDialog.vue
index 237dfd5..7a3568e 100644
--- a/src/views/service/serviceContract/AddServiceContractDialog.vue
+++ b/src/views/service/serviceContract/AddServiceContractDialog.vue
@@ -254,6 +254,8 @@
 <script>
 import CommonSelectView from "@/components/makepager/CommonSelectView"
 import CommonFormTableView from "@/components/makepager/CommonFormTableView"
+import { getAllData } from "@/api/client/client"
+import { getAddSubOrder, getUpdateSubOrder } from "@/api/sales/subOrder"
 export default {
   name: "AddServiceContractDialog",
   props: {
@@ -263,27 +265,7 @@
         return {
           visible: false,
           title: "鏂板缓",
-          infomation: {
-            customName: "",
-            serviceContractNumber: "AC6521",
-            owner: "5",
-            contactName: "",
-            salesOpportunity: "",
-            contractOrder: "",
-            quotation: "",
-            contractType: "",
-            signDate: "",
-            startDate: "",
-            endDate: "",
-            contractStatus: "",
-            serviceNumber: "",
-            termsTreaty: "",
-            notes: "",
-            approvalWorkflow: "",
-            approvalSteps: "",
-            approvalPerson: "",
-            approvalOpinion: ""
-          }
+          infomation: {}
         }
       }
     }
@@ -332,8 +314,94 @@
   },
   created() {
     this.setTableForm()
+    this.getCommonData()
   },
   methods: {
+    getCommonData() {
+      getAllData()
+        .then((res) => {
+          this.memberOptions = res.data.member
+        })
+        .catch((err) => {
+          console.log(err)
+        })
+    },
+    // 淇濆瓨
+    saveClick(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          console.log(this.editConfig.infomation)
+          const params = this.saveParams()
+          console.log(params)
+          if (this.editConfig.title === "鏂板缓") {
+            getAddSubOrder(params)
+              .then((res) => {
+                console.log(res)
+                this.editConfig.visible = false
+                if (res.code === 200) {
+                  this.$message({
+                    message: "娣诲姞鎴愬姛",
+                    type: "success"
+                  })
+                  this.$parent.getData()
+                }
+              })
+              .catch((err) => {
+                console.log(err)
+              })
+          } else {
+            getUpdateSubOrder(params)
+              .then((res) => {
+                console.log(res)
+                this.editConfig.visible = false
+                if (res.code === 200) {
+                  this.$message({
+                    message: "缂栬緫鎴愬姛",
+                    type: "success"
+                  })
+                  this.$parent.getData()
+                }
+              })
+              .catch((err) => {
+                console.log(err)
+              })
+          }
+        } else {
+          console.log("error submit")
+          return false
+        }
+      })
+    },
+    saveParams() {
+      let data = this.editConfig.infomation
+      let params = {
+        id: this.editConfig.title === "鏂板缓" ? 0 : data.id,
+        clientId: data.clientId || 0,
+        masterOrderId: data.masterOrderId || 0,
+        memberId: data.memberId || 0,
+        number: data.number || "",
+        product: [
+          {
+            amount: 0,
+            desc: "",
+            id: 0,
+            name: "",
+            number: "",
+            price: 0,
+            total: 0
+          }
+        ]
+      }
+      return params
+    },
+
+    handleClose() {
+      this.editConfig.visible = false
+    },
+    // 娣诲姞闄勪欢
+    addAnnexClick() {},
+    // 璁剧疆鍏佽涓婁紶鏂囦欢鏍煎紡
+    setFormatClick() {},
     setTableForm() {
       this.productTableList = {
         tableData: [
@@ -365,14 +433,7 @@
           { label: "鎻忚堪", prop: "other8" }
         ]
       }
-    },
-    handleClose() {
-      this.editConfig.visible = false
-    },
-    // 娣诲姞闄勪欢
-    addAnnexClick() {},
-    // 璁剧疆鍏佽涓婁紶鏂囦欢鏍煎紡
-    setFormatClick() {}
+    }
   }
 }
 </script>

--
Gitblit v1.8.0