/*-------------------------------文档信息-----------------------------------
///功能：移库单
///创建人: 翟新乐
///创建时间：------------------------
///修改人：------------------------
///修改时间：-----------------------
///修改原因：-----------------------
///详细说明：-----------------------
---------------------------------------------------------------------*/
var strDivP030201 = "divP030201";            //弹出层
var strTableTp030201 = "Tp030201";          //gridId
var strOptrTypeP030201 = "1";               //操作标志位
var strRecordsP030201=5;                      //添加空白行的行数
var strDeletHtml = "";                      //删除时要传递的数据
var iRowP030201=1;                            //行号
var iColP030201=1;                            //列
var objRecords=[];                             //存放修改数据
var strBlData = [];                         //修改时验证字段
var strBjData="";                              //修改前相应字段字符串
var ykData=[];                                 //移库类型

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

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

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

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

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

//自定义grid方法
function createGridP030201(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 AddEmptyRowP030201() {
    for (var i = 999999999; i < 999999999 + strRecordsP030201; i++) {
        $("#" + strTableTp030201).addRowData(i, { flag: "" });
    }
    resizeGridScroll(strTableTp030201);
}

//释放内存
function freeMemeyP030201() {
    strOptrTypeP030201 = "1";
    strDeletHtml = "";
    iRowP030201 = 1;
    iColP030201 = 1;
    objRecords = [];
    strBlData = [];
    strBjData = "";
}

//打开窗口得方法。strType:新增(1),点击修改弹出(2)
function showDialog_P030201(strType) {
    try {
        $(".operate").remove();
        strOptrTypeP030201 = strType;
        objRecords = null;
        creatDiv_ShowDlgHaveTbl(strDivP030201, "移库单", false, true, strTableTp030201, "800");

        if (strOptrTypeP030201 == "1") {
            creatDialogItem_P030201("");
        }
        else if (strOptrTypeP030201 == "2") {
            $("#idMust", $("#" + strDivP030201)).append("NO:" + objSelRowP0302.djbh);
            creatDialogItem_P030201(objSelRowP0302.djbh);
        }
    } catch (e) { }
}

//按钮添加空白行方法
function addNewRowP030201() {
    $("#" + strTableTp030201).addRowData(++strRecordsP030201 + 999999999, { id: strRecordsP030201, cz: "" });
    AddCzHtmlP030201();
    resizeGridScroll(strTableTp030201);
}

//创建表单元素方法
function creatDialogItem_P030201(strDjbh) {
    var config = ParseData(window.external.DoOptions(strTableTp030201, "GetTableConfig", "{}"));
    if (config == null) {
        window.parent.cihoAlert(msg.other.modelInfoFail);
        return;
    }

    if (strDjbh != "") {
        objRecords = ParseData(window.external.DoOptions(strTableTp030201, 'GetList', "{\"djbh\":\"" + strDjbh + "\" ,\"djType\":\"" + objSelRowP0302.yklxdm + "\"}"));
    }
    //创建头部
    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=" + strTableTp030201 + "></table>";
    //strForm += "</br></br></br>";
    $("#" + strDivP030201 + "_divform").append(strForm);

    //下拉框的值
    loadCombData()
    //设置默认值
    $("#djdate").val(getNowDate());
    inputAndBindData("djdate", false, "#" + strDivP030201, dateChange_P030201);

    //创建表格
    createGridP030201(strTableTp030201, config.colNames, config.colModel);
    //$("#gbox_" + strTableTp030201).css("height", "157");
    $("#" + strTableTp030201).setGridHeight(141);
    resizeGridScroll(strTableTp030201);
    //设置属性&nbsp;
    $("#" + strTableTp030201).setColProp("a1", { formatter: formatterP030201b1 });
    $("#" + strTableTp030201).setColProp("spmc", { edittype: "custom" });
    $("#" + strTableTp030201).setColProp("spmc", { editoptions: { custom_element: my_inputP030201, custom_value: my_valueP030201} });
    //添加单元格编辑和保存事件
    $("#" + strTableTp030201).setGridParam({ afterEditCell: afterEditCell_P030201 });
    $("#" + strTableTp030201).setGridParam({ afterSaveCell: afterSaveCell_P030201 });

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

        if (objRecords.Records == "{}") {
            objRecords.Records = "";
        }
        strRecordsP030201 = objRecords.Records.length > 5 ? objRecords.Records.length - objRecords.Records.length : (5 - objRecords.Records.length);
    }
    else {
        strRecordsP030201 = 5;
    }
    //合计
    GetTotalP030201();
    //空白hang
    AddEmptyRowP030201();
    //操作按钮
    AddCzHtmlP030201();
    $("#" + strTableTp030201).setLabel("cz", '<img id="btnAddP030201"  style="cursor:pointer;padding-top:5px"  title="添加行" src="../../Content/Default/images/edit_add.gif" onclick="addNewRowP030201() "/>');
    //$(".ui-jqgrid-htable th:visible:last").html('<img id="btnAddP030201"  style="cursor:pointer"  title="添加行" src="../../Content/Default/images/edit_add.gif" onclick="addNewRowP030201() "/>');
    //底部开始
    strForm = "<ul>"
    for (i = 0; i < config.pageFooter.length; i++) {
        Item = config.pageFooter[i];
        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>";
    $("#" + strDivP030201 + "_divform").append(strForm);
    //设置底部默认值
    if (strOptrTypeP030201 == "1") {
        $("#czydm", "#" + strDivP030201).val(window.parent.objLoginInfo.name);
    }
    $("#czydm", "#" + strDivP030201).attr("disabled", true);

    if (strOptrTypeP030201 == "2") {
        //日期
        $("#djdate", "#" + strDivP030201).attr("disabled", true);
        $("#djdate", "#" + strDivP030201).val(objRecords.djdate);
        //移库类型
        $("#yklxdm", "#" + strDivP030201).combobox('setValue', objRecords.yklxdm);
        $("#yklxdm", "#" + strDivP030201).combobox('setText', objRecords.yklxmc);
        //经手人
        $("#zydm", "#" + strDivP030201).combobox('setValue', objRecords.zydm);
        $("#zydm", "#" + strDivP030201).combobox('setText', objRecords.zymc);
        //调出仓库
        $("#outckdm", "#" + strDivP030201).combobox('setValue', objRecords.outckdm);
        $("#outckdm", "#" + strDivP030201).combobox('setText', objRecords.outckmc);
        //调入仓库
        $("#inckkhdm", "#" + strDivP030201).combobox('setValue', objRecords.inckkhdm);
        $("#inckkhdm", "#" + strDivP030201).combobox('setText', objRecords.inckkhmc);
        //制单人
        $("#czydm", $("#" + strDivP030201 + "_divform")).val(objRecords.czymc);
        //备注
        $("#bz", "#" + strDivP030201).val(escape(objRecords.bz));
        if (objRecords.yklxmc == "配送移库") {  //修改前的数据串
            strBlData.push("spdm");
            strBlData.push("a1");
            strBjData = getCompareData(strTableTp030201, strBlData);
        }
    }
    //设定状态
    $(":input", $("#" + strDivP030201 + "_divform")).change(function () {
        $("#" + strDivP030201 + "_divform").data("change", true);
    });

    $("#" + strDivP030201).dialog("option", "position", "center");
    $("#" + strDivP030201 + "_divform").data("change", false);

    setTimeout(function () { $("#bz", "#" + strDivP030201).focus(); }, 100);
    

    //释放内存
    config = {};
    strForm = null;
    Item = null;
}

//日期控件变更时，datachange
function dateChange_P030201() {
    dataChangeStateP030201(true);
}

//加载combobox的信息的方法
function loadCombData() {
    var objZy = getComboboxData('TZyxx');
    objZy.push({ "mc": "<font color='red'>添加经手人</font>", "dm": "-1" });
    var objCk = loadCkdmData();
    var objKh = getComboboxData('Tkhxx1');
    objKh.push({ "mc": "<font color='red'>添加客户</font>", "dm": "-1" });
    //移库类型
    $("#yklxdm", "#" + strDivP030201).combobox({
        textField: "mc",
        valueField: "dm",
        width: _iWidth80,
        listWidth: _iWidth80,
        panelHeight: 42,
        editable: false,
        onChange: function (newValue, oldValue) {
            dataChangeStateP030201(true);
        },
        onSelect: function (options) {
            if (options.dm == "602") {
                $("#inckkhdm", "#" + strDivP030201).combobox("loadData", objKh);
            }
            else {
                var objInck = loadCkdmData();
                $("#inckkhdm", "#" + strDivP030201).combobox("loadData", objInck);
                objInck = {};
            }
        }
    });
    ykData = [{ "dm": "601", "mc": "移库" }, { "dm": "602", "mc": "配送移库"}];
    $("#yklxdm", "#" + strDivP030201).combobox("loadData", ykData);
    if (strOptrTypeP030201 == "1") {
        $("#yklxdm", "#" + strDivP030201).combobox("setValue", "601");
    }
    //职员
    $("#zydm", "#" + strDivP030201).combobox({
        textField: "mc",
        valueField: "dm",
        width: _iWidth80,
        listWidth: _iWidth80,
        onChange: function (newValue, oldValue) {
            dataChangeStateP030201(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "经手人", table: "Tflxx" }, { jquery: $("#zydm", "#" + strDivP030201), model: "TZyxx" });
                ciho.showTypeDialog();
                $("#zydm", "#" + strDivP030201).combobox("setValue", "");
            }
        }
    });
    if (objZy != "{}") {
        $("#zydm", "#" + strDivP030201).combobox("loadData", objZy);
    }
    //调出仓库
    $("#outckdm", "#" + strDivP030201).combobox({
        textField: "mc",
        valueField: "dm",
        width: _iWidth80,
        listWidth: _iWidth80,
        onChange: function (newValue, oldValue) {
            dataChangeStateP030201(true);
        },
        afterChange: function (newValue, newText) {
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "调出仓库", table: "Tflxx" }, { jquery: $("#outckdm", "#" + strDivP030201), model: "TCkxx" });
                ciho.showTypeDialog();
                $("#outckdm", "#" + strDivP030201).combobox("setValue", "");
            }
        }
    });
    if (objCk != "{}") {
        $("#outckdm", "#" + strDivP030201).combobox("loadData", objCk);
    }
    //调入仓库
    $("#inckkhdm", "#" + strDivP030201).combobox({
        textField: "mc",
        valueField: "dm",
        width: _iWidth80,
        listWidth: _iWidth80,
        onChange: function (newValue, oldValue) {
            dataChangeStateP030201(true);
        },
        afterChange: function (newValue, newText) {
            $(this).combobox("setText", newText.replace(/&nbsp;/g, ""));
            if (newValue == "-1") {
                if ($("#yklxdm", "#" + strDivP030201).combobox("getValue") == "602") {
                    ciho.IniData({ id: "divAddType", title: "客户", table: "Tflxx" }, { jquery: $("#inckkhdm", "#" + strDivP030201), model: "Tkhxx" });
                    ciho.showTypeDialog();
                }
                else {
                    ciho.IniData({ id: "divAddType", title: "调入仓库", table: "Tflxx" }, { jquery: $("#inckkhdm", "#" + strDivP030201), model: "TCkxx" });
                    ciho.showTypeDialog();
                }
                $("#inckkhdm", "#" + strDivP030201).combobox("setValue", "");
            }
        }
    });
    if (objCk != "{}" || objKh != "{}") {
        if (strOptrTypeP030201 == "2" && objRecords.Records[0].yklxdm == "602") {
            $("#inckkhdm", "#" + strDivP030201).combobox("loadData", objKh);
        }
        else {
            $("#inckkhdm", "#" + strDivP030201).combobox("loadData", objCk);
        }
    }
    $("#inckkhdm,#outckdm").combobox("setText", "");
    $(".layoutpanel").css("z-index", "50000009");
    objZy = null;
}

