dropDown.js
4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
require('../util/select2');
var $ = require('jquery');
var urlObj = {
'supplier': '/supplier/supplier/getSupplierListByIdName',
'brand': '/brand/getBrandNames',
'managerName': '/supplier/storeadmin/managerName',//根据身份选择管理员
'sortattribute': '/erpproduct/sortattribute/ajax/automatic', // 品类关联实物测量属性
'sortsize': '/erpproduct/sortsize/ajax/automatic',//尺码模糊查询【验证通过】
'queryBrand': '/goods/query/brand',//查询品牌列表接口
'querySupplier': '/goods/query/supplier',//查询供应商列表接口
'queryShop': '/goods/query/shop', // 查询店铺列表接口
'queryShopPass': '/goods/query/shopPass', // 查询通过审核店铺列表接口
'maxSort': '/goods/query/maxSort',//查询一级类目列表接口
'shopsRest': '/ShopsRest/getShopsByName', // 店铺列表
'xiangouID': '/limit/xiangouID/selectActivityListForSelect', //限购ID
'sortsize2':'/erpproduct/sortsize/ajax/querySizeListBySortId4Html',//尺码
'sortbybrand':'/goods/query/queryShopsByBrandId',
'getjitSup':'/goods/query/getJitSupplierByBrandld',
// 'getsort':'/goods/query/querySortBySmallSort',
'sortlist': '/product/class/queryAllProductSortList',
'productPool': '/runManage/subjectManage/queryBaseProductPoolListByName',
'firstCategory': '/operations/helpcategory/getCategoryListByPid',
'getByCategoryId': '/operations/helpcontent/getSecondCategoryList',
'getAllHelpCategory': '/operations/helpcontent/getAllHelpCategory',
'getHelpCategory': '/operations/helpcontent/getHelpCategory',
'queryAll4Select': '/goods/brandSeries/queryAll4Select', //品牌款型系列
'getSelectItems': '/meterManage/brand/getSelectItems',//品牌获取选择选项的枚举
// 逛
'guangGetAuthorList':'/guang/article/getAuthorList', // 逛-获取作者
'guangGetSortList':'/guang/article/getSortList', // 逛-获取作者
'guangGetTagCategoryByStatus':'/guang/tagSort/getTagItems',
'guangCommentGetFilterItems':'/guang/comment/getItems', // 逛-评论列表-获取筛选条件
'guangPlusSatrChannel':'/guang/plustarcategory/getCategoryNames', // 逛-plus star 频道
};
var minimumResultsForSearch=["sortbybrand","getjitSup","sortsize2"];
var dropDown = function(option) {
new dropDown.prototype.init(option);
}
dropDown.prototype = {
constructor: dropDown,
init: function(_option) {
var option = {
el: '.select2-offscreen',
url: urlObj[_option.ajax]
};
for (var i in _option) {
if (_option.hasOwnProperty(i)) {
option[i] = _option[i];
}
}
if(minimumResultsForSearch.indexOf(_option.ajax)>-1){
option.minimumResultsForSearch=Infinity
}
if (option.ajax) {
$(option.el).select2({
minimumResultsForSearch: option.minimumResultsForSearch||0,
ajax: {
url: option.url,
dataType: 'json',
type: 'POST',
delay: 250,
data: function(params) {
var param={};
if(Object.prototype.toString.call(option.params)=="[object Function]"){
param=option.params();
}else{
param=option.params;
}
var data = $.extend({}, {
idName: params.term
}, param || {});
return data;
},
processResults: function(data, params) {
params.page = params.page || 1;
data.data.data.unshift({
id: '-1',
text: "请选择"
});
return {
results: data.data.data
}
},
cache: true
}
});
} else {
$(option.el).select2();
}
}
}
dropDown.prototype.init.prototype = dropDown.prototype;
module.exports = dropDown;