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 |  260 +++++++++++++++++++++++++++++----------------------
 1 files changed, 147 insertions(+), 113 deletions(-)

diff --git a/src/views/service/serviceContract/AddServiceContractDialog.vue b/src/views/service/serviceContract/AddServiceContractDialog.vue
index bd8c2ef..7a3568e 100644
--- a/src/views/service/serviceContract/AddServiceContractDialog.vue
+++ b/src/views/service/serviceContract/AddServiceContractDialog.vue
@@ -1,7 +1,7 @@
 <template>
-  <div class="service-contract">
+  <div class="add-service-contract">
     <el-dialog
-      :title="editCommonConfig.title + '瀹㈡埛绠$悊'"
+      :title="editCommonConfig.title + '鏈嶅姟鍚堝悓'"
       :visible.sync="editConfig.visible"
       :width="dialogWidth"
       :before-close="handleClose"
@@ -164,8 +164,21 @@
             <el-row>
               <el-col :span="12">
                 <el-form-item label="闄勪欢" prop="">
+                  <template slot="label">
+                    <div style="display: flex; float: right">
+                      <div style="font-size: 16px">
+                        <i class="el-icon-warning-outline" title="鏈�澶氫笂浼�20涓檮浠讹紝鏈�澶ч檺鍒�5MB"></i>
+                      </div>
+                      <span style="margin-left: 5px">闄勪欢</span>
+                    </div>
+                  </template>
                   <div class="annex-view">
-                    <div @click="addAnnexClick">娣诲姞</div>
+                    <div @click="addAnnexClick">
+                      <div style="display: flex; float: right">
+                        <div style="font-size: 16px"><i class="el-icon-paperclip"></i></div>
+                        <span>娣诲姞</span>
+                      </div>
+                    </div>
                     <div class="setFormat" @click="setFormatClick">璁剧疆鍏佽涓婁紶鐨勬枃浠舵牸寮�</div>
                   </div>
                 </el-form-item>
@@ -183,50 +196,9 @@
               </el-select>
             </div>
           </div>
-          <div class="basic-info-view">
-            <el-form ref="form" :model="productTableList" :show-message="false" label-position="right">
-              <el-table :data="productTableList.tableData" style="width: 100%">
-                <el-table-column prop="id" label="#" width="30"></el-table-column>
-                <el-table-column prop="productName" label="浜у搧鍚嶇О">
-                  <template slot-scope="scope">
-                    <el-form-item
-                      label=" "
-                      :prop="'productTableList.tableData.' + scope.$index + '.productName'"
-                      :rules="[{ required: true, message: '杈撳叆涓嶈兘涓虹┖' }]"
-                    >
-                      <el-input
-                        v-model.trim="scope.row.productName"
-                        maxlength="50"
-                        size="mini"
-                        style="width: 60px"
-                      ></el-input>
-                    </el-form-item>
-                  </template>
-                </el-table-column>
-                <el-table-column prop="productNumber" label="浜у搧缂栧彿"></el-table-column>
-                <el-table-column prop="startDate" label="鏈嶅姟寮�濮嬫棩">
-                  <el-form-item
-                    label=" "
-                    prop="'productTableList.tableData.' + scope.$index + '.startDate'"
-                    :rules="[{ required: true, message: '杈撳叆涓嶈兘涓虹┖' }]"
-                  >
-                    <el-date-picker v-model="scope.row.startDate" type="date" placeholder="閫夋嫨鏃ユ湡"> </el-date-picker>
-                  </el-form-item>
-                </el-table-column>
-                <el-table-column prop="address" label="鏈嶅姟鍒版湡鏃�"> </el-table-column>
-                <el-table-column prop="productNumber" label="鏁伴噺"></el-table-column>
-                <el-table-column prop="name" label="鍚◣鍗曚环"> </el-table-column>
-                <el-table-column prop="address" label="涓嶅惈绋庡崟浠�"> </el-table-column>
-                <el-table-column prop="productNumber" label="鎶樻墸鐜�(%)"></el-table-column>
-                <el-table-column prop="name" label="鎶樻墸棰�"> </el-table-column>
-                <el-table-column prop="address" label="绋�(閿�鍞�)"> </el-table-column>
-                <el-table-column prop="productNumber" label="瀹為檯鍚◣鍗曚环"></el-table-column>
-                <el-table-column prop="name" label="浠风◣鍚堣"> </el-table-column>
-                <el-table-column prop="address" label="鎻忚堪"> </el-table-column>
-              </el-table>
-            </el-form>
+          <div class="product-view">
+            <CommonFormTableView :show-summary="showSummary" :product-table-list="productTableList" />
           </div>
-
           <!-- 閫夋嫨瀹℃壒娴佺▼ -->
           <div class="basic-info-title">閫夋嫨瀹℃壒娴佺▼</div>
           <div class="basic-info-view">
@@ -254,6 +226,7 @@
                   <el-input v-model="editConfig.infomation.approvalSteps"></el-input>
                 </el-form-item>
               </el-col>