//取仓库的数据方法
function loadCkdmData() {
    var objCkData = getComboboxData('TCkxx');
    objCkData.push({ "mc": "<font color='red'>添加仓库</font>", "dm": "-1" });
    return objCkData;
}

//单元格编辑方法
function afterEditCell_P030201(rowid, cellname, value, iRow, iCol) {
    iRowP030201 = iRow;
    iColP030201 = iCol;
    var item = $("#" + rowid + " :input:[name='" + cellname + "']", this);
    switch (cellname) {
        case "spmc":
            var objSp = getComboboxData('Tspxx');
            objSp.push({ "mc": "<font color='red'>添加药品</font>", "dm": "-1" });
            item.combobox({
                width: _iWidth190,
                listWidth: _iWidth190,
                valueField: "dm",
                textField: "mc"
            });
            if (objSp != "{}") {
                item.combobox("loadData", objSp);
            }

            var strSpmc = $("#" + strTableTp030201).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) {
                    dataChangeStateP030201(true);
                    ChangeZtP030201(rowid);
                    if (!newValue) {
                        $("#" + strTableTp030201).setCell(rowid, "spdm", "&nbsp;");
                    }
                    else {
                        $("#" + strTableTp030201).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 "a1":
            item.val(value);
            item.autoNumeric({ mDec: window.parent.strCountPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            item.change(function () { dataChangeStateP030201(true); ChangeZtP030201(rowid); });
            break;
    }
    $(".layoutpanel").css("z-index", "50000009");
}

//单元格保存方法
function afterSaveCell_P030201(rowid, cellname, value, iRow, iCol) {
    var objTable = $("#" + strTableTp030201);
    var strB1 = objTable.getCell(rowid, "a1");
    if (isNaN(parseFloat(strB1))) {
        objTable.setCell(rowid, "a1", "&nbsp;");
    }
    else {
        strB1 = parseFloat(strB1);
        objTable.setCell(rowid, "a1", parseFloat(strB1).toFixed(window.parent.strCountPlace));
    }
    GetTotalP030201();
    objTable = null;
}

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

//添加操作按钮的方法
function AddCzHtmlP030201() {
    $("#" + strTableTp030201 + " tr:visible").hover(function () {
        var strButtonHtml = "";
        strButtonHtml += "<a href=\"#\" style=\"color:red;text-decoration:none;\" onclick=\"deleteData_P030201(" + this.id + ");return false;\">删除</a> ";
        $("#" + strTableTp030201).jqGrid("setCell", this.id, "cz", strButtonHtml);
    }, function () {
        $("#" + strTableTp030201).jqGrid("setCell", this.id, "cz", "&nbsp;");
    });
}

//删除的方法
function deleteData_P030201(strID) {
    try {
        var objTr = $("#" + strTableTp030201).getRowData(strID);
        $("#" + strTableTp030201).saveCell(iRowP030201, iColP030201);
        if (objTr.spdm || objTr.flag) {//如果有商品代码
            window.parent.cihoAlert(
                    msg.del.delConfirm,
                     msgBox.dlgBtn.YesNo,
                     function (strRet) {
                         if (msgBox.dlgRst.Yes == strRet) {
                             if (objTr.glsl>0) {
                                 //if (objTr.glsl != "0") {
                                     window.parent.cihoAlert(msg.del.delForbid);
                                     return;
                                 //}
                             } else {
                                 if (objTr.mxguid) {
                                     strDeletHtml += "{\"mxguid\":\"" + objTr.mxguid + "\",";
                                     strDeletHtml += "\"flag\":\"3\"},";
                                 }
                                 $("#" + strTableTp030201).delRowData(strID);
                                 dataChangeStateP030201(true);
                                 GetTotalP030201();
                                 resizeGridScroll(strTableTp030201);
                             }
                         }
                     }
                );
        }
        else {
            $("#" + strTableTp030201).delRowData(strID);
            GetTotalP030201();
        }
        resizeGridScroll(strTableTp030201);
        //objTr = null;
    } catch (e) { }
}

//检查关联并保存的方法
function saveMyData_P030201(save) {
    try {
        //检查关联数量    
        var objTable = $("#" + strTableTp030201);
        objTable.saveCell(iRowP030201, iColP030201);
        var arrIds = objTable.getDataIDs();
        //var alterMsg = null;
        for (var i = 0; i < arrIds.length; i++) {
            var objTr = objTable.getRowData(arrIds[i]);
            var strGlsl = parseFloat(objTr.glsl);
            if (strGlsl && strGlsl != parseFloat(objTr.a1)) {
                //alterMsg = msg.other.dnh + objTable.getInd(arrIds[i]) + msg.other.pihao;
                window.parent.cihoAlert(msg.other.pihaoNoSame, msgBox.dlgBtn.OK, function (result) {
                    if (result == msgBox.dlgRst.Ok) {
                        objTable = null;
                        saveData_P030201(save);
                    }
                });
                return;
            }
        }
        objTable = null;
        saveData_P030201(save);
    } catch (e) { }
}

//保存数据的方法
function saveData_P030201(save) {
    var strRecord = saveMyDataTp030201(save);
    if (!strRecord) {
        return;
    }
    if (strOptrTypeP030201 == "1") {    //新增
        var objResult = ParseData(window.external.DoOptions(strTableTp030201, "Add", strRecord));
    }
    else {      //修改
        var objResult = ParseData(window.external.DoOptions(strTableTp030201, "Edit", strRecord));
    }
    if (!objResult) {
        window.parent.cihoAlert(msg.other.dbOprateErr);
        return;
    }
    if (objResult.ReturnCode != "0") {
        window.parent.cihoAlert(objResult.MSG);
        return;
    }
    if (strOptrTypeP030201 == "2" && $("#yklxdm", "#" + strDivP030201).combobox('getText') == "配送移库") { //修改时，并且移库类型为配送移库时，数据有改变，调用后台方法
        var strNewData = getCompareData(strTableTp030201, strBlData);
        if (strBjData != strNewData) {
            window.external.DoOptions(strTableTp030201, 'DoOthers', "{'flag':true,'djdate':'" + objRecords.djdate + "','yklxdm':'602'}");
        }
        strNewData = null;
    }
    loadGridDataP0302();
    //resizeGrid(strTableP0302);
    //清除修改数据
    objTable = null;
    strRecordsP030201 = 5;
    if (save == "2") { //保存新增
        strOptrTypeP030201 = "1";
        $("#" + strTableTp030201).clearGridData();
        AddEmptyRowP030201();
        AddCzHtmlP030201();
        $(":input", $("#" + strDivP030201)).val("");
        //清除单据编号
        $("#idMust", $("#" + strDivP030201)).empty();
        $("#yklxdm", "#" + strDivP030201).combobox('setValue', ykData[0].dm);
        $("#zydm", "#" + strDivP030201).combobox('setValue', '');
        $("#outckdm", "#" + strDivP030201).combobox('setValue', '');
        var strIndata = loadCkdmData();
        $("#inckkhdm", "#" + strDivP030201).combobox("loadData", strIndata);
        $("#inckkhdm", "#" + strDivP030201).combobox('setValue', '');

        $("#czydm", "#" + strDivP030201).val(window.parent.objLoginInfo.name);
        $("#djdate", "#" + strDivP030201).val(getNowDate());
        $("#djdate", "#" + strDivP030201).attr("disabled", false);
        $("#" + strTableTp030201).footerData('set', { a1: "" });
        dataChangeStateP030201(false);
        strIndata = {};
        setTimeout(function () { $("#bz", "#" + strDivP030201).focus(); }, 100);
    }
    else {
        //$("#" + strDivP030201).dialog('close');
        cihoDlgClose(strDivP030201);
    }
    freeMemeyP030201();
}

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

    //移库类型数据
    var strLxValue = $("#yklxdm", $("#" + strDivP030201 + "_divform")).combobox('getValue');    
    if (!strLxValue) {
        if ((strOptrTypeP030201 == "2") && objRecords.Records != "{}" && $("#yklxdm", "#" + strDivP030201).combobox('getText') == objRecords.Records[0].yklxmc) {
            strLxValue = objRecords.Records[0].yklxdm;
        }
        else {
            window.parent.cihoAlert(msg.kc.selYklx, null, function () { $("#yklxdm", $("#" + strDivP030201 + "_divform")).combobox('focus'); });
            return false;
        }
    }
    strData += ",\"yklxdm\":\"" + strLxValue + "\"";

    //经手人数据
    var strZy = $("#zydm", "#" + strDivP030201).combobox('getValue');
    if (!strZy) {
        if ((strOptrTypeP030201 == "2") && objRecords.Records != "{}" && $("#zydm", "#" + strDivP030201).combobox('getText') == objRecords.Records[0].zymc) {
            strZy = objRecords.Records[0].zydm;
        } else {
            window.parent.cihoAlert(msg.sz.jsr.seljsr, null, function () { $("#zydm", "#" + strDivP030201).combobox('focus'); });
            return false;
        }
    }
    strData += ",\"zydm\":\"" + strZy + "\"";

    //仓库代码
    var strCk = $("#outckdm", "#" + strDivP030201).combobox('getValue');
    if (!strCk) {
        if ((strOptrTypeP030201 == "2") && objRecords.Records != "{}" && $("#outckdm", "#" + strDivP030201).combobox('getText') == objRecords.Records[0].outckmc) {
            strCk = objRecords.Records[0].outckdm;
        } else {
            window.parent.cihoAlert(msg.sz.ck.selCk, null, function () { $("#outckdm", "#" + strDivP030201).combobox('focus'); });
            return false;
        }
    }

    //仓库代码
    var strCkdr = $("#inckkhdm", "#" + strDivP030201).combobox('getValue');
    if (!strCkdr) {
        if ((strOptrTypeP030201 == "2") && objRecords.Records != "{}" && $("#inckkhdm", "#" + strDivP030201).combobox('getText') == objRecords.Records[0].inckkhmc) {
            strCkdr = objRecords.Records[0].inckkhdm;
        } else {
            window.parent.cihoAlert(msg.sz.ck.selCk, null, function () { $("#inckkhdm", "#" + strDivP030201).combobox('focus'); });
            return false;
        }
    }
    if (strCk == strCkdr) {
        window.parent.cihoAlert(msg.kc.ckNamenotEque, null, function () { $("#inckkhdm", "#" + strDivP030201).combobox('focus'); });
        return;
    }
    strData += ",\"outckdm\":\"" + strCk + "\"";
    strData += ",\"inckkhdm\":\"" + strCkdr + "\"";

    if (strOptrTypeP030201 == "2") {    //修改时，加入djbh
        strData += ",\"djbh\":\"" + objSelRowP0302.djbh + "\"";
    }
    //表格的数据
    strData += ",Records:[";
    var objTable = $("#" + strTableTp030201);
    objTable.saveCell(iRowP030201, iColP030201);
    var arrIds = objTable.getDataIDs();
    var bAddTable = false;
    var intSlHj = 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 (strOptrTypeP030201 == "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 (strOptrTypeP030201 == "1" && objTr.flag == "1") {
            strData += "\"mxguid\":\"\",";
        }
        if (strOptrTypeP030201 == "2" && objTr.flag == "2") {
            strData += "\"mxguid\":\"" + objTr.mxguid + "\",";
        }
        if (objTr.spdm == "" || objTr.spdm == "-1" || objTr.spdm == undefined) {
            alterMsg += msg.other.dnh + strIndex + msg.sz.yp.lnEmpOrNotExit;
            window.parent.cihoAlert(alterMsg);
            return;
        }
        if (objTr.a1 == "" || objTr.a1 == undefined) {
            alterMsg += msg.other.dnh + strIndex + msg.sz.yp.lnAmountEmp;
            window.parent.cihoAlert(alterMsg);
            return;
        }
        else {
            if (parseFloat(objTr.a1)<=0) {
                alterMsg += msg.other.dnh + strIndex + msg.sz.yp.lnAmountNOtZero;
                window.parent.cihoAlert(alterMsg);
                return;
            }
        }
        intSlHj += parseFloat(objTr.a1);
        bAddTable = true;
        strData += "\"spdm\":\"" + objTr.spdm + "\",";
        strData += "\"a1\":\"" + objTr.a1 + "\",";
        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);
    }
    if (intSlHj > window.parent._MaxPerBill) {  //合计大于1亿
        window.parent.cihoAlert(msg.other.djhjExtent);
        return;
    }
    strData += "]"
    //尾部
    if (strOptrTypeP030201 == "1") {    //新增时，制单人数据取自登陆用户的dm
        strData += ",\"czydm\":\"" + window.parent.objLoginInfo.code + "\"";
    }
    else {  //修改时，制单人取自数据库返回的数据
        strData += ",\"czydm\":\"" + objRecords.Records[0]["czydm"] + "\"";
    }
    strData += ",\"bz\":\"" + trim($("#bz", "#" + strDivP030201 + "_divform").val()) + "\"";
    strData += "}";
    //释放内存
    objTable = null;
    strCkdr = null;
    strCk = null;
    strZy = null;
    strLxValue = null;

    return strData;
}