easyui常用方法

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 = ' [修改商品]';
            html += ' [删除商品]';
            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);
                    }
                });

你可能感兴趣的:(easyui常用方法)