/*************************
*功能：预提管理维护
*创建人：张振华
*时间：2010-08-16
*备注：此时间是加注释时间
*************************/

var strTableP050601 = "Tp050601";
var strDivP050601 = "divP050601";
var strOptrTypeP050601; //保存标志位
var objRecordsP050601;  //修改的时候的数据库中的记录
var RulesList = { Type: "0", CumToTotal: true, Rules: [] }; //type:0按数量，1按金额


//判断是否选择了预提方式
function checkYtfs() {
    if (!$("#ytfs", "#" + strDivP050601).combobox('getValue')) {
        window.parent.cihoAlert(msg.gz.ytTypeNoSel, null, function () { $("#ytfs", "#" + strDivP050601).focus(); });
        return false;
    }
    return true;
}

//修改层的状态
function dataChangeStateP050601(bState) {
    $("#" + strDivP050601 + "_divform").data("change", bState);
}

//释放内存
function freeMemory_P050601() {
    strOptrTypeP050601 = null;
    objRecordsP050601 = null;
    //RulesList = null;
}

//弹出层
//1:新增，2:修改，3:查看，4:该规则产生了单据的修改
function showDialogP050601(strType) {
    try {

        //数据库返回的结果
        var objResult;

        //清楚浮动层
        $(".operate").hide();

        //存储保存标志位
        strOptrTypeP050601 = strType;

        //弹出空的层
        if (strType == "3") {
            creatDiv_ShowDialog(strDivP050601, "预提规则设置", false, false, strTableP050601, "400");
        }
        else {
            creatDiv_ShowDialog(strDivP050601, "预提规则设置", false, true, strTableP050601, "400");
        }

        //往层里添加内容
        if (strOptrTypeP050601 == "1") {
            addContentP050601("");
        }
        else if (strOptrTypeP050601 == "2") {
            objResult = ParseData(window.external.DoOptions(strTableP050601, "GetSingle", "{\"gzguid\":\"" + objSelRowP0506.gzguid + "\"}"));
            if (objResult.flag == "4") {
                strOptrTypeP050601 = objResult.flag;
            }
            addContentP050601();
        }
        else if (strOptrTypeP050601 == "3") {
            addContentP050601();
        }

        $('#' + strDivP050601 + "_content").css("margin-top", "-100px");

        //关闭窗口时，清空窗口中的内容
        $("#" + strDivP050601).unbind("dialogclose").bind("dialogclose", function () { freeMemory_P050601(); $(this).empty(); });

    }
    catch (e) {
        proceError("P050601", e.ToString());
    }

}

