From 4dab41eef4ffde0c2631fbc7147cd2eee3cd0780 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Thu, 04 Mar 2021 18:57:56 +0800
Subject: [PATCH] 优化订单业绩

---
 zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html |  129 +++++++++++++++++++++++++++++-------------
 1 files changed, 88 insertions(+), 41 deletions(-)

diff --git a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html
index bd63766..45d6218 100644
--- a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html
+++ b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html
@@ -180,6 +180,8 @@
                             </el-table-column>
                             <el-table-column  label="小计" :formatter="calOrderTotalFormatter">
                             </el-table-column>
+                            <el-table-column  label="支付方式"  prop="payMethod">
+                            </el-table-column>
                         </el-table>
                     </el-row>
                     <el-row v-show="isRefund">
@@ -308,15 +310,19 @@
                                 label="收款">
                         </el-table-column>
                         <el-table-column
+                                prop="payMethod"
+                                label="支付方式">
+                        </el-table-column>
+                        <el-table-column
                                 prop="t3"
                                 label="业绩类型">
                             <template slot-scope="scope">
-                                <el-select v-model="scope.row.t3" placeholder="请选择业绩类型">
+                                <el-select v-model="scope.row.achieveType" placeholder="请选择业绩类型">
                                     <el-option
                                             v-for="item in achieveTypeList"
-                                            :key="item.key"
+                                            :key="item.value"
                                             :label="item.value"
-                                            :value="item.key">
+                                            :value="item.value">
                                     </el-option>
                                 </el-select>
                             </template>
@@ -325,7 +331,7 @@
                                 prop="achieve"
                                 label="业绩">
                             <template slot-scope="scope">
-                                <el-input v-model="scope.row.t1"></el-input>
+                                <el-input  @input="checkAchieveMoney" v-model="scope.row.goodsCash"></el-input>
                             </template>
                         </el-table-column>
                         <el-table-column
@@ -354,9 +360,9 @@
                                            size="mini"
                                            @click="delAchieve(scope.$index, scope.row)">删除
                                 </el-button>
-                                <el-tooltip content="分享业绩" placement="top">
-                                    <el-button @click="shareAchieve(scope.$index, scope.row)" icon="el-icon-share"
-                                               size="mini" type="primary"></el-button>
+                                <el-tooltip content="分享业绩" placement="top" v-if="!scope.row.isShare">
+                                    <el-button  @click="shareAchieve(scope.$index, scope.row)" icon="el-icon-share"
+                                                size="mini" type="primary"></el-button>
                                 </el-tooltip>
                             </template>
                         </el-table-column>
@@ -453,9 +459,9 @@
             </el-col>
         </el-row>
 
-<!--        <el-row style="text-align: center; margin: 20px 0 10px 0">-->
-<!--            <el-checkbox v-model="printPaper">打印小票</el-checkbox>-->
-<!--        </el-row>-->
+        <!--        <el-row style="text-align: center; margin: 20px 0 10px 0">-->
+        <!--            <el-checkbox v-model="printPaper">打印小票</el-checkbox>-->
+        <!--        </el-row>-->
 
         <el-row style="text-align: center; margin: 10px 0 0 0">
             <el-button type="primary" @click="confirmSubmit">确认收款</el-button>
@@ -482,15 +488,7 @@
             activeName : "first",
             circleUrl : "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
             userList : [],
-            achieveTypeList : [
-                {
-                    "key" : "现金业绩",
-                    "value" : "现金业绩"
-                },{
-                    "key" : "划扣业绩",
-                    "value" : "划扣业绩"
-                },
-            ],
+            achieveTypeList : [],
             orderItems : [],
             achieveItems : [],
             flowItems : [],
@@ -546,8 +544,15 @@
         created : function() {
             let _this = this;
             this.orderParam = /*[[${orderParam}]]*/
-            this.queryOrderDetailData(this.orderParam);
-
+                this.queryOrderDetailData(this.orderParam);
+            // 业绩类型
+            AjaxProxy.requst({
+                app: _this,
+                url: basePath + '/admin/customerDictionary/getListByParentCode/YJLX',
+                callback: function (data) {
+                    _this.achieveTypeList = data.rows;
+                }
+            });
         },
         methods : {
             calRefund() {
@@ -855,34 +860,76 @@
             },
             saveAchieve() {
                 let _this = this;
-                AjaxProxy.requst({
-                    app: _this,
-                    data: _this.achieveItems,
-                    contentType: 'application/json',
-                    url: basePath + '/admin/achieve/add',
-                    callback: function (data) {
-                        _this.$message.success(data.info);
-                    }
-                });
-            },
-            shareAchieve(index, row) {
-                var row2 = JSON.parse(JSON.stringify(row));
-                row2.id = null;
-                row2.isShare = true;
-                this.achieveItems.push(row2);
-            },
-            delAchieve(index, row) {
-                let _this = this;
-                if (row.id) {
+                if(_this.checkAchieveMoney()){
                     AjaxProxy.requst({
                         app: _this,
-                        url: basePath + '/admin/achieve/del?id=' + row.id,
+                        data: _this.achieveItems,
+                        contentType: 'application/json',
+                        url: basePath + '/admin/achieve/add',
                         callback: function (data) {
+                            _this.$message.success(data.info);
                         }
                     });
                 }
 
+            },
+
+            shareAchieve(index, row) {
+                var row2 = JSON.parse(JSON.stringify(row));
+                row2.id = null;
+                row2.isShare = true;
+                this.achieveItems.splice(index+1,0,row2);
+                this.calculationAchieve();
+            },
+            //业绩均分订单金额
+            calculationAchieve(){
+                console.log("计算业绩");
+                let jsqMap={};
+                this.achieveItems.forEach(achieve=>{
+                    key=achieve.achieveType+achieve.orderItemId;
+                    if(!jsqMap[key]){
+                        jsqMap[key]=1;
+                    }else{
+                        jsqMap[key]++;
+                    }
+                });
+                this.achieveItems.forEach(achieve=>{
+                    key=achieve.achieveType+achieve.orderItemId;
+                    achieve.goodsCash=(achieve.zkTotal/jsqMap[key]).toFixed(2);
+                });
+            },
+            //校验业绩是否大于订单收款金额
+            checkAchieveMoney(){
+                console.log("校验业绩是否大于订单收款金额");
+                let jsqMap={};
+                let isOk=true;
+                this.achieveItems.forEach(achieve=>{
+                    if(!isNaN(achieve.goodsCash)  ){
+                        key=achieve.achieveType+achieve.orderItemId;
+                        if(!jsqMap[key]){
+                            jsqMap[key]=parseFloat(achieve.goodsCash);
+                        }else{
+                            jsqMap[key]=jsqMap[key]+parseFloat(achieve.goodsCash);
+                        }
+                        if(jsqMap[key]>achieve.zkTotal) {
+                            this.$message.error("【"+achieve.goodsName + "】业绩分配金额大于支付金额");
+                            isOk = false;
+                            return;
+                        }
+                    }else{
+                        this.$message.error("【"+achieve.goodsName + "】业绩分配金额请填写数字");
+                        isOk=false;
+                        return;
+                    }
+                });
+                console.log("isOk",isOk);
+                return isOk;
+            },
+            //删除业绩
+            delAchieve(index, row) {
+                let _this = this;
                 _this.achieveItems.splice(index, 1);
+                this.calculationAchieve();
             },
             checkAchieveIsDel(items) {
                 var achieveIds = [];

--
Gitblit v1.9.1