935090232@qq.com
2021-04-14 95f9ea7eb339c36cade6c67d0385c49ec2d81477
zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/order-form.html
@@ -237,6 +237,18 @@
                        </template>
                    </el-table-column>
                </el-table>
                <el-row style="text-align: center; margin-top: 10px;">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="page.currentPage"
                            :page-sizes="[10, 20, 30, 50]"
                            :page-size="page.pageSize"
                            layout="total, prev, pager, next, jumper"
                            :total="page.total">
                    </el-pagination>
                </el-row>
                <el-row class="btn-box">
                    <el-button size="mini" type="danger" @click="closeXm()">关闭</el-button>
                    <el-button size="mini" type="primary" @click="chouseGoods()">确认</el-button>
@@ -287,6 +299,7 @@
                            <el-input @change="calculationTotal" v-model="scope.row.zkPrice"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="小计">
                        <template slot-scope="scope">
@@ -377,7 +390,7 @@
        </el-col>
    </el-row>
    <!-- 业绩设置 -->
    <el-drawer
            title="业绩设置"
            :visible.sync="drawer"
@@ -414,27 +427,43 @@
                                prop="orderItem.payMoney"
                                label="收款">
                        </el-table-column>
                        <el-table-column
                                label="业绩类型" width="150">
                                label="支付方式"
                                width="130">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.t3" placeholder="请选择业绩类型">
                                <el-select  v-model="scope.row.payMethod"
                                            placeholder="请选择支付方式">
                                    <el-option
                                            v-for="item in achieveTypeList"
                                            :key="item.key"
                                            :label="item.value"
                                            :value="item.key">
                                            v-for="item in itemSimplePayMethods"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                            :disabled="item.disabled">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column
                                label="业绩" width="100">
                                label="业绩类型" width="150">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.achieveMoney"></el-input>
                                <el-select v-model="scope.row.achieveType" @change="calculationAchieve" placeholder="请选择业绩类型">
                                    <el-option
                                            v-for="item in achieveTypeList"
                                            :key="item.value"
                                            :label="item.value"
                                            :value="item.value">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column
                                label="业绩" >
                            <template slot-scope="scope">
                                <el-input @input="checkAchieveMoney" v-model="scope.row.goodsCash"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column width="100"
                                label="提成">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.commission"></el-input>
@@ -461,7 +490,7 @@
                                           size="mini"
                                           @click="delAchieve(scope.$index, scope.row)">删除
                                </el-button>
                                <el-tooltip content="分享业绩" placement="top">
                                <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>
@@ -474,6 +503,7 @@
        </el-row>
    </el-drawer>
    <!-- 收款 -->
    <el-dialog title="收款" :visible.sync="dialogSettleVisible">
        <el-row type="flex" align="middle" style="padding: 0 0 10px 0;">
            <el-col :span="5" style="text-align: center;">应收</el-col>
@@ -574,6 +604,13 @@
            vipList: [],
            currentVipInfo: {},
            vipLoading: false,
            itemSimplePayMethods:[{
                value: '现金',
                label:'现金',
            },{
                value: '划扣',
                label:'划扣',
            }],
            payMethods: [{
                value: '现金支付',
                img: '/images/pay/cash.png',
@@ -611,14 +648,11 @@
                type: '欠款'
            },],
            achieveList: [],
            //业绩岗位
            achievePostList : [
            ],
            //业绩类型
            achieveTypeList : [
                {
                    "key" : "现金业绩",
                    "value" : "现金业绩"
                },{
                    "key" : "划扣业绩",
                    "value" : "划扣业绩"
                },
            ],
            //会员可用的充值卡
            moneyCards: [],
@@ -637,6 +671,11 @@
            searchTableData: [],
            //表格加载效果
            loading: false,
            page : {
                currentPage : 1,
                pageSize : 10,
                total : 0
            },
            /******搜索表格数据END********/
            dialogSettleVisible : false,
@@ -660,12 +699,22 @@
            if (vipId) {
                _this.changeVip(vipId);
            }
            //获取用户列表
            //获取业绩用户列表
            AjaxProxy.requst({
                app: _this,
                url: basePath + '/admin/shopAll',
                callback: function (data) {
                    _this.userList = data.rows;
                }
            });
            // 业绩类型
            AjaxProxy.requst({
                app: _this,
                url: basePath + '/admin/customerDictionary/getListByParentCode/YJLX',
                callback: function (data) {
                    _this.achieveTypeList = data.rows;
                }
            });