//添加弹出层内容
function addContentP050601(strBh) {

    //常用变量
    var objGrid = $("#" + strTableP0506);
    var objNames = objGrid.jqGrid('getGridParam', "colNames");
    var objIndexs = objGrid.jqGrid('getGridParam', "colModel");

    //费用科目，预提方式，预提时间，费用经受人，客户，药品，职员
    var objFykm = ParseData(window.external.DoOptions(strTableP050601, "GetTreeList", "{}")).Records;
    var objYtType = [{ "dm": "0", "mc": "按销售预提" }, { "dm": "1", "mc": "按回款预提"}];
    var objYtTime = [{ "dm": "1", "mc": "每月末" }, { "dm": "0", "mc": "每笔业务" }, { "dm": "2", "mc": "每季度末" }, { "dm": "3", "mc": "每年末"}];
    var objkh = getComboboxData("Tkhxx1");
    objkh.push({ "mc": "<font color='red'>添加客户</font>", "dm": "-1" });
    var objSp = getComboboxData("Tspxx");
    objSp.push({ "mc": "<font color='red'>添加商品</font>", "dm": "-1" });
    var objZy = getComboboxData("TZyxx");
    objZy.push({ "mc": "<font color='red'>添加职员</font>", "dm": "-1" });

    //其他变量定义
    var i = 0;
    var strForm = "";
    var sign = "";
    var item;

    //填空弹出层样式
    strForm += "<ul>"
    for (i = 0; i < objIndexs.length; i++) {

        item = objIndexs[i];
        if (item.name == "rn" || item.name == "dx" ||
         item.name == "id" || item.name == "gzguid") {
            continue;
        }

        //判断是否必填，加样式
        if (item.editrules.required == true) {
            sign = "<font color='red'>*</font>";
        }
        else {
            sign = "";
        }

        if (item.edittype == "text") {
            if (item.name == "gz") {
                strForm += "<li>";
                strForm += sign;
                strForm += objNames[i] + "：";
                strForm += "<a href='#' onclick=\"if(checkYtfs()){ showDialogP050602('1');};return false;\" style='; color:red; text-decoration:none;'>设置</a>（详细的计算方式、区间设置）";
                strForm += "</li>";
            }
            else if (item.name == "a1") {
                strForm += "<li>";
                strForm += sign;
                strForm += objNames[i] + "：";
                strForm += "<input type='text'  value=''  name='" + item.name + "'";
                strForm += " id='" + item.name + "' "; //限制输入长度
                strForm += " />"; //限制输入，粘贴特殊字符;
                strForm += "</li>";
            }
            else {
                strForm += "<li>";
                strForm += sign;
                strForm += objNames[i] + "：";
                strForm += "<input type='text'  value=''  name='" + item.name + "'";
                strForm += " id='" + item.name + "' maxlength='50'"; //限制输入长度
                strForm += " onkeypress='return checkValidate(event)' onpaste='return validatePaste()'/>"; //限制输入，粘贴特殊字符;
                strForm += "</li>";
            }
        }
        else if (item.edittype == "select") {
            if (item.name == "fykmdm" || item.name == "spdm"
            || item.name == "khdm" || item.name == "zydm"
            || item.name == "jsrdm" || item.name == "ytsj"
             || item.name == "ytfs") {
                strForm += "<li>";
                strForm += sign;
                strForm += objNames[i] + "：";
                strForm += "<select name='" + item.name + "' id='" + item.name + "'";
                strForm += " class='easyui-combobox' >";
                strForm += "</select>";
                strForm += "</li>";
            }
        }
        else if (item.edittype == "checkbox") {
            if (item.name == "zt") {
                strForm += "<li>";
                strForm += sign;
                strForm += "立即启用：";
                strForm += "<input  id='" + item.name + "' type='checkbox'/>";
                strForm += "</li>";
            }
        }
    }
    strForm += "</ul>"

    //填充弹出层
    $("#" + strDivP050601 + "_divform").append(strForm);

    //费用科目
    $("#fykmdm", "#" + strDivP050601).combobox({
        width: _iWidth190,
        panelHeight: 62,
        textField: "mc",
        valueField: "dm",
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") {
                showDialogP060601("1", $("#fykmdm"));
            }
        }
    });
    objFykm.push({ dm: "-1", mc: "<font color='red'>添加科目</font>" });
    $("#fykmdm", "#" + strDivP050601).combobox("loadData", objFykm);

    //预提方式
    $("#ytfs", "#" + strDivP050601).combobox({
        width: _iWidth190,
        panelHeight: 42,
        textField: "mc",
        valueField: "dm",
        editable: false,
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        },
        onSelect: function (Record) {
            if (Record.dm == "1") {
                RulesList.Type = "1";
            }
            else {
                RulesList.Type = "0";
            }
            RulesList.CumToTotal = true;
            RulesList.Rules = [];
        }
    });
    $("#ytfs", "#" + strDivP050601).combobox("loadData", objYtType);

    //预提时间
    $("#ytsj", "#" + strDivP050601).combobox({
        width: _iWidth190,
        panelHeight: 82,
        textField: "mc",
        valueField: "dm",
        editable: false,
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        }
    });
    $("#ytsj", "#" + strDivP050601).combobox("loadData", objYtTime);

    //经手人代码
    $("#jsrdm", "#" + strDivP050601).combobox({
        width: _iWidth190,
        listWidth: _iWidth190,
        textField: "mc",
        valueField: "dm",
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "经手人", table: "Tflxx" }, { jquery: $("#jsrdm", "#" + strDivP050601), model: "TZyxx", other: $("#zydm", "#" + strDivP050601) });
                ciho.showTypeDialog();
            }
        }
    });
    $("#jsrdm", "#" + strDivP050601).combobox("loadData", objZy);

    //客户
    $("#khdm", "#" + strDivP050601).combobox({
        width: _iWidth190,
        listWidth: _iWidth190,
        textField: "mc",
        valueField: "dm",
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        },
        afterChange: function (newValue, newText) {
            $(this).combobox("setText", newText.replace(/&nbsp;/g, ""));
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "客户", table: "Tflxx" }, { jquery: $("#khdm", "#" + strDivP050601), model: "Tkhxx" });
                ciho.showTypeDialog();
            }
        }
    });
    $("#khdm", "#" + strDivP050601).combobox("loadData", objkh);

    //药品
    $("#spdm", "#" + strDivP050601).combobox({
        width: _iWidth190,
        listWidth: _iWidth190,
        textField: "mc",
        valueField: "dm",
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "药品", table: "Tflxx" }, { jquery: $("#spdm", "#" + strDivP050601), model: "Tspxx" });
                ciho.showTypeDialog();
            }
        }
    });
    $("#spdm", "#" + strDivP050601).combobox("loadData", objSp);

    //职员
    $("#zydm", "#" + strDivP050601).combobox({
        width: _iWidth190,
        listWidth: _iWidth190,
        textField: "mc",
        valueField: "dm",
        onChange: function (newValue, oldValue) {
            dataChangeStateP050601(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "职员", table: "Tflxx" }, { jquery: $("#zydm", "#" + strDivP050601), model: "TZyxx", other: $("#jsrdm", "#" + strDivP050601) });
                ciho.showTypeDialog();
            }
        }
    });
    $("#zydm", "#" + strDivP050601).combobox("loadData", objZy);

    //结束日期绑定事件负默认值
    inputAndBindData("edate");
    $("#edate", "#" + strDivP050601).blur(function () {
        $("#" + strDivP050601 + "_divform").data("change", true);
    });
    $("#edate", "#" + strDivP050601).val(getNowDate());

    //开始日期绑定事件负默认值
    inputAndBindData("sdate");
    $("#sdate", "#" + strDivP050601).blur(function () {
        $("#" + strDivP050601 + "_divform").data("change", true);
    });
    $("#sdate", "#" + strDivP050601).val(getNowDate());

    //备注
    $("#a1", "#" + strDivP050601).focus(function () { this.select(); });

    //设置层序
    $(".layoutpanel").css("z-index", "50000009");

    //加载修改数据
    if (strOptrTypeP050601 != "1") {
        RulesList.Type = objSelRowP0506.slje;
        RulesList.CumToTotal = objSelRowP0506.celj;
        $("#gzname", "#" + strDivP050601).val(objSelRowP0506.gzname);

        $("#fykmdm", "#" + strDivP050601).combobox('setValue', objSelRowP0506.fykmdm);
        if ($("#fykmdm", "#" + strDivP050601).combobox('getText') == objSelRowP0506.fykmdm) {
            $("#fykmdm", "#" + strDivP050601).combobox('setText', objSelRowP0506.fykmmc);
        }
        $("#ytfs", "#" + strDivP050601).combobox('setValue', objSelRowP0506.ytfs);

        $("#khdm", "#" + strDivP050601).combobox('setValue', objSelRowP0506.khdm);
        if ($("#khdm", "#" + strDivP050601).combobox('getText') == objSelRowP0506.khdm) {
            $("#khdm", "#" + strDivP050601).combobox('setText', objSelRowP0506.khmc);
        }

        $("#spdm", "#" + strDivP050601).combobox('setValue', objSelRowP0506.spdm);
        if ($("#spdm", "#" + strDivP050601).combobox('getText') == objSelRowP0506.spdm) {
            $("#spdm", "#" + strDivP050601).combobox('setText', objSelRowP0506.spmc);
        }

        $("#zydm", "#" + strDivP050601).combobox('setValue', objSelRowP0506.zydm);
        if ($("#zydm", "#" + strDivP050601).combobox('getText') == objSelRowP0506.zydm) {
            $("#zydm", "#" + strDivP050601).combobox('setText', objSelRowP0506.zymc);
        }

        $("#jsrdm", "#" + strDivP050601).combobox('setValue', objSelRowP0506.jsrdm);
        if ($("#jsrdm", "#" + strDivP050601).combobox('getText') == objSelRowP0506.jsrdm) {
            $("#jsrdm", "#" + strDivP050601).combobox('setText', objSelRowP0506.jsrmc);
        }
        $("#ytsj", "#" + strDivP050601).combobox('setValue', objSelRowP0506.ytsj);

        $("#sdate", "#" + strDivP050601).val(objSelRowP0506.sdate);
        $("#edate", "#" + strDivP050601).val(objSelRowP0506.edate);
        $("#a1", "#" + strDivP050601).val(escape(objSelRowP0506.a1));
        if (objSelRowP0506.zt == "已停用") {
            $("#zt", "#" + strDivP050601)[0].checked = false;
        }
        else {
            $("#zt", "#" + strDivP050601)[0].checked = true;
        }
    }

    // 查看的情况
    if (strOptrTypeP050601 == "3" || strOptrTypeP050601 == "4") {
        $("#fykmdm", "#" + strDivP050601).combobox('disable');
        $("#ytfs", "#" + strDivP050601).combobox('disable');
        $("#khdm", "#" + strDivP050601).combobox('disable');
        $("#spdm", "#" + strDivP050601).combobox('disable');
        $("#zydm", "#" + strDivP050601).combobox('disable');
        $("#jsrdm", "#" + strDivP050601).combobox('disable');
        $("#ytsj", "#" + strDivP050601).combobox('disable');
        $("#gzname", "#" + strDivP050601).attr("disabled", true);
    }
    if (strOptrTypeP050601 == "3") {
        $("#sdate", "#" + strDivP050601).attr("disabled", true);
        $("#edate", "#" + strDivP050601).attr("disabled", true);
        $("#a1", "#" + strDivP050601).attr("disabled", true);
        $("#zt", "#" + strDivP050601).attr("disabled", true);
    }
    if (strOptrTypeP050601 == "4") {
        $("#gzname", "#" + strDivP050601).attr("disabled", false);
    }

    //设定状态
    $(":input", $("#" + strDivP050601 + "_divform")).change(function () {
        $("#" + strDivP050601 + "_divform").data("change", true);
    });
    $("#" + strDivP050601 + "_divform").data("change", false);

    setTimeout('$("#gzname", "#" + strDivP050601).focus()', 100);

    //释放内存
    objGrid = null;
    objFykm = null;

}

