logis-provider-1.0.0.js
2.74 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
(function() {
var e = function(options) {
this.init(options);
};
e.areas = {};
e.prototype = {
init : function(options) {
e.areas = options.areas;
},
dialog : function(pos, checked, disabled) {
var areas = $.extend(true,{}, e.areas);
if (checked && checked.length) {
for (k in areas.group) {
var a = areas.group[k].areas;
for (j in a) {
var g = '' + areas.group[k].areas[j].code
if ($.inArray(g, checked) != -1) {
areas.group[k].areas[j].checked = true;
}
}
}
}
if (disabled && disabled.length) {
for (k in areas.group) {
var a = areas.group[k].areas;
for (j in a) {
var g = '' + areas.group[k].areas[j].code
if ($.inArray(g, disabled) != -1) {
areas.group[k].areas[j].disabled = true;
}
}
}
}
var o = $('#J_AreaTemplate').tpl(areas),
content = '<form method="post">' + o + '<div class="btns"><button type="button" class="J_Submit">确定</button><button type="button" class="J_Cancel">取消</button></div></form>',
dialog = new AreaDialog(pos, '选择区域', content, e.areas, checked);
dialog.show();
},
delRule: function(o){
if (confirm('确定要删除当前地区的设置吗?')) {
var tr = $(o).parents('tr')[0];
$(tr).remove()
}
},
addRule: function(o){
var div = $(o).parents('.J_PostageDetail')[0];
var i = $(div).find('tbody tr').length + 1,
rid = 'n' + i,
express = $(div).attr('data-delivery'),
type = this.getType(),
data = {
rid: rid,
express: express,
type: type[0],
typeUnit: type[1],
};
if (i == 1) { // 第一个
var firstRuleTpl = $('#J_FirstRuleTemplate').tpl(data);
$(div).find('.tbl-except').html(firstRuleTpl)
} else {
ruleTpl = $('#J_RuleTemplate').tpl(data);
$(div).find('tbody').append(ruleTpl)
}
},
toggle: function(o) {
var i = $(o).parents('.J_Section')[0];
var s = $(i).find('.J_PostageDetail');
if ($(o).prop('checked')) {
if (s.length > 0) {
s.show()
} else {
var type = this.getType();
var express = $(i).find('.J_Delivery').attr('data-type'),
data = {
express: express,
type: type[0],
typeUnit: type[1],
},
ruleTpl = $('#J_InitRuleTemplate').tpl(data);
$(i).append(ruleTpl)
}
} else {
if (s.length > 0) {
s.hide()
}
}
},
getType: function () {
var v = $('input[name="valuation"]:checked').val(),
n = '',
m = '';
if (v == undefined) {
v = $('input[name="valuation"]').val();
}
if (v == 1) {
n = '件';
m = '件';
} else if (v == 2) {
n = '重';
m = 'kg';
} else if (v == 3) {
n = '体积';
m = 'm³';
}
return [n, m];
}
}
window.LogisProvider = e
})();