@@ -714,10 +763,11 @@
                                                    orderItem: item,
                                                    staff: _this.staffUser,
                                                    saleId: _this.staffUser.suId,
                                                    achieveMoney: item.payMoney,
                                                    goodsCash: item.payMoney,
                                                    commission : 0,
                                                    t3 : '现金业绩',
                                                    achieveType : _this.achieveTypeList[0].value,
                                                    isShare: false,
                                                    payMethod:item.payMethod,
                                                });
                                            });
                                            _this.order.payMoney = orderPayMoney;
@@ -801,7 +851,7 @@
             * @param{type} 1 = 购买 2=赠送
             * */
            pushToSelectGoods(goods, type) {
                let _this=this;
                //判断是否被选中
                let selected = false;
                this.order.items.forEach(item => {
@@ -822,7 +872,6 @@
                    item.price = goods.sealPice;
                    item.goodsId = goods.id;
                    item.isFree = '否';
                    item.payMethod = '现金';
                    if (type == BUY_TYPE_NOT_FREE) {
                        //购买
                        item.zkPrice = goods.sealPice;
@@ -841,10 +890,11 @@
                            orderItem: item,
                            staff: this.staffUser,
                            saleId: this.staffUser.suId,
                            achieveMoney: item.payMoney,
                            t3: '现金业绩',
                            goodsCash: item.payMoney,
                            achieveType : _this.achieveTypeList[0].value,
                            commission: 0,
                            isShare: false,
                            payMethod:'现金',
                        });
                    } else {
                        //加入业绩
@@ -852,10 +902,11 @@
                            orderItem: item,
                            staff: this.loginUser,
                            saleId: this.loginUser.suId,
                            achieveMoney: item.payMoney,
                            t3: '现金业绩',
                            goodsCash: item.payMoney,
                            achieveType : _this.achieveTypeList[0].value,
                            commission: 0,
                            isShare: false,
                            payMethod:'现金',
                        });
                    }
                    this.order.items.push(item);
@@ -900,11 +951,15 @@
                                // }
                                _this.order.payMoney += parseFloat(item.payMoney);
                                //重新计算业绩金额
                                _this.achieveList.forEach(achieve=>{
                                    if(achieve.orderItem==item){
                                        achieve.achieveMoney=item.payMoney;
                                    if(achieve.orderItem.uuid==item.uuid){
                                        achieve.orderItem.payMoney=item.payMoney;
                                    }
                                })
                                _this.calculationAchieve();
                            });
                            _this.order.payMoney = _this.order.payMoney.toFixed(2);
                            //计算欠款
