Edit.js
2.19 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
var $ = require('jquery'),
edit = require('../../common/edit');
var e = new edit("#basicForm", {bucket: "yhb-img02"});
e.on("validate", function () {
var contactPhone = $.trim($("#contactPhone").val());
if (contactPhone) {
if (!(/^[0-9-()]*$/.test(contactPhone))) {
return "请输入正确的公司联系电话";
}
}
//phone
var phone = $.trim($("#phone").val());
if (phone) {
if (!(/^[0-9-()]*$/.test(phone))) {
return "请输入正确的联系人电话";
}
}
if (!phone && !contactPhone) {
return "请在公司联系电话,联系人电话至少填一个";
}
return true;
});
e.init();
var submit = function (callback, config) {
e.submit($("#basicForm").attr("action"), function (option) {
option.success = function (res) {
if (res.code == "200") {
e.$tip(config.msg || "提交成功", function () {
if (+option.data.operations == 1) {
location.href = "/supplier/supplier/index";
} else {
location.href = "/supplier/supplier/managelist";
}
}, 'growl-success');
} else {
e.$tip(res.message);
}
return false;
},
option.error = function (res) {
e.$tip("提交失败");
}
callback && callback(option.data);
});
};
//添加暂存,提交审核
$(document).on('click','#btnTemporary',function () {
submit(function (data) {
data.operations = 1;
data.status = 100;
}, {msg: "暂存成功"});
return false;
});
//到审核表
$(document).on('click','#btnReview',function () {
submit(function (data) {
data.operations ? data.operations : data.operations = 1;
if (+data.status == 300) {
data.operations = 2;
}
data.status = 200;
}, {msg: "提交成功"});
return false;
});
//供应商列表
$(document).on('click','#updatecheck',function () {
submit(function (data) {
data.operations = 2;
data.status = 200;
}, {msg: "提交成功"});
return false;
});