//查询仓库
function FastSearch_Warehouse() {
    $("#wh_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Warehouse.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'wh_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'wh_code', 'width': '80', 'label': '仓库编码' },
            { 'columnName': 'wh_name', 'width': '100', 'label': '仓库名称'}],
        select: function (event, ui) {
            SearchService_Warehouse(ui.item.wh_id);
            return false;
        }
    });
}
//查询部门
function FastSearch_Department() {
    $("#dep_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Department.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'dep_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'dep_code', 'width': '80', 'label': '部门编码' },
            { 'columnName': 'dep_name', 'width': '100', 'label': '部门名称'}],
        select: function (event, ui) {
            SearchService_Department(ui.item.dep_id);
            return false;
        }
    });
}
//查询仓库
function FastSearch_D_Warehouse() {
    $("#d_wh_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Warehouse.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'wh_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'wh_code', 'width': '80', 'label': '仓库编码' },
            { 'columnName': 'wh_name', 'width': '100', 'label': '仓库名称'}],
        select: function (event, ui) {
            SearchService_D_Warehouse(ui.item.wh_id);
            return false;
        }
    });
}
//查询部门
function FastSearch_D_Department() {
    $("#d_dep_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Department.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'dep_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'dep_code', 'width': '80', 'label': '部门编码' },
            { 'columnName': 'dep_name', 'width': '100', 'label': '部门名称'}],
        select: function (event, ui) {
            SearchService_D_Department(ui.item.dep_id);
            return false;
        }
    });
}
//查询员工
function FastSearch_Employee() {
    $("#ele_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Employee.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'ele_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'ele_code', 'width': '80', 'label': '员工编码' },
            { 'columnName': 'ele_name', 'width': '100', 'label': '员工名称'},
            { 'columnName': 'dep_name', 'width': '100', 'label': '所属部门'}],
        select: function (event, ui) {
            SearchService_Employee(ui.item.ele_id);
            return false;
        }
    });
}

//查询供应商
function FastSearch_Vendor() {
    $("#vd_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Vendor.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'vd_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'vd_code', 'width': '80', 'label': '供应商编码' },
            { 'columnName': 'vd_name', 'width': '100', 'label': '供应商名称'}],
        select: function (event, ui) {
            SearchService_Vendor(ui.item.vd_id);
            return false;
        }
    });
}
//查询客户
function FastSearch_Customer() {
    $("#cus_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Customer.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'cus_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'cus_code', 'width': '80', 'label': '客户编码' },
            { 'columnName': 'cus_name', 'width': '100', 'label': '客户名称'}],
        select: function (event, ui) {
            SearchService_Customer(ui.item.cus_id);
            return false;
        }
    });
}
//查询币种
function FastSearch_Currency() {
    $("#crc_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Currency.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'crc_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'crc_code', 'width': '80', 'label': '币种编码' },
            { 'columnName': 'crc_name', 'width': '100', 'label': '币种名称' },
            { 'columnName': 'exchange_rate', 'width': '100', 'label': '汇率'}],
        select: function (event, ui) {
            SearchService_Currency(ui.item.crc_id);
            return false;
        }
    });
}
//查询销售类型
function FastSearch_SaleType() {
    $("#st_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_SaleType.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'st_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'st_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'st_name', 'width': '100', 'label': '名称'}],
        select: function (event, ui) {
            SearchService_SaleType(ui.item.st_id);
            return false;
        }
    });
}
//查询采购类型
function FastSearch_PurchaseType() {
    $("#pt_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_PurchaseType.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'pt_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'pt_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'pt_name', 'width': '100', 'label': '名称'}],
        select: function (event, ui) {
            SearchService_PurchaseType(ui.item.pt_id);
            return false;
        }
    });
}
//查询收发类型
function FastSearch_IOType(iot_flag) {
    $("#iot_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_IOType.aspx?iot_flag=' + iot_flag,
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'iot_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'iot_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'iot_name', 'width': '100', 'label': '名称'}],
        select: function (event, ui) {
            SearchService_IOType(ui.item.iot_id);
            return false;
        }
    });
}
//查询费用
function FastSearch_Cost() {
    $("#cst_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Cost.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'cst_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'cst_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'cst_name', 'width': '100', 'label': '名称'}],
        select: function (event, ui) {
            SearchService_Cost(ui.item.cst_id);
            return false;
        }
    });
}
//查询发运方式
function FastSearch_ShipWay() {
    $("#sw_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_ShipWay.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'sw_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'sw_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'sw_name', 'width': '100', 'label': '名称'}],
        select: function (event, ui) {
            SearchService_ShipWay(ui.item.sw_id);
            return false;
        }
    });
}
//查询结算方式
function FastSearch_SettleStyle() {
    $("#ss_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_SettleStyle.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'ss_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'ss_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'ss_name', 'width': '100', 'label': '名称' }],
        select: function (event, ui) {
            SearchService_SettleStyle(ui.item.ss_id);
            return false;
        }
    });
}
//查询结算账户
function FastSearch_Account() {
    $("#ac_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_Account.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'ac_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'ac_code', 'width': '80', 'label': '编码' },
            { 'columnName': 'ac_name', 'width': '100', 'label': '名称' }],
        select: function (event, ui) {
            SearchService_Account(ui.item.ac_id);
            return false;
        }
    });
}
//查询存货
var inventory_auto_search = true;//启用输入自动搜索
var flag_is_sale = 0;//只显示开启销售属性的存货
var flag_is_purchase = 0;//只显示开启采购属性的存货
var flag_cus_id = "";//客户id
var order_can_see_cus_inv_sale = "0";//只显示客户指定的存货
function FastSearch_Inventory() {
    $("#i_code").fast_search({
        url: '../../Component/FastSearch/FastSearch_Inventory.aspx?is_sale=' + flag_is_sale
            + '&is_purchase=' + flag_is_purchase
            + '&flag_cus_id=' + flag_cus_id
            + '&order_can_see_cus_inv_sale=' + order_can_see_cus_inv_sale,
        replaceNull: true,
        searchButton: true,
        autoSearch: inventory_auto_search,
        colModel: [{ 'columnName': 'i_id', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'i_code', 'width': '120', 'label': '编码' },
            { 'columnName': 'i_name', 'width': '120', 'label': '名称' },
            { 'columnName': 'standard', 'width': '120', 'label': '规格型号' },
            { 'columnName': 'munit', 'width': '60', 'label': '单位'}/*,
            { 'columnName': 'small_pic_url', 'width': '150', 'label': '图片'}*/],
        select: function (event, ui) {
            SearchService_Inventory(ui.item.i_id);
            return false;
        }
    });
}
//查询登录用户
function FastSearch_Member() {
    $("#username").fast_search({
        url: '../../Component/FastSearch/FastSearch_Member.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'uid', 'hidden': true, 'width': '80', 'label': 'id' },
            { 'columnName': 'username', 'width': '80', 'label': '用户名' },
            { 'columnName': 'nickname', 'width': '100', 'label': '姓名' }],
        select: function (event, ui) {
            SearchService_Member(ui.item.uid);
            return false;
        }
    });
}
//查询核销类型
function FastSearch_CancelType() {
    $("#cl_type_name").fast_search({
        url: '../../Component/FastSearch/FastSearch_CancelType.aspx',
        replaceNull: true,
        searchButton: true,
        colModel: [{ 'columnName': 'cl_type', 'width': '80', 'label': '编码' },
            { 'columnName': 'cl_type_name', 'width': '100', 'label': '名称' }],
        select: function (event, ui) {
            SearchService_CancelType(ui.item.cl_type);
            return false;
        }
    });
}