/*--------------------------文档信息-------------------------------------------
///
///功能：    采购管理-付款单
///创建人：  李孟昌
///创建时间：2011年05月28日
///修改人：  王思波
///修改时间：2011年05月31日
///修改人：  翟新乐
///修改时间：2011年08月13日
///修改原因：--------------
///详细说明：--------------
///
-----------------------------------------------------------------------------*/

//本页全局变量
{
    var strDialogIDP010103 = "divP010103";      //弹出层ID
    var objRecord = [];                              //存放后台返回数据
    var oldValue = 0;
    var strTableNameP010103;                    //表格ID
    var strDel = "";          //保存累加的字符串  要求使用 / 分割
    var dataLength = 0;       //从数据库中取出的长度
    var iRowP010103 = 1;          //选中行号
    var iColP010103 = 1;          //列号
    var arr = [];           //记录灰化的行ID
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓**事件方法 开始**↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/

//释放内存
function freeMemory_P010103() {
    objRecord = [];
    oldValue = 0;
    strDel = "";
    dataLength = 0;
    iRowP010103 = 1;
    iColP010103 = 1;
    arr = [];
}

//创建弹出窗口方法
function showDialog_P010103() {
    try {
        strTableNameP010103 = "Tp010103";
        var config = [];
        config = ParseData(window.external.DoOptions(strTableNameP010103, 'GetTableConfig', '{}'));     //取得列配置

        objRecord = ParseData(window.external.DoOptions(strTableNameP010103, 'GetList', "{\"djbh\":\"" + objSelRowP0101.djbh + "\"}"));     //取得数据

        creatDiv_ShowDlgHaveTbl(strDialogIDP010103, '付款单', false, false, strTableNameP010103, "800");        //创建窗口
        $("#idMust", $("#" + strDialogIDP010103)).append("NO:" + objSelRowP0101.djbh);
        var header = createInputsP010103(config.pageHeader);
        $("#" + strDialogIDP010103 + "_divform").append(header);

        var myData = objRecord.Records;
        if (myData == "{}") {      //如果数据等于空 那么设置 myData 为空
            myData = [];
        }
        dataLength = myData.length;
        var dataCount = dataLength > 5 ? dataLength : 5;
        $("#" + strDialogIDP010103 + "_divform").append("<table id='Tp010103'></table>");
        addColFormatter_P010103(config.colModel);  //格式化
        createGridP010103(strTableNameP010103, config.colNames, config.colModel);   //生成grid
        //$("#gbox_" + strTableNameP010103).css("height", "157");
        $("#" + strTableNameP010103).setGridHeight(141);
        //设置属性
        $("#" + strTableNameP010103).setColProp("cz", { align: "center" });
        $("#" + strTableNameP010103).setColProp("d1", { edittype: "custom" });
        $("#" + strTableNameP010103).setColProp("d1", { editoptions: { custom_element: my_inputP010103, custom_value: my_valueP010103} });
        $("#" + strTableNameP010103).setColProp("e1", { edittype: "custom" });
        $("#" + strTableNameP010103).setColProp("e1", { editoptions: { custom_element: my_inputP010103, custom_value: my_valueP010103} });
        //给grid 添加EditCell 事件
        $("#" + strTableNameP010103).setGridParam({ afterEditCell: afterEditCell_P010103 });
        $("#" + strTableNameP010103).setGridParam({ afterSaveCell: afterSaveCell_P010103 });

        //var sfJinE = 0;
        for (var i = 0; i < dataCount; i++) {   //加载数据
            if (myData[i]) {
                //sfJinE += parseFloat(myData[i].a2);
                $("#" + strTableNameP010103).addRowData(i + 1, myData[i]);
            }
            else {
                $("#" + strTableNameP010103).addRowData(i + 1, { "editable": "True", "gysdm": "", "e1": "", "d1": "", "cz": "", "c1": "", "a3": "", "a2": "", "a1": "", "djdate": "", "zydm": "", "kmdm": "", "djbh": "", "mxguid": "", "fkdate": "" });
            }

        }
        GetTotalP010103();
        //调整表格的自适应的高度
        resizeGridScroll(strTableNameP010103);
        $("#" + strTableNameP010103).data("nextNum", dataCount + 1);
        $("#" + strTableNameP010103).setLabel("cz", '<img id="btnAdd"  style="cursor:pointer;padding-top:5px"  title="添加行" src="  ../../Content/Default/images/edit_add.gif" onclick="addNewRowP010103()"/>')
        //$(".ui-jqgrid-htable th:visible:last").html('<img id="btnAdd"  style="cursor:pointer"  title="添加行" src="  ../../Content/Default/images/edit_add.gif" onclick="addNewRowP010103()"/>');
        //保存按钮
        var btnItem = "<div class=\"clr\"></div>";
        btnItem += "<div class=\"box_btn_width\">";
        btnItem += "    <div class=\"box_btn\">";
        btnItem += "        <div class=\"btn01\"><a href=\"#\" onclick=\"saveMyData('" + strDialogIDP010103 + "',0, '" + strTableNameP010103 + "');return false;\" )\">保存退出</a></div>";
        btnItem += "    </div>";
        btnItem += "</div>";
        $(".pop_box", "#" + strDialogIDP010103).append(btnItem);

        creatDialogItem_P010103(objRecord);     //填充界面元素

        addDelete_P010103();           //添加鼠标移动的显示 删除的操作

        LoadStyle();                   //格式化的灰化效果s     
        $(":input", $("#" + strDialogIDP010103 + "_divform")).change(function () {
            $("#" + strDialogIDP010103 + "_divform").data("change", true);
        });

        $("#" + strDialogIDP010103).dialog("option", "position", "center");
        //释放内存
        config = null;
        dataCount = null;
        header = null;
        btnItem = null;
    } catch (e) { }
}

//点击保存按钮方法
function saveMyDataTp010103() {
    var strDataJson = "";
    //上面的不可编辑区域  和  要删除的数组
//    var strData = "{";
//    strData += "\"djbh\":\"" + objSelRowP0101.djbh + "\""
//    strData += ",\"gysdm\":\"" + objSelRowP0101.gysdm + "\"";
//    strData += ",\"djdate\":\"" + objSelRowP0101.djdate + "\""
//    strData += ",\"delete\":\"" + strDel + "\""
//    //表格的数据
//    strData += ",Records:[";
    var objTable = $("#" + strTableNameP010103);
    var arrIds = objTable.getDataIDs();
    var isNullCount = 0;
    for (var i = 0; i < arrIds.length; i++) {
        objTable.saveCell(iRowP010103, iColP010103);
        var objTr = objTable.getRowData(arrIds[i]);
        if ((objTr.fkdate == "") && (objTr.kmdm == "") && (objTr.a2 == "") && (objTr.zydm == "")) {
            isNullCount++;
            if (isNullCount == arrIds.length) {
                strDataJson = "";
            }
            if (checkEmptyRow(objTr, "flag,mxguid,cz,editable,djbh,c1")) {
                if (objTr.mxguid!="") {
                    if (strDel != null && strDel != "") {
                        strDel += (objTr.mxguid + "/");
                    }
                    else {
                        strDel = (objTr.mxguid + "/");
                    }
                }
            }
            continue;
        }
        else {
            var strIndex = objTable.getInd(arrIds[i]);
            strDataJson += "{";
            if (objTr.fkdate == "" || objTr.fkdate == undefined) {
                window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.notDateEmp);
                return;
            }
            else {
                //日期的验证
                if (checkDatePattern(objTr.fkdate) == false) {
                    window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.dateErrors);
                    return;
                }
                else if ((objTr.fkdate.replace(/-/g, "/")) < (window.parent._startDate.replace(/-/g, "/"))) {
                    window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.dateNotExtent);
                    return;
                }
            }

            if (objTr.kmdm == "" || objTr.kmdm == undefined) {
                window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.notClientEmp);
                return;
            }

            if (objTr.a2 == "" || objTr.a2 == undefined) {
                window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.notSfEmp);
                return;
            }
            //        else if (parseFloat(objTr.a2) <= 0) {
            //            window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.notEuqalZero);
            //            return;
            //        }

            if (objTr.zydm == "" || objTr.zydm == undefined) {
                window.parent.cihoAlert(msg.other.dnh + strIndex + msg.fkd.notJsrEmp);
                return;
            }
            strDataJson += "\"mxguid\":\"" + objTr.mxguid + "\",";
            strDataJson += "\"editable\":\"" + objTr.editable + "\",";
            strDataJson += "\"a1\":\"" + objTr.a1 + "\",";
            strDataJson += "\"fkdate\":\"" + formatDate(objTr.fkdate) + "\",";
            strDataJson += "\"a3\":\"" + trim(objTr.a3) + "\",";
            strDataJson += "\"a2\":\"" + objTr.a2 + "\",";
            strDataJson += "\"zydm\":\"" + objTr.zydm + "\",";
            strDataJson += "\"kmdm\":\"" + objTr.kmdm + "\"";
            if (arrIds.length != i)
                strDataJson += "},";
            else
                strDataJson += "}";
        }
    }
    //strData += strDeletHtml;
    var strData = "{";
    strData += "\"djbh\":\"" + objSelRowP0101.djbh + "\""
    strData += ",\"gysdm\":\"" + objRecord.gysdm + "\"";
    strData += ",\"djdate\":\"" + objSelRowP0101.djdate + "\""
    strData += ",\"delete\":\"" + strDel + "\""
    //表格的数据
    strData += ",Records:[" + strDataJson + "";
    if (strData.substring(strData.length - 1, strData.length) != "[") {
        strData = strData.substr(0, strData.length - 1);
    }
    strData += "]}"

    //验证付款金额
    var isSaveData = true;
    if (parseFloat($("#wfjedivP010103").val()) < 0) {
        window.parent.cihoAlert(msg.fkd.muQianFuKuan + (0 - parseFloat($("#wfjedivP010103").val())) + msg.fkd.yuan, msgBox.dlgBtn.Yes);
        return false;
    }
    if (isSaveData == true) {
        var objResult = ParseData(window.external.DoOptions(strTableNameP010103, "Edit", strData));
        if (objResult.ReturnCode == 0) {
            //设定状态
            $("#" + strDialogIDP010103 + "_divform").data("change", false);
            cihoDlgClose(strDialogIDP010103);
            freeMemory_P010103();
            loadGridData_P0101();
            //resizeGridScroll(strTableP0101);
            //释放内存
            isSaveData = null;
            objTable = null;
            objResult = null;
            objTr = null;
        }
        else {
            window.parent.cihoAlert(msg.save.saveFail);
        }
    }
}

