常用代码备忘

【HTML】
                <div class="page-title-box">
                    <div id="divPageTitle" data-role="title"></div>
                    <div id="divBranch">
                        <label for="branch">分店:</label>
                        <div id="branch"></div>
                    </div>
                </div>


【DM】

    mediaTypeList: [
        { name: "ID卡", value: 0 },
        { name: "IC卡", value: 1 },
        { name: "可视卡", value: 2 },
    ],

    branchID: null,
    branchList: null,
    getBranchList: function (finished) {
        var that = this;
        myBOCaller.getBranchList(function(result){
            //用返回值并更新List
            that.branchList = utils.getPropValue(result);
            //回调页面函数
            finished(that.branchList);
        });
    },
    outletList: null,
    getOutletList: function (finished) {
        var that = this;
        myBOCaller.getOutletList(this.branchID, 
            function (result) {
                //用返回值并更新List
                that.outletList = utils.getPropValue(result);
                //回调页面函数
                finished(that.outletList);
            });
    },
    onBeforeOpen: function (e) {
        if (e.where)
            e.where += " and ";
        e.where += "(aBranchID = '" + this.branchID + "')";
    },


    onAfterAdd: function (e) {
        if (e.tableName.toLowerCase() == "PubOutlet".toLowerCase()) {
            e.currentItem.set("BranchID", this.branchID);
        }
    },


【Browser】
        this.isAutoOpen = false;


    onAfterInit: function (e) {
        //装载分店资料
        this.dm.getBranchList(function (result) {
            $("#branch").kendoDropDownList({
                index: -1,
                dataTextField: "BranchName",
                dataValueField: "ID",
                valuePrimitive: true,
                dataSource: result,
                change: function () {
                    var branch = $("#branch").data("kendoDropDownList");
                    if (branch) {
                        var id = branch.value();
                        page.dm.branchID = id;
                        page.openData("", "");
                    };
                },
            });
            //默认选择第一个
            if (page.dm.branchList.length) {
                var branch = $("#branch").data("kendoDropDownList");
                branch.select(0);
                branch.trigger("change");
            }
        });
    },
    onBeforeShowEditor: function (e) {
        var branchID = null;
        var branch = $("#branch").data("kendoDropDownList");
        if (branch)
            branchID = branch.value();
        if (!branchID) {
            smartAlert("请选择分店");
            e.ignore = true;
        };
        e.params.push("branchID=" + branchID);
    },


【Editor】

        this.dm.branchID = utils.getRequestParams()["branchID"] || null;

    onAfterInit: function () {
        //装载营业部门
        this.dm.getOutletList(function (result) {
            $("#inpOutlet").kendoComboBox({
                index: -1,
                dataTextField: "OutletName",
                dataValueField: "ID",
                valuePrimitive: true,
                dataSource: result,
                change: function (e) {
                    var value = this.value();
                    if (value && this.selectedIndex == -1) {
                       smartAlert("输入了无效的营业部门。");
                        this.value("");
                    };
                },
            });
        });
    },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值