//验证
function checkFormP050601(strDialog, strType) {

    //规则名称
    var strGzName = trim($("#gzname", "#" + strDivP050601).val());

    //验证规则名称为空
    if (!strGzName) {
        window.parent.cihoAlert(msg.gz.gzSameNoEmpty, null, function () { $("#gzname", "#" + strDivP050601).focus(); });
        return false;
    }

    //验证规则名称重复
    var objTable = $("#" + strTableP0506);
    var arrIds = objTable.getDataIDs();

    if (strOptrTypeP050601 == "1") {
        //新增时验证
        for (var i = 0; i < arrIds.length; i++) {
            var objTr = objTable.getRowData(arrIds[i]);
            if (objTr.gzname == strGzName) {
                window.parent.cihoAlert(msg.gz.gzSameName, null, function () { $("#gzname", "#" + strDivP050601).focus(); });
                return false;
            }
        }
    }
    else {
        //修改时验证
        for (var i = 0; i < arrIds.length; i++) {
            var objTr = objTable.getRowData(arrIds[i]);

            if (objSelRowP0506 != null && objSelRowP0506.gzguid != objTr.gzguid && objTr.gzname == strGzName) {
                window.parent.cihoAlert(msg.gz.gzSameName, null, function () { $("#gzname", "#" + strDivP050601).focus(); });
                return false;
            }
        }
    }

    //费用科目
    var strFykm = $("#fykmdm", "#" + strDivP050601).combobox('getValue');
    if (!strFykm) {
        window.parent.cihoAlert(msg.gz.fyKmNoEmpty, null, function () { $("#fykmdm", "#" + strDivP050601).combobox("focus"); });
        return false;
    }

    //预提方式
    var strYtType = $("#ytfs", "#" + strDivP050601).combobox('getValue');
    if (!strYtType) {
        window.parent.cihoAlert(msg.gz.ytTypeNoEmpty, null, function () { $("#ytfs", "#" + strDivP050601).combobox("focus"); });
        return false;
    }

    //费用经手人
    var strJsr = $("#jsrdm", "#" + strDivP050601).combobox('getValue');
    if (strJsr == undefined) {
        window.parent.cihoAlert(msg.cw.fyjsrNotExit, null, function () { $("#jsrdm", "#" + strDivP050601).combobox("focus"); });
        return false;
    }

    //预提时间
    var strTime = $("#ytsj", "#" + strDivP050601).combobox('getValue');
    if (!strTime) {
        window.parent.cihoAlert(msg.gz.ytsjNoEmpty, null, function () { $("#ytsj", "#" + strDivP050601).combobox("focus"); });
        return false;
    }

    //开始时间
    var strSTime = $("#sdate", "#" + strDivP050601).val();

    //时间是空 
    if (!strSTime) {
        window.parent.cihoAlert(msg.gz.STimeNoEmpty, null, function () { $("#sdate", "#" + strDivP050601).focus(); });
        return false;
    }

    //格式不对
    if (checkDatePattern(strSTime) == false) {
        window.parent.cihoAlert(msg.dt.dtTypeErr, null, function () { $("#sdate", "#" + strDivP050601).focus(); });
        return false;
    }

    //验证早于起始时间
    if (strSTime.replace(/-/g, "/") < window.parent._startDate) {
        window.parent.cihoAlert(msg.other.djrqExtent, null, function () { $("#sdate", "#" + strDivP050601).focus(); });
        return false;
    }

    //结束时间
    var strETime = $("#edate", "#" + strDivP050601).val();

    //结束时间
    if (strETime == "") {
        window.parent.cihoAlert(msg.gz.ETimeNoEmpty, null, function () { $("#edate", "#" + strDivP050601).focus(); });
        return false;
    }

    //日期格式
    if (checkDatePattern(strETime) == false) {
        window.parent.cihoAlert(msg.dt.dtTypeErr, null, function () { $("#edate", "#" + strDivP050601).focus(); });
        return false;
    }

    //验证早于起始时间
    if (strETime.replace(/-/g, "/") < window.parent._startDate) {
        window.parent.cihoAlert(msg.other.djrqExtent, null, function () { $("#edate", "#" + strDivP050601).focus(); });
        return false;
    }

    //结束时间必须大于开始时间
    strSTime = strSTime.replace(/-/g, "/");
    strETime = strETime.replace(/-/g, "/");
    if (strETime < strSTime) {
        window.parent.cihoAlert(msg.dt.dtStOverEd, null, function () { $("#edate", "#" + strDivP050601).focus(); });
        return false;
    }

    //预提规则
    if (strOptrTypeP050601 == "1" && RulesList.Rules.length == 0) {
        window.parent.cihoAlert(msg.gz.gzSetNoEmpty);
        return false;
    }

    //客户药品职员至少选择一个
    var strKh = $("#khdm", "#" + strDivP050601).combobox('getValue');
    var strYp = $("#spdm", "#" + strDivP050601).combobox('getValue');
    var strZy = $("#zydm", "#" + strDivP050601).combobox('getValue');
    if (!strKh && !strYp && !strZy) {
        window.parent.cihoAlert(msg.gz.KhYpZySelOne, null, function () { $("#khdm", "#" + strDivP050601).combobox("focus"); });
        return false;
    }

    //修改的时候，如果规则是按数量，
    //预提对象选择按销售回款的问题。
    if ((strOptrTypeP050601 == "2" || strOptrTypeP050601 == "4") && $("#ytfs", "#" + strDivP050601).combobox("getValue") == "1" && RulesList.Rules.length == 0 && objSelRowP0506.slje == "0") {
        window.parent.cihoAlert("预提规则是按数量，此时预提方式只能是按销售回款", null, function () { $("#ytfs", "#" + strDivP050601).combobox("focus"); });
        return false;
    }

    //释放内存
    objTable = null;

}