//删除行方法
function delRowP010103(rowId) {
    try {
        var delItem = $("#" + strTableNameP010103).getRowData(rowId);
        $("#" + strTableNameP010103).saveCell(iRowP010103, iColP010103);
        if ((delItem.fkdate == "") && (delItem.kmdm == "") && (delItem.a2 == "") && (delItem.zydm == "")) {
            $("#" + strTableNameP010103).delRowData(rowId);
        }
        else {
            window.parent.cihoAlert(
                    msg.del.delConfirm  //message information
                    , msgBox.dlgBtn.YesNo     //按钮类型msgBox.dlgBtn.YesNo  msgBox.dlgBtn.YesNoCancel
                    , function (strRet) {//回调函数
                        if (msgBox.dlgRst.Yes == strRet) {
                            if (delItem.mxguid) {                               //如果数据库中存在此项
                                strDel += (delItem.mxguid + "/");
                            }
                            var bcYouHui = parseFloat(delItem.a1);  //本次优惠
                            if (isNaN(bcYouHui))
                                bcYouHui = 0;
                            var sfJinE = parseFloat(delItem.a2);   //实付金额
                            if (!isNaN(sfJinE)) {
                                $("#wfjedivP010103").val((parseFloat($("#wfjedivP010103").val()) + (bcYouHui + sfJinE)).toFixed(window.parent.strMoneyPlace));   //设置 未付金额    
                            }
                            $("#" + strTableNameP010103).delRowData(rowId);
                            dataChangeState_P10103(true);
                            GetTotalP010103();
                            resizeGridScroll(strTableNameP010103);
                        }
                    }
                );
        }
        resizeGridScroll(strTableNameP010103);
    } catch (e) { }
}

