easyui常用方法

2018-05-20  本文已影响15人  仙道喵喵

1、下拉框“商品列表”实现

               //下拉框“商品列表”实现
                w.find('#select_Product').combobox({
                    url: '/api/sys/SupplierProducts/Get_Product_And_Supplier',
                    //data: treeDataOrganize,
                    method: 'get',
                    editable: true,
                    valueField: 'product_id',
                    textField: 'product_name',
                    panelHeight: 500,
                    formatter: formatItem_product,
                    prompt: '请选择产品,必须选择!',
                    onHidePanel: combobox_clear_unexsits_value,
                    loadFilter: function (data_rows) {
                       //实现已被添加的商品,不再出现在下拉框中
                        //detail_rows是包含已被添加商品的数组
                        for (var b in detail_rows) {  //遍历已被添加商品数组
                            row = data_rows.find(function (x) {  //在数据源中查找包含商品记录的数据行
                                return x.product_id == detail_rows[b].product_id;  
                            });
                            if (row != null) { //若数据行存在,则从数据源中删除该元素
                                data_rows.splice(data_rows.indexOf(row), 1);
                            }
                        }
                            
                        return data_rows;
                    },
                    onSelect: function (node) {
                        // alert(node.id);
                        this.form.product_id = ko.observable(node.id);
                    }
                });


  //#region 页面:数据行按钮,修改本商品
    formatterPermit = function (value, row) {
        if (row.id != null) {
            //根据本组的值查找对象数组行,filter返回所有满足条件的元素
            var search_rows = saleOrderData.filter(function (x) {
                return x.sale_id == row.sale_id && x.product_id != row.product_id;
            });

            var html = '<a href="#" onclick=\'detailDialog(1,' + JSON.stringify(row) + ',' + JSON.stringify(search_rows) + ')\'><span class="icon icon-edit">&nbsp;</span>[修改商品]</a>';
            html += '<a href="#" onclick=\'detailDeleteDialog(' + JSON.stringify(row) + ')\' style="margin-left:10px"><span class="icon icon-cross ">&nbsp;</span>[删除商品]</a>';
            return html;
        }

    };
    //#endregion

2、下拉框“客户列表”实现

               //下拉框“客户列表”实现
                w.find('#select_customer').combobox({
                    url: '/api/sys/customer',
                    //data: treeDataOrganize,
                    method: 'get',
                    editable: true,
                    valueField: 'id',
                    textField: 'company_name',
                    panelHeight: 500,
                    formatter: formatItem_customer,
                    prompt: '请选择客户,必须选择!',
                    onHidePanel: combobox_clear_unexsits_value,
                    loadFilter: function (data_rows) {
                        //for (var a in data_rows) {
                        //    for (var b in detail_rows) {
                        //        if (data_rows[a].product_id == detail_rows[b].product_id) {
                        //            data_rows.splice(a, 1);
                        //        }
                        //    }
                        //}
                        return data_rows;
                    },
                    onSelect: function (node) {
                        // alert(node.id);
                        this.form.customer_id = ko.observable(node.id);
                    }
                });


//保存前获取值
this.form.customer_id = w.find('#select_customer').combobox('getValue');

3、下拉框“系统用户”实现

    //下拉框“审核人”实现
                w.find('#select_reviewer_person').combobox({
                    url: '/api/sys/user/Get_uers_by_role?role=super',
                    method: 'get',
                    editable: true,
                    valueField: 'user_code',
                    textField: 'user_name',
                    prompt: '请选择审核人员,必须选择!',
                    onHidePanel: combobox_clear_unexsits_value,
                    formatter: formatItem_user,
                    onSelect: function (record) {
                    }
                });

4、下拉框“物流公司”实现

 //下拉框“物流公司”实现
                w.find('#select_logistics_company').combobox({
                    url: '/api/sys/LogisticsCompany/Get_logistics_company_by_type?type=1',
                    method: 'get',
                    editable: true,
                    valueField: 'id',
                    textField: 'name',
                    prompt: '请选择物流公司!',
                    onHidePanel: combobox_clear_unexsits_value,
                    formatter: formatItem_logistics_company,
                    onSelect: function (record) {
                        w.find('#input_logistics_company_phone').textbox('setValue', record.phone);
                    }
                });
上一篇下一篇

猜你喜欢

热点阅读