/*-------------------------------文档信息-----------------------------------
///功能：其他收入款
///创建人: 翟新乐
///创建时间：2011-07-01
///修改人：------------------------
///修改时间：-----------------------
///修改原因：-----------------------
///详细说明：-----------------------
---------------------------------------------------------------------*/
var strDivP050301 = "divP0503";            //弹出层
var strTableTp050301 = "Tp050301";          //gridId
var strOptrTypeP050301 = "1";               //操作标志位
var strRecordsP050301 = 5;                       //添加空白行的行数
var strDeletHtml = "";                      //删除数据传递的数据
var iRowP050301 = 1;                             //行
var iColP050301 = 1;                             //列
var objRecords = [];                              //修改取到的数据

//自定义combobox
function my_inputP050301(value, options) {
    var strHtml = "<select class=\"easyui-combobox\" name=\"" + options.name + "\"  id=\"" + options.id + "\">";
    return $(strHtml);
}

//getText
function my_valueP050301(ele) {
    return ele.combobox('getText');
}

//自定义元素
function my_inputTree(value, options) {
    var strHtml = "<input id=\"" + options.id + "\" class=\"ciho-Input\"  name=\"" + options.name + "\" >";
    return $(strHtml);
}

//获取自定义元素的值
function my_valueTree(ele) {
    return ele.cihoComboTree('getText');
}

//格式数量方法
function formatterP050301b1(cellValue) {
    if (!isNaN(parseFloat(cellValue))) {
        return parseFloat(cellValue).toFixed(window.parent.strMoneyPlace);
    }
    else {
        return "&nbsp;";
    }
}

//改变标志位方法
function ChangeZtP050301(rowId) {
    var objTable = $("#" + strTableTp050301);
    if (objTable.getCell(rowId, "mxguid") == "") {
        objTable.setCell(rowId, "flag", "1");
    }
    objTable = null;
}

//数据状态方法
function dataChangeStateP050301(bState) {
    //修改Data change状态
    $("#" + strDivP050301 + "_divform").data("change", bState);
}

//释放内存
function freeMomeyP050301() {
    strOptrTypeP050301 = "1";
    strDeletHtml = "";
    iRowP050301 = 1;
    iColP050301 = 1;
    objRecords = [];
}

//自定义grid方法
function createGridP050301(strTableID, objColNames, objColModel) {
    $("#" + strTableID).jqGrid({
        datatype: "local",
        colNames: objColNames,
        colModel: objColModel,
        data: [],
        rownumbers: true,
        rowNum: 9999,
        sortname: "id",
        autowidth: true,
        //height: "100%",
        footerrow: true,
        cellEdit: true,
        cellsubmit: "clientArray",
        gridview: true,
        rownumWidth: 30
    }); //.parent(".ui-jqgrid-bdiv").siblings().css("width", "100%");
    //增加表头‘序号’列
    //$("table.ui-jqgrid-htable th:first", $("#gbox_" + strTableID)).text("序号");
    $("#" + strTableID).setLabel("rn", "序号");
}

//添加空白行方法
function AddEmptyRowP050301() {
    for (var i = 999999999; i < 999999999 + strRecordsP050301; i++) {
        $("#" + strTableTp050301).addRowData(i, { flag: "" });
    }
    resizeGridScroll(strTableTp050301);
}

//打开窗口方法，strType:新增(1),点击修改弹出(2)
function showDialog_P050301(strType) {
    try {
        $(".operate").remove();
        strOptrTypeP050301 = strType;
        objRecords = null;
        creatDiv_ShowDlgHaveTbl(strDivP050301, "其它收款", false, true, strTableTp050301, "800");
        if (strOptrTypeP050301 == "1") {
            creatDialogItem_P050301("");
        }
        else if (strOptrTypeP050301 == "2") {
            $("#idMust", $("#" + strDivP050301)).append("NO:" + objSelRowP0503.djbh);
            creatDialogItem_P050301(objSelRowP0503.djbh);
        }
        $("#bz", "#" + strDivP050301).focus();
    } catch (e) { }
}

