category.Edit.js
3.44 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
119
120
webpackJsonp([22],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
var $ = __webpack_require__(1);
var common=__webpack_require__(2);
var ViewModel=window.ViewModel;
var RESPONSEDATA=ViewModel.data||{};
//
var needTaxRateFlag = RESPONSEDATA.sortLevel && RESPONSEDATA.sortLevel >= 3;
$("#new-class-form").html(common.util.__template2($("#template").html(),RESPONSEDATA));
var NUMN={
columns: [{
state: "prov",
text: "一级分类",
hide: false,
addclass: ""
}, {
state: "city",
text: "二级分类",
hide: false,
addclass: ""
}, {
state: "area",
text: "三级分类",
hide: false,
addclass: ""
}],
datas: [{
sortName: RESPONSEDATA.firstSortName,
code: "",
id: RESPONSEDATA.firstSortId
}, {
sortName: RESPONSEDATA.secondSortName,
code: "",
id: RESPONSEDATA.secondSortId
}, {
sortName: RESPONSEDATA.threeSortName,
code: "",
id: RESPONSEDATA.threeSortId
}],
complete : function (selectData, bool) { // 判断是不是选择了三级或者四级品类
if (selectData.length >= 2 && selectData[0].id && selectData[1].id) {
$(".category-min-level-3").show();
needTaxRateFlag = true;
$("#compositeRate").val(RESPONSEDATA.compositeRate || '0.091');
} else {
$(".category-min-level-3").hide();
$("#taxRate").val('');
$("#compositeRate").val('');
$("#netWeight").val('');
$("#grossWeight").val('');
//$("input[name=taxRate]").val('');
$("input:radio[name=taxRate]").attr("checked",false);
needTaxRateFlag = false;
}
}
}
var sort=new common.tabTree("#sortTree",NUMN);
sort.init();
if (RESPONSEDATA.id != null) { // 修改品类页面不允许修改所属品类
sort.isfeeze=true;
}
var e=new common.edit("#new-class-form", {
"bucket" : "sort"
});
e.on("bind",function(){
$("#orderBy").keyup(function(){
$(this).val($(this).val().replace(/^\D+$/g,''));
});
});
e.on("validate",function(){
if(!(/^\d+$/g.test($("#orderBy").val()))){
return "排序字段请输入0~100的正整数";
}
});
e.on("validate",function(){
if (needTaxRateFlag && '' == $("#taxRate").val()) {
return "发票税率未填";
}
});
e.init();
$(document).on("click",".btn-success",function(){
e.submit($("#new-class-form").attr("action"),function(option){
var sortArr=sort.getAddress();
option.data.firstSortId=sortArr[0]?sortArr[0].id:-1;
option.data.secondSortId=sortArr[1]?sortArr[1].id:-1;
option.data.threeSortId=sortArr[2]?sortArr[2].id:-1;
console.log(option.data);
// option.debug=true;
option.success=function(res){
res=res;
if(res.code=="200"){
e.$tip('提交成功',function(){
location.href="/erpproduct/sort/index";
},'growl-success');
}else{
e.$tip(res.message);
}
return false;
}
option.error=function(res){
e.$tip("提交失败");
};
});
});
/***/ }
]);