+              \
               <el-col :span="20">
                 <el-form-item label="瀹℃壒浜�" prop="approvalPerson">
                   <el-input v-model="editConfig.infomation.approvalPerson"></el-input>
@@ -280,6 +253,9 @@
 
 <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: {
@@ -289,32 +265,12 @@
         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: {}
         }
       }
     }
   },
-  components: { CommonSelectView },
+  components: { CommonSelectView, CommonFormTableView },
   computed: {
     searchCommonHeight() {
       return this.$refs.searchCommonView.offsetHeight
@@ -327,19 +283,8 @@
       rules: {
         serviceContractNumber: [{ required: true, message: "璇疯緭鍏ユ湇鍔″悎鍚岀紪鍙�", trigger: "blur" }],
         signDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-        owner: [{ required: true, message: "璇烽�夋嫨璐熻矗浜�", trigger: "change" }],
-        approvalOpinion: [{ required: true, message: "璇疯緭鍏ュ鎵规剰瑙�", trigger: "blur" }]
+        owner: [{ required: true, message: "璇烽�夋嫨璐熻矗浜�", trigger: "change" }]
       },
-      businessSourceOptions: [
-        { value: "1", label: "鍚庡彴娉ㄥ唽" },
-        { value: "2", label: "浠g悊鍟嗗鎴�" },
-        { value: "3", label: "鐢佃瘽闄岀敓鎷滆" },
-        { value: "4", label: "鐩存帴璁块棶" },
-        { value: "5", label: "椤圭洰鍚堜綔" },
-        { value: "6", label: "涓汉鑷壘" },
-        { value: "7", label: "浜屾閿�鍞�" },
-        { value: "8", label: "鍏徃鐢佃瘽" }
-      ],
       ownerOptions: [
         // 璐熻矗浜�
         { value: "1", label: "BOSS" },
@@ -358,35 +303,144 @@
         { value: "3", label: "娆у厓(鈧�)" }
       ], // 甯佺
       approvalWorkflowOptions: [], // 瀹℃壒娴佺▼
-      productTableList: {
-        tableData: [
-          {
-            id: "1",
-            productNumber: "123",
-            date: "2016-05-02",
-            name: "鐜嬪皬铏�",
-            address: "涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1518 寮�"
-          }
-        ]
+      productTableList: {},
+      showSummary: {
+        show: true,
+        total: true,
+        sumProp: ["other1", "other2", "other3", "other4"],
+        mergeNumber: 3
       }
     }
   },
-  created() {},
+  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() {}
+    setFormatClick() {},
+    setTableForm() {
+      this.productTableList = {
+        tableData: [
+          {
+            id: "1",
+            productName: "涓婃捣鏈夐檺鍏徃",
+            other0: "ZDYBD03-1",
+            other1: "12",
+            other2: "5.00",
+            other4: "3.00",
+            other3: "2.00"
+          }
+        ],
+        tableColumn: [
+          { label: "#", prop: "id", width: 40 },
+          { label: "浜у搧鍚嶇О", prop: "productName", input: true, isRequird: true },
+          { label: "浜у搧缂栧彿", prop: "other0" },
+          { label: "鏈嶅姟寮�濮嬫棩", prop: "other5", date: true, isRequird: true, min: 100 },
+          { label: "鏈嶅姟鍒版湡鏃�", prop: "other6", date: true, isRequird: true, min: 100 },
+          { label: "鏁伴噺", prop: "other1", input: true, isRequird: true },
+          { label: "鍚◣鍗曚环", prop: "other9", input: true },
+          { label: "涓嶅惈绋庡崟浠�", prop: "other7", input: true },
+          { label: "鎶樻墸鐜�(%)", prop: "other6", input: true },
+          { label: "鎶樻墸棰�", prop: "other2" },
+          { label: "绋�(閿�鍞�)", prop: "other7", input: true },
+          { label: "瀹為檯鍚◣鍗曚环", prop: "other3" },
+          { label: "涓嶅惈绋庨噾棰�", prop: "other4" },
+          { label: "浠风◣鍚堣", prop: "other3", input: true },
+          { label: "鎻忚堪", prop: "other8" }
+        ]
+      }
+    }
   }
 }
 </script>
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="scss" scoped>
-.service-contract {
+.add-service-contract {
   .basic-info {
     .basic-info-title {
       background-color: #f4f8fe;
@@ -431,26 +485,6 @@
     background-color: #f5f5f5;
     height: 55px;
     line-height: 55px;
-  }
-}
-::v-deep {
-  .el-dialog__header {
-    padding: 12.5px 10px;
-    border-bottom: 1px solid #e5e5e5;
-    .el-dialog__title {
-      font-size: 15px;
-      color: #323232;
-      font-weight: bold;
-    }
-  }
-  .el-dialog__body {
-    padding: 0px;
-  }
-  .el-dialog__footer {
-    padding: 0px;
-    text-align: center;
-    box-sizing: border-box;
-    border-top: 1px solid #dadee5;
   }
 }
 </style>

--
Gitblit v1.8.0