//按钮添加空白行方法
function addNewRowP050301() {
    $("#" + strTableTp050301).addRowData(++strRecordsP050301 + 999999999, { id: strRecordsP050301, cz: "" });
    AddCzHtmlP050301();
    resizeGridScroll(strTableTp050301);
}

//创建表单元素方法
function creatDialogItem_P050301(strDjbh) {
    var config = ParseData(window.external.DoOptions(strTableTp050301, "GetTableConfig", "{}"));
    if (config == null) {
        window.parent.cihoAlert(msg.other.modelInfoFail);
        return;
    }
    if (strDjbh != "") {
        objRecords = ParseData(window.external.DoOptions(strTableTp050301, 'GetList', "{\"djbh\":\"" + strDjbh + "\"}"));
    }
    //创建头部
    var i = 0;
    var strForm = "";
    var Item;
    strForm += "<ul>";
    for (i = 0; i < config.pageHeader.length; i++) {
        Item = config.pageHeader[i];
        if (Item.hidden == true) {
            continue;
        }
        if (Item.edittype == "text") {
            strForm += "<li class='inp_70'>";
            strForm += Item.xsmc + "：";
            strForm += "<input type='text'  name='" + Item.index + "' ";
            strForm += " value=''  ";
            strForm += " id='" + Item.index + "'";
            strForm += " maxlength='50'   onkeypress='return checkValidate(event)' onpaste='return validatePaste()'/>";
            strForm += "</li>";
        }
        else {
            strForm += "<li>";
            strForm += Item.xsmc + "：";
            strForm += "<select name='" + Item.index + "' id='" + Item.index + "'";
            strForm += " class='easyui-combobox' >";
            strForm += "</select>";
            strForm += "</li>";
        }
    }
    strForm += "</ul>";
    strForm += "<table id=" + strTableTp050301 + "></table>";
    //strForm += "</br></br></br>";
    $("#" + strDivP050301 + "_divform").append(strForm);
    //下拉框的值
    loadKmData_P050301();
    //设置默认值
    $("#djdate").val(getNowDate());
    inputAndBindData("djdate", false, "#" + strDivP050301, dateChange_P050301);

    //创建表格
    var objTable = $("#" + strTableTp050301);
    createGridP050301(strTableTp050301, config.colNames, config.colModel);
    //$("#gbox_" + strTableTp050301).css("height", "157");
    $("#" + strTableTp050301).setGridHeight(141);
    resizeGridScroll(strTableTp050301);
    //设置属性&nbsp;
    objTable.setColProp("je", { formatter: formatterP050301b1 });
    objTable.setColProp("srxmmc", { edittype: "custom" });
    objTable.setColProp("srxmmc", { editoptions: { custom_element: my_inputTree, custom_value: my_valueTree} });
    objTable.setColProp("spmc", { edittype: "custom" });
    objTable.setColProp("spmc", { editoptions: { custom_element: my_inputP050301, custom_value: my_valueP050301} });
    objTable.setColProp("zymc", { edittype: "custom" });
    objTable.setColProp("zymc", { editoptions: { custom_element: my_inputP050301, custom_value: my_valueP050301} });
    objTable.setColProp("dwmc", { edittype: "custom" });
    objTable.setColProp("dwmc", { editoptions: { custom_element: my_inputP050301, custom_value: my_valueP050301} });
    //添加单元格编辑和保存事件
    objTable.setGridParam({ afterEditCell: afterEditCell_P050301 });
    objTable.setGridParam({ afterSaveCell: afterSaveCell_P050301 });

    if (objRecords != undefined) {
        //加载表格数据
        loadTreeData(strTableTp050301, objRecords.Records);

        if (objRecords.Records == "{}") {
            objRecords.Records = "";
        }
        strRecordsP050301 = objRecords.Records.length > 5 ? objRecords.Records.length - objRecords.Records.length : (5 - objRecords.Records.length);
    }
    else {
        strRecordsP050301 = 5;
    }
    //合计
    GetTotalP050301();
    //空白hang
    AddEmptyRowP050301();
    //操作按钮
    AddCzHtmlP050301();
    $("#" + strTableTp050301).setLabel("cz", '<img id="btnAddP050301"  style="cursor:pointer;padding-top:5px"  title="添加行" src="../../Content/Default/images/edit_add.gif" onclick="addNewRowP050301() "/>');
    //$(".ui-jqgrid-htable th:visible:last").html('<img id="btnAddP050301"  style="cursor:pointer"  title="添加行" src="../../Content/Default/images/edit_add.gif" onclick="addNewRowP050301() "/>');

    //底部开始
    strForm = "<ul>"
    for (i = 0; i < config.pageFooter.length; i++) {
        Item = config.pageFooter[i];
        if (Item.index == "czymc") {
            continue;
        }
        if (Item.edittype == "text") {
            if (config.pageFooter[i]["name"] == "bz") {
                strForm += "<li class='bz'>";
                strForm += Item.xsmc + "：";
                strForm += "<input type='text'  name='" + Item.index + "' ";
                strForm += " value=''";
                strForm += " id='" + Item.index + "'>";
                strForm += "</li>";
            }
            else {
                strForm += "<li class='inp_70'>";
                strForm += Item.xsmc + "：";
                strForm += "<input type='text'  name='" + Item.index + "' ";
                strForm += " value=''";
                strForm += " id='" + Item.index + "'>";
                strForm += "</li>";
            }
        }
    }
    strForm += "</ul>";
    $("#" + strDivP050301 + "_divform").append(strForm);

    //设置底部默认值
    if (strOptrTypeP050301 == "1") {    //新增时，设置制单人的数据
        $("#czydm", "#" + strDivP050301).val(window.parent.objLoginInfo.name);
    }
    $("#czydm", "#" + strDivP050301).attr("disabled", true);
    $("#bz", $("#" + strDivP050301 + "_divform")).attr("disabled", false);
    if (strOptrTypeP050301 == "2") {        //页尾头部数据
        //日期
        $("#djdate", "#" + strDivP050301).attr("disabled", true);
        $("#djdate", "#" + strDivP050301).val(objRecords.djdate);
        //收款账户
        $("#kmdm", "#" + strDivP050301).combobox('setValue', objRecords.kmdm);
        $("#kmdm", "#" + strDivP050301).combobox('setText', objRecords.kmmc);
        //制单人
        $("#czydm", $("#" + strDivP050301 + "_divform")).val(objRecords.czymc);
        //摘要
        $("#bz", "#" + strDivP050301).val(escape(objRecords.bz));
    }
    //设定状态
    $(":input", $("#" + strDivP050301 + "_divform")).change(function () {
        dataChangeStateP050301(true);
    });

    $("#" + strDivP050301).dialog("option", "position", "center");
    dataChangeStateP050301(false);
    setTimeout(function () { $("#bz", "#" + strDivP050301).focus(); }, 100);
    //释放内存
    config = null;
    objKm = {};
    objTable = null;
    strForm = null;
    Item = null;
    i = null;
}

