/*************************
*功能：销售同期比较
*创建人：张振华
*时间：2010-08-15
*备注：此时间是加注释时间
*************************/

var strTableP020102 = "Tp020102";   //tableID
var strDivP020102 = "divP020102";   //弹出层ID
var strOptrTypeP020102 = "1";           //新增，修改
var strRecordsCountP020102 = 1;     //表格的记录数
var iRowP020102 = -1;   //行索引
var iColP020102 = -1;   //列索引
var objRecordsP020102;  //修改或者退货的时候存的单据的信息
var strDeletHtmlP020102 = "";   //删除的数据
var objCompDataP020102 = [];    //要比较的数据
var iFristIndexP020102 = 999999999;

//修改Data change状态
function dataChangeStateP010102(bState) {
    $("#" + strDivP020102 + "_divform").data("change", bState);
}

//该变保存状态
function ChangeFlagP020102(rowId) {

    var objTable = $("#" + strTableP020102);
    if (objTable.getCell(rowId, "mxguid") == "") {
        objTable.setCell(rowId, "flag", "1");

    }
    else {
        objTable.setCell(rowId, "flag", "2");
    }

    objTable = null;
}

//计算合计
function getTotalP020102() {

    //变量定义
    var objTable = $("#" + strTableP020102);
    var arrIds = objTable.getDataIDs();
    var strTotalA1 = 0;     //数量
    var strTotalThje = 0;   //金额
    var strTotalTpje = 0;   //退票金额

    //循环表格计算合计
    for (var i = 0; i < arrIds.length; i++) {
        var strA1 = parseFloat(objTable.getCell(arrIds[i], "a1"));
        var strThje = parseFloat(objTable.getCell(arrIds[i], "thje"));
        var strTpje = parseFloat(objTable.getCell(arrIds[i], "tpje"));
        if (!isNaN(strA1)) {
            strTotalA1 += strA1;
        }
        if (!isNaN(strThje)) {
            strTotalThje += strThje;
        }
        if (!isNaN(strTpje)) {
            strTotalTpje += strTpje;
        }
    }

    //给表格底部赋值
    $("#" + strTableP020102).footerData("set", { rn: "合计", a1: strTotalA1, thje: strTotalThje, tpje: strTotalTpje }, true);

    //释放内存
    objTable = null;
}

//页面加载时添加的添加空行
function addEmptyRowsP020102() {
    for (var i = iFristIndexP020102; i < iFristIndexP020102 + strRecordsCountP020102; i++) {
        $("#" + strTableP020102).addRowData(i, { flag: "" });
    }
}

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

//格式化单价
function formatterP020102Price(cellValue) {

    if (!isNaN(parseFloat(cellValue))) {
        return parseFloat(cellValue).toFixed(window.parent.strPricePlace);
    }
    else {
        return "&nbsp;";
    }
}

//格式化金额
function formatterP020102Money(cellValue) {

    if (!isNaN(parseFloat(cellValue))) {
        return parseFloat(cellValue).toFixed(window.parent.strMoneyPlace);
    }
    else {
        return "&nbsp;";
    }
}

//格式化A3
function formatterP020102A3(cellValue) {
    if (cellValue == "True" || cellValue == "是") {
        return "是";
    }
    else if (cellValue == "False" || cellValue == "否") {
        return "否";
    }
    else {
        return "&nbsp;";
    }
}

//添加一空行
function addEmptyRowP020102() {
    $("#" + strTableP020102).addRowData(++strRecordsCountP020102 + iFristIndexP020102, { id: strRecordsCountP020102 });
    addCzHtmlP020102();
}

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

    return $(strHtml);
}

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

//根据开票单位获得开票税率
function getdkslbyKpdw(strKpdwdm) {

    //开票单位
    var objKpxx = window.parent._arrCmbKpdw;

    //查找税率
    for (var i = 0; i < objKpxx.Records.length; i++) {
        if (objKpxx.Records[i].dm == strKpdwdm) {
            return { kpsl: objKpxx.Records[i].kpsl, mc: objKpxx.Records[i].mc };
        }
    }

}

