CapitalSubmitSystembillRequestJs.jsp
7.63 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<%@page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.hrm.User"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.general.Util"%>
<%@page import="java.util.*"%>
<%@page import="org.json.JSONObject"%>
<%
User user = HrmUserVarify.getUser (request , response) ;
if(user==null){
response.sendRedirect("/notice/noright.jsp") ;
return ;
}
int requestid = Util.getIntValue(request.getParameter("requestid"),0);
int workflowid = Util.getIntValue(request.getParameter("workflowid"),0);
int formid = Util.getIntValue(request.getParameter("formid"),0);
String cpt_field = "";//资产字段
String cptnum_field = "";//数量字段
String cptprice_field = "";//资产单价
String totalamount_field = "";//总价
if(formid==14){//入库
cpt_field = "cptid";
cptnum_field = "number_n";
cptprice_field = "unitprice";
totalamount_field = "totalamount";
}else if(formid==18){//调拨
cpt_field = "capitalid";
cptnum_field = "number_n";
cptprice_field = "unitprice";
totalamount_field = "totalamount";
}else if(formid==19){//领用
cpt_field = "capitalid";
cptnum_field = "number_n";
cptprice_field = "unitprice";
totalamount_field = "totalamount";
}else if(formid==201){//报废
cpt_field = "capitalid";
cptnum_field = "numbers";
}else if(formid==221){//减损
cpt_field = "lossCpt";
cptnum_field = "losscount";
}
%>
<script language="javascript">
jQuery().ready(function(){
var formid = '<%=formid%>';
//金额
if(formid==14||formid==18||formid==19){
var changfield = WfForm.convertFieldNameToId("<%=cptnum_field%>","detail_1")+","+WfForm.convertFieldNameToId("<%=cptprice_field%>","detail_1");
WfForm.bindDetailFieldChangeEvent(changfield,function(id,rowIndex,value){
add(id,rowIndex,value);
});
}
WfForm.registerCheckEvent(WfForm.OPER_SAVE+","+WfForm.OPER_SUBMIT, function(callback){
var temprequestid = '<%=requestid%>';
var poststr = "";
var check_flag = false;
if(formid=='14'){//资产入库
var cpt_field = WfForm.convertFieldNameToId("<%=cpt_field%>","detail_1")+'_';
var cptnum_field = WfForm.convertFieldNameToId("<%=cptnum_field%>","detail_1")+'_';
var indexnum0 = WfForm.getDetailAllRowIndexStr("detail_1");
if(indexnum0!=""){
var resourceIdArray = indexnum0.split(",");
for(var i=0;i<resourceIdArray.length;i++){
try{
var zcid = WfForm.getFieldValue(cpt_field+resourceIdArray[i]);//领用的资产id
var cptnum = WfForm.getFieldValue(cptnum_field+resourceIdArray[i]);//领用的数量
if(zcid==undefined||zcid==""||cptnum==undefined||cptnum==""){
check_flag = true;
}else{
poststr += "|"+zcid+","+ cptnum;
}
}catch(e){
//alert(e);
}
}
}
if(poststr!=""){
poststr =poststr.substr(1);
}
callback();//执行callback,表示继续执行,否则流程停止
}else{
if(formid=='221'){//减损:主表,归还、减损、借用、送修
var cpt_field = WfForm.convertFieldNameToId("<%=cpt_field%>");
var cptnum_field = WfForm.convertFieldNameToId("<%=cptnum_field%>");;
var zcid = WfForm.getFieldValue(cpt_field);//减损的资产id
var cptnum = WfForm.getFieldValue(cptnum_field);//减损的数量
if(zcid!=undefined && zcid!=""&&cptnum!=undefined && cptnum!=""){
poststr += "|"+zcid+","+ cptnum;
}else if(zcid!=undefined&&zcid!=""&&(cptnum==undefined||cptnum=="")){
check_flag = true;
}
}else{//明细表:入库、报废、领用、调拨
var cpt_field = WfForm.convertFieldNameToId("<%=cpt_field%>","detail_1")+'_';
var cptnum_field = WfForm.convertFieldNameToId("<%=cptnum_field%>","detail_1")+'_';
var indexnum0 = WfForm.getDetailAllRowIndexStr("detail_1");
if(indexnum0!=""){
var resourceIdArray = indexnum0.split(",");
for(var i=0;i<resourceIdArray.length;i++){
try{
var zcid = WfForm.getFieldValue(cpt_field+resourceIdArray[i]);//资产id
var cptnum = WfForm.getFieldValue(cptnum_field+resourceIdArray[i]);//操作资产的数量
if(cptnum==undefined||cptnum==""){
if(zcid!=undefined&&zcid!=""){
check_flag = true;
}
}else{
if(zcid!=undefined&&zcid!=""){
poststr += "|"+zcid+","+ cptnum;
}
}
}catch(e){
//alert(e);
}
}
}
}
//除了入库,入库领用、变更,资产不为空、数量为空,需要校验
if(check_flag){
alert("<%=SystemEnv.getHtmlLabelNames("503026,82241",user.getLanguage())%>");
}else{
if(poststr!=""){
poststr =poststr.substr(1);
jQuery.ajax({
url : "/mobile/e9/cpt/CptNumForManager.jsp",
type : "post",
async : true,
processData : false,
data : "poststr="+poststr+"&formid="+formid+"&requestid="+temprequestid,
dataType : "json",
success: function do4Success(data){
if(data&&data.msg && data.msg!=""){
alert(data.msg);
}else{
callback();//执行callback,表示继续执行,否则流程停止
}
}
});
}else{
//alert("<%=SystemEnv.getHtmlLabelName(386122,user.getLanguage())%>");
callback();//执行callback,表示继续执行,否则流程停止
}
}
}
});
});
//累计求和
function add(id,rowIndex,value){
var cptnum_field = WfForm.convertFieldNameToId("<%=cptnum_field%>","detail_1")+'_';
var cptprice_field = WfForm.convertFieldNameToId("<%=cptprice_field%>","detail_1")+'_';
var rowIndexs = WfForm.getDetailAllRowIndexStr("detail_1");
var amount = 0;
for(var index = 0;index < rowIndexs.length;index++){
var fieldnumber_v = WfForm.getFieldValue(cptnum_field+index);
var fieldprice_v = WfForm.getFieldValue(cptprice_field+index);
var temporaryAmount = toFloat(fieldnumber_v,0)*toFloat(fieldprice_v,0);
amount += eval(temporaryAmount) ;
}
WfForm.changeFieldValue(WfForm.convertFieldNameToId("<%=totalamount_field%>"), {
value: amount
});
}
//删除累计求和
function addDelete(){
var cptnum_field = WfForm.convertFieldNameToId("<%=cptnum_field%>","detail_1")+'_';
var cptprice_field = WfForm.convertFieldNameToId("<%=cptprice_field%>","detail_1")+'_';
var rowIndexs = WfForm.getDetailAllRowIndexStr("detail_1");
var amount = 0;
for(var index = 0;index < rowIndexs.length;index++){
var fieldnumber_v = WfForm.getFieldValue(cptnum_field+index);
var fieldprice_v = WfForm.getFieldValue(cptprice_field+index);
var temporaryAmount = toFloat(fieldnumber_v,0)*toFloat(fieldprice_v,0);
amount += eval(temporaryAmount) ;
}
WfForm.changeFieldValue(WfForm.convertFieldNameToId("<%=totalamount_field%>"), {
value: amount
});
}
function toFloat(str , def) {
if(isNaN(parseFloat(str))) return def ;
else return str ;
}
function toInt(str , def) {
if(isNaN(parseInt(str))) return def ;
else return str ;
}
function _customDelFun0(){ //明细2删除成功后触发事件
addDelete();
}
function _customAddFun0(addIndexStr){ //明细2新增成功后触发事件,addIndexStr即刚新增的行标示,添加多行为(1,2,3)
}
</script>