$(function () {
    $("#jqGrid").jqGrid({
        url: '../mkstorecampminus/list',
        datatype: "json",
        colModel: [
			{label: 'campMinusId', name: 'campMinusId', index: 'camp_minus_id', key: true, hidden: true},
            {
                label: '活动图片', name: 'advImgUrl', index: 'advImgUrl', align: 'center', width: 30,
                formatter: function (value) {
                    return transImg(value);
                }
            },
			{label: '活动名称', name: 'campName', index: 'camp_name', width: 60, align: 'center'},
            {label: '减免活动类型', name: 'campMinusType', index: 'camp_minus_type', width: 50, align: 'center',
                formatter: function (value) {
                    if (value == '00') {
                        return '满x元减';
                    } else if (value == '01') {
                        return '满x件减';
                    } else if (value == '10') {
                        return '满x元折';
                    } else if (value == '11') {
                        return '满x件折';
                    }
                    return '';
                }},
			// {label: '第三方商户id', name: 'thirdMerchSn', index: 'third_merch_sn', width: 80},
            {label: '所属门店', name: 'storeName', index: 'storeName', width: 60, align: 'center'},
			// {label: '活动id', name: 'storeTopicId', index: 'store_topic_id', width: 80},
			{label: '活动时间', name: 'inValidTime', index: 'inValidTime', width: 110, align: 'center'},
			// {label: '减免方式【minus_mode，00:满足最高层级减一次，10:每满一次减一次】，1、减免方式选择10时，满件、满元每人最多项必填；2、减免方式为00，如设置每满100（2件）减10元，满200（4件）减20元....等； 按最高层级优惠满减，仅减一次。', name: 'minusMode', index: 'minus_mode', width: 80},
			// {label: '满元减条件(元)', name: 'yuanMinusCond', index: 'yuan_minus_cond', width: 80},
			// {label: '满元减优惠(元)', name: 'yuanMinusPref', index: 'yuan_minus_pref', width: 80},
			// {label: '满件减条件(件)', name: 'pieceMinusConf', index: 'piece_minus_conf', width: 80},
			// {label: '满件减优惠(元)', name: 'pieceMinusPref', index: 'piece_minus_pref', width: 80},
			// {label: '满减件每人优惠(元)，填0代表不设置上限，减免活动类型为10，且减免方式选择10时，满件每人最多项必填。', name: 'pieceMinusEachDisc', index: 'piece_minus_each_disc', width: 80},
			// {label: '满元折条件(元)，大于等于0的2位小数', name: 'yuanDiscCond', index: 'yuan_disc_cond', width: 80},
			// {label: '满元折优惠(折)，大于0且小于10的1位小数。', name: 'yuanDiscPref', index: 'yuan_disc_pref', width: 80},
			// {label: '满件折条件(件)，大于等于0的整数', name: 'pieceDiscConf', index: 'piece_disc_conf', width: 80},
			// {label: '满件折优惠(折)，大于0且小于10的数，可带1位小数。', name: 'pieceDiscPref', index: 'piece_disc_pref', width: 80},
			// {label: '适用类型，【apply_type，00:全部商品参与，01:指定商品参与，02:指定商品不参与】', name: 'applyType', index: 'apply_type', width: 80},
			{label: '是否有效', name: 'isValid', index: 'is_valid', width: 50, align: 'center',
                formatter: function (value) {
                    if (value == '0') {
                        return '有效';
                    } else if (value == '1') {
                        return '无效';
                    }
                    return '';
                }},
			{label: '活动状态', name: 'isPast', index: 'is_past', width: 50, align: 'center',
                formatter: function (value) {
                    if (value == '0') {
                        return '<span style="font-weight: bolder;background: #58d44d;color: white">进行中</span>';
                    } else if (value == '1') {
                        return '<span style="font-weight: bolder;background: #B2AEBC;color: white;">已结束</span>';
                    }else if (value == '2') {
                        return '<span style="font-weight: bolder;background: red;color: white">未开始</span>';
                    }
                    return '';
                }},
            {label: '统计', name: 'minusStat', index: 'promStat', width: 70, align: 'center'},
            {label: '操作', width: 150, align: 'center', sortable: false,
                formatter: function (value, col, row) {
                    let htmlStr = '';
                    if ((row.isPast == '1' || row.isValid == 1) && row.applyType != '00') {//已结束，适用类型不为全部商品
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.showInfo(" + row.campMinusId + ")'>活动详情</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.showGoods(" + row.campMinusId + ")'>查看商品</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.delById(" + row.campMinusId + ")'>删除活动</button>";
                    }
                    if ((row.isPast == '0' && row.isValid == 0) && row.applyType != '00') {//进行中，适用类型不为全部商品
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateById(" + row.campMinusId + ")'>编辑活动</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updatePastById(" + row.campMinusId + ")'>结束活动</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateGoods("+row.storeId+",\""+row.goodsBizType+"\","+row.campMinusId+",\""+row.applyType+"\","+row.storeTopicId+")'>管理商品</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.putOn(" + row.campMinusId + ")'>投放</button>";
                    }
                    if ((row.isPast == '2' && row.isValid == 0) && row.applyType != '00') {//未开始，适用类型不为全部商品
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateById(" + row.campMinusId + ")'>编辑活动</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateStartPastById(" + row.campMinusId + ")'>立即开始</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateGoods("+row.storeId+",\""+row.goodsBizType+"\","+row.campMinusId+",\""+row.applyType+"\","+row.storeTopicId+")'>管理商品</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.putOn(" + row.campMinusId + ")'>投放</button>";
                    }
                    if ((row.isPast == '1' || row.isValid == 1) && row.applyType == '00') {//已结束，适用类型是00全部商品
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.showInfo(" + row.campMinusId + ")'>活动详情</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.delById(" + row.campMinusId + ")'>删除活动</button>";
                    }
                    if ((row.isPast == '0' && row.isValid == 0) && row.applyType == '00') {//进行中，适用类型是00全部商品
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateById(" + row.campMinusId + ")'>编辑活动</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updatePastById(" + row.campMinusId + ")'>结束活动</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.putOn(" + row.campMinusId + ")'>投放</button>";
                    }
                    if ((row.isPast == '2' && row.isValid == 0) && row.applyType == '00') {//未开始，适用类型是00全部商品
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateById(" + row.campMinusId + ")'>编辑活动</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.updateStartPastById(" + row.campMinusId + ")'>立即开始</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                            "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.putOn(" + row.campMinusId + ")'>投放</button>";
                    }
                    return htmlStr;
                }
            }
        ],
		viewrecords: true,
        height: 580,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });

    $("#jqGridOrder").jqGrid({
        url: '../mkstorecampminusgoods/queryCampMinusGoodsByIdList',
        datatype: "json",
        colModel: [
            {label: '所属门店', name: 'storeName', index: 'storeName', width: 80, align: 'center'},
            {label: '商品名称', name: 'goodsName', index: 'goodsName', width: 80, align: 'center'},
            {label: '销售价', name: 'retailPrice', index: 'retailPrice', width: 60, align: 'center'},
            {label: '成本价', name: 'marketPrice', index: 'marketPrice', width: 120, align: 'center'},
            {label: '实际销量', name: 'actualTotalPrice', index: 'actualTotalPrice', width: 120, align: 'center',
                formatter: function (value) {
                    if (value == null) {
                        return '0';
                    }
                    return value;
                }},
            {label: '商品状态', name: 'isOnSale', index: 'isOnSale', width: 120, align: 'center',
                formatter: function (value) {
                    if (value == '0') {
                        return '下架';
                    } else if (value == '1') {
                        return '上架';
                    }
                    return value;
                }
            },
            {label: '操作', width: 130, align: 'center', sortable: false,
                formatter: function (value, col, row) {
                    let htmlStr = "-" ;
                    if(!vm.isShowGoods){
                        htmlStr = "<button class='btn btn-outline btn-primary' " +
                            "onclick='vm.delCheckGoods(" + row.minusGoodId + ")'>移除</button>" ;
                    }
                    return htmlStr;
                }
            }
        ],
        viewrecords: true,
        height: 550,
        width:1680,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: false,
        multiselect: true,
        pager: "#jqGridPagerOrder",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            $("#jqGridOrder").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
});

let vm = new Vue({
	el: '#rrapp',
	data: {
        title: null,
		mkStoreCampMinus: {},
		ruleValidate: {
			name: [
				{required: true, message: '名称不能为空', trigger: 'blur'}
			]
		},
		q: {
            campName: '',
            isPast:''
		},

        isOperatorShow: false,
        thirdMerchantBizList: [],
        storeList: [],
        showList: true,//新增修改活动框
        showViewList: false,//查询页面框
        showInfoList: true,//查询明细框
        isShowGoods: true,//为true在查看商品页则不能操作【添加商品】，为false则在管理商品页可以操作【添加商品】
        updateGoodsList: true,//管理商品框
        showStoreGoodsList: true,//添加活动商品框
        macros: [],
        minusTypeUnitAttrList: [{'yuanMinusCond': '', 'yuanMinusPref': '', 'isDelete': 0}],//满元满减
        minusTypePieceAttrList: [{'pieceMinusConf': '', 'pieceMinusPref': '', 'isDelete': 0}],//满件满减
        minusTypeDiscUnitAttrList: [{'yuanDiscCond': '', 'yuanDiscPref': '', 'isDelete': 0}],//满元满折
        minusTypeDiscPieceAttrList: [{'pieceDiscConf': '', 'pieceDiscPref': '', 'isDelete': 0}],//满件满折
        minusTypeUnitMode10List: [{'yuanMinusCond': '', 'yuanMinusPref': '', 'pieceMinusEachDisc': '', 'isDelete': 0}],//满元满减，且减免类型为每满一次减一次
        minusTypePieceMode10List: [{'pieceMinusConf': '', 'pieceMinusPref': '', 'pieceMinusEachDisc': '', 'isDelete': 0}],//满件满减，且减免类型为每满一次减一次
        isMinusShow: false,
        isUnitAttrShow: false,//满元满减
        isPieceAttrShow: false,//满件满减
        isDiscUnitAttrShow: false,//满元满折
        isDiscPieceAttrShow: false,//满件满折
        isUnitMode10Show: false,//满元满减，且减免类型为每满一次减一次
        isPieceMode10Show: false,//满件满减，且减免类型为每满一次减一次
        minusModeType: '',
        campMinusType:'',
        isValidationByUnit: true,
        isValidationByPiece: true,
        isValidationByDiscUnit: true,
        isValidationByDiscPiece: true,
        isValidationByUnitMode: true,
        isValidationByPieceMode: true,
        g:{
            goodsName:''
        },
        campMinusId: '',
        storeId: '',
        goodsBizType: '',
        applyType: '',
        storeTopicId: '',
        currentPage: 1,
        limit: 30,
        totalPage:'',
        totalCount:'',
        goodsList: [],
        s:{
            goodsName:''
        },
        checkGoodsByHtmlList:[],//选择商品前端储存的数组
        mkStoreTicketDiscountGoods:{checkGoodsList:[]},
        mkStoreCampMinusGoodsEntity:{}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		add: function () {
			vm.showList = false;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.showGoodsList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = true;
            vm.mkStoreCampMinus = {isValid:'0',isStoreShow:'0',applyType:'00',campMinusType:'00',minusMode:'00',advImgUrl:''};
            vm.isMinusShow = true;
            vm.minusModeType = '00';
            vm.chanCampMinusType('00');
            vm.chanMinusMode('00');
			vm.title = "新增满减满折活动";
            vm.thirdMerchantBizList = [];
            vm.storeList = [];
            vm.minusTypeUnitAttrList = [{'yuanMinusCond': '', 'yuanMinusPref': '', 'isDelete': 0}];
            vm.minusTypePieceAttrList = [{'pieceMinusConf': '', 'pieceMinusPref': '', 'isDelete': 0}];
            vm.minusTypeDiscUnitAttrList = [{'yuanDiscCond': '', 'yuanDiscPref': '', 'isDelete': 0}];
            vm.minusTypeDiscPieceAttrList = [{'pieceDiscConf': '', 'pieceDiscPref': '', 'isDelete': 0}];
            vm.minusTypeUnitMode10List = [{'yuanMinusCond': '', 'yuanMinusPref': '', 'pieceMinusEachDisc': '', 'isDelete': 0}];
            vm.minusTypePieceMode10List = [{'pieceMinusConf': '', 'pieceMinusPref': '', 'pieceMinusEachDisc': '', 'isDelete': 0}];
            vm.getThirdMerchantBizList();
            vm.isOperatorShow = false;
		},
		update: function (event) {
            let campMinusId = getSelectedRow();
			if (campMinusId == null) {
				return;
			}
            vm.showList = false;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.showGoodsList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = true;
            vm.title = "修改满减满折活动";
            vm.isOperatorShow = true;
            vm.getThirdMerchantBizList();
            vm.getInfo(campMinusId)
		},
        updateById: function (campMinusId) {
            if (campMinusId == null) {
                return;
            }
            vm.showList = false;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.showGoodsList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = true;
            vm.isMinusShow = true;
            vm.title = "修改满减满折活动";
            vm.getThirdMerchantBizList();
            vm.getInfo(campMinusId);
            vm.isOperatorShow = true;
        },
        showInfo: function(campMinusId){
            if(campMinusId == null){
                return;
            }
            vm.title = "查看满减满折信息";
            vm.showList = true;
            vm.showViewList = true;
            vm.showInfoList = false;
            vm.showGoodsList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = true;
            vm.getShowInfo(campMinusId);
        },
        showGoods: function (campMinusId) {
            if(campMinusId == null){
                return;
            }
            vm.title = "查看商品";
            vm.showList = true;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.updateGoodsList = false;
            vm.isShowGoods = true;//为true则不可以添加商品
            vm.showStoreGoodsList = true;
            vm.reloadOrder();
        },
        updateGoods: function (storeId,goodsBizType,campMinusId,applyType,storeTopicId) {
            if(storeId == null || goodsBizType == null || campMinusId == null || applyType == null || storeTopicId == null){
                return;
            }
            vm.campMinusId = campMinusId;
            vm.storeId = storeId;
            vm.goodsBizType = goodsBizType;
            vm.applyType = applyType;
            vm.storeTopicId = storeTopicId;
            vm.title = "管理商品";
            vm.showList = true;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.updateGoodsList = false;
            vm.isShowGoods = false;//为false则可以添加商品
            vm.showStoreGoodsList = true;

            vm.reloadOrderSearch();
        },
        queryOrder: function () {
            vm.reloadOrder();
        },
        reloadOrderSearch: function() {
            vm.g = {
                goodsName: ''
            }
            vm.reloadOrder();
        },
        reloadOrder: function () {
            let page = $("#jqGridOrder").jqGrid('getGridParam', 'page');
            $("#jqGridOrder").jqGrid('setGridParam', {
                postData: {'goodsName': vm.g.goodsName, 'campMinusId': vm.campMinusId},
                page: page
            }).trigger("reloadGrid");
        },
        saveCampMinusGoods: function () {
            if(vm.storeId == null || vm.goodsBizType == null || vm.storeTopicId == null){
                return;
            }
            vm.title = "添加活动商品";
            vm.showList = true;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = false;
            //查询门店业务类型下的商品列表
            vm.getGoodsList(vm.storeId,vm.goodsBizType);
        },
        /**
         * 选择商品参数查询
         */
        reloadGoodsByStore: function (){
            vm.getGoodsList(vm.storeId,vm.goodsBizType);
        },
        /**
         * 选择商品重置参数查询
         */
        reloadGoodsSearch: function (){
            vm.s.goodsName='';
            vm.getGoodsList(vm.storeId,vm.goodsBizType);
        },
        /**
         * 返回管理商品
         */
        reloadCampGoods: function () {
            vm.showList = true;
            vm.showViewList = true;
            vm.showInfoList = true;
            vm.updateGoodsList = false;
            vm.isShowGoods = false;//为false则可以添加商品
            vm.showStoreGoodsList = true;
            vm.reloadOrder();
        },
        /**
         * 商品选中
         * @param item 商品信息
         */
        selectThisGoods: function (item) {
            if(item.isCheck==0){
                for(var i = 0; i < vm.goodsList.length; i++){
                    if(vm.goodsList[i].goodsId == item.goodsId){
                        vm.goodsList[i].isCheck = 1;
                    }
                }
                vm.checkGoodsByHtmlList.push({goodsId: item.goodsId, storeRealId: item.id, goodsName: item.goodsName, applyType: vm.applyType, discGoodTempId:item.discGoodTempId});
            }else{
                for(var i = 0; i < vm.goodsList.length; i++){
                    if(vm.goodsList[i].goodsId == item.goodsId){
                        vm.goodsList[i].isCheck = 0;
                    }
                }
                for (var g = 0; g < vm.checkGoodsByHtmlList.length; g++) {
                    if(item.goodsId == vm.checkGoodsByHtmlList[g].goodsId){
                        vm.checkGoodsByHtmlList.remove(vm.checkGoodsByHtmlList[g]);
                    }
                }
                //删除取消选中的商品
                vm.mkStoreTicketDiscountGoods.storeRelaId=item.id;
                $.ajax({
                    type: "POST",
                    url: '../mkstoreticketgoodstemp/updateTempByStoreTopicIsValid',
                    contentType: "application/json",
                    data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
                    success: function (r) {
                    }
                });
            }

        },
        /**
         * 选择指定商品保存按钮
         */
        ok : function () {
            vm.checkGoodsDataList =[];
            vm.mkStoreTicketDiscountGoods.checkGoodsList = vm.checkGoodsByHtmlList;
            vm.mkStoreTicketDiscountGoods.isSubmit = 0;//ok按钮提交的数据则为0
            vm.mkStoreTicketDiscountGoods.storeTopicId = vm.storeTopicId;
            $.ajax({
                type: "POST",
                url: '../mkstoreticketgoodstemp/batchSaveStoreTopicGoods',
                contentType: "application/json",
                data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
                success: function (r) {
                    if (r.code === 0) {
                        vm.mkStoreCampMinusGoodsEntity.storeTopicId = vm.storeTopicId;
                        vm.mkStoreCampMinusGoodsEntity.campMinusId = vm.campMinusId;
                        $.ajax({
                            type: "POST",
                            url: '../mkstorecampminusgoods/batchSaveCampMinusGoods',
                            contentType: "application/json",
                            data: JSON.stringify(vm.mkStoreCampMinusGoodsEntity),
                            success: function (r) {
                                if (r.code === 0) {
                                    vm.reloadCampGoods();
                                } else {
                                    alert(r.msg);
                                }
                            }
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        /**
         * 选择指定商品取消按钮
         */
        cancel: function () {
            vm.checkGoodsByHtmlList =[];
            // console.log(vm.checkGoodsByHtmlList);
            //点击取消按钮如有分页记录的数据就删除
            vm.mkStoreTicketDiscountGoods.checkGoodsList=vm.checkGoodsByHtmlList;
            vm.mkStoreTicketDiscountGoods.isSubmit = 1;//cancel按钮提交的数据则为1
            $.ajax({
                type: "POST",
                url: '../mkstoreticketgoodstemp/batchSaveStoreTopicGoods',
                contentType: "application/json",
                data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
                success: function (r) {
                    if (r.code === 0) {
                        vm.reloadCampGoods();
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        /**
         * 指定商品分页，分页则将当前页选中的商品保存
         */
        loadGoodsDataByPage: function (value) {
            vm.currentPage = value;
            vm.mkStoreTicketDiscountGoods.checkGoodsList=vm.checkGoodsByHtmlList;//选择商品前端储存的数组
            vm.mkStoreTicketDiscountGoods.isSubmit = 1;//分页记录的数据则为1
            vm.mkStoreTicketDiscountGoods.storeTopicId = vm.storeTopicId;
            $.ajax({
                type: "POST",
                url: '../mkstoreticketgoodstemp/batchSaveStoreTopicGoods',
                contentType: "application/json",
                data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
                success: function (r) {
                    if (r.code === 0) {
                    } else {
                        alert(r.msg);
                    }
                }
            });
            vm.getGoodsList(vm.storeId, vm.goodsBizType);
        },
        handlePageSize: function (value) {
            vm.limit = value;
            vm.currentPage = 1;
            vm.getGoodsList(vm.storeId);
        },
        /**
         * 删除已选中商品
         * @param minusGoodId
         */
        delCheckGoods: function (minusGoodId) {
            var minusGoodIds = [minusGoodId];
            if (minusGoodIds == null){
                return;
            }

            confirm('所选中的商品移除后，将不再参加此活动', function () {
                $.ajax({
                    type: "POST",
                    url: "../mkstorecampminusgoods/delete",
                    contentType: "application/json",
                    data: JSON.stringify(minusGoodIds),
                    success: function (r) {
                        if (r.code == 0) {
                            alert('操作成功', function (index) {
                                vm.reloadOrder();
                            });
                        } else {
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        /**
         * 查询选择商品分页
         * @param storeId
         */
        getGoodsList: function(storeId,goodsBizType){
            if(vm.storeId == null || vm.goodsBizType == null || vm.storeTopicId == null){
                return;
            }
            $.get("../productstorerela/queryGoodsRealListByTopicId?storeId=" + storeId +"&goodsName="+vm.s.goodsName+"&applyType="+vm.applyType+"&goodsBizType="+goodsBizType
                +"&storeTopicId="+vm.storeTopicId+"&page="+vm.currentPage+"&limit="+vm.limit, function (r) {
                if(r.code == 0){
                    vm.goodsList = r.page.list;
                    vm.totalPage = r.page.totalPage;
                    vm.totalCount = r.page.totalCount;
                    vm.currentPage = r.page.currPage;
                    vm.limit = r.page.pageSize;
                }
            });
        },
        putOn: function (campMinusId) {
            if (campMinusId == null) {
                return;
            }
            $("#qrcodeCanvas").html("");
            $.get("../mkstorecampminus/qrcodeCanvasByCampMinus/" + campMinusId, function (r) {
                var qrcSrc = r.url;
                $("#qrcImg .qrcImg").attr("src", qrcSrc);

                $("#qrcodeCanvas").html($("#qrcImg").html());

                openWindow({
                    title: "二维码",
                    area: ['450px', '450px'],
                    content: jQuery("#qrcode"),
                    btn1: function (index) {
                        $("#qrcImg").show();
                        $("#qrcImg").hide();
                        layer.close(index);
                    }
                });
            });

            $("#qrcImg").hide();
        },
		saveOrUpdate: function (event) {
            let url = vm.mkStoreCampMinus.campMinusId == null ? "../mkstorecampminus/save" : "../mkstorecampminus/update";
            vm.mkStoreCampMinus.minusTypeUnitAttrList = vm.minusTypeUnitAttrList;
            vm.mkStoreCampMinus.minusTypePieceAttrList = vm.minusTypePieceAttrList;
            vm.mkStoreCampMinus.minusTypeDiscUnitAttrList = vm.minusTypeDiscUnitAttrList;
            vm.mkStoreCampMinus.minusTypeDiscPieceAttrList = vm.minusTypeDiscPieceAttrList;
            vm.mkStoreCampMinus.minusTypeUnitMode10List = vm.minusTypeUnitMode10List;
            vm.mkStoreCampMinus.minusTypePieceMode10List = vm.minusTypePieceMode10List;
            if(vm.mkStoreCampMinus.campMinusType=='00' && vm.mkStoreCampMinus.minusMode=='00'){
                if(!vm.isValidationByUnit){
                    alert('优惠内容活动层级信息错误，请根据错误提示修改正确');
                    return;
                }
            }
            if(vm.mkStoreCampMinus.campMinusType=='00' && vm.mkStoreCampMinus.minusMode=='10'){
                if(!vm.isValidationByUnitMode){
                    alert('优惠内容活动层级信息错误，请根据错误提示修改正确');
                    return;
                }
            }
            if(vm.mkStoreCampMinus.campMinusType=='01' && vm.mkStoreCampMinus.minusMode=='00'){
                if(!vm.isValidationByPiece){
                    alert('优惠内容活动层级信息错误，请根据错误提示修改正确');
                    return;
                }
            }
            if(vm.mkStoreCampMinus.campMinusType=='01' && vm.mkStoreCampMinus.minusMode=='10'){
                if(!vm.isValidationByPieceMode){
                    alert('优惠内容活动层级信息错误，请根据错误提示修改正确');
                    return;
                }
            }
            if(vm.mkStoreCampMinus.campMinusType=='10'){
                if(!vm.isValidationByDiscUnit){
                    alert('优惠内容活动层级信息错误，请根据错误提示修改正确');
                    return;
                }
            }
            if(vm.mkStoreCampMinus.campMinusType=='11'){
                if(!vm.isValidationByDiscPiece){
                    alert('优惠内容活动层级信息错误，请根据错误提示修改正确');
                    return;
                }
            }
			$.ajax({
				type: "POST",
			    url: url,
			    contentType: "application/json",
			    data: JSON.stringify(vm.mkStoreCampMinus),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
			});
		},
		del: function (event) {
            let campMinusIds = getSelectedRows();
			if (campMinusIds == null){
				return;
			}

			confirm('确定要删除选中的记录？', function () {
				$.ajax({
					type: "POST",
				    url: "../mkstorecampminus/delete",
				    contentType: "application/json",
				    data: JSON.stringify(campMinusIds),
				    success: function (r) {
						if (r.code == 0) {
							alert('操作成功', function (index) {
								$("#jqGrid").trigger("reloadGrid");
							});
						} else {
							alert(r.msg);
						}
					}
				});
			});
		},
        delById: function (campMinusId) {
            if (campMinusId == null){
                return;
            }
            let campMinusIds = [campMinusId];
            confirm('确定要删除选中的记录？', function () {
                $.ajax({
                    type: "POST",
                    url: "../mkstorecampminus/delete",
                    contentType: "application/json",
                    data: JSON.stringify(campMinusIds),
                    success: function (r) {
                        if (r.code == 0) {
                            alert('操作成功', function (index) {
                                $("#jqGrid").trigger("reloadGrid");
                            });
                        } else {
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        updatePastById: function (campMinusId) {
            if (campMinusId == null){
                return;
            }
            confirm('结束进行中的活动会影响用户正常购买，建议您提前告知或说明，确定要结束活动吗？', function () {
                $.ajax({
                    type: "POST",
                    url: "../mkstorecampminus/updatePastById",
                    contentType: "application/json",
                    data: JSON.stringify(campMinusId),
                    success: function (r) {
                        if (r.code == 0) {
                            alert('操作成功', function (index) {
                                $("#jqGrid").trigger("reloadGrid");
                            });
                        } else {
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        updateStartPastById: function (campMinusId) {
            if (campMinusId == null){
                return;
            }
            confirm('开始后，活动立即生效，确定要开始活动吗？', function () {
                $.ajax({
                    type: "POST",
                    url: "../mkstorecampminus/updateStartPastById",
                    contentType: "application/json",
                    data: JSON.stringify(campMinusId),
                    success: function (r) {
                        if (r.code == 0) {
                            alert('操作成功', function (index) {
                                $("#jqGrid").trigger("reloadGrid");
                            });
                        } else {
                            alert(r.msg);
                        }
                    }
                });
            });
        },
		getInfo: function(campMinusId){
			$.get("../mkstorecampminus/info/"+campMinusId, function (r) {
                vm.mkStoreCampMinus = r.mkStoreCampMinus;
                vm.minusModeType = r.mkStoreCampMinus.minusModeType;
                vm.minusMode = r.mkStoreCampMinus.minusMode;
                vm.chanCampMinusType(r.mkStoreCampMinus.campMinusType);
                vm.chanMinusMode(r.mkStoreCampMinus.minusMode);
                if (r.mkStoreCampMinus.minusTypeUnitAttrList.length > 0) {
                    vm.minusTypeUnitAttrList = r.mkStoreCampMinus.minusTypeUnitAttrList;
                    for(var i=0; i<r.mkStoreCampMinus.minusTypeUnitAttrList.length; i++){
                        $("#"+(i+'unit')).html('');
                        $("#"+(i+'unit_pref')).html('');
                    }
                } else {
                    vm.minusTypeUnitAttrList = [{'yuanMinusCond': '', 'yuanMinusPref': '', 'isDelete': 0}];
                }

                if (r.mkStoreCampMinus.minusTypePieceAttrList.length > 0) {
                    vm.minusTypePieceAttrList = r.mkStoreCampMinus.minusTypePieceAttrList;
                    for(var i=0; i<r.mkStoreCampMinus.minusTypePieceAttrList.length; i++){
                        $("#"+(i+'piece_conf')).html('');
                        $("#"+(i+'piece_pref')).html('');
                    }
                } else {
                    vm.minusTypePieceAttrList = [{'pieceMinusConf': '', 'pieceMinusPref': '', 'isDelete': 0}];
                }

                if (r.mkStoreCampMinus.minusTypeDiscUnitAttrList.length > 0) {
                    vm.minusTypeDiscUnitAttrList = r.mkStoreCampMinus.minusTypeDiscUnitAttrList;
                    for(var i=0; i<r.mkStoreCampMinus.minusTypeDiscUnitAttrList.length; i++){
                        $("#"+(i+'disc_unit_cond')).html('');
                        $("#"+(i+'disc_unit_pref')).html('');
                    }
                } else {
                    vm.minusTypeDiscUnitAttrList = [{'yuanDiscCond': '', 'yuanDiscPref': '', 'isDelete': 0}];
                }

                if (r.mkStoreCampMinus.minusTypeDiscPieceAttrList.length > 0) {
                    vm.minusTypeDiscPieceAttrList = r.mkStoreCampMinus.minusTypeDiscPieceAttrList;
                    for(var i=0; i<r.mkStoreCampMinus.minusTypeDiscPieceAttrList.length; i++){
                        $("#"+(i+'piece_disc_conf')).html('');
                        $("#"+(i+'piece_disc_ref')).html('');
                    }
                } else {
                    vm.minusTypeDiscPieceAttrList = [{'pieceDiscConf': '', 'pieceDiscPref': '', 'isDelete': 0}];
                }

                if (r.mkStoreCampMinus.minusTypeUnitMode10List.length > 0) {
                    vm.minusTypeUnitMode10List = r.mkStoreCampMinus.minusTypeUnitMode10List;
                    for(var i=0; i<r.mkStoreCampMinus.minusTypeUnitMode10List.length; i++){
                        $("#"+(i+'unit_mode')).html('');
                        $("#"+(i+'unit_mode_pref')).html('');
                        $("#"+(i+'unit_mode_each')).html('');
                    }
                } else {
                    vm.minusTypeUnitMode10List = [{'yuanMinusCond': '', 'yuanMinusPref': '', 'pieceMinusEachDisc': '', 'isDelete': 0}];
                }

                if (r.mkStoreCampMinus.minusTypePieceMode10List.length > 0) {
                    vm.minusTypePieceMode10List = r.mkStoreCampMinus.minusTypePieceMode10List;
                    for(var i=0; i<r.mkStoreCampMinus.minusTypePieceMode10List.length; i++){
                        $("#"+(i+'piece_mode')).html('');
                        $("#"+(i+'piece_mode_pref')).html('');
                        $("#"+(i+'piece_mode_each')).html('');
                    }
                } else {
                    vm.minusTypePieceMode10List = [{'pieceMinusConf': '', 'pieceMinusPref': '', 'pieceMinusEachDisc': '', 'isDelete': 0}];
                }
            });
		},
        getShowInfo: function(campMinusId){
            $.get("../mkstorecampminus/info/"+campMinusId, function (r) {
                vm.mkStoreCampMinus = r.mkStoreCampMinus;
                if (r.mkStoreCampMinus.minusTypeUnitAttrList.length > 0) {
                    vm.minusTypeUnitAttrList = r.mkStoreCampMinus.minusTypeUnitAttrList;
                } else {
                    vm.minusTypeUnitAttrList = [];
                }

                if (r.mkStoreCampMinus.minusTypePieceAttrList.length > 0) {
                    vm.minusTypePieceAttrList = r.mkStoreCampMinus.minusTypePieceAttrList;
                } else {
                    vm.minusTypePieceAttrList = [];
                }

                if (r.mkStoreCampMinus.minusTypeDiscUnitAttrList.length > 0) {
                    vm.minusTypeDiscUnitAttrList = r.mkStoreCampMinus.minusTypeDiscUnitAttrList;
                } else {
                    vm.minusTypeDiscUnitAttrList = [];
                }

                if (r.mkStoreCampMinus.minusTypeDiscPieceAttrList.length > 0) {
                    vm.minusTypeDiscPieceAttrList = r.mkStoreCampMinus.minusTypeDiscPieceAttrList;
                } else {
                    vm.minusTypeDiscPieceAttrList = [];
                }

                if (r.mkStoreCampMinus.minusTypeUnitMode10List.length > 0) {
                    vm.minusTypeUnitMode10List = r.mkStoreCampMinus.minusTypeUnitMode10List;
                } else {
                    vm.minusTypeUnitMode10List = [];
                }

                if (r.mkStoreCampMinus.minusTypePieceMode10List.length > 0) {
                    vm.minusTypePieceMode10List = r.mkStoreCampMinus.minusTypePieceMode10List;
                } else {
                    vm.minusTypePieceMode10List = [];
                }
            });
        },
        getThirdMerchantBizList: function() {
            $.get("../thirdmerchantbiz/queryAll", function (r) {
                vm.thirdMerchantBizList = r.list;
            });
        },
        changeStore: function (option) {
            var thirdMerchSn = option.value;
            if(thirdMerchSn){
                vm.getStoreList(thirdMerchSn);
            }
        },
        getStoreList: function(thirdMerchSn){
            $.get("../store/queryAll?thirdMerchSn=" + thirdMerchSn, function (r) {
                vm.storeList = r.list;
            });
        },
        reloadSearch: function() {
            vm.q = {
                campName: '',
                isPast:''
            }
            vm.reload();
		},
		reload: function (event) {
            vm.showList = true;
            vm.showViewList = false;
            vm.showInfoList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
			$("#jqGrid").jqGrid('setGridParam', {
                postData: {'campName': vm.q.campName,"isPast":vm.q.isPast},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
		},
        /**
         * 详情页返回
         * @param event
         */
        reloadInfoBack: function (event) {
            vm.showList = true;
            vm.showViewList = false;
            vm.showInfoList = true;
            vm.updateGoodsList = true;
            vm.showStoreGoodsList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'campName': vm.q.campName,"isPast":vm.q.isPast},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        },
        handleSubmit: function (name) {
            handleSubmitValidate(this, name, function () {
                vm.saveOrUpdate()
            });
        },
        handleReset: function (name) {
            handleResetForm(this, name);
        },
        handleSuccessAdvImgUrl: function (res, file) {
            vm.mkStoreCampMinus.advImgUrl = file.response.url;
        },
        handleFormatError: function (file) {
            this.$Notice.warning({
                title: '文件格式不正确',
                desc: '文件 ' + file.name + ' 格式不正确，请上传 jpg 或 png 格式的图片。'
            });
        },
        handleMaxSize: function (file) {
            this.$Notice.warning({
                title: '超出文件大小限制',
                desc: '文件 ' + file.name + ' 太大，不能超过 100K。'
            });
        },
        eyeImageAdvImgUrl: function () {
            var url = vm.mkStoreCampMinus.advImgUrl;
            eyeImage(url);
        },
        /**
         * 减免活动类型联动 00:满x元减，01:满x件减，10:满x元折，11:满x件折，减免活动类型为00，01时，减免方式必选
         * @param value
         */
        chanCampMinusType: function (value) {
            if(value == '00'){
                vm.campMinusType = '00';
                vm.isMinusShow = true;
                vm.isUnitAttrShow = true;
                vm.isPieceAttrShow = false;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = false;
                if(!vm.isOperatorShow){
                    vm.mkStoreCampMinus.minusMode='00';
                }
            }
            if(value == '01'){
                vm.campMinusType = '01';
                vm.isMinusShow = true;
                vm.isUnitAttrShow = false;
                vm.isPieceAttrShow = true;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = false;
                if(!vm.isOperatorShow){
                    vm.mkStoreCampMinus.minusMode='00';
                }
            }
            if(value == '10'){
                vm.campMinusType = '10';
                vm.isMinusShow = false;
                vm.isUnitAttrShow = false;
                vm.isPieceAttrShow = false;
                vm.isDiscUnitAttrShow = true;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = false;
            }
            if(value == '11'){
                vm.campMinusType = '11';
                vm.isMinusShow = false;
                vm.isUnitAttrShow = false;
                vm.isPieceAttrShow = false;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = true;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = false;
            }
        },
        /**
         * 减免方式联动 00:满足最高层级减一次，10:每满一次减一次
         * @param value
         */
        chanMinusMode: function (value) {
            //满x元减，满足最高层级减一次
            if(value == '00' && vm.campMinusType == '00'){
                vm.minusModeType = '00';
                vm.isMinusShow = true;
                vm.isUnitAttrShow = true;
                vm.isPieceAttrShow = false;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = false;
            }
            if(value == '00' && vm.campMinusType == '01'){
                vm.minusModeType = '00';
                vm.isMinusShow = true;
                vm.isUnitAttrShow = false;
                vm.isPieceAttrShow = true;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = false;
            }
            if(value == '10' && vm.campMinusType == '00'){
                vm.minusModeType = '10';
                vm.isMinusShow = true;
                vm.isUnitAttrShow = false;
                vm.isPieceAttrShow = false;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = true;
                vm.isPieceMode10Show = false;
            }
            if(value == '10' && vm.campMinusType == '01'){
                vm.minusModeType = '10';
                vm.isMinusShow = true;
                vm.isUnitAttrShow = false;
                vm.isPieceAttrShow = false;
                vm.isDiscUnitAttrShow = false;
                vm.isDiscPieceAttrShow = false;
                vm.isUnitMode10Show = false;
                vm.isPieceMode10Show = true;
            }
        },
        addAttrRow1: function () {
            if(vm.minusTypeUnitAttrList.length <10){
                vm.minusTypeUnitAttrList.push({'yuanMinusCond': '', 'yuanMinusPref': '', 'isDelete': 0});
            }
        },
        delAttrRow1: function (index) {
            //最后一行时禁止删除
            if (vm.minusTypeUnitAttrList.length == 1) {
                return;
            }
            vm.minusTypeUnitAttrList[index].isDelete = 1;
            var minusTypeUnitAttrList = [];
            for(var i=0;i<vm.minusTypeUnitAttrList.length;i++){
                if(vm.minusTypeUnitAttrList[i].isDelete == 0){
                    minusTypeUnitAttrList.push(vm.minusTypeUnitAttrList[i]);
                }
            }
            vm.minusTypeUnitAttrList = minusTypeUnitAttrList;
        },
        addAttrRow2: function () {
            if(vm.minusTypePieceAttrList.length <10) {
                vm.minusTypePieceAttrList.push({'pieceMinusConf': '', 'pieceMinusPref': '', 'isDelete': 0});
            }
        },
        delAttrRow2: function (index) {
            //最后一行时禁止删除
            if (vm.minusTypePieceAttrList.length == 1) {
                return;
            }
            vm.minusTypePieceAttrList[index].isDelete = 1;
            var minusTypePieceAttrList = [];
            for(var i=0;i<vm.minusTypePieceAttrList.length;i++){
                if(vm.minusTypePieceAttrList[i].isDelete == 0){
                    minusTypePieceAttrList.push(vm.minusTypePieceAttrList[i]);
                }
            }
            vm.minusTypePieceAttrList = minusTypePieceAttrList;
        },
        addAttrRow3: function () {
            if(vm.minusTypeDiscUnitAttrList.length <10) {
                vm.minusTypeDiscUnitAttrList.push({'yuanDiscCond': '', 'yuanDiscPref': '', 'isDelete': 0});
            }
        },
        delAttrRow3: function (index) {
            //最后一行时禁止删除
            if (vm.minusTypeDiscUnitAttrList.length == 1) {
                return;
            }
            vm.minusTypeDiscUnitAttrList[index].isDelete = 1;
            var minusTypeDiscUnitAttrList = [];
            for(var i=0;i<vm.minusTypeDiscUnitAttrList.length;i++){
                if(vm.minusTypeDiscUnitAttrList[i].isDelete == 0){
                    minusTypeDiscUnitAttrList.push(vm.minusTypeDiscUnitAttrList[i]);
                }
            }
            vm.minusTypeDiscUnitAttrList = minusTypeDiscUnitAttrList;
        },
        addAttrRow4: function () {
            if(vm.minusTypeDiscPieceAttrList.length <10) {
                vm.minusTypeDiscPieceAttrList.push({'pieceDiscConf': '', 'pieceDiscPref': '', 'isDelete': 0});
            }
        },
        delAttrRow4: function (index) {
            //最后一行时禁止删除
            if (vm.minusTypeDiscPieceAttrList.length == 1) {
                return;
            }
            vm.minusTypeDiscPieceAttrList[index].isDelete = 1;
            var minusTypeDiscUnitAttrList = [];
            for(var i=0;i<vm.minusTypeDiscPieceAttrList.length;i++){
                if(vm.minusTypeDiscPieceAttrList[i].isDelete == 0){
                    minusTypeDiscUnitAttrList.push(vm.minusTypeDiscPieceAttrList[i]);
                }
            }
            vm.minusTypeDiscPieceAttrList = minusTypeDiscPieceAttrList;
        },
        checkNumber: function(value) {
            var re = /^\d+(\.\d{1,2})?$/;
            if (value != "") {
                if (!re.test(value)) {
                    return false;
                }
            }
            return true;
        },
        checkList: function (list, value) {
            for(var i=0; i < list.length; i++){
                if(list[i] != null && list[i] != undefined && list[i] != ''){
                    if(value >= list[i]){
                        return false;
                    }
                }
            }
            return true;
        },
        /**
         * 满元满减，校验【满元减条件】
         * @param index 当前编辑的活动层级条件
         */
        checkCoudByUnitAttr: function (index) {
            var minusTypeUnitAttrList = vm.minusTypeUnitAttrList;
            var inputY = parseFloat(minusTypeUnitAttrList[index].yuanMinusCond);
            if(minusTypeUnitAttrList[index].yuanMinusCond == ''){
                $("#"+(index+'unit')).html('* 不能为空');
                vm.isValidationByUnit = false;
                return;
            }else {
                //先把非数字的都替换掉，除了数字和.
                minusTypeUnitAttrList[index].yuanMinusCond = minusTypeUnitAttrList[index].yuanMinusCond.replace(/[^\d.]/g,"");
                //必须保证第一个为数字而不是.
                minusTypeUnitAttrList[index].yuanMinusCond = minusTypeUnitAttrList[index].yuanMinusCond.replace(/^\./g,"");
                //保证只有出现一个.而没有多个.
                minusTypeUnitAttrList[index].yuanMinusCond = minusTypeUnitAttrList[index].yuanMinusCond.replace(/\.{2,}/g,".");
                //保证.只出现一次，而不能出现两次以上
                minusTypeUnitAttrList[index].yuanMinusCond = minusTypeUnitAttrList[index].yuanMinusCond.replace(".","$#$").replace(/\./g,"").replace("$#$",".");

                minusTypeUnitAttrList[index].yuanMinusCond = minusTypeUnitAttrList[index].yuanMinusCond.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
                if(minusTypeUnitAttrList[index].yuanMinusCond.indexOf(".")< 0 && minusTypeUnitAttrList[index].yuanMinusCond !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
                    minusTypeUnitAttrList[index].yuanMinusCond= parseFloat(minusTypeUnitAttrList[index].yuanMinusCond)+'';
                }
                var re = /^\d+(\.\d{1,2})?$/
                if (!re.test(vm.minusTypeUnitAttrList[index].yuanMinusCond)) {
                    $("#"+(index+'unit')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByUnit = false;
                    return;
                }else{
                    $("#"+(index+'unit')).html('');
                    vm.isValidationByUnit = true;
                }

                if (vm.minusTypeUnitAttrList[index].yuanMinusCond>=vm.minusTypeUnitAttrList[index].yuanMinusPref) {
                    $("#"+(index+'unit')).html('');
                    $("#"+(index+'unit_pref')).html('');
                    vm.isValidationByUnit = true;
                }else{
                    $("#"+(index+'unit')).html('* 不能小于满元减优惠'+vm.minusTypeUnitAttrList[index].yuanMinusPref);
                    vm.isValidationByUnit = false;
                    return;
                }
            }
            if(minusTypeUnitAttrList[0].yuanMinusCond != null){
                for (var i = 0; i < minusTypeUnitAttrList.length; i++) {
                    if(minusTypeUnitAttrList[i].yuanMinusCond != ''){
                        //下层比较
                        if(index<i){
                            // console.log(index+"<="+i+"；输入："+inputY+"<比较"+minusTypeUnitAttrList[i].yuanMinusCond);
                            if(inputY >= minusTypeUnitAttrList[i].yuanMinusCond && minusTypeUnitAttrList[i].yuanMinusCond != ''){
                                // console.log("下层比较,不满足条件1："+(index+10));
                                $("#"+(index+'unit')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'unit')).html('* 层级必须递增且不可相同');
                                vm.isValidationByUnit = false;
                            }
                            if(inputY < minusTypeUnitAttrList[i].yuanMinusCond && minusTypeUnitAttrList[i].yuanMinusCond != ''){
                                if(minusTypeUnitAttrList.length > 1){
                                    var yuanMinusCond = '';
                                    if((i+1) == minusTypeUnitAttrList.length){
                                        yuanMinusCond = '';
                                    }else{
                                        yuanMinusCond = minusTypeUnitAttrList[i+1].yuanMinusCond;
                                    }
                                    // console.log("下层比较,"+minusTypeUnitAttrList[i].yuanMinusCond+">"+(i+1)+"层比较："+yuanMinusCond);
                                    if(yuanMinusCond != '' && minusTypeUnitAttrList[i].yuanMinusCond >= parseFloat(yuanMinusCond)){
                                        // console.log("下层比较,不满足条件1："+(i+10));
                                        $("#"+(i+'unit')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'unit')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByUnit = false;
                                    }else {
                                        // console.log("下层比较,满足条件1："+(i+10));
                                        $("#"+(i+'unit')).html('');
                                        $("#"+(index+'unit')).html('');
                                        vm.isValidationByUnit = true;
                                    }
                                }else{
                                    // console.log("下层比较,满足条件1："+(i+10));
                                    $("#"+(i+'unit')).html('');
                                    $("#"+(index+'unit')).html('');
                                    vm.isValidationByUnit = true;
                                }
                            }
                        }
                        //上层比较
                        if(index>i){
                            // console.log(index+">"+i+"；输入："+inputY+">比较"+minusTypeUnitAttrList[i].yuanMinusCond);
                            if(inputY <= minusTypeUnitAttrList[i].yuanMinusCond && minusTypeUnitAttrList[i].yuanMinusCond != ''){
                                // console.log("上层比较,不满足条件2："+(index+10));
                                $("#"+(index+'unit')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'unit')).html('* 层级必须递增且不可相同');
                                vm.isValidationByUnit = false;
                            }
                            if(inputY > minusTypeUnitAttrList[i].yuanMinusCond && minusTypeUnitAttrList[i].yuanMinusCond != ''){
                                if(minusTypeUnitAttrList.length > 1){
                                    var yuanMinusCond = '';
                                    if((i+1) == minusTypeUnitAttrList.length){
                                        yuanMinusCond = '';
                                    }else{
                                        yuanMinusCond = minusTypeUnitAttrList[i+1].yuanMinusCond;
                                    }
                                    // console.log("上层比较,"+minusTypeUnitAttrList[i].yuanMinusCond+">"+(i+1)+"层比较："+yuanMinusCond);
                                    if(yuanMinusCond != '' && minusTypeUnitAttrList[i].yuanMinusCond >= parseFloat(yuanMinusCond)){
                                        // console.log("上层比较,不满足条件1："+(i+10));
                                        $("#"+(i+'unit')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'unit')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByUnit = false;
                                    }else {
                                        // console.log("上层比较,满足条件2："+(i+10));
                                        $("#"+(i+'unit')).html('');
                                        $("#"+(index+'unit')).html('');
                                        vm.isValidationByUnit = true;
                                    }
                                }else{
                                    // console.log("上层比较,满足条件2："+(i+10));
                                    $("#"+(i+'unit')).html('');
                                    $("#"+(index+'unit')).html('');
                                    vm.isValidationByUnit = true;
                                }
                            }
                        }
                    }else{
                        $("#"+(index+'unit')).html('');
                        vm.isValidationByUnit = true;
                    }
                }
            }
        },
        /**
         * 满元满减,校验【满元减优惠】
         * @param index
         */
        checkYuanMinusPref: function (index) {
            //先把非数字的都替换掉，除了数字和.
            vm.minusTypeUnitAttrList[index].yuanMinusPref = vm.minusTypeUnitAttrList[index].yuanMinusPref.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/;
            if (vm.minusTypeUnitAttrList[index].yuanMinusPref != '') {
                if (!re.test(vm.minusTypeUnitAttrList[index].yuanMinusPref)) {
                    $("#"+(index+'unit_pref')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByUnit = false;
                }else if (vm.minusTypeUnitAttrList[index].yuanMinusPref<= 0) {
                    $("#"+(index+'unit_pref')).html('* 不能小于等于0');
                    vm.isValidationByUnit = false;
                }else if (vm.minusTypeUnitAttrList[index].yuanMinusPref>vm.minusTypeUnitAttrList[index].yuanMinusCond) {
                    $("#"+(index+'unit_pref')).html('* 不能大于满元减条件'+vm.minusTypeUnitAttrList[index].yuanMinusCond);
                    vm.isValidationByUnit = false;
                }else{
                    if(vm.minusTypeUnitAttrList[index].yuanMinusPref<vm.minusTypeUnitAttrList[index].yuanMinusCond){
                        $("#"+(index+'unit')).html('');
                    }
                    $("#"+(index+'unit_pref')).html('');
                    vm.isValidationByUnit = true;
                }
            }
        },
        /**
         * 满件满减，校验【满件减条件】
         * @param index 当前编辑的活动层级条件
         */
        checkCoudByPieceAttr: function (index) {
            vm.minusTypePieceAttrList[index].pieceMinusConf = vm.minusTypePieceAttrList[index].pieceMinusConf.replace(/[^\d]/g,"");
            var re = /^[+]{0,1}(\d+)$/;
            if (vm.minusTypePieceAttrList[index].pieceMinusConf != '') {
                if (!re.test(vm.minusTypePieceAttrList[index].pieceMinusConf)) {
                    $("#"+(index+'piece_conf')).html('* 只允许输入大于等于0的整数');
                    vm.isValidationByPiece = false;
                }else if(vm.minusTypePieceAttrList[index].pieceMinusConf < 0){
                    $("#"+(index+'piece_conf')).html('* 只允许输入大于等于0的整数');
                    vm.isValidationByPiece = false;
                }else{
                    $("#"+(index+'piece_conf')).html('');
                    vm.isValidationByPiece = true;
                }

                var minusTypePieceAttrList = vm.minusTypePieceAttrList;
                var inputY = parseInt(minusTypePieceAttrList[index].pieceMinusConf);
                for (var i = 0; i < minusTypePieceAttrList.length; i++) {
                    if(minusTypePieceAttrList[i].pieceMinusConf != ''){
                        //下层比较
                        if(index<i){
                            if(inputY >= minusTypePieceAttrList[i].pieceMinusConf && minusTypePieceAttrList[i].pieceMinusConf != ''){
                                $("#"+(index+'piece_conf')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'piece_conf')).html('* 层级必须递增且不可相同');
                                vm.isValidationByPiece = false;
                            }
                            if(inputY < minusTypePieceAttrList[i].pieceMinusConf && minusTypePieceAttrList[i].pieceMinusConf != ''){
                                if(minusTypePieceAttrList.length > 1){
                                    var pieceMinusConf = '';
                                    if((i+1) == minusTypePieceAttrList.length){
                                        pieceMinusConf = '';
                                    }else{
                                        pieceMinusConf = minusTypePieceAttrList[i+1].pieceMinusConf;
                                    }
                                    if(pieceMinusConf != '' && minusTypePieceAttrList[i].pieceMinusConf >= parseInt(pieceMinusConf)){
                                        $("#"+(i+'piece_conf')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'piece_conf')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByPiece = false;
                                    }else {
                                        $("#"+(i+'piece_conf')).html('');
                                        $("#"+(index+'piece_conf')).html('');
                                        vm.isValidationByPiece = true;
                                    }
                                }else{
                                    $("#"+(i+'piece_conf')).html('');
                                    $("#"+(index+'piece_conf')).html('');
                                    vm.isValidationByPiece = true;
                                }
                            }
                        }
                        //上层比较
                        if(index>i){
                            if(inputY <= minusTypePieceAttrList[i].pieceMinusConf && minusTypePieceAttrList[i].pieceMinusConf != ''){
                                $("#"+(index+'piece_conf')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'piece_conf')).html('* 层级必须递增且不可相同');
                                vm.isValidationByPiece = false;
                            }
                            if(inputY > minusTypePieceAttrList[i].pieceMinusConf && minusTypePieceAttrList[i].pieceMinusConf != ''){
                                if(minusTypePieceAttrList.length > 1){
                                    var pieceMinusConf = '';
                                    if((i+1) == minusTypePieceAttrList.length){
                                        pieceMinusConf = '';
                                    }else{
                                        pieceMinusConf = minusTypePieceAttrList[i+1].pieceMinusConf;
                                    }
                                    if(pieceMinusConf != '' && minusTypePieceAttrList[i].pieceMinusConf >= parseInt(pieceMinusConf)){
                                        $("#"+(i+'piece_conf')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'piece_conf')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByPiece = false;
                                    }else {
                                        $("#"+(i+'piece_conf')).html('');
                                        $("#"+(index+'piece_conf')).html('');
                                        vm.isValidationByPiece = true;
                                    }
                                }else{
                                    $("#"+(i+'piece_conf')).html('');
                                    $("#"+(index+'piece_conf')).html('');
                                    vm.isValidationByPiece = true;
                                }
                            }
                        }
                    }else{
                        $("#"+(index+'piece_conf')).html('');
                        vm.isValidationByPiece = true;
                    }
                }
            }
        },
        /**
         * 满件满减，校验【满件减优惠】
         * @param index
         */
        checkPieceMinusPref: function (index) {
            vm.minusTypePieceAttrList[index].pieceMinusPref = vm.minusTypePieceAttrList[index].pieceMinusPref.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypePieceAttrList[index].pieceMinusPref != '') {
                if (!re.test(vm.minusTypePieceAttrList[index].pieceMinusPref)) {
                    $("#"+(index+'piece_pref')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByPiece = false;
                }else if (vm.minusTypePieceAttrList[index].pieceMinusPref<= 0) {
                    $("#"+(index+'piece_pref')).html('* 不能小于等于0');
                    vm.isValidationByPiece = false;
                }else{
                    $("#"+(index+'piece_pref')).html('');
                    vm.isValidationByPiece = true;
                }
            }
        },
        /**
         * 满元满折，校验【满元折条件】
         * @param index
         */
        checkYuanDiscCondByDiscUnit: function (index) {
            vm.minusTypeDiscUnitAttrList[index].yuanDiscCond = vm.minusTypeDiscUnitAttrList[index].yuanDiscCond.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypeDiscUnitAttrList[index].yuanDiscCond != '') {
                if (!re.test(vm.minusTypeDiscUnitAttrList[index].yuanDiscCond)) {
                    $("#"+(index+'disc_unit_cond')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByDiscUnit = false;
                }else if (vm.minusTypeDiscUnitAttrList[index].yuanDiscCond< 0) {
                    $("#"+(index+'disc_unit_cond')).html('* 不能小于0');
                    vm.isValidationByDiscUnit = false;
                }else{
                    $("#"+(index+'disc_unit_cond')).html('');
                    vm.isValidationByDiscUnit = true;
                }

                var minusTypeDiscUnitAttrList = vm.minusTypeDiscUnitAttrList;
                var inputY = parseFloat(minusTypeDiscUnitAttrList[index].yuanDiscCond);
                for (var i = 0; i < minusTypeDiscUnitAttrList.length; i++) {
                    if(minusTypeDiscUnitAttrList[i].yuanDiscCond != ''){
                        //下层比较
                        if(index<i){
                            if(inputY >= minusTypeDiscUnitAttrList[i].yuanDiscCond && minusTypeDiscUnitAttrList[i].yuanDiscCond != ''){
                                $("#"+(index+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                vm.isValidationByDiscUnit = false;
                            }
                            if(inputY < minusTypeDiscUnitAttrList[i].yuanDiscCond && minusTypeDiscUnitAttrList[i].yuanDiscCond != ''){
                                if(minusTypeDiscUnitAttrList.length > 1){
                                    var yuanDiscCond = '';
                                    if((i+1) == minusTypeDiscUnitAttrList.length){
                                        yuanDiscCond = '';
                                    }else{
                                        yuanDiscCond = minusTypeDiscUnitAttrList[i+1].yuanDiscCond;
                                    }
                                    if(yuanDiscCond != '' && minusTypeDiscUnitAttrList[i].yuanDiscCond >= parseFloat(yuanDiscCond)){
                                        $("#"+(i+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByDiscUnit = false;
                                    }else {
                                        $("#"+(i+'disc_unit_cond')).html('');
                                        $("#"+(index+'disc_unit_cond')).html('');
                                        vm.isValidationByDiscUnit = true;
                                    }
                                }else{
                                    $("#"+(i+'disc_unit_cond')).html('');
                                    $("#"+(index+'disc_unit_cond')).html('');
                                    vm.isValidationByDiscUnit = true;
                                }
                            }
                        }
                        //上层比较
                        if(index>i){
                            if(inputY <= minusTypeDiscUnitAttrList[i].yuanDiscCond && minusTypeDiscUnitAttrList[i].yuanDiscCond != ''){
                                $("#"+(index+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                vm.isValidationByDiscUnit = false;
                            }
                            if(inputY > minusTypeDiscUnitAttrList[i].yuanDiscCond && minusTypeDiscUnitAttrList[i].yuanDiscCond != ''){
                                if(minusTypeDiscUnitAttrList.length > 1){
                                    var yuanDiscCond = '';
                                    if((i+1) == minusTypeDiscUnitAttrList.length){
                                        yuanDiscCond = '';
                                    }else{
                                        yuanDiscCond = minusTypeDiscUnitAttrList[i+1].yuanDiscCond;
                                    }
                                    if(yuanDiscCond != '' && minusTypeDiscUnitAttrList[i].yuanDiscCond >= parseFloat(yuanDiscCond)){
                                        $("#"+(i+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'disc_unit_cond')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByDiscUnit = false;
                                    }else {
                                        $("#"+(i+'disc_unit_cond')).html('');
                                        $("#"+(index+'disc_unit_cond')).html('');
                                        vm.isValidationByDiscUnit = true;
                                    }
                                }else{
                                    $("#"+(i+'disc_unit_cond')).html('');
                                    $("#"+(index+'disc_unit_cond')).html('');
                                    vm.isValidationByDiscUnit = true;
                                }
                            }
                        }
                    }else{
                        $("#"+(index+'disc_unit_cond')).html('');
                        vm.isValidationByDiscUnit = true;
                    }
                }
            }
        },
        /**
         * 满元满折，校验【满元折优惠】
         * @param index
         */
        checkYuanDiscPrefByDiscUnit: function (index) {
            vm.minusTypeDiscUnitAttrList[index].yuanDiscPref = vm.minusTypeDiscUnitAttrList[index].yuanDiscPref.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,1})?$/
            if (vm.minusTypeDiscUnitAttrList[index].yuanDiscPref != '') {
                if (!re.test(vm.minusTypeDiscUnitAttrList[index].yuanDiscPref)) {
                    $("#"+(index+'disc_unit_pref')).html('* 最多只保留小数点后1位的正数');
                    vm.isValidationByDiscUnit = false;
                }else if(vm.minusTypeDiscUnitAttrList[index].yuanDiscPref > 10){
                    $("#"+(index+'disc_unit_pref')).html('* 请输入不大于 10 的数值');
                    vm.isValidationByDiscUnit = false;
                }else if(vm.minusTypeDiscUnitAttrList[index].yuanDiscPref <= 0){
                    $("#"+(index+'disc_unit_pref')).html('* 数值不能小于等于0');
                    vm.isValidationByDiscUnit = false;
                }else{
                    $("#"+(index+'disc_unit_pref')).html('');
                    vm.isValidationByDiscUnit = true;
                }
            }
        },
        /**
         * 满件满折，校验【满件折条件】
         * @param index
         */
        checkConfByDiscPiece: function (index) {
            vm.minusTypeDiscPieceAttrList[index].pieceDiscConf = vm.minusTypeDiscPieceAttrList[index].pieceDiscConf.replace(/[^\d]/g,"");
            var re = /^[+]{0,1}(\d+)$/;
            if (vm.minusTypeDiscPieceAttrList[index].pieceDiscConf != '') {
                if (!re.test(vm.minusTypeDiscPieceAttrList[index].pieceDiscConf)) {
                    $("#"+(index+'piece_disc_conf')).html('* 只允许输入大于等于0的整数');
                    vm.isValidationByDiscPiece = false;
                }else if(vm.minusTypeDiscPieceAttrList[index].pieceDiscConf < 0){
                    $("#"+(index+'piece_disc_conf')).html('* 只允许输入大于等于0的整数');
                    vm.isValidationByDiscPiece = false;
                }else{
                    $("#"+(index+'piece_disc_conf')).html('');
                    vm.isValidationByDiscPiece = true;
                }

                var minusTypeDiscPieceAttrList = vm.minusTypeDiscPieceAttrList;
                var inputY = parseInt(minusTypeDiscPieceAttrList[index].pieceDiscConf);
                for (var i = 0; i < minusTypeDiscPieceAttrList.length; i++) {
                    if(minusTypeDiscPieceAttrList[i].pieceDiscConf != ''){
                        //下层比较
                        if(index<i){
                            if(inputY >= minusTypeDiscPieceAttrList[i].pieceDiscConf && minusTypeDiscPieceAttrList[i].pieceDiscConf != ''){
                                $("#"+(index+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                vm.isValidationByDiscPiece = false;
                            }
                            if(inputY < minusTypeDiscPieceAttrList[i].pieceDiscConf && minusTypeDiscPieceAttrList[i].pieceDiscConf != ''){
                                if(minusTypeDiscPieceAttrList.length > 1){
                                    var pieceDiscConf = '';
                                    if((i+1) == minusTypeDiscPieceAttrList.length){
                                        pieceDiscConf = '';
                                    }else{
                                        pieceDiscConf = minusTypeDiscPieceAttrList[i+1].pieceDiscConf;
                                    }
                                    if(pieceDiscConf != '' && minusTypeDiscPieceAttrList[i].pieceDiscConf >= parseInt(pieceDiscConf)){
                                        $("#"+(i+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByDiscPiece = false;
                                    }else {
                                        $("#"+(i+'piece_disc_conf')).html('');
                                        $("#"+(index+'piece_disc_conf')).html('');
                                        vm.isValidationByDiscPiece = true;
                                    }
                                }else{
                                    $("#"+(i+'piece_disc_conf')).html('');
                                    $("#"+(index+'piece_disc_conf')).html('');
                                    vm.isValidationByDiscPiece = true;
                                }
                            }
                        }
                        //上层比较
                        if(index>i){
                            if(inputY <= minusTypeDiscPieceAttrList[i].pieceDiscConf && minusTypeDiscPieceAttrList[i].pieceDiscConf != ''){
                                $("#"+(index+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                $("#"+(i+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                vm.isValidationByDiscPiece = false;
                            }
                            if(inputY > minusTypeDiscPieceAttrList[i].pieceDiscConf && minusTypeDiscPieceAttrList[i].pieceDiscConf != ''){
                                if(minusTypeDiscPieceAttrList.length > 1){
                                    var pieceDiscConf = '';
                                    if((i+1) == minusTypeDiscPieceAttrList.length){
                                        pieceDiscConf = '';
                                    }else{
                                        pieceDiscConf = minusTypeDiscPieceAttrList[i+1].pieceDiscConf;
                                    }
                                    if(pieceDiscConf != '' && minusTypeDiscPieceAttrList[i].pieceDiscConf >= parseInt(pieceDiscConf)){
                                        $("#"+(i+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                        $("#"+(index+'piece_disc_conf')).html('* 层级必须递增且不可相同');
                                        vm.isValidationByDiscPiece = false;
                                    }else {
                                        $("#"+(i+'piece_disc_conf')).html('');
                                        $("#"+(index+'piece_disc_conf')).html('');
                                        vm.isValidationByDiscPiece = true;
                                    }
                                }else{
                                    $("#"+(i+'piece_disc_conf')).html('');
                                    $("#"+(index+'piece_disc_conf')).html('');
                                    vm.isValidationByDiscPiece = true;
                                }
                            }
                        }
                    }else{
                        $("#"+(index+'piece_disc_conf')).html('');
                        vm.isValidationByDiscPiece = true;
                    }
                }

            }else {
                $("#"+(index+'piece_disc_conf')).html('* 不能为空');
                vm.isValidationByDiscPiece = false;
            }
        },
        /**
         * 满件满折，校验【满件折优惠】
         * @param index
         */
        checkPrefByDiscPiece: function (index) {
            vm.minusTypeDiscPieceAttrList[index].pieceDiscPref = vm.minusTypeDiscPieceAttrList[index].pieceDiscPref.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,1})?$/
            if (vm.minusTypeDiscPieceAttrList[index].pieceDiscPref != '') {
                if (!re.test(vm.minusTypeDiscPieceAttrList[index].pieceDiscPref)) {
                    $("#"+(index+'piece_disc_ref')).html('* 最多只保留小数点后1位的正数');
                    vm.isValidationByDiscPiece = false;
                }else if(vm.minusTypeDiscPieceAttrList[index].pieceDiscPref > 10){
                    $("#"+(index+'piece_disc_ref')).html('* 请输入不大于 10 的数值');
                    vm.isValidationByDiscPiece = false;
                }else if(vm.minusTypeDiscPieceAttrList[index].pieceDiscPref <= 0){
                    $("#"+(index+'piece_disc_ref')).html('* 数值不能小于等于0');
                    vm.isValidationByDiscPiece = false;
                }else{
                    $("#"+(index+'piece_disc_ref')).html('');
                    vm.isValidationByDiscPiece = true;
                }
            }
        },
        /**
         * 满元满减，且减免类型为每满一次减一次，校验【满元减条件】
         * @param index
         */
        checkYuanCondByMode: function (index) {
            vm.minusTypeUnitMode10List[index].yuanMinusCond = vm.minusTypeUnitMode10List[index].yuanMinusCond.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypeUnitMode10List[index].yuanMinusCond != '') {
                if (!re.test(vm.minusTypeUnitMode10List[index].yuanMinusCond)) {
                    $("#"+(index+'unit_mode')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByUnitMode = false;
                }else if (vm.minusTypeUnitMode10List[index].yuanMinusCond<= 0) {
                    $("#"+(index+'unit_mode')).html('* 不能小于等于0');
                    vm.isValidationByUnitMode = false;
                }else{
                    $("#"+(index+'unit_mode')).html('');
                    vm.isValidationByUnitMode = true;
                }
            }
        },
        /**
         * 满元满减，且减免类型为每满一次减一次，校验【满元减优惠】
         * @param index
         */
        checkYuanPrefByMode: function (index) {
            vm.minusTypeUnitMode10List[index].yuanMinusPref = vm.minusTypeUnitMode10List[index].yuanMinusPref.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypeUnitMode10List[index].yuanMinusPref != '') {
                if (!re.test(vm.minusTypeUnitMode10List[index].yuanMinusPref)) {
                    $("#"+(index+'unit_mode_pref')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByUnitMode = false;
                }else if (vm.minusTypeUnitMode10List[index].yuanMinusPref<= 0) {
                    $("#"+(index+'unit_mode_pref')).html('* 不能小于等于0');
                    vm.isValidationByUnitMode = false;
                }else{
                    $("#"+(index+'unit_mode_pref')).html('');
                    vm.isValidationByUnitMode = true;
                }
            }
        },
        /**
         * 满元满减，且减免类型为每满一次减一次，校验【每人最多】
         * @param index
         */
        checkEachDiscByUnitMode: function (index) {
            vm.minusTypeUnitMode10List[index].pieceMinusEachDisc = vm.minusTypeUnitMode10List[index].pieceMinusEachDisc.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypeUnitMode10List[index].pieceMinusEachDisc != '') {
                if (!re.test(vm.minusTypeUnitMode10List[index].pieceMinusEachDisc)) {
                    $("#"+(index+'unit_mode_each')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByUnitMode = false;
                }else if (vm.minusTypeUnitMode10List[index].pieceMinusEachDisc< 0) {
                    $("#"+(index+'unit_mode_each')).html('* 不能小于0');
                    vm.isValidationByUnitMode = false;
                }else{
                    $("#"+(index+'unit_mode_each')).html('');
                    vm.isValidationByUnitMode = true;
                }
            }
        },
        /**
         * 满件满减，且减免类型为每满一次减一次，校验【满件减条件】
         * @param index
         */
        checkPieceConfByMode: function (index) {
            vm.minusTypePieceMode10List[index].pieceMinusConf = vm.minusTypePieceMode10List[index].pieceMinusConf.replace(/[^\d]/g,"");
            var re = /^[+]{0,1}(\d+)$/;
            if (vm.minusTypePieceMode10List[index].pieceMinusConf != '') {
                if (!re.test(vm.minusTypePieceMode10List[index].pieceMinusConf)) {
                    $("#"+(index+'piece_mode')).html('* 只允许输入大于0的整数');
                    vm.isValidationByPieceMode = false;
                }else if(vm.minusTypePieceMode10List[index].pieceMinusConf <= 0){
                    $("#"+(index+'piece_mode')).html('* 只允许输入大于0的整数');
                    vm.isValidationByPieceMode = false;
                }else{
                    $("#"+(index+'piece_mode')).html('');
                    vm.isValidationByPieceMode = true;
                }
            }
        },
        /**
         * 满件满减，且减免类型为每满一次减一次，校验【满件减优惠】
         * @param index
         */
        checkPiecePrefByMode: function (index) {
            vm.minusTypePieceMode10List[index].pieceMinusPref = vm.minusTypePieceMode10List[index].pieceMinusPref.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypePieceMode10List[index].pieceMinusPref != '') {
                if (!re.test(vm.minusTypePieceMode10List[index].pieceMinusPref)) {
                    $("#"+(index+'piece_mode_pref')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByPieceMode = false;
                }else if (vm.minusTypePieceMode10List[index].pieceMinusPref<= 0) {
                    $("#"+(index+'piece_mode_pref')).html('* 不能小于等于0');
                    vm.isValidationByPieceMode = false;
                }else{
                    $("#"+(index+'piece_mode_pref')).html('');
                    vm.isValidationByPieceMode = true;
                }
            }
        },
        /**
         * 满件满减，且减免类型为每满一次减一次，校验【每人最多】
         * @param index
         */
        checkEachDiscByPieceMode: function (index) {
            vm.minusTypePieceMode10List[index].pieceMinusEachDisc = vm.minusTypePieceMode10List[index].pieceMinusEachDisc.replace(/[^\d.]/g,"");
            var re = /^\d+(\.\d{1,2})?$/
            if (vm.minusTypePieceMode10List[index].pieceMinusEachDisc != '') {
                if (!re.test(vm.minusTypePieceMode10List[index].pieceMinusEachDisc)) {
                    $("#"+(index+'piece_mode_each')).html('* 最多只保留小数点后2位的正数');
                    vm.isValidationByPieceMode = false;
                }else if (vm.minusTypePieceMode10List[index].pieceMinusEachDisc< 0) {
                    $("#"+(index+'piece_mode_each')).html('* 不能小于0');
                    vm.isValidationByPieceMode = false;
                }else{
                    $("#"+(index+'piece_mode_each')).html('');
                    vm.isValidationByPieceMode = true;
                }
            }
        },
	},
    mounted() {
        $.get("../sys/macro/queryMacrosByValue?value=goodsBizType", function (r) {
            vm.macros = r.list;
        });

    }
});
