$(function() {
    var ERROK = 200;
    var contextPath = $("#contextPath").val()
    var table;
    var orgList = [];
    template.config("escape", false);
    var tpl = {
        "detailTpl": '<div class="dialog-wp">\
					<div class="mask"></div>\
					<div class="dialog dialog-order-con">\
						<div class="title-wp">\
							<span>订单详情</span>\
							<span class="close-btn"></button>\
						</div>\
						<div class="dialog-order-wp ">\
				 			<div class="base-info-wp clearfloat">\
				 				<div class="info-left">\
				 					<div class="info-item clearfloat">\
				 						<div class="info-tip">订单号：</div>\
				 						<div class="info-con"><%=number%></div>\
				 					</div>\
									 <div class="info-item clearfloat">\
										<div class="info-tip">送餐时间：</div>\
										<div class="info-con"><%=dinnerTime%></div>\
									</div>\
									 <div class="info-item clearfloat">\
										<div class="info-tip">下单时间：</div>\
										<div class="info-con"><%=createTime%></div>\
									</div>\
									 <div class="info-item clearfloat">\
										<div class="info-tip">预订人：</div>\
										<div class="info-con"><%=userName%>（<%=mobile%>）</div>\
									</div>\
									 <div class="info-item clearfloat">\
										<div class="info-tip">部门：</div>\
										<div class="info-con"><%=dept%></div>\
									</div>\
									 <div class="info-item clearfloat">\
										<div class="info-tip">送餐地址：</div>\
										<div class="info-con"><%=address%></div>\
									</div>\
									 <div class="info-item clearfloat">\
										<div class="info-tip">备注信息：</div>\
										<div class="info-con"><%=remark%></div>\
									</div>\
				 				</div>\
				 				<div class="info-right">\
				 					<%if(status==1){%>\
				 						待送餐\
				 					<%}else if(status==2){%>\
				 						待评价\
									<%}else if(status==3){%>\
										已完成\
									<%}else if(status==4){%>\
										已取消\
				 					<%}%>\
				 				</div>\
				 			</div>\
				 			<div class="order-detail-wp <%if(status!=3){%> active <%}%>" >\
				 				<div class="order-list-wp  clearfloat">\
				 					<div class="o-l-left">订单详情：</div>\
				 					<div class="order-list">\
				 						<%for(var i=0;i<orderInfoList.length;i++){%>\
					 						<div class="order-item  clearfloat">\
					 							<div class="order-img" style="background-image: url(<%=orderInfoList[i].mealImagesUrl%>)"  data-img="<%=orderInfoList[i].mealImagesUrl%>" onclick="hideEnlarge(this)"></div>\
					 							<div class="order-con  ">\
				 									<div class="order-con-top clearfloat">\
													 	<div class="order-name"><%=orderInfoList[i].mealFood%></div>\
														<div class="order-num"><%if(isTempOrder==1){%> 临时工作餐 <%}else{%> <%=integral%>积分<%}%></div>\
				 									</div>\
													 <div class="order-con-btm clearfloat">\
													 	<div class="order-name">x<%=orderInfoList[i].foodCount%></div>\
				 										<%if(!!orderInfoList[i].userName){%>\
															<div class="order-num" ><%=orderInfoList[i].userName%>(<%=orderInfoList[i].mobile%>)</div>\
				 										<%}%>\
													</div>\
					 							</div>\
					 						</div>\
				 						<%}%>\
				 					</div>\
				 				</div>\
				 				<div class="order-sum clearfloat">\
				 					<div class="order-sum-left">总计：<span class="red"><%=sumCount%></span>份<%if(!!meetCount){%>,会议餐<span class="red"><%=meetCount%></span>份<%}%></div>\
				 					<div class="order-sum-right"><span class="red"><%=sumIntegral%>积分</div>\
				 				</div>\
				 			</div>\
				 			<%if(status==3){%>\
					 			<div class="comment-list">\
					 				<div class="com-item  clearfloat">\
					 					<div class="com-tip">评价：</div>\
					 					<div class="com-con">\
					 						\
												 <%if(star==1){%>\
													很糟糕（1星）\
												<%}else if(star==2){%>\
													一般般（2星）\
												<%}else if(star==3){%>\
													滿意（3星）\
												<%}else if(star==4){%>\
													很滿意（4星）\
												<%}else if(star==5){%>\
													完美（5星）\
												<%}%>\
					 						\
					 					</div>\
					 				</div>\
									 <div class="com-item clearfloat">\
										<div class="com-tip">评价详情：</div>\
										<div class="com-con"><%=comment%></div>\
									</div>\
									 <div class="com-item clearfloat">\
										<div class="com-tip">评价图片：</div>\
										<div class="com-con  clearfloat">\
					 						<%if(!!evaluateImages){%>\
												 <% var urlList = evaluateImages.substring(0,evaluateImages.length-1).split(";") %>\
												<%for(var k=0;k<urlList.length;k++){%>\
													<div class="com-img"  style="background-image: url(<%=urlList[k]%>)"  data-img="<%=urlList[k]%>" onclick="hideEnlarge(this)"></div>\
												<%}%>\
					 						<%}%>\
					 					</div>\
									</div>\
					 			</div>\
				 			<%}%>\
						</div>\
					</div>\
				</div>	',
        exportTpl: '<div class="dialog-wp">\
					<div class="mask"></div>\
					<div class="dialog export-or-download-con">\
						<div class="title-wp">\
							<span>今日订单汇总</span>\
							<span class="close-btn"></button>\
						</div>\
						<div class="export-or-download-wp">\
							<div class="choose-item-wp">\
								<span class="tip">项目</span>\
								<input class="default-select d-orgid" id="orgId" org__id="" autocomplete="off"/>\
								<span class="select_wrap _hide"></span>\
							</div>\
							<div class="export-or-download-btns">\
						 		<button class="sure-operate-btn btn-red-width90" type="button">确定下载</button> \
							</div>\
						</div>\
					</div>\
                </div>',
        warnTpl: '<div class="dialog-wp">\
        <div class="mask"></div>\
        <div class="dialog export-or-download-con" style="width: 340px;">\
            <div class="title-wp">\
                <span>订餐提醒</span>\
                <span class="close-btn"></button>\
            </div>\
            <%if(!orgid){%>\
                <div class="export-or-download-wp">\
                    <div class="choose-item-wp">\
                        <span class="tip" style="margin-left: 33px;">项 目：</span>\
                        <input class="default-select w-orgid" id="orgId" org__id="" autocomplete="off"/>\
                        <span class="select_wrap _hide"></span>\
                    </div>\
                </div>\
            <%}%>\
            <%if(orgid){%>\
                <input type="hidden" class="default-select w-orgid" id="orgId" org__id="<%=orgid%>" autocomplete="off"/>\
            <%}%>\
            <div class="export-or-download-wp">\
                <div class="choose-item-wp">\
                    <span class="tip" style="margin-left: -23px;">提醒渠道：</span>\
                    <div class="checkbox-wp">\
                        <span class="checkbox-input">\
                            <input type="checkbox" id="warnM" class="check-item"/>\
                            <span class="checkbox-inner"></span>\
                        </span>		\
                        <label class="checkbox-con">微信客服消息提醒订餐</label>\
                    </div>\
                    <div class="checkbox-wp" style="margin: 10px 0 10px 92px;">\
                        <span class="checkbox-input">\
                            <input type="checkbox" id="warn" class="check-item"/>\
                            <span class="checkbox-inner"></span>\
                        </span>		\
                        <label class="checkbox-con">只在长假后的第一天发送短信</label>\
                    </div>\
                </div>\
                <div class="export-or-download-btns">\
                        <button class="sure-operate-btn btn-red-width90" type="button">确定</button> \
                </div>\
            </div>\
        </div>\
    </div>',
        remindTpl: '<div class="dialog-wp">\
        <div class="mask"></div>\
        <div class="dialog export-or-download-con" style="width: 340px;">\
            <div class="title-wp">\
                <span>订餐提醒</span>\
                <span class="close-btn"></button>\
            </div>\
            <%if(!orgid){%>\
                <div class="export-or-download-wp">\
                    <div class="choose-item-wp">\
                        <span class="tip" style="margin-left: 33px;">项 目：</span>\
                        <input class="default-select w-orgid" id="orgId" org__id="" autocomplete="off"/>\
                        <span class="select_wrap _hide" style="width: 200px"></span>\
                    </div>\
                </div>\
            <%}%>\
            <%if(orgid){%>\
                <input type="hidden" class="default-select w-orgid" id="orgId" org__id="<%=orgid%>" autocomplete="off"/>\
            <%}%>\
            <div class="export-or-download-wp">\
                <div class="choose-item-wp" style="width: 100%;">\
                    <div style="padding: 0 38px;text-align: left;">\
                        <span class="tip">订餐提醒：</span>\
                        <div class="checkbox-wp">\
                            <span class="checkbox-input">\
                                <input type="checkbox" id="mealCheck" class="check-item"/>\
                                <span class="checkbox-inner"></span>\
                            </span>		\
                            <label class="checkbox-con">开启</label>\
                        </div>\
                    </div>\
                    <div style="padding-left: 110px;color: #999999;font-size: 15px;text-align: left;">开启后会给订餐人员推送消息</div>\
                </div>\
                <div class="export-or-download-btns">\
                        <button class="sure-operate-btn btn-red-width90" type="button">确定</button> \
                </div>\
            </div>\
        </div>\
    </div>',
        deptTpl: '<option value="">请选择部门</option>\
						<%for(var i=0;i<data.length;i++){%>\
						<option value="<%=data[i].id%>"><%=data[i].itemname%></option>\
					<%}%>\
					'
    }
    var api = {
        init: function() {
            this.render();
            this.bindEvent();
        },
        render: function() {
            this.rendertable();
            this.itemAjax();
            // this.ajaxDepart()
            //$("body").append(template.render(tpl.exportTpl)({orgList: orgList}));
        },
        bindEvent: function() {
            var _this = this;
            layui.use('laydate', function() {
                var laydate = layui.laydate;
                //执行一个laydate实例
                laydate.render({
                    elem: '#beginTime' //提交开始时间
                });
                laydate.render({
                    elem: '#endTime' //提交结束时间
                });
                //执行一个laydate实例
                laydate.render({
                    elem: '#orderTime' //提交开始时间
                });
                laydate.render({
                    elem: '#endOrderTime' //提交结束时间
                });
            });
            //重置
            $(".set-btn").on("click", function() {
                var $orgId = $("#conditionform  .single-orgid");
                var $dom = $("#conditionform input,#conditionform select")
                if($orgId.length){
                    $dom.val("").removeAttr('com__id dep__id')
                }else{
                    $dom.val("").removeAttr('org__id com__id dep__id')
                }
                _this.againRenderTable({type:1});
            });
            //今日订单汇总
            $(".orderSummary-btn").on("click", function() {
                var $orgId = $("#conditionform  .single-orgid");
                _this.exportOrder($orgId.length);
            });
            // 订餐提醒
            $(".warnOrder").on("click",function() {
                var orgid = $("#conditionform .single-orgid").attr("org__id")
                $("body").append(template.render(tpl.remindTpl)({orgid:orgid}));
                if(orgid){
                    // _this.getOrgByMessage(orgid);
                    _this.getPushSetByOrgIdHandler(orgid);
                }
                $(".close-btn").on("click", function() {
                    $(".dialog-wp").remove();
                });
                $(".sure-operate-btn").on("click", function() {
                    var orgId = $(".w-orgid").attr('org__id');
                    var isStatus
                    if (!orgId) {
                        layer.msg("请选择项目");
                        return false;
                    };
                    $("#mealCheck").attr('checked')?isStatus = 1:isStatus = 0;
                    _this.isSetStatusHandler(isStatus, orgId, function () {
                        $(".dialog-wp").remove();
                    })

                    // _this.isSetMessage(isSetMessage,isSetWechatMessage,orgId, function() {
                    //     $(".dialog-wp").remove();
                    // })
                })
            })
            // 模糊搜索
            _this.search_fuzzy()
        },
        // 模糊搜索事件
        search_fuzzy: function() {
            var _this = this
            var default_option = {
                org_attrName: 'org__id',
                com_attrName: 'com__id',
                dep_attrName: 'dep__id',
                org_spanName: 'org__span',
                com_spanName: 'com__span',
                dep_spanName: 'dep__span',
                org_path: '/admin/templ/getOrgListByName',
                com_path: '/admin/templ/getVirList',
                dep_path: '/admin/templ/getDept',
                contextPath: $("#contextPath").val()
            }
            var option_1 = $.extend(true, {}, default_option, {
                org_target: '.default-select#orgId',
                com_target: '.default-select#companyId',
                dep_target: '.default-select#departmentId',
            });
            var option_2 = $.extend(true, {}, default_option, {
                org_target: '.d-orgid',
            });
            var option_3 = $.extend(true, {}, default_option, {
                org_target: '.w-orgid',
            });
            function eve(option_, otherOption) {
                var obj = $.extend(true, {}, option_, otherOption);
                var type = obj.type
                var _path, _target, _attrName, _spanName
                if (type == 1) {
                    _path = obj.org_path
                    _target = obj.org_target
                    _attrName = obj.org_attrName
                    _spanName = obj.org_spanName
                } else if (type == 2) {
                    _path = obj.com_path
                    _target = obj.com_target
                    _attrName = obj.com_attrName
                    _spanName = obj.com_spanName
                } else if (type == 3) {
                    _path = obj.dep_path
                    _target = obj.dep_target
                    _attrName = obj.dep_attrName
                    _spanName = obj.dep_spanName
                }
                $('body').on("input", _target, function(event) {
                    var _this = $(this)
                    var obj_input = $.extend(true, {}, obj, { "_this": _this });
                    cjqt.search_fuzzy.event_input(_this, _attrName, _spanName, contextPath, _path, obj_input)
                });
                $('body').on("focus", _target, function(event) {
                    var _this = $(this)
                    var obj_focus = $.extend(true, {}, obj, { "_this": _this });
                    cjqt.search_fuzzy.event_focus(_this, _attrName, _spanName, contextPath, _path, obj_focus)
                });
                $('body').on('blur', _target, function(event) {
                    var _this = $(this)
                    var obj_blur = $.extend(true, {}, obj, { "_this": _this });
                    cjqt.search_fuzzy.event_blur(_this, _attrName, obj_blur)
                });
                $('body').on('click', _target + '~.select_wrap>.' + _spanName, function(event) {
                    event.preventDefault();
                    event.stopPropagation();
                    /* Act on the event */
                    var _this = $(this)
                    var obj_click = $.extend(true, {}, obj, { "_this": _this });
                    cjqt.search_fuzzy.event_click(_this, _attrName, _target, obj_click)
                });

            }
            // 搜索联动
            eve(option_1, { type: 1 })
            eve(option_1, { type: 2 })
            eve(option_1, { type: 3 })
            // 今日订单汇总
            eve(option_2, { type: 1 })
            // 订餐提醒
            eve(option_3, { type: 1,
                click_callback:function(){
                    var orgId = $('.w-orgid').attr('org__id')
                    // _this.getOrgByMessage(orgId);
                    _this.getPushSetByOrgIdHandler(orgId);
				}
            })
        },
        rendertable: function() {
            var _this = this;
            var $orgId = $("#conditionform  .single-orgid");
            var orgId = $("#conditionform  #orgId").attr('org__id')
            layui.use('table', function() {
                table = layui.table;
                //方法级渲染
                table.render({
                    elem: '#LAY_table_user',
                    url: $("#contextPath").val() + "/admin/dinner/getOrderDinnerList",
                    method: "post",
                    skin: 'nob' //行边框风格
                        ,
                    even: true //开启隔行背景
                        ,
                    size: 'lg' //小尺寸的表格
                        ,
                    cols: [
                        [{
                            field: 'index',
                            title: '序号',
                            width: '80',
                            templet: '#indexTpl'
                        }, {
                            field: 'dept',
                            title: '部门',
                            width: '200',
                        }, {
                            field: 'userName',
                            title: '预订人',
                            width: '200',
                        }, {
                            field: 'dinnerTime',
                            title: '送餐时间',
                            width: '200',
                        }, {
                            field: 'number',
                            title: '订单号',
                            width: '200',
                        }, {
                            field: 'orderInfoStr',
                            title: '订餐信息',
                            width: '200',
                        }, {
                            field: 'integral',
                            title: '消费积分',
                            width: '200',
                        }, {
                            field: 'address',
                            title: '送餐地址',
                            width: '200',
                        }, {
                            field: 'createTime',
                            title: '下单时间',
                            width: '200',
                        }, {
                            field: 'status',
                            title: '状态',
                            width: '200',
                            templet: function(data) {
                                //1启用0禁用
                                if (data.status == "1") {
                                    return '待送餐'
                                } else if (data.status == "2") {
                                    return '待评价'
                                } else if (data.status == "3") {
                                    return '已完成'
                                } else if (data.status == "4") {
                                    return '已取消'
                                }
                            }
                        }, {
                            field: 'star',
                            title: '星级',
                            width: '200',
                            templet: function(data) {
                                //1启用0禁用
                                if (data.star == 1) {
                                    return '1星(很糟糕)'
                                } else if (data.star == 2) {
                                    return '2星(一般般)'
                                } else if (data.star == 3) {
                                    return '3星(满意)'
                                } else if (data.star == 4) {
                                    return '4星(很满意)'
                                } else if (data.star == 5) {
                                    return '5星(完美)'
                                } else {
                                    return ''
                                }
                            }
                        }, {
                            field: 'typeName',
                            title: '类型',
                            width: '100',
                        }, {
                            title: '可操作',
                            fixed: 'right',
                            width: '200',
                            align: 'center',
                            templet: function(data) {
                                var str = '';
                                //str += '<button class="t-btn t-red-btn t-edit-btn" data-id=' + data.id + ' data-type="1" >修改</button>';
                                str += '<button class="t-btn t-red-btn t-detail-btn" data-id=' + data.orderId + ' data-orgid=' + data.orgId + '>详情</button>';
                                return str;
                            }
                        }]
                    ],
                    id: 'testReload',
                    page: true,
                    response: {
                        statusName: 'code' //数据状态的字段名称，默认：code
                            ,
                        statusCode: 200 //成功的状态码，默认：0
                            ,
                        countName: "count" //数据总数的字段名称，默认：count
                            ,
                        dataName: "data" //数据列表的字段名称，默认：data
                    },
                    where:{
                    	orgId: orgId,
                    },
                    request: {
                        pageName: 'pageNo' //页码的参数名称，默认：page
                            ,
                        limitName: 'pageSize' ,//每页数据量的参数名，默认：limit

                    },
                    done: function(res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //查看详情
                        $(".t-detail-btn").on("click", function() {
                            var id = $(this).data("id");
                            var orgId = $(this).data("orgid")
                            _this.ajaxDetail(id, orgId);
                        })
                    }
                });
                //查询
                $('#conditionform  .search-btn').on('click', function() {
                    _this.againRenderTable();
                });
            });
        },
        /**
         * 今日订单汇总
         * @param length 判断是单项目还是多项目 ，为0多项目 不为0单项目
         */
        exportOrder: function(length) {
            var _this = this;
            if (!!length) {
                this.exportOrderAjax($("#conditionform  .single-orgid").attr('org__id'))
            } else {
                $("body").append(template.render(tpl.exportTpl)({ orgList: orgList }));
                $(".close-btn").on("click", function() {
                    $(".dialog-wp").remove();
                });
                $(".sure-operate-btn").on("click", function() {
                    var orgId = $(".d-orgid").attr('org__id');
                    if (!orgId) {
                        layer.msg("请选择项目");
                        return false;
                    };
                    _this.exportOrderAjax(orgId, function() {
                        $(".dialog-wp").remove();
                    })
                })
            }

        },
        /**
         * 导出订单汇总请求
         * @param orgId 项目id
         * @param callback
         */
        exportOrderAjax: function(orgId, callback) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/exportExcel",
                data: {
                    orgId: orgId
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        location.href = $("#contextPath").val() + "/upload/OrderExcel"+orgId+".xls";
                        callback && callback();
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('ervirtualArchIdror')
                }
            });
        },

        /*重新渲染table*/
        againRenderTable: function(option) {
            var obj = $.extend(true, {}, option);
            var type = obj.type || ''
            var $orgId = $("#conditionform  .single-orgid");
            var orgId = $("#conditionform  #orgId").attr('org__id')
            if (type == 1) {
                table.reload('testReload', {
                    where: {
                        userName: '',
                        status: '',
                        star: '',
                        dept: '',
                        beginTime: '',
                        endTime: '',
                        orderTime: '',
                        endOrderTime: '',
                        orgId: $orgId.length?orgId:'',
                        virtualArchId: '',
                        type: ''
                    },
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            } else {
                table.reload('testReload', {
                    where: {
                        userName: $("#conditionform .userName").val(),
                        status: $("#conditionform .status").val(),
                        star: $("#conditionform .star").val(),
                        dept: $("#conditionform #departmentId").attr('dep__id'),
                        beginTime: $("#conditionform .beginTime").val(),
                        endTime: $("#conditionform .endTime").val(),
                        orderTime: $("#conditionform .orderTime").val(),
                        endOrderTime: $("#conditionform .endOrderTime").val(),
                        orgId: orgId,
                        virtualArchId: $("#conditionform  #companyId").attr('com__id'),
                        type: $("#conditionform  .type").val()
                    },
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            }

        },
        //请求项目列表
        itemAjax: function() {
            $.ajax({
                type: "post",
                url: contextPath + "/admin/templ/getOrgList",
                success: function(data) {
                    if (data.code == ERROK) {
                        orgList = data.data;
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /**
         * 获取部门
         * @param id
         */
        ajaxDepart: function(id) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/appUser/getDeptAndAddress",
                data: {
                    type: 1
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        $(".dept").html(template.render(tpl.deptTpl)(data))

                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /**
         * 获取详情
         * @param id 详情id
         * @param orgId   项目id
         */
        ajaxDetail: function(id, orgId) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/getOrderDinnerInfo",
                data: {
                    id: id
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        _this.getIntegral(orgId, function(integral) {
                            data.data.integral = integral;
                            $("body").append(template.render(tpl.detailTpl)(data.data));
                            //关闭弹窗
                            $(".close-btn").on("click", function() {
                                $(".dialog-wp").remove();
                            });
                        })

                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /*
         * 根据项目获取单日积分设置
         * @param orgId
         * @param callback
         */
        getIntegral: function(orgId, callback) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/place/getIntegralByOrgId",
                data: {
                    orgId: orgId
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        callback(data.data);
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /**
         * 短信提醒功能
         * @param isSetMessage 0不开启1开启
         * @param orgId   项目id
         */
        isSetMessage: function(isSetMessage,isSetWechatMessage, orgId,callback) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/place/setOrgByMessage",
                data: {
                    orgId: orgId,
                    isSetMessage: isSetMessage,
                    isSetWechatMessage:isSetWechatMessage
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        layer.msg('设置成功')
                        callback()
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /**
         * 设置订餐推送开关
         * @param isStatus // 当前开关状态
         * @param orgId // 项目开关
         * @param callback 返回数据
         */
        isSetStatusHandler: function(isStatus, orgId, callback) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/place/saveAndPushSet",
                data: {
                    orgId: orgId,
                    status: isStatus,
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        layer.msg('设置成功')
                        callback()
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /**
         * 判断是否开启短信提醒功能
         * @param orgId   项目id
         */
        getOrgByMessage: function(orgId) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/place/getOrgByMessage",
                data: {
                    orgId: orgId
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        data.data.isSetMessage == 1?$("#warn").attr('checked',"checked"):$("#warn").attr('checked',false)
                        data.data.isSetWechatMessage == 1?$("#warnM").attr('checked',"checked"):$("#warnM").attr('checked',false)
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        },
        /**
         * 判断是否开启订餐提醒功能
         * @param orgId   项目id
         */
        getPushSetByOrgIdHandler: function (orgId) {
            var _this = this;
            $.ajax({
                type: "post",
                url: contextPath + "/admin/dinner/place/getPushSetByOrgId",
                data: {
                    orgId: orgId
                },
                success: function(data) {
                    if (data.code == ERROK) {
                        data.data.status == 1?$("#mealCheck").attr('checked',"checked"):$("#mealCheck").attr('checked',false)
                    } else {
                        layer.msg(data.msg)
                    }
                },
                error: function(error) {
                    layer.msg('error')
                }
            });
        }
    };
    api.init();
})