//保存到数据库
function saveToDbP050601(strDialog, strType) {

    //客户，商品，职员
    var strKhdm = $("#khdm", "#" + strDivP050601).combobox('getValue');
    var strSpdm = $("#spdm", "#" + strDivP050601).combobox('getValue');
    var strZydm = $("#zydm", "#" + strDivP050601).combobox('getValue');

    //数据库返回结果
    var objResult;

    //拼接字符串
    var strData = "{";
    strData += "\"gzname\":\"" + trim($("#gzname", "#" + strDivP050601).val()) + "\"";
    strData += ",\"fykmdm\":\"" + $("#fykmdm", "#" + strDivP050601).combobox('getValue') + "\"";
    strData += ",\"ytfs\":\"" + $("#ytfs", "#" + strDivP050601).combobox('getValue') + "\"";
    if (strKhdm == undefined) {
        strKhdm = "";
    }
    if (strSpdm == undefined) {
        strSpdm = "";
    }
    if (strZydm == undefined) {
        strZydm = "";
    }
    strData += ",\"khdm\":\"" + strKhdm + "\"";
    strData += ",\"spdm\":\"" + strSpdm + "\"";
    strData += ",\"zydm\":\"" + strZydm + "\"";
    strData += ",\"jsrdm\":\"" + $("#jsrdm", "#" + strDivP050601).combobox('getValue') + "\"";
    strData += ",\"ytsj\":\"" + $("#ytsj", "#" + strDivP050601).combobox('getValue') + "\"";
    strData += ",\"sdate\":\"" + $("#sdate", "#" + strDivP050601).val() + "\"";
    strData += ",\"edate\":\"" + $("#edate", "#" + strDivP050601).val() + "\"";
    strData += ",\"a1\":\"" + trim($("#a1", "#" + strDivP050601).val()) + "\"";
    strData += ",\"zt\":\"" + $("#zt", "#" + strDivP050601)[0].checked + "\"";
    if (strOptrTypeP050601 == "2" || strOptrTypeP050601 == "4") {
        strData += ",\"gzguid\":\"" + objSelRowP0506.gzguid + "\"";
    }
    strData += ",\"slje\":\"" + RulesList.Type + "\"";
    strData += ",\"celj\":\"" + RulesList.CumToTotal + "\"";
    strData += ",\"Records\":["

    //规则区间
    for (var i = 0; i < RulesList.Rules.length; i++) {
        if (i != 0) {
            strData += ",";
        }
        strData += "{";
        strData += "\"start\":\"" + RulesList.Rules[i].sData + "\"";
        strData += ",\"end\":\"" + RulesList.Rules[i].eData + "\"";
        strData += ",\"ytbl\":\"" + RulesList.Rules[i].rate + "\"";
        strData += "}";
    }
    strData += "]";
    strData += "}";

    //传入后台进行数据库操作
    if (strOptrTypeP050601 == "1") {
        //新增
        objResult = ParseData(window.external.DoOptions(strTableP050601, "Add", strData));
    }
    else if (strOptrTypeP050601 == "2") {
        //修改
        objResult = ParseData(window.external.DoOptions(strTableP050601, "Edit", strData));
    }
    else if (strOptrTypeP050601 == "4") {
        //修改
        objResult = ParseData(window.external.DoOptions(strTableP050601, "Edit", strData));
    }

    //数据库操作是失败弹出信息
    if (objResult.ReturnCode != 0) {
        window.parent.cihoAlert(strRet.MSG);
        return;
    }

    //清除修改数据
    searchDataClickP0506();

    if (strType == "2") {
        //保存新增
        $(":input", $("#" + strDivP050601)).val("");
        $("#fykmdm", "#" + strDivP050601).combobox('setValue', '');
        $("#ytfs", "#" + strDivP050601).combobox('setValue', '');
        $("#khdm", "#" + strDivP050601).combobox('setValue', '');
        $("#spdm", "#" + strDivP050601).combobox('setValue', '');
        $("#zydm", "#" + strDivP050601).combobox('setValue', '');
        $("#jsrdm", "#" + strDivP050601).combobox('setValue', '');
        $("#ytsj", "#" + strDivP050601).combobox('setValue', '');
        $("#edate", "#" + strDivP050601).val(getNowDate());
        $("#sdate", "#" + strDivP050601).val(getNowDate());

        $("#fykmdm", "#" + strDivP050601).combobox('enable');
        $("#ytfs", "#" + strDivP050601).combobox('enable');
        $("#khdm", "#" + strDivP050601).combobox('enable');
        $("#spdm", "#" + strDivP050601).combobox('enable');
        $("#zydm", "#" + strDivP050601).combobox('enable');
        $("#jsrdm", "#" + strDivP050601).combobox('enable');
        $("#ytsj", "#" + strDivP050601).combobox('enable');

        setTimeout(function () { $("#gzname", "#" + strDivP050601).focus(); }, 100);
    }
    else {
        //保存退出
        cihoDlgClose(strDialog);
    }
    //修改状态
    changePageZt("p0506", "1");

    //设定状态
    $("#" + strDivP050601 + "_divform").data("change", false);

    //释放内存
    strOptrTypeP050601 = "1";
    RulesList.Rules = [];
    objRecordsP050601 = null;

    //刷新管理画面的下拉框的值
    reLoadCombo();

}

//保存数据
function saveDataP050601(strDialog, strType) {

    //验证表单
    if (checkFormP050601(strDialog, strType) == false) {
        return;
    }

    //保存
    saveToDbP050601(strDialog, strType);
}