//编辑单元格方法
function afterEditCell_P010103(rowid, cellname, value, iRow, iCol) {
    iRowP010103 = iRow;
    iColP010103 = iCol;
    for (var i = 0; i < dataLength; i++) {
        if (arr[i] == rowid) {
            $("#" + strTableNameP010103).restoreCell(iRow, iCol);
            return;
        }
    }
    if (cellname == 'e1') {
        var jsr = $(":input[name='e1']", "#" + strDialogIDP010103);
        var jsrs = ParseData(window.external.DoOptions("TZyxx", "GetComboBoxData", "")).Records;
        jsrs.push({ "mc": "<font color='red'>添加经手人</font>", "dm": "-1" });
        jsr.combobox({
            valueField: "dm",
            textField: "mc",
            width: _iWidth100,
            listWidth: _iWidth100
        });

        jsr.combobox("loadData", jsrs);
        jsr.combobox('focus');
        var strZydm = $("#" + strTableNameP010103).getCell(rowid, "zydm");
        jsr.combobox("setValue", strZydm);
        if (jsr.combobox("getText") == strZydm) {
            jsr.combobox('setText', value);
        }
        jsr.combobox({
            onChange: function (newValue, oldValue) {
                if (!newValue) {
                    $("#" + strTableNameP010103).setCell(rowid, "zydm", "&nbsp;");
                }
                else {
                    $("#" + strTableNameP010103).setCell(rowid, "zydm", newValue);
                }
                $("#" + strDialogIDP010103 + "_divform").data("change", true);
            },
            afterChange: function (newValue, newText) {
                if (newValue == "-1") {
                    ciho.IniData({ id: "divAddType", title: "经手人", table: "Tflxx" }, { model: "TZyxx", jquery: $(this) });
                    ciho.showTypeDialog();
                    $(this).combobox("setValue", "");
                }
            }

        });
    }
    if (cellname == 'd1') {
        var kmMc = $(":input[name='d1']", "#" + strDialogIDP010103);
        var fkzh = ParseData(window.external.DoOptions("TKjkm", "GetComboBoxData", "")).Records;
        fkzh.push({ "mc": "<font color='red'>添加付款账户</font>", "dm": "-1" });
        kmMc.combobox({
            valueField: "dm",
            textField: "mc",
            width: _iWidth100,
            listWidth: _iWidth100
        });

        //给combobox 加载数据
        kmMc.combobox("loadData", fkzh);
        kmMc.combobox('focus');
        var strKmdm = $("#" + strTableNameP010103).getCell(rowid, "kmdm");
        kmMc.combobox("setValue", strKmdm);
        if (kmMc.combobox("getText") == strKmdm) {
            kmMc.combobox('setText', value);
        }
        kmMc.combobox({
            onChange: function (newValue, oldValue) {
                if (!newValue) {
                    $("#" + strTableNameP010103).setCell(rowid, "kmdm", "&nbsp;");
                }
                else {
                    $("#" + strTableNameP010103).setCell(rowid, "kmdm", newValue);
                }
                $("#" + strDialogIDP010103 + "_divform").data("change", true);
            },
            afterChange: function (newValue, newText) {
                if (newValue == "-1") {
                    ciho.IniData({ id: "divAddType", title: "付款账户", table: "Tflxx" }, { model: "Tkjkm", jquery: $(this) });
                    ciho.showTypeDialog();
                    $(this).combobox("setValue", "");
                }
            }

        });
        kmMc.change(function () { $("#" + strDialogIDP010103 + "_divform").data("change", true); });


    }
    var objTable = $("#" + strTableNameP010103);
    if (cellname == 'fkdate') {
        inputAndBindData(":input[name='fkdate']", false, "#" + strDialogIDP010103, null);
        $(":input[name='fkdate']", "#" + strDialogIDP010103).change(function () { dataChangeState_P10103(true); });
    }

    if (cellname == "a1") {   //本次优惠
        if (value == "") {
            oldValue = 0;
        }
        else {
            oldValue = parseFloat(value);
            var sfJinE = parseFloat($("#" + strTableNameP010103).getCell(rowid, "a2")); //实付金额
            if (!isNaN(sfJinE))
                oldValue += sfJinE;
        }
        var objA1 = $(":input[name='a1']", "#" + strDialogIDP010103);   //本次优惠
        objA1.autoNumeric({ mDec: window.parent.strMoneyPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
        objA1.change(function () { $("#" + strDialogIDP010103 + "_divform").data("change", true); });

    }
    if (cellname == "a2") {               //如果单元格 为实付金额
        if (value == "") {
            oldValue = 0;
        }
        else {
            oldValue = parseFloat(value);
            var bcYouHui = parseFloat($("#" + strTableNameP010103).getCell(rowid, "a1"));   //本次优惠
            if (!isNaN(bcYouHui)) {
                oldValue += bcYouHui;
            }
        }
        var objA2 = $(":input[name='a2']", "#" + strDialogIDP010103);   //实付金额
        objA2.autoNumeric({ mDec: window.parent.strMoneyPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
        objA2.change(function () { $("#" + strDialogIDP010103 + "_divform").data("change", true); });
    }
    if (cellname == "a3") {
        $(":input[name='a3']", "#" + strDialogIDP010103).val(value);
        $(":input[name='a3']", "#" + strDialogIDP010103).focus(function () { this.select(); });
        $(":input[name='a3']", "#" + strDialogIDP010103).change(function () { dataChangeState_P10103(true) });
    }
    $(".layoutpanel").css("z-index", "50000009");
}

//保存单元格方法
function afterSaveCell_P010103(rowid, cellname, value, iRow, iCol) {
    var strLnopay = 0;
    if (cellname == 'a1' || cellname == 'a2') {
        var objTable = $("#" + strTableNameP010103);
        var arrIds = objTable.getDataIDs();
        var strYhje = 0;
        var strSfje = 0;
        for (var intI = 0; intI < arrIds.length; intI++) {
            var objTr = objTable.getRowData(arrIds[intI]);
            if (objTr.a2==""&&objTr.a1 == "") {
                continue;
            }
            var sfJinE = $(this).getCell(arrIds[intI], "a2") == "" ? 0 : parseFloat($(this).getCell(arrIds[intI], "a2")); //实付金额 
            var bcYouHui = $(this).getCell(arrIds[intI], "a1") == "" ? 0 : parseFloat($(this).getCell(arrIds[intI], "a1"));   //本次优惠
            strYhje += bcYouHui;
            strSfje += sfJinE;
        }
        //strLnopay = parseFloat(objSelRowP0101.nopay) + parseFloat(objSelRowP0101.youhui) + parseFloat(objSelRowP0101.yifukuan) - strYhje - strSfje;
        strLnopay = parseFloat(objSelRowP0101.a4) - strYhje - strSfje;
        $("#wfjedivP010103").val(parseFloat(strLnopay).toFixed(window.parent.strMoneyPlace));   //设置 未付金额
    }
    GetTotalP010103();               //刷新合计数值
    //释放内存
    objTable = null;
    sfJinE = null;
    bcYouHui = null;
    strLnopay = null;
    strYhje = null;
    strSfje = null;
}

//数据状态方法
function dataChangeState_P10103(bState) {
    //修改Data change状态
    $("#" + strDialogIDP010103 + "_divform").data("change", bState);
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑**事件方法 结束**↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓**自定义方法 开始**↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/

//创建select表单元素方法
function my_inputP010103(value, options) {
    return $('<select name="' + options.name + '" id="' + options.id + '"></select>').addClass("easyui-combobox");
}

//保存选中的值方法
function my_valueP010103(ele) {
    return ele.combobox('getText');
}

//格式列中数据方法
function addColFormatter_P010103(objColModel) {
    for (var intI = 0; intI < objColModel.length; intI++) {
        if (objColModel[intI]["name"] == "a1") {
            objColModel[intI].formatter = function (cellvalue, options, rowObject) {
                if (cellvalue != "") {
                    return parseFloat(cellvalue).toFixed(window.parent.strMoneyPlace);
                }
                else {
                    return "&nbsp;";
                }
            }
        }
        //优惠
        else if (objColModel[intI]["name"] == "a2") {
            objColModel[intI].formatter = function (cellvalue, options, rowObject) {
                if (cellvalue != "") {
                    return parseFloat(cellvalue).toFixed(window.parent.strMoneyPlace);
                }
                else {
                    return "&nbsp;";
                }
            }
        }

    }
}

//统计  实付金额的 合计方法
function GetTotalP010103() {

    var objTable = $("#" + strTableNameP010103);
    var arrIds = objTable.getDataIDs();
    var sfJinE = 0;
    var yhJinE = 0;
    for (var i = 0; i < arrIds.length; i++) {
        var strTemp1 = parseFloat(objTable.getCell(arrIds[i], "a2"));
        if (!isNaN(strTemp1)) {
            sfJinE += strTemp1;
        }
        var strTemp2 = parseFloat(objTable.getCell(arrIds[i], "a1"));
        if (!isNaN(strTemp2)) {
            yhJinE += strTemp2;
        }
    }
    $("#" + strTableNameP010103).footerData("set", { rn: "合计", a1: yhJinE.toFixed(window.parent.strMoneyPlace), a2: sfJinE.toFixed(window.parent.strMoneyPlace) });
    //释放内存
    objTable = null;
    arrIds = null;
    sfJinE = null;
    yhJinE = null;

}

//添加新行方法
function addNewRowP010103() {
    var nextNum = $("#" + strTableNameP010103).data("nextNum") + 1;
    $("#" + strTableNameP010103).addRowData(nextNum, { "editable": "True", "gysdm": "", "e1": "", "d1": "", "cz": "", "c1": "", "a3": "", "a2": "", "a1": "", "djdate": "", "zydm": "", "kmdm": "", "djbh": "", "mxguid": "", "fkdate": "" });
    $("#" + strTableNameP010103).data("nextNum", nextNum);
    addDelete_P010103();
    resizeGridScroll(strTableNameP010103);
}

//创建jqGrid 创建一个 Grid 此时不提供数据
function createGridP010103(strTableID, objColNames, objColModel) {
    $("#" + strTableID).jqGrid({
        datatype: "local",
        colNames: objColNames,
        colModel: objColModel,
        data: [],
        rownumbers: true,
        rowNum: 9999,
        sortname: "id",
        rownumWidth: 30,
        autowidth: true,
        //        width: 600,
        //        height: "100%",
        footerrow: true,
        cellEdit: true,
        cellsubmit: "clientArray",
        gridview: true
    }); //.parent(".ui-jqgrid-bdiv").siblings().css("width", "100%");

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

//灰化数据的方法
function LoadStyle() {
    var arrIds = $("#" + strTableNameP010103).jqGrid("getDataIDs");
    for (var i = 0; i < dataLength; i++) {
        var strEditable = $("#" + strTableNameP010103).jqGrid("getCell", arrIds[i], "editable");
        if (strEditable == "False") {
            $("#" + strTableNameP010103).setCell(arrIds[i], "fkdate", "", { color: "#ccc" });
            $("#" + strTableNameP010103).setCell(arrIds[i], "d1", "", { color: "#ccc" });
            $("#" + strTableNameP010103).setCell(arrIds[i], "e1", "", { color: "#ccc" });
            $("#" + strTableNameP010103).setCell(arrIds[i], "a1", "", { color: "#ccc" });
            $("#" + strTableNameP010103).setCell(arrIds[i], "a2", "", { color: "#ccc" });
            $("#" + strTableNameP010103).setCell(arrIds[i], "a3", "", { color: "#ccc" });
            arr.push(arrIds[i]);
        }
    }
}

//修改、删除按钮的添加方法
function addDelete_P010103() {
    $("#Tp010103 tr:visible").hover(function () {
        var strButtonHtml = "";
        var arrIds = $("#" + strTableNameP010103).jqGrid("getDataIDs");
        var strEditable = $("#" + strTableNameP010103).jqGrid("getCell", this.id, "editable");
        if (strEditable != undefined && strEditable == "False") {//如果数据库中不允许编辑那么这一行  不显示 删除按钮
            $("#Tp010103").jqGrid("setCell", this.id, "cz", null);
        }
        else {
            strButtonHtml += "<a href=\"#\" style=\"color:red;text-decoration:none;\" onclick=\"delRowP010103(" + this.id + ");return false;\">删除</a> ";
            $("#Tp010103").jqGrid("setCell", this.id, "cz", strButtonHtml);
        }
    }, function () {
        $("#Tp010103").jqGrid("setCell", this.id, "cz", "　");
    });
}

//给页面元素赋值方法
function creatDialogItem_P010103(data) {
    //日期
    $("#djdatedivP010103").val(data.djdate);
    //供应商
    $("#gysdmdivP010103").val(data.gysmc);
    //未付款
    $("#wfjedivP010103").val(parseFloat(data.wfje).toFixed(window.parent.strMoneyPlace));
}

//加载页面元素方法
function createInputsP010103(arr) {
    var strForm = "<ul>";
    for (var i = 0; i < arr.length; i++) {
        var Item = arr[i];
        if (!Item.hidden) {
            if (Item.edittype == "text") {
                if (Item["name"] == "djdate" || Item["name"] == "wfje") {
                    strForm += "<li class='inp_70'>";
                    strForm += Item.xsmc + "：";
                    strForm += "<input type='text'  name='" + Item.index + strDialogIDP010103 + "' ";
                    if (!Item.editable) {
                        strForm += "disabled='disabled' "; ;
                    }
                    strForm += " value=''  ";
                    strForm += " id='" + Item.index + strDialogIDP010103 + "'";
                    strForm += " maxlength='50'   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 + strDialogIDP010103 + "' ";
                    if (!Item.editable) {
                        strForm += "disabled='disabled' "; ;
                    }
                    strForm += " value=''  ";
                    strForm += " id='" + Item.index + strDialogIDP010103 + "'";
                    strForm += " maxlength='50'   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>";
    return strForm;
}

/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑**自定义方法 结束**↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/