//编辑单元格之后的事件
function afterEditCell_P020102(rowId, cellname, value, iRow, iCol) {

    //行索引，列索引
    iRowP020102 = iRow;
    iColP020102 = iCol;

    //table对象，编辑的Item对象
    var objTable = $("#" + strTableP020102);
    var item = $("#" + rowId + " :input[name='" + cellname + "']", this);

    switch (cellname) {
        case "spmc":
            //取得商品信息加到下拉框中
            var objSp = getComboboxData('Tspxx');
            var strSpdm = $("#" + strTableP020102).getCell(rowId, "spdm");
            item.combobox({
                width: 78,
                listWidth: 78,
                valueField: "dm",
                textField: "mc"
            });
            if (objSp != "{}") {
                objSp.push({ "mc": "<font color='red'>添加药品</font>", "dm": "-1" });
                item.combobox("loadData", objSp);
            }
            item.combobox("setValue", strSpdm);
            if (item.combobox("getText") == strSpdm) {
                item.combobox('setText', value);
            }
            item.combobox({
                onChange: function (newValue, oldValue) {
                    if (newValue != undefined && newValue != "-1") {
                        $("#" + strTableP020102).setCell(rowId, "spdm", newValue);
                    }
                    else {
                        $("#" + strTableP020102).setCell(rowId, "spdm", "&nbsp;");
                    }
                    //下拉项改变
                    objTable.setCell(rowId, "a3", "否");
                    dataChangeStateP010102(true);
                    ChangeFlagP020102(rowId);
                },
                afterChange: function (newValue, newText) {
                    //选中添加药品时弹出对话框
                    if (newValue == "-1") {
                        ciho.IniData({ id: "divAddType", title: "药品", table: "Tflxx" }, { model: "Tspxx", jquery: $(this) });
                        ciho.showTypeDialog();
                    }
                }
            });
            item.combobox('focus');

            //释放内存
            objSp = null;
            strSpdm = null;
            break;
        case "a3":
            item.combobox({
                width: 78,
                panelHeight: 42,
                valueField: "dm",
                textField: "mc",
                editable: false
            });
            item.combobox("loadData", [{ dm: "是", mc: "是" }, { dm: "否", mc: "否"}]);
            item.combobox('setValue', value);
            item.combobox({
                onChange: function (newValue, oldValue) {
                    //选是的时候带出退票单价,数量；选否的时候清楚数据
                    if (newValue != undefined && newValue == "是") {

                        var strA1 = objTable.getCell(rowId, "a1");
                        var strA2 = objTable.getCell(rowId, "a2");
                        var strThje = objTable.getCell(rowId, "thje");

                        if (objTable.getCell(rowId, "a4") == "") {
                            objTable.setCell(rowId, "a4", strA1, { color: "Black" });
                        }
                        else {
                            objTable.setCell(rowId, "a4", "", { color: "Black" });
                        }

                        if (objTable.getCell(rowId, "a5") == "") {
                            objTable.setCell(rowId, "a5", strA2, { color: "Black" });
                        }
                        else {
                            objTable.setCell(rowId, "a5", "", { color: "Black" });
                        }

                        if (objTable.getCell(rowId, "tpje") == "") {
                            objTable.setCell(rowId, "tpje", strThje, { color: "Black" });
                        }
                        else {
                            objTable.setCell(rowId, "tpje", "", { color: "Black" });
                        }
                        //getTotalP020102();
                    }
                    else {
                        objTable.setCell(rowId, "a4", "&nbsp;");
                        objTable.setCell(rowId, "a5", "&nbsp;");
                        objTable.setCell(rowId, "tpje", "&nbsp;");
                        objTable.setCell(rowId, "kpdwdm", "&nbsp;");
                        objTable.setCell(rowId, "kpdwmc", "&nbsp;");
                        objTable.setCell(rowId, "dksl", "&nbsp;");
                    }

                    //下拉框改变时，层状态改变
                    dataChangeStateP010102(true);
                    ChangeFlagP020102(rowId);
                }
            });
            item.combobox('focus');

            break;
        case "kpdwmc":
            //如果是否退票是否的时候，该单元格不能编辑
            if (objTable.getCell(rowId, "a3") == "否" || objTable.getCell(rowId, "a3") == "") {
                objTable.restoreCell(iRow, iCol);
                return;
            }
            //开票单位信息，开票单位代码
            var objKpdw = getComboboxData('Tkpdwxx');
            var strKpdwdm = objTable.getCell(rowId, "kpdwdm");
            item.combobox({
                width: 78,
                listWidth: 78,
                valueField: "dm",
                textField: "mc"
            });
            objKpdw.push({ "mc": "<font color='red'>添加开票单位</font>", "dm": "-1" });
            if (objKpdw != "{}") {
                item.combobox("loadData", objKpdw);
            }
            item.combobox("setValue", strKpdwdm);
            if (item.combobox("getText") == strKpdwdm) {
                item.combobox('setText', value);
            }
            item.combobox({
                afterChange: function (newValue, newText) {
                    if (newValue != undefined && newValue != "-1" && newValue != "") {
                        $("#" + strTableP020102).setCell(rowId, "kpdwdm", newValue);
                        $("#" + strTableP020102).setCell(rowId, "a6", getdkslbyKpdw(newValue).kpsl);

                    }
                    else {
                        $("#" + strTableP020102).setCell(rowId, "kpdwdm", "&nbsp;");
                    }
                    dataChangeStateP010102(true);
                    ChangeFlagP020102(rowId);
                    if (newValue == "-1") {
                        ciho.IniData({ id: "divAddType", title: "开票单位", table: "Tflxx" }, { jquery: $(this), model: "Tkpdwxx" });
                        ciho.showTypeDialog();
                    }
                    
                }

            });
            item.combobox('focus');
            //是否内存
            objKpdw = null;
            break;
        case "a1":
            //退货数量
            item.autoNumeric({ mDec: window.parent.strCountPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            break;
        case "a2":
            //退货单价
            item.autoNumeric({ mDec: window.parent.strPricePlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            break;
        case "a5":
            //退票单价
            if (objTable.getCell(rowId, "a3") == "否" || objTable.getCell(rowId, "a3") == "") {
                objTable.restoreCell(iRow, iCol);
                return;
            }
            item.autoNumeric({ mDec: window.parent.strPricePlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            break;
        case "a4":
            //退票数量
            if (objTable.getCell(rowId, "a3") == "否" || objTable.getCell(rowId, "a3") == "") {
                objTable.restoreCell(iRow, iCol);
                return;
            }
            item.autoNumeric({ mDec: window.parent.strCountPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            break;
        case "xsy":
            //销售员信息，销售员代码
            var objZy = getComboboxData('TZyxx');
            var strXsydm = objTable.getCell(rowId, "xsydm");

            item.combobox({
                width: 78,
                listWidth: 78,
                valueField: "dm",
                textField: "mc"
            });
            if (objZy != "{}") {
                objZy.push({ "mc": "<font color='red'>添加销售员</font>", "dm": "-1" });
                item.combobox("loadData", objZy);
            }
            item.combobox("setValue", strXsydm);
            if (item.combobox("getText") == strXsydm) {
                item.combobox('setText', value);
            }
            item.combobox({
                onChange: function (newValue, oldValue) {
                    if (newValue != undefined) {
                        $("#" + strTableP020102).setCell(rowId, "xsydm", newValue);
                    }
                    else {
                        $("#" + strTableP020102).setCell(rowId, "xsydm", "&nbsp;");
                    }
                    dataChangeStateP010102(true);
                    ChangeFlagP020102(rowId);
                },
                afterChange: function (newValue, newText) {
                    if (newValue == "-1") {
                        ciho.IniData({ id: "divAddType", title: "销售员", table: "Tflxx" }, { jquery: $(this), model: "TZyxx" });
                        ciho.showTypeDialog();
                    }
                }
            });
            item.combobox('focus');

            //释放内存
            objZy = null;
            strXsydm = null;
            break;
        default:
    }

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

    //给编辑的单元格里面的text添加事件
    item.change(function () { dataChangeStateP010102(true); ChangeFlagP020102(rowId); });

    //释放内存
    item = null;
}

//保存单元格之后的事件
function afterSaveCell_P020102(rowId, cellname, value, iRow, iCol) {

    switch (cellname) {
        case "a1":
            //根据退货数量，退货单价计算金额
            var strA1 = parseFloat(value);
            var strA2 = parseFloat($(this).getCell(rowId, "a2"));
            if (isNaN(strA1) || isNaN(strA2)) {
                $(this).setCell(rowId, "thje", "&nbsp;");
            }
            else {
                $(this).setCell(rowId, "thje", parseFloat(strA1 * strA2).toFixed(window.parent.strMoneyPlace));
            }
            break;
        case "a2":
            //根据退货数量，退货单价计算金额
            var strA1 = parseFloat($(this).getCell(rowId, "a1"));
            var strA2 = parseFloat(value);
            if (isNaN(strA1) || isNaN(strA2)) {
                $(this).setCell(rowId, "thje", "&nbsp;");
            }
            else {
                $(this).setCell(rowId, "thje", parseFloat(strA1 * strA2).toFixed(window.parent.strMoneyPlace));
            }
            break;
        case "a3":
            $("#" + strTableP020102).setCell(rowId, "a3", value);
            break;
        case "a4":
            //根据退票数量，退票单价计算退票金额
            var strA4 = parseFloat(value);
            var strA5 = parseFloat($(this).getCell(rowId, "a5"));
            if (isNaN(strA4) || isNaN(strA5)) {
                $(this).setCell(rowId, "tpje", "&nbsp;");
            }
            else {
                $(this).setCell(rowId, "tpje", parseFloat(strA4 * strA5).toFixed(window.parent.strMoneyPlace));
            }
            break;
        case "a5":
            //根据退票数量，退票单价计算退票金额
            var strA4 = parseFloat($(this).getCell(rowId, "a4"));
            var strA5 = parseFloat(value);
            if (isNaN(strA4) || isNaN(strA5)) {
                $(this).setCell(rowId, "tpje", "&nbsp;");
            }
            else {
                $(this).setCell(rowId, "tpje", parseFloat(strA4 * strA5).toFixed(window.parent.strMoneyPlace));
            }
            break;
    }

    //计算合计
    //getTotalP020102();
}

//创建grid
function createGridP020102(strTableID, objColNames, objColModel) {

    $("#" + strTableID).jqGrid({
        datatype: "local",
        sortname: "id",
        colNames: objColNames,
        colModel: objColModel,
        data: [],
        rowNum: 9999999,
        // footerrow: true,
        rownumbers: true,
        autowidth: true,
        rownumWidth: 30,
        cellEdit: true,
        cellsubmit: "clientArray",
        gridview: true
    }).parent(".ui-jqgrid-bdiv").siblings();

    //增加表头‘序号’列
    $("table.ui-jqgrid-htable th:first", $("#gbox_" + strTableID)).text("序号");
}

//浮动删除
function addCzHtmlP020102() {
    $("#" + strTableP020102 + " tr:visible", "#" + strDivP020102).hover(function () {
        var strButtonHtml = "";
        strButtonHtml += "<a  style=\"color:red;text-decoration:none;cursor:pointer;\" onclick=\"deleteData_P020102(" + this.id + ");return false;\">删除</a> ";
        $("#" + strTableP020102).jqGrid("setCell", this.id, "cz", strButtonHtml);
    }, function () {
        $("#" + strTableP020102).jqGrid("setCell", this.id, "cz", "&nbsp;");
    });
}

//释放内存
function freeMemory_P020102() {
    strOptrTypeP020102 = null;
    iRowP020102 = null;
    iColP020102 = null;
    objRecords = null;
    objCompDataP020102 = null;
}

//填充弹出层内容
function addContentP020102(strBh) {

    //列配置信息
    var config = ParseData(window.external.DoOptions(strTableP020102, "GetTableConfig", "{}"));

    //职员，仓库，客户，会计科目
    var objZy = getComboboxData("TZyxx");
    objZy.push({ "mc": "<font color='red'>添加经手人</font>", "dm": "-1" });
    var objCk = getComboboxData("TCkxx");
    objCk.push({ "mc": "<font color='red'>添加仓库</font>", "dm": "-1" });
    var objKh = getComboboxData("Tkhxx1");
    objKh.push({ "mc": "<font color='red'>添加客户</font>", "dm": "-1" });
    var objKm = getComboboxData("TKjkm");
    objKm.push({ "mc": "<font color='red'>添加账户</font>", "dm": "-1" });

    //获取数据
    objRecordsP020102 = { Records: [] };
    if (strBh != "") {
        objRecordsP020102 = ParseData(window.external.DoOptions(strTableP020102, 'GetList', '{djbh:' + strBh + ' }'));
    }

    //公共变量
    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 += "</li>";
        }
        else if (Item.edittype == "select") {
            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=" + strTableP020102 + "></table>";

    //配置显示尾部
    strForm += "<ul>";
    for (i = 0; i < config.pageFooter.length; i++) {

        Item = config.pageFooter[i];
        if (Item.hidden == true) {
            continue;
        }
        if (Item.edittype == "text") {
            if (Item.index == "bz") {
                strForm += "<li class='bz'>";
                strForm += Item.xsmc + "：";
                strForm += "<input type='text'  name='" + Item.index + "' ";
                strForm += " value=''  ";
                strForm += " id='" + Item.index + "' onkeypress='return checkValidate(event)' onpaste='return validatePaste()'>";
                strForm += "</li>";
            } else {
                strForm += "<li class='inp_150'>";
                strForm += Item.xsmc + "：";
                strForm += "<input type='text'  name='" + Item.index + "' ";
                strForm += " value=''  ";
                strForm += " id='" + Item.index + "' onkeypress='return checkValidate(event)' onpaste='return validatePaste()' >";
                strForm += "</li>";
            }
        }
        else if (Item.edittype == "select") {
            strForm += "<li>";
            strForm += Item.xsmc + "：";
            strForm += "<select name='" + Item.index + "' id='" + Item.index + "'";
            strForm += " class='easyui-combobox' >";
            strForm += "</select>";
            strForm += "</li>";
        }

    }
    strForm += "</ul>";

    //添加到弹出层里
    $("#" + strDivP020102 + "_divform").append(strForm);

    //客户信息
    $("#khdm", "#" + strDivP020102).combobox({
        width: _iWidth150,
        listWidth: _iWidth150,
        textField: "mc",
        valueField: "dm",
        afterChange: function (newValue, newText) {
            dataChangeStateP010102(true);
            $(this).combobox("setText", newText.replace(/&nbsp;/g, ""));
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "客户", table: "Tflxx" }, { jquery: $("#khdm", "#" + strDivP020102), model: "Tkhxx" });
                ciho.showTypeDialog();
            }
        }
    });
    if (objKh != "{}") {
        $("#khdm", "#" + strDivP020102).combobox("loadData", objKh);
    }

    //职员信息
    $("#zydm", "#" + strDivP020102).combobox({
        width: _iWidth150,
        listWidth: _iWidth150,
        textField: "mc",
        valueField: "dm",
        afterChange: function (newValue, newText) {
            dataChangeStateP010102(true);
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "经手人", table: "Tflxx" }, { jquery: $("#zydm", "#" + strDivP020102), model: "TZyxx" });
                ciho.showTypeDialog();
            }
        }
    });
    if (objZy != "{}") {
        $("#zydm", "#" + strDivP020102).combobox("loadData", objZy);
    }

    //仓库信息
    $("#ckdm", "#" + strDivP020102).combobox({
        width: _iWidth150,
        listWidth: _iWidth150,
        textField: "mc",
        valueField: "dm",
        onChange: function (newValue, oldValue) {
            dataChangeStateP010102(true);
        },
        afterChange: function (newValue, newText) {
            dataChangeStateP010102(true);
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "仓库", table: "Tflxx" }, { jquery: $("#ckdm", "#" + strDivP020102), model: "TCkxx" });
                ciho.showTypeDialog();
            }
        }
    });
    if (objCk != "{}") {
        if (objCk.length == 2) {
            objCk[0].selected = true;
        }
        $("#ckdm", "#" + strDivP020102).combobox("loadData", objCk);
    }

    //获取列表数据
    var objTable = $("#" + strTableP020102);

    createGridP020102(strTableP020102, config.colNames, config.colModel);
    $("#" + strTableP020102).setGridHeight(46);

    //设置属性
    objTable.setColProp("a1", { formatter: formatterP020102Count });
    objTable.setColProp("a2", { formatter: formatterP020102Price });
    objTable.setColProp("thje", { formatter: formatterP020102Money });
    objTable.setColProp("a4", { formatter: formatterP020102Count });
    objTable.setColProp("a5", { formatter: formatterP020102Price });
    objTable.setColProp("tpje", { formatter: formatterP020102Money });
    objTable.setColProp("a3", { formatter: formatterP020102A3 });
    objTable.setColProp("spmc", { edittype: "custom" });
    objTable.setColProp("spmc", { editoptions: { custom_element: my_inputP020102, custom_value: my_valueP020102} });
    objTable.setColProp("a3", { edittype: "custom" });
    objTable.setColProp("a3", { editoptions: { custom_element: my_inputP020102, custom_value: my_valueP020102} });
    objTable.setColProp("xsy", { edittype: "custom" });
    objTable.setColProp("xsy", { editoptions: { custom_element: my_inputP020102, custom_value: my_valueP020102} });
    objTable.setColProp("kpdwmc ", { edittype: "custom" });
    objTable.setColProp("kpdwmc", { editoptions: { custom_element: my_inputP020102, custom_value: my_valueP020102} });

    //单元格事件
    objTable.setGridParam({ afterEditCell: afterEditCell_P020102 });
    objTable.setGridParam({ afterSaveCell: afterSaveCell_P020102 });

    //加载数据
    loadTreeData(strTableP020102, objRecordsP020102.Records);

    //计算合计
    //getTotalP020102();

    //就算添加空行
    if (objRecordsP020102.Records == "{}") {
        objRecordsP020102.Records = [];
    }

    //计算当前表格中记录数

    strRecordsCountP020102 = 1 - objRecordsP020102.Records.length;
    // strRecordsCountP020102 = objRecordsP020102.Records.length > 5 ? objRecordsP020102.Records.length : (5 - objRecordsP020102.Records.length);

    //不足五行时添加空行
    if (strRecordsCountP020102 <= 5) {
        addEmptyRowsP020102();
    }

    //添加浮动删除
    // addCzHtmlP020102();

    //表格头部添加按钮
    //$(".ui-jqgrid-htable th:visible:last").html('<img id="btnAddP010102"  style="cursor:pointer"  title="添加行" src="../../Content/Default/images/edit_add.gif" onclick="addEmptyRowP020102(); return false;"/>');

    //付款账户信息
    $("#kmdm", "#" + strDivP020102).combobox({
        width: _iWidth150,
        listWidth: _iWidth150,
        textField: "mc",
        valueField: "dm",
        panelHeight: getComHeight(objKm),
        onSelect: function (strRecord) {
            if ($("#fkje", "#" + strDivP020102).val() == "") {
                var objIDs = $("#" + strTableP020102).getDataIDs();
                var strA3 = $("#" + strTableP020102).getCell(objIDs[0], "thje");
                if (strA3) {
                    $("#fkje", "#" + strDivP020102).val(strA3);
                }
                else {
                    $("#fkje", "#" + strDivP020102).val(parseFloat(0).toFixed(window.parent.strMoneyPlace));
                }
            }
            $("#fkdate", "#" + strDivP020102).val($("#djdate", "#" + strDivP020102).val());
        },
        afterChange: function (newValue, newText) {
            dataChangeStateP010102(true);
            $(this).combobox("setText", newText.replace(/&nbsp;/g, ""));
            if (newValue == "-1") {
                ciho.IniData({ id: "divAddType", title: "账户", table: "Tflxx" }, { jquery: $("#kmdm", "#" + strDivP020102), model: "Tkjkm" });
                ciho.showTypeDialog();
            }
        }
    });
    if (objKm != "{}") {
        $("#kmdm", "#" + strDivP020102).combobox("loadData", objKm);
    }

    //付款金额
    $("#fkje", "#" + strDivP020102).autoNumeric({ mDec: window.parent.strMoneyPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");

    //制单人
    $("#czydm", "#" + strDivP020102).attr("disabled", true);
    $("#czydm", "#" + strDivP020102).val(window.parent.objLoginInfo.name);

    //给付款日期添加默认值和事件
    inputAndBindData("fkdate", null, "#" + strDivP020102);
    $("#fkdate", "#" + strDivP020102).blur(function () {
        $("#" + strDivP020102 + "_divform").data("change", true);
    });

    //给单据日期添加默认值和事件
    inputAndBindData("djdate", null, "#" + strDivP020102);
    $("#djdate", "#" + strDivP020102).val(getNowDate());
    $("#djdate", "#" + strDivP020102).blur(function () {
        $("#" + strDivP020102 + "_divform").data("change", true);
    });

    //在修改（2）和退货（3）时加载数据
    if (strOptrTypeP020102 == "2") {
        $("#djdate", "#" + strDivP020102).attr("disabled", true);
        $("#djdate", "#" + strDivP020102).val(objRecordsP020102.djdate);
        $("#czydm", "#" + strDivP020102).val(objRecordsP020102.czymc);
    }
    else if (strOptrTypeP020102 == "3") {
        $("#djdate", "#" + strDivP020102).attr("disabled", false);
        $("#djdate", "#" + strDivP020102).val(getNowDate());
    }
    if (strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") {

        //客户信息
        $("#khdm", "#" + strDivP020102).combobox('setValue', objRecordsP020102.khdm);
        if ($("#khdm", "#" + strDivP020102).combobox('getValue') == objRecordsP020102.khdm) {
            $("#khdm", "#" + strDivP020102).combobox('setText', objRecordsP020102.khmc);
        }

        //经手人信息
        $("#zydm", "#" + strDivP020102).combobox('setValue', objRecordsP020102.zydm);
        if ($("#zydm", "#" + strDivP020102).combobox('getValue') == objRecordsP020102.zydm) {
            $("#zydm", "#" + strDivP020102).combobox('setText', objRecordsP020102.zymc);
        }

        //仓库信息
        $("#ckdm", "#" + strDivP020102).combobox('setValue', objRecordsP020102.ckdm);
        if ($("#ckdm", "#" + strDivP020102).combobox('getValue') == objRecordsP020102.ckdm) {
            $("#ckdm", "#" + strDivP020102).combobox('setText', objRecordsP020102.ckmc);
        }

        //账户信息
        $("#kmdm", "#" + strDivP020102).combobox('setValue', objRecordsP020102.kmdm);
        if ($("#kmdm", "#" + strDivP020102).combobox('getValue') == objRecordsP020102.kmdm) {
            $("#kmdm", "#" + strDivP020102).combobox('setText', objRecordsP020102.kmmc);
        }

        if (!isNaN(parseFloat(objRecordsP020102.fkje))) {
            $("#fkje", "#" + strDivP020102).val(parseFloat(objRecordsP020102.fkje).toFixed(window.parent.strMoneyPlace));
        }
        $("#fkdate", "#" + strDivP020102).val(objRecordsP020102.fkdate);
        $("#bz", "#" + strDivP020102).val(escape(objRecordsP020102.bz));

        //记录原始值
        var strData = [];
        strData.push("spdm");
        strData.push("a1");
        strData.push("a2");

        objCompDataP020102 = getCompareData(strTableP020102, strData);
    }

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

    //调整滚动条
    resizeGridScroll(strTableP020102);
    
    //设置层序
    $(".layoutpanel").css("z-index", "50000009");

    //释放内存
    config = null;
    objZy = null;
    objCk = null;
    objKh = null;
    objKm = null;
    objTable = null;
}

//弹出层
function showDialogP020102(strType) {
    try {
        //清楚浮动层
        $(".operate").hide();

        //保存操作标志位
        strOptrTypeP020102 = strType;

        //弹出层
        creatDiv_ShowDlgHaveTbl(strDivP020102, "销售退货单", false, true, strTableP020102, "940");

        //往层里添加数据
        if (strOptrTypeP020102 == "1") {
            addContentP020102("");
        }
        else if (strOptrTypeP020102 == "2") {
            $("#idMust", "#" + strDivP020102).append("NO:" + objSelRowP0201.djbh);
            addContentP020102(objSelRowP0201.djbh);
        }
        else if (strOptrTypeP020102 == "3") {
            addContentP020102(objSelRowP0201.djbh);
        }

        setTimeout('$("#fkje", "#" + strDivP020102).focus();', 100);
    }
    catch (e) {
        proceError("P010102", e.ToString());
    }
}

//验证表单
function checkForm(dialog, save) {

    //单据日期不能为空
    if ($("#djdate ", "#" + strDivP020102).val() == "") {
        window.parent.cihoAlert(msg.dt.inputThDt, null, function () { $("#djdate", "#" + strDivP020102).focus(); });
        return false;
    }

    //验证日期
    if (checkDatePattern($("#djdate", "#" + strDivP020102).val()) == false) {
        window.parent.cihoAlert(msg.dt.dtTypeErr, msgBox.dlgBtn.Ok, function () { $("#djdate", "#" + strDivP020102).focus(); });
        return false;
    }

    //验证早于起始时间
    if ($("#djdate", "#" + strDivP020102).val().replace(/-/g, "/") < window.parent._startDate) {
        window.parent.cihoAlert(msg.other.thrqExtent, msgBox.dlgBtn.Ok, function () { $("#djdate", "#" + strDivP020102).focus(); });
        return false;
    }

    var strKhValue = $("#khdm", "#" + strDivP020102).combobox('getValue');
    if (strKhValue == undefined) {

        //修改时，验证数据是否是停用的数据
        if (strOptrTypeP020102 == "2" && $("#khdm", "#" + strDivP020102).combobox('getText') != objRecordsP020102.khmc) {
            window.parent.cihoAlert(msg.sz.kh.empOrNotExit, msgBox.dlgBtn.Ok, function () { $("#khdm", "#" + strDivP020102).combobox('focus'); });
            return false;
        }
        //新增的时候
        if (strOptrTypeP020102 == "1") {
            window.parent.cihoAlert(msg.sz.kh.empOrNotExit, msgBox.dlgBtn.Ok, function () { $("#khdm", "#" + strDivP020102).combobox('focus'); });
            return false;
        }
    }

    //职员不能为空
    var strZy = $("#zydm", "#" + strDivP020102).combobox('getValue');
    if (!strZy) {


        //修改时，验证数据是否是停用的数据
        if (strOptrTypeP020102 == "2" && $("#zydm", "#" + strDivP020102).combobox('getText') != objRecordsP020102.zymc) {
            window.parent.cihoAlert(msg.sz.jsr.empOrNotExit, msgBox.dlgBtn.Ok, function () { $("#zydm", "#" + strDivP020102).combobox('focus'); });
            return false;
        }

        //新增的时候
        if (strOptrTypeP020102 == "1") {
            window.parent.cihoAlert(msg.sz.jsr.empOrNotExit, msgBox.dlgBtn.Ok, function () { $("#zydm", "#" + strDivP020102).combobox('focus'); });
            return false;
        }
    }

    //仓库不能为空
    var strCk = $("#ckdm", "#" + strDivP020102).combobox('getValue');
    if (!strCk) {

        //修改时，验证数据是否是停用的数据
        if (strOptrTypeP020102 == "2" && $("#ckdm", "#" + strDivP020102).combobox('getText') != objRecordsP020102.zymc) {
            window.parent.cihoAlert(msg.sz.ck.empOrNotExit, msgBox.dlgBtn.Ok, function () { $("#ckdm", "#" + strDivP020102).combobox('focus'); });
            return false;
        }
        //新增的时候
        if (strOptrTypeP020102 == "1") {
            window.parent.cihoAlert(msg.sz.ck.empOrNotExit, msgBox.dlgBtn.Ok, function () { $("#ckdm", "#" + strDivP020102).combobox('focus'); });
            return false;
        }
    }

    //验证表格中的数据
    var objTable = $("#" + strTableP020102);
    var arrIds = objTable.getDataIDs();
    var bAddTable = false;

    for (var i = 0; i < arrIds.length; i++) {

        var objTr = objTable.getRowData(arrIds[i]);
        var alterMsg = "";

        //如果标志位是空不验证
        if (objTr.flag == "") {
            continue;
        }

        //        //如果这行中一条数据没有也不验证
        //        if (checkEmptyRow(objTr, "flag,mxguid,glsl,a6,djbh")) {
        //            continue;
        //        }

        //标记表格里有记录
        bAddTable = true;

        if (!objTr.spdm) {
            // alterMsg = msg.other.dnh + (i + 1) + msg.sz.yp.lnEmpOrNotExit;
            alterMsg = msg.cx.lxglYp;
            window.parent.cihoAlert(alterMsg);
            return false;
        }
        if (!objTr.a1) {
            //alterMsg = msg.other.dnh + (i + 1) + msg.sz.yp.lnAmountEmp;
            alterMsg = msg.sz.yp.ypslEmp;
            window.parent.cihoAlert(alterMsg);
            return false;
        }
        if (!objTr.a2) {
            // alterMsg = msg.other.dnh + (i + 1) + msg.sz.yp.lnPriceEmp;
            alterMsg = msg.sz.yp.ypPrice;
            window.parent.cihoAlert(alterMsg);
            return false;
        }

        //选择是否开票的时候，开票数量，开票单价不能为空
        if (objTr.a3 == "是") {
            if (!objTr.a4) {
                //alterMsg = msg.other.dnh + (i + 1) + msg.other.TpSlNoEmpty;
                alterMsg = msg.other.TpSlNoEmptyOneRow;
                window.parent.cihoAlert(alterMsg);
                return false;
            }
            if (!objTr.a5) {
                // alterMsg += msg.other.dnh + (i + 1) + msg.other.TpDjNoEmpty;
                alterMsg = msg.other.TpDjNoEmptyOneRow;
                window.parent.cihoAlert(alterMsg);
                return false;
            }
            if (!objTr.kpdwdm) {
                //alterMsg += msg.other.dnh + (i + 1) + msg.sz.kp.KpNoEmpty;
                alterMsg = msg.sz.kp.KpNoEmptyOneRow;
                window.parent.cihoAlert(alterMsg);
                return false;
            }
            if (parseFloat(objTr.a4) * parseFloat(objTr.a5) == 0) {
                window.parent.cihoAlert(msg.other.tpMoneyOrNotExit);
                return false;
            }
        }

    }

    //表格中是否有记录
    if (bAddTable == false) {
        window.parent.cihoAlert(msg.other.djNotExit);
        return false;
    }

    //收款单位，收款日期，收款金额三项有一项不为空就都不为空
    var strKmdm = $("#kmdm", "#" + strDivP020102).combobox('getValue');
    var strFkje = $("#fkje", "#" + strDivP020102).val();
    var strFkdate = $("#fkdate", "#" + strDivP020102).val();

    if (strKmdm) {
        if ((strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") && objRecordsP020102.Records != "{}" && $("#kmdm", "#" + strDivP020102).combobox('getText') == objRecordsP020102.kmmc) {
            strKmdm = objRecordsP020102.kmdm;
        }
    }

    if (strKmdm || strFkje || strFkdate) {
        if (!strKmdm) {
            window.parent.cihoAlert(msg.other.inputFkzh, msgBox.dlgBtn.Ok, function () { $("#kmdm", "#" + strDivP020102).combobox('focus') });
            return false;
        }
        if (!strFkje) {
            window.parent.cihoAlert(msg.other.inputFkje, msgBox.dlgBtn.Ok, function () { $("#fkje", "#" + strDivP020102).focus(); });
            return false;
        }
        if (!strFkdate) {
            window.parent.cihoAlert(msg.dt.inputFkDt, msgBox.dlgBtn.Ok, function () { $("#fkdate", "#" + strDivP020102).focus(); });
            return false;
        }
    }

    //收款金额不一致，提示保存
    //var strThje = $("#" + strTableP020102).footerData('get').thje;
    var strThje = $("#" + strTableP020102).getCell(arrIds[0], "thje");
    if (window.parent.bShowMsgOfMoney == true && strFkje != "" && parseFloat(strThje) != parseFloat(strFkje)) {
        window.parent.cihoAlert(msg.other.difMoney, msgBox.dlgBtn.YesNo, function (result) {
            if (result == msgBox.dlgRst.Yes) {
                saveDataToDbP020102(dialog, save);
                return false;
            }
            else if (result == msgBox.dlgRst.No) {
                return false;
            }
        });
        return false;
    }

    //金额不能过大
    if (parseFloat(strThje) > window.parent._MaxPerBill || parseFloat(strFkje) > window.parent._MaxPerBill) {
        window.parent.cihoAlert(msg.other.djhjExtent);
        return false;
    }

    //起始结束时间
    if (strFkdate != "") {
        strFkdate = strFkdate.replace(/-/g, "/");
        if (strFkdate < window.parent._startDate) {
            window.parent.cihoAlert(msg.other.fkrqExtent, msgBox.dlgBtn.Ok, function () { $("#fkdate", "#" + strDivP020102).focus(); });
            return false;
        }
    }

    //释放内存
    objTable = null;

}

//保存到数据库
function saveDataToDbP020102(dialog, save) {

    //表格对象，所有记录的行ID
    var objTable = $("#" + strTableP020102);
    var arrIds = objTable.getDataIDs();
    var objNewData;

    //加载要保存的数据
    var strData = "{";
    strData += "\"djdate\":\"" + $("#djdate", "#" + strDivP020102).val() + "\"";

    //供应商数据
    var strKhValue = $("#khdm", "#" + strDivP020102).combobox('getValue');
    if (!strKhValue) {
        if ((strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") && objRecords.Records != "{}" && $("#khdm", "#" + strDivP020102).combobox('getText') == objRecordsP020102.Records[0].khmc) {
            strKhValue = objRecords.Records[0].khdm;
        }
    }
    strData += ",\"khdm\":\"" + strKhValue + "\"";

    //经手人数据
    var strZy = $("#zydm", "#" + strDivP020102).combobox('getValue');
    if (!strZy) {
        if ((strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") && objRecords.Records != "{}" && $("#zydm", "#" + strDivP020102).combobox('getText') == objRecordsP020102.Records[0].zymc) {
            strZy = objRecords.Records[0].zydm;
        }
    }
    strData += ",\"zydm\":\"" + strZy + "\"";

    //仓库代码
    var strCk = $("#ckdm", "#" + strDivP020102).combobox('getValue');
    if (!strCk) {
        if ((strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") && objRecords.Records != "{}" && $("#ckdm", "#" + strDivP020102).combobox('getText') == objRecordsP020102.Records[0].ckmc) {
            strCk = objRecords.Records[0].ckdm;
        }
    }
    strData += ",\"ckdm\":\"" + strCk + "\"";

    //修改（2）和退货（3）的时候单据编号
    if (strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") {
        strData += ",\"djbh\":\"" + objSelRowP0201.djbh + "\"";
    }

    //组表格里的数据
    strData += ",\"Records\":["

    for (var i = 0; i < arrIds.length; i++) {

        //当前行
        var objTr = objTable.getRowData(arrIds[i]);

        //改行数据没有变化直接跳出
        if (objTr.flag == "") {
            continue;
        }

        //改行记录有变化，但是数据时空
        if (checkEmptyRow(objTr, "flag,mxguid,glsl,a6,djbh")) {
            if (strOptrTypeP020102 == "2" && strDeletHtmlP020102.indexOf(objTr.mxguid) == -1) {
                if (strDeletHtmlP020102 != null && strDeletHtmlP020102 != "") {
                    strDeletHtmlP020102 += ",{\"mxguid\":\"" + objTr.mxguid + "\",\"flag\":\"3\"}";
                }
                else {
                    strDeletHtmlP020102 = ",{\"mxguid\":\"" + objTr.mxguid + "\",\"flag\":\"3\"}";
                }
            }
            continue;
        }

        strData += "{";

        //修改的时候传mxguid
        if (strOptrTypeP020102 == "2") {
            strData += "\"mxguid\":\"" + objTr.mxguid + "\",";
        }
        strData += "\"spdm\":\"" + objTr.spdm + "\",";
        strData += "\"a1\":\"" + objTr.a1 + "\",";
        strData += "\"a2\":\"" + objTr.a2 + "\",";

        //选是否带票时
        if (objTr.a3 == "是") {
            strData += "\"a3\":true,";
            strData += "\"a4\":\"" + objTr.a4 + "\",";
            strData += "\"a5\":\"" + objTr.a5 + "\",";
            strData += "\"kpdwdm\":\"" + objTr.kpdwdm + "\",";
            strData += "\"a6\":\"" + objTr.a6 + "\",";
        }
        else {
            strData += "\"a3\":false,";
        }
        strData += "\"xsydm\":\"" + objTr.xsydm + "\",";
        strData += "\"flag\":\"" + objTr.flag + "\"";
        strData += "},";
    }

    //替换掉，
    if (strData.substring(strData.length - 1, strData.length) != "[") {
        strData = strData.substr(0, strData.length - 1);
    }

    //组删除的数据
    if (strDeletHtmlP020102 != null) {
        strData += strDeletHtmlP020102;
    }
    strData += "]"

    //收款账户，收款金额，收款日期
    var strKmdm = $("#kmdm", "#" + strDivP020102).combobox('getValue') + "";
    var strFkje = $("#fkje", "#" + strDivP020102).val();
    var strFkdate = $("#fkdate", "#" + strDivP020102).val();
    if (!strKmdm) {
        if ((strOptrTypeP020102 == "2" || strOptrTypeP020102 == "3") && objRecordsP020102.Records != "{}" && $("#kmdm", "#" + strDivP020102).combobox('getText') == objRecordsP020102.kmmc) {
            strKmdm = objRecordsP020102.Records.kmdm;
        }
    }
    if (strKmdm && strFkje && strFkdate) {
        strData += ",\"kmdm\":\"" + strKmdm + "\"";
        strData += ",\"fkje\":\"" + strFkje + "\"";
        strData += ",\"fkdate\":\"" + strFkdate + "\"";
    }

    strData += ",\"czydm\":\"" + window.parent.objLoginInfo.code + "\"";
    strData += ",\"bz\":\"" + trim($("#bz", "#" + strDivP020102).val()) + "\"";
    strData += "}";

    var objResult;
    if (strOptrTypeP020102 == "1") {
        //新增
        objResult = ParseData(window.external.DoOptions(strTableP020102, "Add", strData));
    }
    else if (strOptrTypeP020102 == "2") {
        //修改
        objResult = ParseData(window.external.DoOptions(strTableP020102, "Edit", strData));
    }
    else if (strOptrTypeP020102 == "3") {
        //退货
        objResult = ParseData(window.external.DoOptions(strTableP020102, "Add", strData));
    }

    //数据库操作失败时
    if (objResult.ReturnCode != "0") {
        window.parent.cihoAlert(objResult.MSG);
        return;
    }

    //取得最新数据，进行对比
    var strData = [];
    strData.push("spdm");
    strData.push("a1");
    strData.push("a2");

    objNewData = getCompareData(strTableP020102, strData);
    if (objNewData != objCompDataP020102) {
        window.external.DoOptions(strTableP020102, "DoOthers", "{\"flag\":true,\"djdate\":\"" + $("#djdate", "#" + strDivP020102).val() + "\"}")
    }

    //保存新增
    if (save == "2") {
        $("#" + strTableP020102).clearGridData();
        strRecordsCountP020102 = 1;
        addEmptyRowsP020102();
        //addCzHtmlP020102();
        //getTotalP020102();
        $(":input", $("#" + strDivP020102)).val("");
        $("#khdm", "#" + strDivP020102).combobox('setValue', '');
        $("#zydm", "#" + strDivP020102).combobox('setValue', '');
        var objCk = $("#ckdm", "#" + strDivP020102).combobox("getData");
        if (objCk.length == 2) {
            $("#ckdm", "#" + strDivP020102).combobox('setValue', objCk[0].dm);
        }
        else {
            $("#ckdm", "#" + strDivP020102).combobox('setValue', '');
        }
        $("#kmdm", "#" + strDivP020102).combobox('setValue', '');

        $("#czydm", "#" + strDivP020102).val(window.parent.objLoginInfo.name);
        $("#djdate", "#" + strDivP020102).val(getNowDate());
        $("#djdate", "#" + strDivP020102).attr("disabled", false);
        $("#idMust", "#" + strDivP020102).empty();
        setTimeout('$("#fkje", "#" + strDivP020102).focus();', 100);
    }
    else {
        strRecordsCountP020102 = null;
        cihoDlgClose(dialog);
    }

    //释放内存
    objTable = null;
    strDeletHtmlP020102 = "";
    strOptrTypeP020102 = "1";
    objRecordsP020102 = null;
    iRowP020102 = -1;
    iColP020102 = -1;

    //重新加载数据
    searchDataClickP0201();

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

//保存：保存退出（1）,保存新增（2）
function saveMyDataTp020102(dialog, save) {

    //table对象，行ID
    var objTable = $("#" + strTableP020102);
    objTable.saveCell(iRowP020102, iColP020102);
    var arrIds = objTable.getDataIDs();

    //判断关联数量
    for (var i = 0; i < arrIds.length; i++) {
        var objTr = objTable.getRowData(arrIds[i]);
        if (objTr.flag == "") {
            continue;
        }
        var alterMsg = "";
        if ($("#" + strDivP020102 + "_divform").data("change") != false && strOptrTypeP020102 == "2" && objTr.glsl != 0 && objTr.a1 != objTr.glsl) {
            alterMsg = msg.other.pihaoNoSame;
            window.parent.cihoAlert(alterMsg, null, function (result) {
                if (result == msgBox.dlgRst.Ok) {
                    if (checkForm(dialog, save) == false) {
                        return;
                    }
                    saveDataToDbP020102(dialog, save)
                    return;
                }
            });
            return;
        }
    }

    //没有关联直接保存
    if (checkForm(dialog, save) == false) {
        return;
    }
    saveDataToDbP020102(dialog, save);

}

//删除
function deleteData_P020102(rowId) {
    try {

        //删除的那行的数据
        var objTr = $("#" + strTableP020102).getRowData(rowId);

        //保存时取消单元格编辑
        $("#" + strTableP020102).saveCell(iRowP020102, iColP020102);

        //判断改行是否有数据
        if (checkEmptyRow(objTr, "glsl,cz") == false) {

            //判断关联数量
            if (objTr.glsl && objTr.glsl != "0") {
                window.parent.cihoAlert(msg.del.delForbid);
                return;
            }

            //删除时提示
            window.parent.cihoAlert(msg.del.delConfirm, msgBox.dlgBtn.YesNo, function (strRet) {
                if (msgBox.dlgRst.Yes == strRet) {
                    if (strOptrTypeP020102 == "2" && objTr.mxguid != "") {

                        //修改的时候
                        strDeletHtmlP020102 += ",{\"mxguid\":\"" + objTr.mxguid + "\",";
                        strDeletHtmlP020102 += "\"flag\":\"3\"}";

                        $("#" + strTableP020102).delRowData(rowId);
                    }
                    else {
                        //新增的时候
                        $("#" + strTableP020102).delRowData(rowId);

                    }

                    //重新计算合计
                    //getTotalP020102();

                    //有滚动条时改变表格宽度
                    resizeGrid(strTableP0201);

                    return;
                }
            });
        }
        else {
            $("#" + strTableP020102).delRowData(rowId);
        }

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

}