//日期控件变更，datachange
function dateChange_P050301() {
    dataChangeStateP050301(true);
}

//加载账户combobox信息方法
function loadKmData_P050301() {
    var objKm = getComboboxData('TKjkm');
    objKm.push({ "mc": "<font color='red'>添加收款账户</font>", "dm": "-1" });
    //shou款账户
    $("#kmdm", "#" + strDivP050301).combobox({
        textField: "mc",
        valueField: "dm",
        width: _iWidth80,
        listWidth: _iWidth80,
        onChange: function (newValue, oldValue) {
            dataChangeStateP050301(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") { //添加收款账户
                ciho.IniData({ id: "divAddType", title: "收款账户", table: "Tflxx" }, { jquery: $("#kmdm", "#" + strDivP050301), model: "Tkjkm" });
                ciho.showTypeDialog();
                $("#kmdm", "#" + strDivP050301).combobox("setValue", "");
            }
        }
    });
    $("#kmdm", "#" + strDivP050301).combobox("loadData", objKm);
    objKm = {};
    $(".layoutpanel").css("z-index", "50000009");
}

//单元格编辑方法
function afterEditCell_P050301(rowid, cellname, value, iRow, iCol) {

    iRowP050301 = iRow;
    iColP050301 = iCol;
    var item = $("#" + rowid + " :input:[name='" + cellname + "']", this);
    switch (cellname) {
        case "srxmmc":      //收入项目
            var objKjkmdm = ParseData(window.external.DoOptions(strTableTp050301, "GetComboBoxData", "{}")).Records;
            item.cihoComboTree({
                width: 100,
                showBox: false,
                showMode: "all"
            });
            item.cihoComboTree("loadData", objKjkmdm);
            var strXmmc = $("#" + strTableTp050301).getCell(rowid, "srxmdm");

            if (item.cihoComboTree("getText") == strXmmc) {
                item.cihoComboTree('setText', value);
            }
            item.cihoComboTree({
                onSelect: function (Record) {
                    if (Record.dm != undefined) {
                        $("#" + strTableTp050301).setCell(rowid, "srxmdm", Record.dm);
                    }
                    else {
                        $("#" + strTableTp050301).setCell(rowid, "srxmdm", "&nbsp;");
                    }
                    dataChangeStateP050301(true);
                    ChangeZtP050301(rowid);
                }
            });
            item.cihoComboTree("setValue", strXmmc);
            item.cihoComboTree("setText", value);
            item.cihoComboTree("focus");
            break;
        case "zymc":            //关联职员
            var objZy = getComboboxData('TZyxx');
            objZy.push({ "mc": "<font color='red'>添加职员</font>", "dm": "-1" });
            item.combobox({
                width: _iWidth120,
                listWidth: _iWidth120,
                valueField: "dm",
                textField: "mc"
            });
            if (objZy != "{}") {
                item.combobox("loadData", objZy);
            }
            var strZymc = $("#" + strTableTp050301).getCell(rowid, "zydm");

            item.combobox("setValue", strZymc);
            item.combobox("setText", value);
            item.combobox('focus');
            if (item.combobox("getText") == strZymc) {
                item.combobox('setText', value);
            }
            item.combobox({
                onChange: function (newValue, oldValue) {
                    dataChangeStateP050301(true);
                    ChangeZtP050301(rowid);
                    if (!newValue) {
                        $("#" + strTableTp050301).setCell(rowid, "zydm", "&nbsp;");
                    }
                    else {
                        $("#" + strTableTp050301).setCell(rowid, "zydm", newValue);
                    }
                },
                afterChange: function (newValue, newText) {
                    if (newValue == "-1") {
                        ciho.IniData({ id: "divAddType", title: "职员", table: "Tflxx" }, { model: "TZyxx", jquery: $(this) });
                        ciho.showTypeDialog();
                        $(this).combobox("setValue", "");
                    }
                }
            });
            break;
        case "dwmc":            //关联单位
            var objBm = getComboboxData('Tkhxx1');
            objBm.push({ "mc": "<font color='red'>添加关联单位</font>", "dm": "-1" });
            item.combobox({
                width: _iWidth120,
                listWidth: _iWidth120,
                valueField: "dm",
                textField: "mc"
            });
            if (objBm != "{}") {
                item.combobox("loadData", objBm);
            }
            var strBmmc = $("#" + strTableTp050301).getCell(rowid, "dwdm");
            item.combobox("setValue", strBmmc);
            item.combobox("setText", value);
            item.combobox('focus');
            if (item.combobox("getText") == strBmmc) {
                item.combobox('setText', value);
            }
            item.combobox({
                onChange: function (newValue, oldValue) {//debugger
                    dataChangeStateP050301(true);
                    ChangeZtP050301(rowid);
                    if (!newValue) {
                        $("#" + strTableTp050301).setCell(rowid, "dwdm", "&nbsp;");
                    }
                    else {
                        $("#" + strTableTp050301).setCell(rowid, "dwdm", newValue);
                    }
                },
                afterChange: function (newValue, newText) {//debugger
                    $(this).combobox("setText", newText.replace(/&nbsp;/g, ""));
                    if (newValue == "-1") {
                        ciho.IniData({ id: "divAddType", title: "关联单位", table: "Tflxx" }, { model: "Tkhxx", jquery: $(this) });
                        ciho.showTypeDialog();
                        $(this).combobox("setValue", "");
                    }
                }
            });
            break;
        case "spmc":        //关联药品
            var objSp = getComboboxData('Tspxx');
            objSp.push({ "mc": "<font color='red'>添加药品</font>", "dm": "-1" });
            item.combobox({
                width: _iWidth120,
                listWidth: _iWidth120,
                valueField: "dm",
                textField: "mc"
            });
            if (objSp != "{}") {
                item.combobox("loadData", objSp);
            }
            var strSpmc = $("#" + strTableTp050301).getCell(rowid, "spdm");
            item.combobox("setValue", strSpmc);
            item.combobox('focus');
            if (item.combobox("getText") == strSpmc) {
                item.combobox('setText', value);
            }
            item.combobox({
                onChange: function (newValue, oldValue) {
                    dataChangeStateP050301(true);
                    ChangeZtP050301(rowid);
                    if (!newValue) {
                        $("#" + strTableTp050301).setCell(rowid, "spdm", "&nbsp;");
                    }
                    else {
                        $("#" + strTableTp050301).setCell(rowid, "spdm", newValue);
                    }
                },
                afterChange: function (newValue, newText) {
                    if (newValue == "-1") {
                        ciho.IniData({ id: "divAddType", title: "药品", table: "Tflxx" }, { model: "Tspxx", jquery: $(this) });
                        ciho.showTypeDialog();
                        $(this).combobox("setValue", "");
                    }
                }
            });
            break;
        case "je":
            item.val(value);
            item.autoNumeric({ mDec: window.parent.strMoneyPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            break;
    }
    $(".layoutpanel").css("z-index", "50000009");
    item.change(function () { dataChangeStateP050301(true); ChangeZtP050301(rowid); });
}

//单元格保存方法
function afterSaveCell_P050301(rowid, cellname, value, iRow, iCol) {
    var objTable = $("#" + strTableTp050301);
    var strB1 = 0;
    strB1 = objTable.getCell(rowid, "je");
    if (isNaN(parseFloat(strB1))) {
        objTable.setCell(rowid, "je", "&nbsp;");
    }
    else {
        strB1 = parseFloat(strB1);
        objTable.setCell(rowid, "je", parseFloat(strB1).toFixed(window.parent.strMoneyPlace));
    }
    GetTotalP050301();
    //释放内存
    objTable = null;
    strB1 = null;
}

//合计方法
function GetTotalP050301() {
    var objTable = $("#" + strTableTp050301);
    var arrIds = objTable.getDataIDs();
    var strSl = 0;
    for (var i = 0; i < arrIds.length; i++) {
        var intNumSl = parseFloat(objTable.getCell(arrIds[i], "je"));
        if (!isNaN(intNumSl)) {
            strSl += intNumSl;
        }
    }
    objTable.footerData("set", { rn: "合计", je: parseFloat(strSl).toFixed(window.parent.strMoneyPlace) });
    //释放内存
    objTable = null;
    arrIds = null;
    strSl = null;
    intNumSl = null;
}

//添加操作按钮方法
function AddCzHtmlP050301() {

    $("#" + strTableTp050301 + " tr:visible").hover(function () {
        var strButtonHtml = "";
        strButtonHtml += "<a href=\"#\" style=\"color:red;text-decoration:none;\" onclick=\"deleteData_P050301(" + this.id + ");return false;\">删除</a> ";
        $("#" + strTableTp050301).jqGrid("setCell", this.id, "cz", strButtonHtml);
    }, function () {
        $("#" + strTableTp050301).jqGrid("setCell", this.id, "cz", "　");
    });
}

//删除方法
function deleteData_P050301(strID) {
    try {
        var objTr = $("#" + strTableTp050301).getRowData(strID);
        $("#" + strTableTp050301).saveCell(iRowP050301, iColP050301);
        if (objTr.srxmdm || objTr.flag) {//如果有代码
            window.parent.cihoAlert(
                    msg.del.delConfirm,
                     msgBox.dlgBtn.YesNo,
                     function (strRet) {
                         if (msgBox.dlgRst.Yes == strRet) {
                             if (objTr.mxguid) {
                                 strDeletHtml += "{\"mxguid\":\"" + objTr.mxguid + "\",";
                                 strDeletHtml += "\"flag\":\"3\"},";
                             }
                             $("#" + strTableTp050301).delRowData(strID);
                             dataChangeStateP050301(true);
                             GetTotalP050301();
                             resizeGridScroll(strTableTp050301);
                         }
                     }
                );
        }
        else {
            $("#" + strTableTp050301).delRowData(strID);
            GetTotalP050301();
        }
        resizeGridScroll(strTableTp050301);
        //objTr = null;
    } catch (e) { }
}

//保存方法
function saveMyData_P050301(save) {
    var strRecord = saveMyDataTp050301(save);
    if (!strRecord) {
        return;
    }
    if (strOptrTypeP050301 == "1") {    //新增
        var objResult = ParseData(window.external.DoOptions(strTableTp050301, "Add", strRecord));
    }
    else {          //修改
        var objResult = ParseData(window.external.DoOptions(strTableTp050301, "Edit", strRecord));
    }
    if (!objResult) {
        window.parent.cihoAlert(msg.other.dbOprateErr);
        return;
    }
    if (objResult.ReturnCode != "0") {
        window.parent.cihoAlert(objResult.MSG);
        return;
    }
    loadGridDataP0503();
    //resizeGrid(strTableP0503);
    //清除修改数据
    strRecordsP050301 = 5;
    objTable = null;
    objResult = null;
    if (save == "2") {  //保存新增
        strOptrTypeP050301 = "1";
        $("#" + strTableTp050301).clearGridData();
        AddEmptyRowP050301();
        AddCzHtmlP050301();
        $(":input", $("#" + strDivP050301)).val("");
        //清除单据编号
        $("#idMust", $("#" + strDivP050301)).empty();
        $("#kmdm", "#" + strDivP050301).combobox('setValue', '');

        $("#czydm", "#" + strDivP050301).val(window.parent.objLoginInfo.name);
        $("#djdate", "#" + strDivP050301).val(getNowDate());
        $("#djdate", "#" + strDivP050301).attr("disabled", false);
        $("#" + strTableTp050301).footerData('set', { je: "" });
        $("#bz", "#" + strDivP050301).focus();                          //给摘要设置焦点
        dataChangeStateP050301(false);
        $("#bz", "#" + strDivP050301).focus();
    }
    else {
        //$("#" + strDivP050301).dialog('close');
        cihoDlgClose(strDivP050301);
    }
    freeMomeyP050301();
}

//json串组成方法
function saveMyDataTp050301(save) {
    //头部
    var strData = "{";
    if ($("#djdate ", "#" + strDivP050301).val() == "") {       //日期为空
        window.parent.cihoAlert(msg.dt.dtExtentErr, null, function () { $("#djdate").focus(); });
        return false;
    }
    if (($("#djdate", "#" + strDivP050301).val().replace(/-/g, "/")) < (window.parent._startDate.replace(/-/g, "/"))) {    //日期超出系统时间范围
        window.parent.cihoAlert(msg.other.djrqExtent, null, function () { $("#djdate").select(); });
        return;
    }
    strData += "\"djdate\":\"" + $("#djdate", "#" + strDivP050301).val() + "\"";

    //收款账户
    var strLxValue = $("#kmdm", $("#" + strDivP050301 + "_divform")).combobox('getValue');
    if (!strLxValue) {
        if ((strOptrTypeP050301 == "2") && objRecords.Records != "{}" && $("#kmdm", "#" + strDivP050301).combobox('getText') == objRecords.Records[0].kmmc) {
            strLxValue = objRecords.Records[0].kmdm;
        }
        else {
            window.parent.cihoAlert(msg.skd.kmdmNotEmp, null, function () { $("#kmdm", "#" + strDivP050301).combobox('focus'); });
            return false;
        }
    }
    strData += ",\"kmdm\":\"" + strLxValue + "\"";

    if (strOptrTypeP050301 == "2") {    //修改时，加入djbh
        strData += ",\"djbh\":\"" + objSelRowP0503.djbh + "\"";
    }
    //表格的数据
    strData += ",Records:[";
    var objTable = $("#" + strTableTp050301);
    objTable.saveCell(iRowP050301, iColP050301);
    var arrIds = objTable.getDataIDs();
    var bAddTable = false;
    var intJehj = 0;
    for (var i = 0; i < arrIds.length; i++) {
        var objTr = objTable.getRowData(arrIds[i]);
        if (objTr.flag == "") {
            continue;
        }
        if (checkEmptyRow(objTr, "flag,mxguid,cz")) {
            if (strOptrTypeP050301 == "2" && strDeletHtml.indexOf(objTr.mxguid) == -1) {
                if (strDeletHtml != null && strDeletHtml != "") {
                    strDeletHtml += "{\"mxguid\":\"" + objTr.mxguid + "\",\"flag\":\"3\"},";
                }
                else {
                    strDeletHtml = "{\"mxguid\":\"" + objTr.mxguid + "\",\"flag\":\"3\"},";
                }
            }
            continue;
        }
        var strIndex = objTable.getInd(arrIds[i]);
        var alterMsg = "";
        strData += "{";
        if (strOptrTypeP050301 == "1" && objTr.flag == "1") {
            strData += "\"mxguid\":\"\",";
        }
        if (strOptrTypeP050301 == "2" && objTr.flag == "2") {
            strData += "\"mxguid\":\"" + objTr.mxguid + "\",";
        }
        if (objTr.srxmdm == "" || objTr.srxmdm == "-1" || objTr.srxmdm == undefined) {
            alterMsg += msg.other.dnh + strIndex + msg.other.SrxmNotEmp;
            window.parent.cihoAlert(alterMsg);
            return;
        }
        if (objTr.je == "" || objTr.je == undefined) {

            alterMsg += msg.other.dnh + strIndex + msg.other.srjeNotEmp;
            window.parent.cihoAlert(alterMsg);
            return;
        }
        intJehj += parseFloat(objTr.je);
        bAddTable = true;
        strData += "\"srxmdm\":\"" + objTr.srxmdm + "\",";
        strData += "\"dwdm\":\"" + objTr.dwdm + "\",";
        strData += "\"spdm\":\"" + objTr.spdm + "\",";
        strData += "\"zydm\":\"" + objTr.zydm + "\",";
        strData += "\"je\":\"" + objTr.je + "\",";
        strData += "\"flag\":\"" + objTr.flag + "\"";
        strData += "},";
    }
    if (bAddTable == false) {
        window.parent.cihoAlert(msg.kc.notDataEmp);
        return false;
    }
    if (strDeletHtml != null) { //有删除数据时
        strData += strDeletHtml;
    }
    if (strData.substring(strData.length - 1, strData.length) != "[") {
        strData = strData.substr(0, strData.length - 1);
    }
    strData += "]"
    if (intJehj > window.parent._MaxPerBill) {
        window.parent.cihoAlert(msg.other.djhjExtent);
        return;
    }
    //尾部
    if (strOptrTypeP050301 == "1") {    //新增时，制单人数据取自登陆账户数据
        strData += ",\"czydm\":\"" + window.parent.objLoginInfo.code + "\"";
    }
    else {      //修改时取自回台返回的数据
        strData += ",\"czydm\":\"" + objRecords.czydm + "\"";
    }
    strData += ",\"bz\":\"" + trim($("#bz", "#" + strDivP050301 + "_divform").val()) + "\"";
    strData += "}";
    //释放内存
    objTable = null;
    strLxValue = null;
    objTr = null;
    strIndex = null;
    alterMsg = null;
    return strData;
}