limitcode-edit.js
3.14 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
var $ = require('jquery');
var edit=require('../common/edit');
var e=new edit("#basicForm");
var type=$("#basicForm").attr("role");
if (type == 'edit') {
$('#name, #limitTimes, #userUseLimit, #department1, #department2, #limitDateFrom, #limitDateTo, #describe, #UID').prop('disabled', true);
$('input[name="userTypeLimit"]').prop('disabled', true);
}
e.on("render",function(){
if($("#reqDepartment").val()){
var departmentArr = String.prototype.split.call($("#reqDepartment").val(), '/'),
$department1 = $("#department1"),
$department2 = $("#department2");
$department1.val(departmentArr[0]);
if (departmentArr[1]) {
$department2.val(departmentArr[1]).show();
} else {
$department2.hide();
}
}
});
e.on("bind",function(){
if($("#reqDepartment").val()){
var departmentArr = String.prototype.split.call($("#reqDepartment").val(), '/'),
$department1 = $("#department1"),
$department2 = $("#department2");
$("select").change(function() {
if ($(this).is($department1)) {
departmentArr.length = 0;
departmentArr[0] = $(this).val();
if ($(this).val() === "零售部") {
$department2.show();
departmentArr[1] = $department2.val();
} else {
$department2.hide();
}
} else {
departmentArr[1] = $(this).val();
}
$("#reqDepartment").val(departmentArr.join('/'));
});
}
});
e.on("validate",function(){
var num=$.trim($("#limitTimes").val());
if(+num>100000||+num<1){
return "数量(范围:1-100000)";
}
return true;
});
e.on("validate",function(){
var skn=$.trim($("#limitSkn").val());
if(skn.length > 8){
return "skn长度不能超过8位";
}
return true;
});
e.init();
var submit=function(callback){
e.submit($("#basicForm").attr("action"),function(option){
option.success=function(res){
res=res.data;
if(res.code=="200"){
e.$tip('提交成功',function(){
location.href = "/market/limitcode/index";
},'growl-success');
}else{
e.$tip(res.message);
}
return false;
},
option.error=function(res){
e.$tip("提交失败");
}
console.log(option.data);
callback&&callback(option.data);
});
}
$("#save_brand").click(function(){
submit(function(data){
// 限购码状态0:待审核 1:审核通过 2:驳回 3:过期 4:作废
if(+data.status==1){
//不改
}else{
data.status=0;
}
});
return false;
});