FnaBudgetChgApplySystemBill.jsp
8.29 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<%@page import="java.util.UUID"%>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="weaver.general.Util"%>
<%@page import="weaver.workflow.field.BrowserComInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
String guid1 = UUID.randomUUID().toString();
User user = HrmUserVarify.getUser (request , response) ;
if(user==null){
response.sendRedirect("/notice/noright.jsp") ;
return ;
}
%>
<script type="text/javascript" src="/fna/js/e8Common_wev8.js?r=5"></script>
<script type="text/javascript" src="/js/weaver_wev8.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
//初始化 变更的差额
initChangeAmount();
//新预算
WfForm.bindDetailFieldChangeEvent("field596",function(id,rowIndex,value){
var tempValue = Number(value);
if(tempValue < 0){//小于0,置空
WfForm.changeFieldValue("field596_"+rowIndex,{
value:''
});
} else {
changeApplyNumber(rowIndex);
}
});
//审批预算
WfForm.bindDetailFieldChangeEvent("field597",function(id,rowIndex,value){
var tempValue = Number(value);
if(tempValue < 0){//小于0,置空
WfForm.changeFieldValue("field597_"+rowIndex,{
value:''
});
} else {
changeNumber(rowIndex);
}
});
//监听 改变原预算
WfForm.bindDetailFieldChangeEvent("field681,field589,field590,field591",function(id,rowIndex,value){
if(checkSameSubject_E9(rowIndex)){
setRepeatValue(id,rowIndex);
alert("<%=SystemEnv.getHtmlNoteName(98,user.getLanguage())%>");
} else {
getBudget(rowIndex);
}
});
});
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(){ //明细1删除成功后触发事件
addDelete();
}
function _customAddFun0(addIndexStr){ //明细1新增成功后触发事件,addIndexStr即刚新增的行标示,添加多行为(1,2,3)
//console.log("--------------------",addIndexStr);
}
//获取原预算
function getBudget(index) {
var budgetperiod = WfForm.getFieldValue("field591"+"_"+index);
var organizationtype = WfForm.getFieldValue("field681"+"_"+index);
var organizationid = WfForm.getFieldValue("field589"+"_"+index);
var subjid = WfForm.getFieldValue("field590"+"_"+index);
if(subjid!=""&&organizationtype!=""&&organizationid!=""&&budgetperiod!=""){
var _data = "budgetfeetype="+subjid+"&orgtype="+organizationtype+"&orgid="+organizationid+"&applydate="+budgetperiod;
jQuery.ajax({
url : "/workflow/request/BudgetHandlerGetBudgetByDate.jsp",
type : "post",
processData : false,
data : _data,
dataType : "html",
success: function do4Success(msg){
callback(msg, index);
}
});
}else{
callback("", index);
}
}
//变更的差额
function callback(oldBudget, index) {
WfForm.changeFieldValue("field595_"+index, {
value: oldBudget
});
changeNumber(index);
// changeApplyNumber(index);
}
//审批预算改变
function changeNumber(index){
//TD12002 审批预算值大于0时预算差额以审批预算为准计算
var aproveamount = Number(eval(toFloat(WfForm.getFieldValue("field597_"+index),0)));
if(aproveamount > 0) {
changeval = eval(toFloat(WfForm.getFieldValue("field597_"+index),0)) - eval(toFloat(WfForm.getFieldValue("field595_"+index),0));
} else {
changeApplyNumber(index);
return;
}
WfForm.changeFieldValue("field598_"+index, {
value: changeval.toFixed(3)
});
}
//新预算改变
function changeApplyNumber(index){
//TD12002 审批预算值大于0时预算差额以审批预算为准计算
var aproveamount = Number(eval(toFloat(WfForm.getFieldValue("field597_"+index),0)));
if(aproveamount > 0) {
changeNumber(index);
return;
} else {
changeval = eval(toFloat(WfForm.getFieldValue("field596_"+index),0)) - eval(toFloat(WfForm.getFieldValue("field595_"+index),0));
}
WfForm.changeFieldValue("field598_"+index, {
value: changeval.toFixed(3)
});
}
//初始化 变更的差额
function initChangeAmount(){
//都不为空的时候
var rowIndexs = WfForm.getDetailAllRowIndexStr("detail_1");
for(var index = 0;index < rowIndexs.length;index++){
var budgetperiod = WfForm.getFieldValue("field591"+"_"+index);
var organizationtype = WfForm.getFieldValue("field681"+"_"+index);
var organizationid = WfForm.getFieldValue("field589"+"_"+index);
var subjid = WfForm.getFieldValue("field590"+"_"+index);
if(subjid != "" && organizationtype != "" && organizationid != "" && budgetperiod != "") {
changeNumber(index);
}
}
}
//检测在相同期间具备相同的值后,将值置空
function setRepeatValue(fieldId,rowIndex){
// console.log("fieldId",fieldId);
// console.log("rowIndex",rowIndex);
if(fieldId === "field589"){//预算单位
console.log("预算单位");
WfForm.changeFieldValue(fieldId + "_" + rowIndex,{
value: "",
specialobj:[]
});
// WfForm.changeSingleField(fieldId + "_" + rowIndex, {value:""});
} else if(fieldId === "field590"){//科目
console.log("科目");
WfForm.changeFieldValue(fieldId + "_" + rowIndex,{
value: "",
specialobj:[
]
});
} else if(fieldId === "field591"){//预算期间
console.log("预算期间");
WfForm.changeFieldValue(fieldId + "_" + rowIndex,{
value: ""
});
}
}
//检测是否相同
function checkSameSubject_E9(index){
var currentOrgType = WfForm.getFieldValue("field681"+"_"+index);
var currentOrgId = WfForm.getFieldValue("field589"+"_"+index);
var currentSubjectValue = WfForm.getFieldValue("field590"+"_"+index);
var currentBudgetPeriodValue = WfForm.getFieldValue("field591"+"_"+index);
/*
console.log("currentOrgType",currentOrgType);
console.log("currentOrgId",currentOrgId);
console.log("currentSubjectValue",currentSubjectValue);
console.log("currentBudgetPeriodValue",currentBudgetPeriodValue);
*/
var result = false;
if(currentSubjectValue=='' || currentBudgetPeriodValue=='' || currentOrgType =='' || currentOrgId==''){
return result;
}
var rowIndexs = WfForm.getDetailAllRowIndexStr("detail_1");
currentBudgetPeriodValue = currentBudgetPeriodValue.substring(0,7);
for(var i = 0;i < rowIndexs.length ; i++){
if(i != index ){
var indexSubjectValue = WfForm.getFieldValue("field590"+"_"+i);
var indexBudgetPeriodValue = WfForm.getFieldValue("field591"+"_"+i);
indexBudgetPeriodValue = indexBudgetPeriodValue.substring(0,7);
var indexOrgType = WfForm.getFieldValue("field681"+"_"+i);
var indexOrgId = WfForm.getFieldValue("field589"+"_"+i);
if(currentBudgetPeriodValue == indexBudgetPeriodValue && currentSubjectValue == indexSubjectValue
&& indexOrgType == currentOrgType && indexOrgId == currentOrgId){
result = true;
break;
}
}
}
return result;
}
</script>