@@ -946,14 +1001,18 @@
                    let _this = this;
                    if(submitType == 1) {
                        //校验支付方式
                        if (_this.payMoneys.length > 0) {
                            let flows = []
                            var total = 0;
                            _this.payMoneys.forEach(item => {
                            let isPayMethodOk=true;
                            for(let i=0; i<_this.payMoneys.length;i++){
                                let item = _this.payMoneys[i];
                                let flow = {};
                                flow.payMethod = item.type;
                                if (!item.money) {
                                    this.$message.warning("请输入" + item.type + "的付款金额");
                                    _this.$message.warning("请输入" + item.type + "的付款金额");
                                    isPayMethodOk=false;
                                    return false;
                                }
                                flow.amount = parseFloat(item.money);
@@ -963,7 +1022,7 @@
                                }
                                total += parseFloat(item.money);
                                flows.push(flow)
                            })
                            }
                            if (total != _this.order.payMoney) {
                                this.$message.warning("输入付款总金额与应付金额不符");
                                return false;
@@ -979,29 +1038,19 @@
                    _this.achieveList.forEach(achieve => {
                        for (let i = 0; i < _this.order.items.length; i++) {
                            let item = _this.order.items[i];
                            if (!item.achaeveList){
                                item.achaeveList = [];
                            if (!item.achieveList){
                                item.achieveList = [];
                            }
                            if (item.uuid == achieve.orderItem.uuid) {
                                let achieveNew = {
                                    uuid:item.uuid,
                                    beaultId: achieve.saleId,
                                    t1: achieve.achieveMoney,
                                    t3: achieve.t3,
                                    projPercentage: achieve.commission,
                                    achieveType: achieve.achieveType,
                                    goodsCash: achieve.goodsCash,
                                    payMethod: achieve.payMethod,
                                };
                                var flag = true;
                                for(var j = 0; j < item.achaeveList.length; j++) {
                                    if(item.achaeveList[j].uuid == achieveNew.uuid && item.achaeveList[j].beaultId == achieveNew.beaultId) {
                                        flag = false;
                                        break;
                                    }
                                }
                                if (flag) {
                                    item.achaeveList.push(achieveNew);
                                }
                               item.achieveList.push(achieveNew);
                                break;
                            }
                        }
@@ -1009,7 +1058,7 @@
                    console.log(_this.order);
                    //校验业绩金额
                    if (_this.checkAchieve()) {
                    if (_this.checkAchieveMoney()) {
                        let url = basePath + "/admin/order/payOrder";
                        if (submitType == 2) {
                            url = basePath + "/admin/order/saveOrder";
@@ -1065,29 +1114,7 @@
                }
            },
            /**
             * 校验订单业绩设置是否合理
             */
            checkAchieve() {
               /*
               //TODO 前端展示不检测,因为考虑到储值卡支付问题
               let _this = this;
                for (let i = 0; i < _this.order.items.length; i++) {
                    if (_this.achieveList.length > 0) {
                        let item = _this.order.items[i];
                        let sum = 0;
                        item.achieveList.forEach(achieve => {
                            console.log(sum, achieve);
                            sum += parseFloat(achieve.t1);
                        });
                        if (sum > item.payMoney) {
                            this.$message.warning("业绩金额不能大于支付金额【" + item.shoppingGoods.name + "】");
                            return false;
                        }
                    }
                }*/
                return true;
            },
            /**
             * 检查订单是否能够提交
@@ -1164,6 +1191,9 @@
             */
            searchGoods() {
                let _this = this;
                var currentPage = this.page.currentPage;
                var pageSize = this.page.pageSize;
                var offset = (currentPage - 1) * pageSize;
                if (this.queryKey && this.queryKey.trim().length > 0) {
                    this.showSearchTable = true;
                    this.loading = true;
@@ -1171,10 +1201,11 @@
                        app: _this,
                        contentType: 'application/x-www-form-urlencoded',
                        //TODO 优化下拉加载
                        data: {name: _this.queryKey, limit: 10000},
                        data: {name: _this.queryKey, limit: pageSize, offset : offset},
                        url: basePath + "/admin/shoppinggoods/showList",
                        callback: function (data) {
                            _this.searchTableData = data.rows;
                            _this.page.total = data.total;
                            _this.loading = false;
                        }
                    });
@@ -1182,8 +1213,14 @@
                    this.showSearchTable = false;
                }
            },
            handleSizeChange(val) {
                this.page.pageSize = val;
                this.searchGoods();
            },
            handleCurrentChange(val) {
                this.page.currentPage = val;
                this.searchGoods();
            },
            remoteMethod(query) {
                if (query !== '') {
                    this.vipLoading = true;
@@ -1231,11 +1268,61 @@
            shareAchieve(index, row) {
                row2 = JSON.parse(JSON.stringify(row));
                row2.isShare = true;
                this.achieveList.push(row2);
                this.achieveList.splice(index+1,0,row2);
                //this.achieveList=;
                this.calculationAchieve();
            },
            //业绩均分订单金额
            calculationAchieve(){
                console.log("计算业绩");
                let jsqMap={};
                this.achieveList.forEach(achieve=>{
                    key=achieve.achieveType+achieve.orderItem.uuid;
                    if(!jsqMap[key]){
                        jsqMap[key]=1;
                    }else{
                        jsqMap[key]++;
                    }
                });
                this.achieveList.forEach(achieve=>{
                    key=achieve.achieveType+achieve.orderItem.uuid;
                    achieve.goodsCash=(achieve.orderItem.payMoney/jsqMap[key]).toFixed(2);
                });
            },
            //校验业绩是否大于订单收款金额
            checkAchieveMoney(){
                console.log("校验业绩是否大于订单收款金额");
                let jsqMap={};
                let isOk=true;
                for(let i=0 ; i< this.achieveList.length; i++){
                    let achieve=this.achieveList[i];
                    if(!isNaN(achieve.goodsCash)  ){
                        key=achieve.achieveType+achieve.orderItem.uuid;
                        if(!jsqMap[key]){
                            jsqMap[key]=parseFloat(achieve.goodsCash);
                        }else{
                            jsqMap[key]=jsqMap[key]+parseFloat(achieve.goodsCash);
                        }
                        if(jsqMap[key]>achieve.orderItem.payMoney) {
                            this.$message.error("【"+achieve.orderItem.shoppingGoods.name + "】业绩分配金额大于支付金额");
                            isOk = false;
                            return;
                        }
                    }else{
                        this.$message.error("【"+achieve.orderItem.shoppingGoods.name + "】业绩分配金额请填写数字");
                        isOk=false;
                        return;
                    }
                };
                console.log("isOk",isOk);
                return isOk;
            },
            //删除业绩
            delAchieve(index, row) {
                this.achieveList.splice(index, 1);
                this.calculationAchieve();
            },
            print() {
                let _this = this;
@@ -1342,6 +1429,10 @@
                    return false;
                }
                if(!this.checkAchieveMoney()){
                    return ;
                }
                _this.dialogSettleVisible = true;
            }
        }