commit | author | age
|
0d659c
|
1 |
angular.module('expend_standard', []) |
Z |
2 |
.directive('orgSelectorStandard', ['$rootScope', 'http_service', '$compile', '$timeout', 'myServeice', function($rootScope, http_service, $compile, $timeout, myServeice) { |
|
3 |
return { |
|
4 |
restrict: 'EACM', |
|
5 |
scope: { |
|
6 |
datamodel: '=', |
|
7 |
options: '=' |
|
8 |
}, |
|
9 |
template: '<div class="user_element">' + |
|
10 |
'<span name="user_el_content">' + |
|
11 |
'<span class="user_name" ng-repeat="org in org_selected" >' + |
|
12 |
'{{org.orgName}} <a ng-href="javascript:void(0)" ng-click="remove_org(org);"><i class="fa fa-times" aria-hidden="true" style="color:#fff;"></i></a>' + |
|
13 |
'</span>' + |
|
14 |
' <a class="btn_user_el_add_user" href="javascript:void(0);" ng-click="select_org($event);" >选择组织机构</a>' + |
|
15 |
'</span>' + |
|
16 |
'</div>', |
|
17 |
replace: true, |
|
18 |
controller: ['$scope', '$element', function($scope, $element) { |
|
19 |
$scope.org_selected = []; |
|
20 |
|
|
21 |
$scope.select_org = function(e) { |
|
22 |
$('div[name="org_select_popup"]').remove(); |
|
23 |
var activeclass = "{true:'hr_name',false:'hr_name_selected'}[user.state]"; |
|
24 |
var pop_element = $('<div' + |
|
25 |
' name="org_select_popup"' + |
|
26 |
' class="org_select_popup_standard col-md-12"' + |
|
27 |
'onMouseOver ="$(this).draggable();event.stopPropagation();"' + |
|
28 |
'>' + |
|
29 |
'<div class="org_sel_form">' + |
|
30 |
'<div class="row btn_cls org_sel_form_close">' + |
|
31 |
'<a ng-href="javascript:void(0);"><i class="fa fa-times main_close" aria-hidden="true" ng-click="close();"></i></a>' + |
|
32 |
'</div>' + |
|
33 |
'<div class="hr_tree left ztree" style="overflow:auto;">' + '</div>' + |
|
34 |
'<div class="right">' + |
|
35 |
'<div class="right_area">' + |
|
36 |
'<div class="area_title selected_personnel">' + |
|
37 |
'<label>已选人员</label>' + |
|
38 |
'<span class="float_right">' + |
|
39 |
'<a ng-href="javascript:void(0);" class="clear_selected_users" ng-click="clear_org();" ><i class="fa fa-trash-o" aria-hidden="true"></i></a>' + |
|
40 |
'</span>' + |
|
41 |
'</div>' + |
|
42 |
|
|
43 |
'<div class="area_body">' + |
|
44 |
'<ul>'+ |
|
45 |
'<li ng-repeat="org in org_selected">'+ |
|
46 |
'<div class="area_content">'+ |
|
47 |
'<a class="hr_name" ng-href="javascript:void(0);" href="javascript:void(0);">{{org.orgName}}</a>'+ |
|
48 |
'<button class="hr_name_addbtn" ng-click="remove_org(org);">-</button>'+ |
|
49 |
'</div>'+ |
|
50 |
'</li>'+ |
|
51 |
'</ul>'+ |
|
52 |
'</div>' + |
|
53 |
'</div>' + |
|
54 |
'</div>' + |
|
55 |
'</div>' + |
|
56 |
'</div>'); |
|
57 |
$($element).append(pop_element); |
|
58 |
$compile(pop_element)($scope); |
|
59 |
$scope.init_tree(); |
|
60 |
var form_el_div = $($element).closest('div.sub_form_container').children('div').not('[name="journel_budget"]'); |
|
61 |
e.stopPropagation(); |
|
62 |
}; |
|
63 |
}], |
|
64 |
link: function($scope, element, attrs) { |
|
65 |
$scope.stop_prg = function(event) { |
|
66 |
event.stopPropagation(); |
|
67 |
}; |
|
68 |
|
|
69 |
$scope.close = function() { |
|
70 |
$('div[name="org_select_popup"]').remove(); |
|
71 |
myServeice.setpd($scope.parentitem, $scope.users_selected, $scope.type); |
|
72 |
// $scope.query_journel_budget(); |
|
73 |
}; |
|
74 |
//清除选择 |
|
75 |
$scope.clear_org = function(){ |
|
76 |
$scope.org_selected = []; |
|
77 |
$scope.datamodel = [""]; |
|
78 |
} |
|
79 |
//选择组织机构 |
|
80 |
$scope.add_org = function(treeNode) { |
|
81 |
if(treeNode.children && treeNode.children.length != 0){ |
|
82 |
_.each(treeNode.children,function(cd){ |
|
83 |
$scope.add_org(cd); |
|
84 |
}); |
|
85 |
}else{ |
|
86 |
var org_selecting = { |
|
87 |
"orgName":treeNode.name, |
|
88 |
"orgCode":treeNode.orgCode |
|
89 |
}; |
|
90 |
var push_flag = true; |
|
91 |
|
|
92 |
_.each($scope.org_selected,function(_org){ |
|
93 |
if(_org.orgCode == org_selecting.orgCode){ |
|
94 |
push_flag = false; |
|
95 |
} |
|
96 |
}); |
|
97 |
if(push_flag){ |
|
98 |
$scope.org_selected.push(org_selecting); |
|
99 |
if($scope.datamodel && $scope.datamodel.length > 0){ |
|
100 |
$scope.datamodel.splice(0, $scope.datamodel.length); |
|
101 |
} |
|
102 |
_.each($scope.org_selected, function(item) { |
|
103 |
if(!$scope.datamodel) |
|
104 |
$scope.datamodel = []; |
|
105 |
$scope.datamodel.push(item.orgCode); |
|
106 |
}) |
|
107 |
} |
|
108 |
} |
|
109 |
}; |
|
110 |
$scope.remove_org = function(org) { |
|
111 |
_.remove($scope.org_selected,function(n){ |
|
112 |
return n == org; |
|
113 |
}); |
|
114 |
_.pull($scope.datamodel,org.orgCode); |
|
115 |
}; |
|
116 |
function get_org(data,arr){ |
|
117 |
_.each(data,function(_data){ |
|
118 |
if(_data.orgCode == arr){ |
|
119 |
$scope.org_selected.push({ |
|
120 |
"orgName":_data.orgName, |
|
121 |
"orgCode":_data.orgCode |
|
122 |
}) |
|
123 |
} |
|
124 |
}); |
|
125 |
if(data.child){ |
|
126 |
get_org(data.child,arr); |
|
127 |
} |
|
128 |
} |
|
129 |
$scope.init_tree = function() { |
|
130 |
http_service.post('base/data/search/institutionData', {}, function(res) { |
|
131 |
console.log('33333333'); |
|
132 |
if(res.data.opState){ |
|
133 |
var hr_data_str = JSON.stringify(res.data.data).replace(/child/g, 'children').replace(/orgName/g, 'name'); |
|
134 |
var hr_data_json = JSON.parse(hr_data_str); |
|
135 |
var setting = { |
|
136 |
'callback': { |
|
137 |
'onClick': function(event, treeId, treeNode) { |
|
138 |
var orgName = treeNode.name; |
|
139 |
var md_id = treeNode.orgCode; |
|
140 |
if(treeNode.level > 0){ |
|
141 |
$scope.add_org(treeNode); |
|
142 |
} |
|
143 |
} |
|
144 |
} |
|
145 |
}; |
|
146 |
console.log('1110'); |
|
147 |
$.fn.zTree.init($("div.hr_tree"), setting, hr_data_json); |
|
148 |
}else{ |
|
149 |
$scope.$parent.$parent.$parent.$parent.$parent.terro(res.data.errMsg) |
|
150 |
} |
|
151 |
|
|
152 |
}); |
|
153 |
} |
|
154 |
$scope.init_org = function(){ |
|
155 |
http_service.post('base/data/search/institutionData', {}, function(res) { |
|
156 |
console.log(22222222); |
|
157 |
if(res.data.opState){ |
|
158 |
if($scope.datamodel && $scope.datamodel.length != 0){ |
|
159 |
_.each($scope.datamodel,function(_arr){ |
|
160 |
_.each(res.data.data,function(data){ |
|
161 |
get_org(data.child,_arr); |
|
162 |
}) |
|
163 |
}) |
|
164 |
} |
|
165 |
} |
|
166 |
}); |
|
167 |
}; |
|
168 |
$scope.init_org(); |
|
169 |
} |
|
170 |
} |
|
171 |
}]) |
|
172 |
.directive('select4', ['$rootScope', 'http_service', '$timeout', '$interval', |
|
173 |
function($rootScope, http_service, $timeout, $interval) { |
|
174 |
return { |
|
175 |
restrict: 'ACEM', |
|
176 |
templateUrl: './static/templates/select3.html', |
|
177 |
transclude: true, |
|
178 |
scope: { |
|
179 |
style: '=', |
|
180 |
datamodel: '=', |
|
181 |
options: '=' |
|
182 |
}, |
|
183 |
compile: function() { |
|
184 |
return { |
|
185 |
pre: function(scope, iElement, iAttrs, controller) { |
|
186 |
var $scope = scope; |
|
187 |
$scope.type = scope.$parent.type; |
|
188 |
$scope.billid = scope.$parent.billid; |
|
189 |
|
|
190 |
$scope.$watchGroup(['datamodel','options'], function() { |
|
191 |
if(scope.datamodel){ |
|
192 |
if(scope.datamodel.length == 0){//替换控件时清空 |
|
193 |
scope.sel_val_lst = []; |
|
194 |
}else if(scope.datamodel[0] == ''){ |
|
195 |
scope.sel_val_lst = []; |
|
196 |
} |
|
197 |
}else{ |
|
198 |
scope.sel_val_lst = []; |
|
199 |
} |
|
200 |
var mp = _.filter(scope.options, function(op) { |
|
201 |
return _.indexOf(scope.datamodel, op.code) > -1; |
|
202 |
}); |
|
203 |
if(mp.length !== 0){ |
|
204 |
scope.sel_val_lst = _.map(mp, function(m) { |
|
205 |
return { 'value': m.code, 'label': m.value }; |
|
206 |
}); |
|
207 |
} |
|
208 |
|
|
209 |
var typename = _.filter(scope.options, function(op) { |
|
210 |
return _.indexOf(scope.datamodel, op.mdCode) > -1||_.indexOf(scope.datamodel, op.cdCode) > -1; |
|
211 |
}); |
|
212 |
if(typename.length !== 0 && !scope.sel_val_lst){ |
|
213 |
scope.sel_val_lst = _.map(typename, function(n) { |
|
214 |
return {'value': n.mdCode||n.cdCode, 'label': n.mdName||n.cdValue }; |
|
215 |
}); |
|
216 |
// scope.sel_val_lst = scope.datamodel; |
|
217 |
} |
|
218 |
}, true); |
|
219 |
var $el = $(iElement); |
|
220 |
$el.find('div.select-container').css({"padding-left":'10px',"width":"90%"}); |
|
221 |
$el.find('div.suffix').css({"width":"30%","max-width":"26px"}); |
|
222 |
$el.find('div.val-card').css({"padding":"0px","height":"28px","line-height":"28px"}); |
|
223 |
$el.find('div.select-container').on('click', function(event) { |
|
224 |
$('div.drop_down_sel').remove(); |
|
225 |
var $select = $el.find('select'); |
|
226 |
var isMultiple = $select.attr('multiple'); |
|
227 |
var $options = $el.find('select > option'); |
|
228 |
// 增加搜索框 |
|
229 |
var $options_str = '<ul>' + |
|
230 |
'<li class="sel_query">' + |
|
231 |
'<input type="text" name="query" >' + |
|
232 |
'<i class="fa fa-search" aria-hidden="true"></i>' + |
|
233 |
'</li>' + |
|
234 |
'</ul>'; |
|
235 |
// 可多选时 增加全选复选框 |
|
236 |
if($select.attr('multiple')) { |
|
237 |
$options_str += '<ul>' + |
|
238 |
'<li>' + |
|
239 |
'<div>' + |
|
240 |
'<div style="padding:0px 8px 0px 4px; ">' + |
|
241 |
'<input type="checkbox" name="all" >' + |
|
242 |
'</div>' + |
|
243 |
'<div>全选</div>' + |
|
244 |
'</div>' + |
|
245 |
'</li>' + |
|
246 |
'</ul>'; |
|
247 |
} |
|
248 |
_.each(scope.options, function(option) { |
|
249 |
var checked = ''; |
|
250 |
if(_.indexOf(scope.datamodel, option.code) > -1) { |
|
251 |
checked = 'checked'; |
|
252 |
} |
|
253 |
var optionvalue = option.value || option.mdName || option.cdValue; |
|
254 |
var optioncode = option.code || option.mdCode || option.cdCode; |
|
255 |
$options_str += '<ul>' + |
|
256 |
'<li>' + |
|
257 |
'<div>' + |
|
258 |
'<div style="padding:0px 8px 0px 4px; ">' + |
|
259 |
'<input type="checkbox" name="checkbox" label="' + optionvalue + '" value="' + optioncode + '" ' + checked + ' >' + |
|
260 |
'</div>' + |
|
261 |
'<div class="overhidden" title="' + optionvalue + '">' + optionvalue + '</div>' + |
|
262 |
'</div>' + |
|
263 |
'</li>' + |
|
264 |
'</ul>'; |
|
265 |
}); |
|
266 |
var $select_obj = $('<div drop-down-selector="" filterlist="searchlist" class="drop_down_sel" style="background:#fff;">' + |
|
267 |
$options_str + |
|
268 |
'</div>'); |
|
269 |
$el.find('div.select3-element').append($select_obj); |
|
270 |
$('body').off('click').on('click', function() { |
|
271 |
$('div.drop_down_sel').remove(); |
|
272 |
}); |
|
273 |
$('div.drop_down_sel').off('click').on('click', function(event) { |
|
274 |
event.stopPropagation(); |
|
275 |
}); |
|
276 |
|
|
277 |
// 查询功能 |
|
278 |
$select_obj.find('input[name="query"]').on('keyup', function() { |
|
279 |
var $el = $(this); |
|
280 |
var inputs = $select_obj.find('input[name="checkbox"]'); |
|
281 |
inputs.each(function() { |
|
282 |
var val = $(this).attr('label'); |
|
283 |
var input_val = $el.val(); |
|
284 |
if(val.indexOf(input_val) > -1) { |
|
285 |
$(this).closest('ul').show(); |
|
286 |
} else { |
|
287 |
$(this).closest('ul').hide(); |
|
288 |
} |
|
289 |
}); |
|
290 |
}); |
|
291 |
|
|
292 |
// 点击选择 |
|
293 |
$select_obj.find('input[name="checkbox"]').on('click', function() { |
|
294 |
var vals_selected = []; |
|
295 |
if(!isMultiple) { |
|
296 |
$('div.drop_down_sel input[name="checkbox"]').prop('checked', false); |
|
297 |
$(this).prop('checked', true); |
|
298 |
$select.val($(this).val()); |
|
299 |
vals_selected = [{ 'value': $(this).val(), 'label': $(this).attr('label') }]; |
|
300 |
} else { |
|
301 |
var vls = []; |
|
302 |
$('div.drop_down_sel input[name="checkbox"]:checked').each(function() { |
|
303 |
vals_selected.push({ 'value': $(this).val(), 'label': $(this).attr('label') }); |
|
304 |
vls.push($(this).val()); |
|
305 |
}); |
|
306 |
$select.val(vls); |
|
307 |
} |
|
308 |
$timeout(function() { |
|
309 |
scope.sel_val_lst = vals_selected; |
|
310 |
}, 0); |
|
311 |
if(scope.datamodel && scope.datamodel.length > 0){ |
|
312 |
scope.datamodel.splice(0, scope.datamodel.length); |
|
313 |
} |
|
314 |
_.each(vals_selected, function(item) { |
|
315 |
if(!scope.datamodel) |
|
316 |
scope.datamodel = []; |
|
317 |
scope.datamodel.push(item.value); |
|
318 |
}) |
|
319 |
/* |
|
320 |
$timeout(function(){ |
|
321 |
scope.datamodel.concat(select_vals); |
|
322 |
}, 0); |
|
323 |
*/ |
|
324 |
}); |
|
325 |
$select_obj.find('input[name="all"]').on('click', function() { |
|
326 |
if($(this).prop("checked") == false) { |
|
327 |
$('div.drop_down_sel input[name="checkbox"]').each(function() { |
|
328 |
if($(this).prop("checked") == true) { |
|
329 |
$(this).click(); |
|
330 |
} |
|
331 |
}); |
|
332 |
} else { |
|
333 |
$('div.drop_down_sel input[name="checkbox"]').each(function() { |
|
334 |
if($(this).prop("checked") == false) { |
|
335 |
$(this).click(); |
|
336 |
} |
|
337 |
}); |
|
338 |
} |
|
339 |
}) |
|
340 |
event.stopPropagation(); |
|
341 |
}); |
|
342 |
scope.rm_option = function(event) { |
|
343 |
var $elt = $(event.target); |
|
344 |
$elt.closest('div.val-card').remove(); |
|
345 |
var val = $elt.attr('val'); |
|
346 |
var value = JSON.parse(val).value; |
|
347 |
scope.sel_val_lst = _.filter(scope.sel_val_lst, function(t) { |
|
348 |
return JSON.stringify(t) != value; |
|
349 |
}); |
|
350 |
$timeout(function() { |
|
351 |
_.pull(scope.datamodel, value); |
|
352 |
}, 0); |
|
353 |
event.stopPropagation(); |
|
354 |
}; |
|
355 |
}, |
|
356 |
post: function($scope, element, attrs) {} |
|
357 |
} |
|
358 |
} |
|
359 |
} |
|
360 |
} |
|
361 |
]) |
|
362 |
.directive('expenseStandardRow', ['$rootScope', 'http_service', '$timeout','$compile', function($rootScope, http_service, $timeout,$compile) { |
|
363 |
return { |
|
364 |
restrict: 'ACEM', |
|
365 |
template: '<tr>' + |
|
366 |
'<td ng-repeat="col in rowData" >' + |
|
367 |
'<a ' + |
|
368 |
'class="foldBtn" ' + |
|
369 |
'ng-href="javascript:void(0);" ' + |
|
370 |
'ng-click="unfold(expensedata, expenserowdata, $index)" ' + |
|
371 |
'ng-if="!col.code && col.values.length && !isEmpty(col) && expenserowdata[$index].grant_value.length > 1" ' + |
|
372 |
'>' + |
|
373 |
// '<i class="fa fa-plus-square-o" aria-hidden="true"></i>' + |
|
374 |
// '<img src="./static/img/unfold.png" class="unfoldelment"/>' + |
|
375 |
'<img src="./static/img/list.png" class="unfoldelment"/>' + |
|
376 |
'</a>' + |
|
377 |
'<a ' + |
|
378 |
'class="foldBtn" ' + |
|
379 |
'ng-href="javascript:void(0);" ' + |
|
380 |
'ng-click="fold(expensedata, expenserowdata, $index)" ' + |
|
381 |
'ng-if="!col.code && col.values.length && !isEmpty(col) && expenserowdata[$index].group_id" ' + |
|
382 |
'>' + |
|
383 |
// '<i class="fa fa-minus-square-o" aria-hidden="true"></i>' + |
|
384 |
// '<img src="./static/img/unfold.png" class="unfoldelment"/>' + |
|
385 |
'<img src="./static/img/list.png" class="unfoldelment"/>' + |
|
386 |
'</a>' + |
|
387 |
'<div ng-if="col.is_org" org-selector-standard datamodel="expenserowdata[$index].grant_value" options="col.values"></div>'+ |
|
388 |
'<span select4 datamodel="expenserowdata[$index].grant_value" options="col.values" style=style ng-if="!col.is_org && !col.code && !isEmpty(col) && col.elIden && col.elIden.length != 0 != null && col.mdCode" >' + |
|
389 |
'<select multiple ' + |
|
390 |
'ng-options="val.code as val.value for val in col.values" ' + |
|
391 |
'ng-model="expenserowdata[$index].grant_value" ' + |
|
392 |
'value="expenserowdata[$index].grant_value" ' + |
|
393 |
'>' + |
|
394 |
'</select>' + |
|
395 |
'</span>' + |
|
396 |
'<span class="Inverse_icon" ng-click="change_Inverse($index)" ng-if="!col.is_org && !col.code && !isEmpty(col) && col.elIden && col.elIden.length != 0 != null && col.mdCode">'+ |
|
397 |
'<i ng-if="expenserowdata[$index].asInverse == 1" class="fa fa-check-square-o" aria-hidden="true"></i>'+ |
|
398 |
'<i ng-if="expenserowdata[$index].asInverse == 0" class="fa fa-minus-square-o" aria-hidden="true"></i>'+ |
|
399 |
'</span>'+ |
|
400 |
'<input type="text" ng-if= "!col.is_org && !col.code && !isEmpty(col) && !col.values.length && (col.elIden == null || col.elIden.length == 0) && col.eleValue && col.mdCode" ng-model = "expenserowdata[$index].grant_value" class="fxinput" /><span ng-if= "!col.is_org && !col.code && !isEmpty(col) && !col.values.length && col.eleValue && col.mdCode && (col.elIden == null || col.elIden.length == 0)" class="fxclass" ng-click="fxdiv(col,$index)">Fx</span>'+ |
|
401 |
'<input type="text" ng-if="!col.is_org && col.code && !isEmpty(col) && col.mdCode" ng-model="expenserowdata[$index].grant_value">' + |
|
402 |
'<input type="text" ng-if="!col.is_org && !col.code && !col.mdCode && !col.id && !col.value" ng-model="expenserowdata[$index].grant_value">' + |
|
403 |
'<a ng-click="rm_row(expenserowdata);" ng-if="$index === rowData.length-1" style="position:absolute;right:-15px;top:-2px;z-index:9;"><img src="./static/img/delete.png" class="deleteelment"/></a>' + |
|
404 |
'<input type="text" ng-if="col.id && col.notFound != true" class="fxinput" ng-model="expenserowdata[$index].sys_val.show_sys_fx">'+ |
|
405 |
'<span class="fxclass" ng-if="col.id && col.notFound != true" ng-click="sys_fx(col,$index)">Fx</span>'+ |
|
406 |
'</td>' + |
|
407 |
'</tr>', |
|
408 |
replace: true, |
|
409 |
scope: { |
|
410 |
tabletitlescfg: '=', |
|
411 |
expenserowdata: '=', |
|
412 |
expensedata: '=' |
|
413 |
}, |
|
414 |
compile: function() { |
|
415 |
return { |
|
416 |
pre: function(scope, iElement, iAttrs, controller) { |
|
417 |
scope.style = { |
|
418 |
'width': '80%' |
|
419 |
} |
|
420 |
scope.isEmpty = function(obj) { |
|
421 |
return _.keys(obj).length === 1; |
|
422 |
}; |
|
423 |
scope.rm_row = function(rowData) { |
|
424 |
|
|
425 |
|
|
426 |
var delete_index; |
|
427 |
_.each(scope.expensedata, function(_row_data, index) { |
|
428 |
if(_row_data === rowData) { |
|
429 |
|
|
430 |
|
|
431 |
delete_index = index; |
|
432 |
} |
|
433 |
}); |
|
434 |
if(scope.expensedata.length > 1){ |
|
435 |
scope.expensedata.splice(delete_index,1); |
|
436 |
}else{ |
|
437 |
var ex_keys = _.keys(scope.expensedata[0]); |
|
438 |
_.each(ex_keys,function(ekey){ |
|
439 |
scope.expensedata[0][ekey] = {"asInverse":1,"grant_value":""} |
|
440 |
}) |
|
441 |
} |
|
442 |
|
|
443 |
}; |
|
444 |
$('body').off('click').on('click', function() { |
|
445 |
$('div.showtype').remove(); |
|
446 |
}); |
|
447 |
$('div.showtype').off('click').on('click', function(event) { |
|
448 |
event.stopPropagation(); |
|
449 |
}); |
|
450 |
//正选、反选 |
|
451 |
scope.change_Inverse = function(index){ |
|
452 |
if(scope.expenserowdata[index].asInverse == 1){ |
|
453 |
scope.expenserowdata[index].asInverse = 0; |
|
454 |
}else{ |
|
455 |
scope.expenserowdata[index].asInverse = 1; |
|
456 |
} |
|
457 |
} |
|
458 |
scope.unfold = function(allData, rowData, colNum) { |
|
459 |
var colValues = _.uniq(rowData[colNum]['grant_value']); |
|
460 |
var uid = rowData[colNum]['group_id'] || _.uuid(); |
|
461 |
var newRowData = []; |
|
462 |
_.each(allData, function(data) { |
|
463 |
if(data === rowData) { |
|
464 |
for(var i = 0, len = colValues.length; i < len; i++) { |
|
465 |
var dt = _.cloneDeep(data); |
|
466 |
dt[colNum]['grant_value'] = [colValues[i]]; |
|
467 |
dt[colNum]['group_id'] = uid; |
|
468 |
newRowData.push(dt); |
|
469 |
} |
|
470 |
} else { |
|
471 |
newRowData.push(data); |
|
472 |
} |
|
473 |
}); |
|
474 |
scope.expensedata.splice(0, scope.expensedata.length); |
|
475 |
$timeout(function() { |
|
476 |
_.each(newRowData, function(rd) { |
|
477 |
scope.expensedata.push(rd); |
|
478 |
}); |
|
479 |
}, 1); |
|
480 |
|
|
481 |
}; |
|
482 |
scope.fold = function(allData, rowData, colNum) { |
|
483 |
var colValues = rowData[colNum]['grant_value']; |
|
484 |
var uid = rowData[colNum]['group_id']; |
|
485 |
var newRowData = []; |
|
486 |
var gt_vals = []; |
|
487 |
var tmp = {}; |
|
488 |
_.each(allData, function(data) { |
|
489 |
if(!data[colNum]) return false; |
|
490 |
var _uid = data[colNum] && data[colNum]['group_id']; |
|
491 |
if(_uid === uid) { |
|
492 |
if(!tmp[uid]) { |
|
493 |
newRowData.push(rowData); |
|
494 |
tmp[uid] = rowData; |
|
495 |
} |
|
496 |
gt_vals = gt_vals.concat(data[colNum]['grant_value']); |
|
497 |
} else { |
|
498 |
newRowData.push(data); |
|
499 |
} |
|
500 |
}); |
|
501 |
if(!!gt_vals.length && tmp[uid]) { |
|
502 |
tmp[uid][colNum]['grant_value'] = gt_vals; |
|
503 |
tmp[uid][colNum]['group_id'] = null; |
|
504 |
} |
|
505 |
scope.expensedata.splice(0, scope.expensedata.length); |
|
506 |
|
|
507 |
$timeout(function() { |
|
508 |
_.each(newRowData, function(rd) { |
|
509 |
scope.expensedata.push(rd); |
|
510 |
}); |
|
511 |
}, 1); |
|
512 |
}; |
|
513 |
|
|
514 |
// scope.$watch(function(){ |
|
515 |
// return $rootScope.relate |
|
516 |
// },function(){ |
|
517 |
// if($rootScope.relate != undefined){ |
|
518 |
// scope.relation = $rootScope.relate.split(" ")[0]; |
|
519 |
// scope.amounts = $rootScope.relate.split(" ")[1]; |
|
520 |
// } |
|
521 |
// }) |
|
522 |
// |
|
523 |
// scope.$watch(function(){ |
|
524 |
// return $rootScope.pervalue |
|
525 |
// },function(){ |
|
526 |
// if($rootScope.pervalue != undefined){ |
|
527 |
// scope.per = $rootScope.pervalue; |
|
528 |
// } |
|
529 |
// }) |
|
530 |
|
|
531 |
scope.sys_fx = function(col,$index){//系统变量编辑 |
|
532 |
scope.sys_fx_index = $index; |
|
533 |
if(scope.expenserowdata[$index] && scope.expenserowdata[$index]['sys_val'].id == undefined){ |
|
534 |
_.extend(scope.expenserowdata[$index]['sys_val'],col); |
|
535 |
// scope.expenserowdata[$index]['sys_val'] = _.cloneDeep(col); |
|
536 |
} |
|
537 |
scope.sys_col = _.cloneDeep(scope.expenserowdata[$index]['sys_val']); |
|
538 |
scope.joinMath = []; |
|
539 |
_.each(scope.sys_col.children,function(cd){ |
|
540 |
if(cd.joinMathId && cd.joinchildren == undefined){ |
|
541 |
_.each($rootScope.system_titles,function(sys_tit){ |
|
542 |
if(sys_tit.id == cd.joinMathId){ |
|
543 |
_.extend(cd,{'joinchildren':_.cloneDeep(sys_tit.child)}); |
|
544 |
scope.joinMath.push(cd); |
|
545 |
} |
|
546 |
}) |
|
547 |
}else if(cd.joinMathId){ |
|
548 |
scope.joinMath.push(cd); |
|
549 |
} |
|
550 |
}) |
|
551 |
// if(col.group == 1 || col.group == 2){ |
|
552 |
// scope.sys_count_show = true; |
|
553 |
// }else{ |
|
554 |
// scope.sys_count_show = false; |
|
555 |
// } |
|
556 |
scope.sys_count_show = col.group; |
|
557 |
scope.col_type = col.resultFromat; |
|
558 |
if(scope.sys_count_show == 3){ |
|
559 |
scope.sys_sign_list = ["+","-","*","/"]; |
|
560 |
}else{ |
|
561 |
if(col.resultFromat == 10 || col.resultFromat == 30){//系统变量类型为 数值 |
|
562 |
scope.sys_sign_list = ["<",">",">=","<=","==","<>"]; |
|
563 |
// scope.sys_data_type_list = [{"label":"字符","value":"string"},{"label":"数值","value":"number"}]; |
|
564 |
}else if(col.resultFromat == 20){//系统变量类型为 比较 |
|
565 |
scope.sys_sign_list = ["=="]; |
|
566 |
scope.sys_data_type_list = [{"label":"真","value":"true"},{"label":"假","value":"false"}]; |
|
567 |
} |
|
568 |
} |
|
569 |
scope.sys_sign = undefined; |
|
570 |
scope.sys_data = undefined; |
|
571 |
scope.sys_data_type = undefined; |
|
572 |
if(scope.sys_col.sys_count){ |
|
573 |
var sys_relation = _.drop(scope.sys_col.sys_count.split(" ")); |
|
574 |
if(col.resultFromat == 10 || col.resultFromat == 30){ |
|
575 |
scope.sys_sign = sys_relation[0]; |
|
576 |
scope.sys_data = sys_relation[1]; |
|
577 |
// scope.sys_data_type = sys_relation[2].replace("{",""); |
|
578 |
// scope.sys_data_type = scope.sys_data_type.replace("}",""); |
|
579 |
// _.each(scope.sys_data_type_list,function(data_type){ |
|
580 |
// if(data_type.value == scope.sys_data_type){ |
|
581 |
// $timeout(function(){ |
|
582 |
// scope.sys_data_type = _.cloneDeep(data_type); |
|
583 |
// },1) |
|
584 |
// |
|
585 |
// } |
|
586 |
// }) |
|
587 |
}else if(col.resultFromat == 20){ |
|
588 |
scope.sys_sign = sys_relation[0]; |
|
589 |
scope.sys_data_type = sys_relation[1]; |
|
590 |
_.each(scope.sys_data_type_list,function(data_type){ |
|
591 |
if(data_type.value == scope.sys_data_type){ |
|
592 |
$timeout(function(){ |
|
593 |
scope.sys_data_type = _.cloneDeep(data_type); |
|
594 |
},1) |
|
595 |
} |
|
596 |
}) |
|
597 |
} |
|
598 |
} |
|
599 |
var sys_null = ''; |
|
600 |
var sys_fx = "<div class='bg-modal''>"+ |
|
601 |
"<div class='pop_panel' style='width:450px;height:auto;' onMouseOver ='$(this).draggable();event.stopPropagation();'>"+ |
|
602 |
"<div class='custom_validate'>" + |
|
603 |
"<div class='cv_title' style='margin-bottom:5px'>规则公式<div class='close' ng-click='sys_close()'><img src='./static/img/close.png' style='width:60%;margin-top:5px;'></div></div>"+ |
|
604 |
"<div class='relate_title'>"+ |
|
605 |
"<span class='col-md-3'>系统变量</span>"+ |
|
606 |
"<span class='col-md-3' style='text-align: right;'>运算符</span>"+ |
|
607 |
"<span class='col-md-3' ng-show='col_type == 20 && sys_count_show != 3'>数据类型</span>"+ |
|
608 |
"<span class='col-md-3' ng-show='col_type == 10 || col_type == 30 || sys_count_show == 3'>输入值</span>"+ |
|
609 |
"</div>"+ |
|
610 |
"<div style='margin-bottom:5px' class='col-md-4'>"+ |
|
611 |
"<span class='sys_fxspan' title='"+col.mdName+"'>"+col.mdName+"</span>"+ |
|
612 |
"</div>"+ |
|
613 |
"<div style='margin-bottom:5px' class='col-md-3'>"+ |
|
614 |
"<select class='relate_select' ng-change='clear_data()' ng-model='sys_sign' ng-options='sign for sign in sys_sign_list'>"+ |
|
615 |
"<option value=''>-- 请选择 --</option>"+ |
|
616 |
"</select>"+ |
|
617 |
"</div>"+ |
|
618 |
"<div style='margin-bottom:5px' class='col-md-3' ng-show='col_type == 20 && sys_count_show != 3'>"+ |
|
619 |
"<select ng-disabled='(sys_sign.length == 0 || sys_sign == undefined)' class='relate_select' ng-model='sys_data_type' ng-options=' type.label for type in sys_data_type_list track by type.value'>"+ |
|
620 |
"<option value=''>-- 请选择 --</option>"+ |
|
621 |
"</select>"+ |
|
622 |
"</div>"+ |
|
623 |
"<div style='margin-bottom:5px' class='col-md-3' ng-show='col_type == 10 || col_type == 30 || sys_count_show == 3'>"+ |
|
624 |
"<input class='relate_select' type='text' ng-model='sys_data' ng-disabled='(sys_sign.length == 0 || sys_sign == undefined)' />"+ |
|
625 |
"</div>"+ |
|
626 |
"<div class='col-md-12'>"+ |
|
627 |
"<div class='col-md-4' ng-if='parameter.joinMathId == undefined' ng-repeat='parameter in sys_col.children track by $index'>"+ |
|
628 |
"<label>{{parameter.mdName}}<span ng-if='parameter.meName'>-{{parameter.meName}}</span></label>"+ |
|
629 |
"<input type='text' class='sys_text' ng-model='parameter.val'/>"+ |
|
630 |
"</div>"+ |
|
631 |
"</div>"+ |
|
632 |
"<div class='col-md-12' ng-if='joins.joinMathId != undefined' ng-repeat='joins in joinMath track by $index'>"+ |
|
633 |
"<div class='col-md-4' ng-repeat='join in joins.joinchildren track by $index'>"+ |
|
634 |
"<label>{{join.mdName}}<span ng-if='join.meName'>-{{join.meName}}</span></label>"+ |
|
635 |
"<input type='text' class='sys_text' ng-model='join.val'/>"+ |
|
636 |
"</div>"+ |
|
637 |
"</div>"+ |
|
638 |
"<div class='col-md-11 sys_savefx'><button class='btn btn-success btn-favourite savebtn' ng-click='save_sys_fx()'>保存</button></div>" + |
|
639 |
"</div>"+ |
|
640 |
"</div>"+ |
|
641 |
"</div>" |
|
642 |
var $sys_fx = $compile(sys_fx)(scope); |
|
643 |
$('body').append($sys_fx); |
|
644 |
} |
|
645 |
|
|
646 |
scope.sys_close = function(){ |
|
647 |
$('.bg-modal').remove(); |
|
648 |
} |
|
649 |
|
|
650 |
scope.clear_data = function(){ |
|
651 |
if(scope.sys_sign == '' || _.isNull(scope.sys_sign)){ |
|
652 |
scope.sys_data = ''; |
|
653 |
scope.sys_data_type = ""; |
|
654 |
} |
|
655 |
} |
|
656 |
|
|
657 |
scope.save_sys_fx = function(){ |
|
658 |
scope.expenserowdata[scope.sys_fx_index]['sys_val'] = _.cloneDeep(scope.sys_col); |
|
659 |
var sys_arr = []; |
|
660 |
_.each(scope.sys_col.children,function(cd){ |
|
661 |
if(cd.val && cd.val != ""){ |
|
662 |
if(cd.joinMathId == undefined){ |
|
663 |
sys_arr.push(cd.val); |
|
664 |
}else{ |
|
665 |
_.each(scope.joinMath,function(join){ |
|
666 |
if(join.joinMathId == cd.joinMathId){ |
|
667 |
_.each(cd.joinchildren,function(jcd){ |
|
668 |
if(jcd.val && jcd.val != ""){ |
|
669 |
sys_arr.push(jcd.val) |
|
670 |
} |
|
671 |
}) |
|
672 |
} |
|
673 |
}) |
|
674 |
} |
|
675 |
} |
|
676 |
}); |
|
677 |
scope.expenserowdata[scope.sys_fx_index]['sys_val']['show_sys_fx'] = scope.sys_col.name + "(" + sys_arr.join(",") + ")"; |
|
678 |
// if(scope.sys_count_show){//补助条件 与 标准 |
|
679 |
var sys_count = ''; |
|
680 |
var sys_count_str = ''; |
|
681 |
if(scope.sys_sign != undefined && scope.sys_sign != "" && _.isNull(scope.sys_sign) == false){ |
|
682 |
sys_count += " " + scope.sys_sign; |
|
683 |
sys_count_str += " " + scope.sys_sign; |
|
684 |
} |
|
685 |
|
|
686 |
if(scope.sys_data != undefined && scope.sys_data != "" && _.isNull(scope.sys_data) == false){ |
|
687 |
sys_count += " "+scope.sys_data; |
|
688 |
sys_count_str += " " + scope.sys_data; |
|
689 |
} |
|
690 |
|
|
691 |
|
|
692 |
if(scope.sys_data_type != '' && scope.sys_data_type != undefined && scope.sys_data_type.value != "" && _.isNull(scope.sys_data_type.value) == false){ |
|
693 |
if(scope.col_type == 10 || scope.col_type == 30){ |
|
694 |
sys_count += " {"+scope.sys_data_type.value + "}"; |
|
695 |
}else{ |
|
696 |
sys_count += " "+ scope.sys_data_type.value; |
|
697 |
} |
|
698 |
sys_count_str += " "+ scope.sys_data_type.label; |
|
699 |
} |
|
700 |
|
|
701 |
if((scope.sys_sign == undefined || scope.sys_sign == "" || _.isNull(scope.sys_sign) || scope.sys_data == undefined || scope.sys_data == "" || _.isNull(scope.sys_data)) && (scope.col_type == 10 || scope.col_type == 30 || scope.sys_count_show == 3)){//运算符 与输入值必须同时存在 |
|
702 |
scope.expenserowdata[scope.sys_fx_index]['sys_val']['sys_count'] = ''; |
|
703 |
sys_count_str = ''; |
|
704 |
}else if(scope.col_type == 20 && (scope.sys_sign == undefined || scope.sys_sign == "" || _.isNull(scope.sys_sign) || scope.sys_data_type == '' || scope.sys_data_type == undefined || scope.sys_data_type.value == "" || _.isNull(scope.sys_data_type.value))){ |
|
705 |
scope.expenserowdata[scope.sys_fx_index]['sys_val']['sys_count'] = ''; |
|
706 |
sys_count_str = ''; |
|
707 |
}else{ |
|
708 |
scope.expenserowdata[scope.sys_fx_index]['sys_val']['sys_count'] = sys_count; |
|
709 |
} |
|
710 |
scope.expenserowdata[scope.sys_fx_index]['sys_val']['show_sys_fx'] += sys_count_str |
|
711 |
// } |
|
712 |
scope.sys_close(); |
|
713 |
} |
|
714 |
|
|
715 |
scope.fxdiv = function(col,$index){ |
|
716 |
|
|
717 |
scope.fixdiv_index = $index; |
|
718 |
var fxdiv = "<div class='bg-modal''>"+ |
|
719 |
"<div class='pop_panel' style='width:450px;height:270px;' onMouseOver ='$(this).draggable();event.stopPropagation();'>"+ |
|
720 |
"<div class='custom_validate'>" + |
|
721 |
"<div class='cv_title' style='margin-bottom:5px'>规则公式<div class='close' ng-click='close()'><img src='./static/img/close.png' style='width:60%;margin-top:5px;'></div></div>"+ |
|
722 |
"<span class='fxtitle'>补助标准内容</span><span class='fxtitle'>布尔运算符</span><span class='fxtitle'>数据类型</span><span class='fxtitle'>输入值</span>" + |
|
723 |
"<div class='col-md-3 fxspan'>"+col.mdName+"</div>"+ |
|
724 |
"<div class='search_column col-md-3'>"+ |
|
725 |
"<div class='select3-element selectul'>"+ |
|
726 |
"<div class='select-container' style='width:100px;padding-left:10px;' ng-click = 'fxshowss = !fxshowss' class='relation'>{{relation}}"+ |
|
727 |
"<div class='suffix'>"+ |
|
728 |
"<i class='fa fa-caret-down' aria-hidden='true'></i>"+ |
|
729 |
"</div>"+ |
|
730 |
"</div>"+ |
|
731 |
"<ul ng-show='fxshowss' class='showfx' id='showfxs' ng-click='getrelation($event)'>"+ |
|
732 |
"<li><</li>"+ |
|
733 |
"<li><=</li>"+ |
|
734 |
"<li>></li>"+ |
|
735 |
"<li>>=</li>"+ |
|
736 |
"<li>==</li>"+ |
|
737 |
"</ul>"+ |
|
738 |
"</div>"+ |
|
739 |
"</div>"+ |
|
740 |
"<div class='search_column col-md-3'>"+ |
|
741 |
"<div class='select3-element selectul' ng-click='fxshows = !fxshows'>"+ |
|
742 |
"<div class='select-container' style='width:100px;padding-left:10px;' ng-style='style'>{{per}}"+ |
|
743 |
"<div class='suffix'>"+ |
|
744 |
"<i class='fa fa-caret-down' aria-hidden='true'></i>"+ |
|
745 |
"</div>"+ |
|
746 |
"</div>"+ |
|
747 |
"<ul ng-show='fxshows' class='showfx' id='showfx' ng-click='getper($event)'>"+ |
|
748 |
"<li>天数</li>"+ |
|
749 |
"<li>公里数</li>"+ |
|
750 |
"<li>小时数</li>"+ |
|
751 |
"</ul>"+ |
|
752 |
"</div>"+ |
|
753 |
"</div>"+ |
|
754 |
"<div class='col-md-2'><input type='text' ng-model='amounts' min='0' style='width:60px;padding:10px;'/></div>"+ |
|
755 |
"<div class='col-md-11 fxresult'>公式结果:{{aa}}"+ col.mdName +" {{relation}} {{amounts}} {{per}}</div>"+ |
|
756 |
"<div class='col-md-11 savefx'><button class='btn btn-success btn-favourite savebtn' ng-click='savefx()'>保存</button></div>" + |
|
757 |
"</div>"+ |
|
758 |
"</div>"+ |
|
759 |
"</div>" |
|
760 |
var $fxdiv = $compile(fxdiv)(scope); |
|
761 |
$('body').append($fxdiv); |
|
762 |
if(scope.expenserowdata[$index] && scope.expenserowdata[$index].grant_value){ |
|
763 |
if(_.isArray(scope.expenserowdata[$index].grant_value)){ |
|
764 |
var fx_data = scope.expenserowdata[$index].grant_value[0].split(" "); |
|
765 |
}else{ |
|
766 |
var fx_data = scope.expenserowdata[$index].grant_value.split(" "); |
|
767 |
} |
|
768 |
|
|
769 |
scope.relation = fx_data[1]; |
|
770 |
scope.amounts = fx_data[2]; |
|
771 |
scope.per = fx_data[3]; |
|
772 |
} |
|
773 |
// $('body').off('click').on('click',function() { |
|
774 |
// if(scope.fxshows){ |
|
775 |
// $('#showfx').hide(); |
|
776 |
// scope.fxshows = false; |
|
777 |
// } |
|
778 |
// if(scope.fxshowss){ |
|
779 |
// $('#showfxs').hide(); |
|
780 |
// scope.fxshowss = false; |
|
781 |
// } |
|
782 |
// }); |
|
783 |
// $('body').off('click').on('click', function() { |
|
784 |
// $('div.showfx').remove(); |
|
785 |
// }); |
|
786 |
// $('div.drop_down_sel').off('click').on('click', function(event) { |
|
787 |
// event.stopPropagation(); |
|
788 |
// }); |
|
789 |
// $('div.select3-element').off('click').on('click', function(event) { |
|
790 |
// event.stopPropagation(); |
|
791 |
// }); |
|
792 |
|
|
793 |
} |
|
794 |
|
|
795 |
scope.getper = function(event){ |
|
796 |
var event = event || window.event; |
|
797 |
scope.per = event.target.innerHTML; |
|
798 |
scope.per = scope.per.split("").slice(0,-1).join(""); |
|
799 |
scope.fxshows = true; |
|
800 |
} |
|
801 |
|
|
802 |
scope.getrelation = function(event){ |
|
803 |
var event = event || window.event; |
|
804 |
scope.relation = event.target.innerText; |
|
805 |
scope.fxshowss = false; |
|
806 |
} |
|
807 |
scope.close = function(){ |
|
808 |
$('.fxresult').text(""); |
|
809 |
$('.bg-modal').hide(); |
|
810 |
} |
|
811 |
scope.savefx = function(){ |
|
812 |
if(!scope.per || !scope.relation || !scope.amounts){ |
|
813 |
scope.$parent.$parent.$parent.tinfo('请填写完成后保存'); |
|
814 |
}else if(isNaN(scope.amounts)){ |
|
815 |
scope.$parent.$parent.$parent.tinfo('请在输入值处填写数字'); |
|
816 |
}else{ |
|
817 |
scope.result = $('.fxresult').text().substring(5); |
|
818 |
$('.fxresult').text(""); |
|
819 |
if(scope.expenserowdata[scope.fixdiv_index] == undefined){ |
|
820 |
var grant_value_now = {"grant_value":scope.result}; |
|
821 |
var fixdiv_index = scope.fixdiv_index; |
|
822 |
scope.expenserowdata[fixdiv_index] = grant_value_now; |
|
823 |
}else{ |
|
824 |
scope.expenserowdata[scope.fixdiv_index].grant_value = scope.result; |
|
825 |
} |
|
826 |
scope.close(); |
|
827 |
} |
|
828 |
|
|
829 |
} |
|
830 |
|
|
831 |
|
|
832 |
function refreshRowData() { |
|
833 |
scope.rowData = []; |
|
834 |
// |
|
835 |
_.each(scope.expenserowdata,function(row_data){ |
|
836 |
if(row_data != undefined && row_data.asInverse == undefined){ |
|
837 |
_.extend(row_data,{"asInverse":1}); |
|
838 |
} |
|
839 |
}) |
|
840 |
var conditionCfg = scope.tabletitlescfg.expenseConditionsTitles; |
|
841 |
var criteriaCfg = scope.tabletitlescfg.expenseCtriteraTitles; |
|
842 |
var budgetCfg = scope.tabletitlescfg.expenseBudgetTitles; |
|
843 |
var i = 0; |
|
844 |
_.each(conditionCfg, function(cfg) { |
|
845 |
// if(!cfg.mdId) { |
|
846 |
// scope.rowData[i] = {}; |
|
847 |
// } else { |
|
848 |
scope.rowData[i] = cfg; |
|
849 |
// } |
|
850 |
i++; |
|
851 |
}); |
|
852 |
_.each(criteriaCfg, function(cfg) { |
|
853 |
// if(!cfg.mdId) { |
|
854 |
// scope.rowData[i] = {}; |
|
855 |
// } else { |
|
856 |
scope.rowData[i] = cfg; |
|
857 |
// } |
|
858 |
i++; |
|
859 |
}); |
|
860 |
// |
|
861 |
_.each(budgetCfg, function(cfg) { |
|
862 |
_.each(cfg.child, function(sub_cfg) { |
|
863 |
if(!sub_cfg.code && cfg.id == undefined) { |
|
864 |
scope.rowData[i] = {}; |
|
865 |
} else if(cfg.id != undefined){//系统变量处理 |
|
866 |
scope.rowData[i] = cfg; |
|
867 |
} else{ |
|
868 |
scope.rowData[i] = _.extend( |
|
869 |
sub_cfg, { |
|
870 |
'mdId': cfg.mdId, |
|
871 |
'mdDesc': cfg.mdDesc, |
|
872 |
'mdCode': cfg.mdCode, |
|
873 |
'mdName': cfg.mdName, |
|
874 |
'mdType': cfg.mdType |
|
875 |
} |
|
876 |
); |
|
877 |
} |
|
878 |
i++; |
|
879 |
}); |
|
880 |
}); |
|
881 |
_.each(scope.rowData, function(title) { |
|
882 |
if(!title.code && title.mdCode && title.eleCode) { |
|
883 |
http_service.post('base/data/search', { "code": title.mdCode,"cache_id":title.mdCode }, function(res) { |
|
884 |
if(!res.data.opState){ |
|
885 |
return false; |
|
886 |
} |
|
887 |
title['values'] = res.data.data.child; |
|
888 |
title['elIden'] = res.data.data.elIden; |
|
889 |
},true) |
|
890 |
} |
|
891 |
}); |
|
892 |
var is_org; |
|
893 |
_.each(filed,function(_filed){ |
|
894 |
if(_filed.busCode == "orgCode"){ |
|
895 |
is_org = _filed.mdCode; |
|
896 |
} |
|
897 |
}) |
|
898 |
_.each(scope.rowData, function(title){ |
|
899 |
if(title.mdCode == is_org){ |
|
900 |
title[is_org] == true; |
|
901 |
} |
|
902 |
// if(title.mdCode == "F085"){ |
|
903 |
// title['is_org'] = true; |
|
904 |
// } |
|
905 |
}) |
|
906 |
} |
|
907 |
scope.$watch('tabletitlescfg', function() { |
|
908 |
refreshRowData(); |
|
909 |
}, true); |
|
910 |
} |
|
911 |
} |
|
912 |
} |
|
913 |
} |
|
914 |
}]) |
|
915 |
.directive('expenseTable', ['$rootScope', 'http_service','$timeout', function($rootScope, http_service,$timeout) { |
|
916 |
return { |
|
917 |
restrict: 'ACEM', |
|
918 |
templateUrl: './static/templates/expense_standard_table.html', |
|
919 |
replace: true, |
|
920 |
scope: { |
|
921 |
allexpensedata: '=', |
|
922 |
expensedata: '=', |
|
923 |
index: '=', |
|
924 |
tabletitlescfg: '=', |
|
925 |
tabletitlescfgs: '=', |
|
926 |
sstype: '=', |
|
927 |
ssname: '=', |
|
928 |
// ssSubType:'=', |
|
929 |
sstypes: '=', |
|
930 |
ssnames: '=', |
|
931 |
ssrules:'=', |
|
932 |
// ssSubTypes:'=', |
|
933 |
sstypename: '=', |
|
934 |
ssnamename:'=', |
|
935 |
sstnames:'=', |
|
936 |
ssnnames:'=' |
|
937 |
}, |
|
938 |
compile: function() { |
|
939 |
return { |
|
940 |
pre: function(scope, iElement, iAttrs, controller) { |
|
941 |
scope.$watch("tabletitlescfg",function(){ |
|
942 |
scope.expenseConditionsTitles = scope.tabletitlescfg['expenseConditionsTitles']; |
|
943 |
scope.expenseCtriteraTitles = scope.tabletitlescfg['expenseCtriteraTitles']; |
|
944 |
scope.expenseBudgetTitles = scope.tabletitlescfg['expenseBudgetTitles']; |
|
945 |
}); |
|
946 |
scope.expenseConditionsTitles = scope.tabletitlescfg['expenseConditionsTitles']; |
|
947 |
scope.expenseCtriteraTitles = scope.tabletitlescfg['expenseCtriteraTitles']; |
|
948 |
scope.expenseBudgetTitles = scope.tabletitlescfg['expenseBudgetTitles']; |
|
949 |
|
|
950 |
scope.$watch(function(){ |
|
951 |
return scope.ssrules; |
|
952 |
},function(){ |
|
953 |
scope.ssRule = scope.ssrules[scope.index]; |
|
954 |
}) |
|
955 |
|
|
956 |
scope.ssRuleOps = [ |
|
957 |
{"val":"0","name":"无"}, |
|
958 |
{"val":"1","name":"最大"}, |
|
959 |
{"val":"2","name":"最小"}, |
|
960 |
{"val":"3","name":"平均"}, |
|
961 |
{"val":"4","name":"最先到达"}, |
|
962 |
{"val":"5","name":"最后到达"} |
|
963 |
]; |
|
964 |
scope.budgetColspan = function(titles) { |
|
965 |
var colspan = 0; |
|
966 |
_.each(titles, function(title) { |
|
967 |
if(title.child && title.child.length) { |
|
968 |
colspan += title.child.length; |
|
969 |
} else { |
|
970 |
colspan += 1; |
|
971 |
} |
|
972 |
}); |
|
973 |
return colspan; |
|
974 |
}; |
|
975 |
scope.duplicate_expense_strd_table = function() { |
|
976 |
$('div.drop_down_sel').remove(); |
|
977 |
scope.allexpensedata.push(_.cloneDeep(scope.expensedata)); |
|
978 |
scope.tabletitlescfgs.push(_.cloneDeep(scope.tabletitlescfg)); |
|
979 |
// scope.sstypename.push(_.cloneDeep(scope.sstypename)); |
|
980 |
// scope.ssnamename.push(_.cloneDeep(scope.ssnamename)); |
|
981 |
scope.ssnames.push(_.cloneDeep(scope.ssname)); |
|
982 |
scope.sstypes.push(_.cloneDeep(scope.sstype)); |
|
983 |
// scope.ssSubTypes.push(_.cloneDeep(scope.ssSubType)); |
|
984 |
}; |
|
985 |
|
|
986 |
scope.rm_expense_strd_table = function() { |
|
987 |
$('div.drop_down_sel').remove(); |
|
988 |
_.remove(scope.allexpensedata, function(item) { |
|
989 |
return item === scope.expensedata |
|
990 |
}); |
|
991 |
_.remove(scope.tabletitlescfgs, function(item) { |
|
992 |
return item === scope.tabletitlescfg; |
|
993 |
}); |
|
994 |
// _.remove(scope.ssnames,function(item){ |
|
995 |
// return item === scope.ssname |
|
996 |
// }) |
|
997 |
// _.remove(scope.types,function(item){ |
|
998 |
// return item === scope.sstype |
|
999 |
// }) |
|
1000 |
// _.remove(scope.expenseBudgetTitles,function(item){ |
|
1001 |
// return item === scope.expenseBudgetTitles[0] |
|
1002 |
// }) |
|
1003 |
// _.remove(scope.expenseConditionsTitles,function(item){ |
|
1004 |
// return item === scope.expenseConditionsTitles[0] |
|
1005 |
// }) |
|
1006 |
// _.remove(scope.expenseCtriteraTitles,function(item){ |
|
1007 |
// return item === scope.expenseCtriteraTitles[0] |
|
1008 |
// }) |
|
1009 |
// scope.addConditions(); |
|
1010 |
// scope.addCritera(); |
|
1011 |
// scope.addBudget(); |
|
1012 |
|
|
1013 |
// _.each(scope.expenseBudgetTitles,function(budgettitle){ |
|
1014 |
// _.remove(scope.tabletitlescfg,function(item){ |
|
1015 |
// return item === budgettitle |
|
1016 |
// }) |
|
1017 |
// }) |
|
1018 |
// _.each(scope.expenseConditionsTitles,function(conditiontitle){ |
|
1019 |
// _.remove(scope.tabletitlescfg,function(item){ |
|
1020 |
// return item === conditiontitle |
|
1021 |
// }) |
|
1022 |
// }) |
|
1023 |
// _.each(scope.expenseCtriteraTitles,function(ctriteratitle){ |
|
1024 |
// _.remove(scope.tabletitlescfg,function(item){ |
|
1025 |
// return item === ctriteratitle |
|
1026 |
// }) |
|
1027 |
// }) |
|
1028 |
// scope.sstypename='' |
|
1029 |
// scope.ssnamename='' |
|
1030 |
scope.sstypes.splice(scope.index,1) |
|
1031 |
scope.ssnames.splice(scope.index,1) |
|
1032 |
scope.ssrules.splice(scope.index,1) |
|
1033 |
scope.ssRule = scope.ssrules[scope.index]; |
|
1034 |
}; |
|
1035 |
|
|
1036 |
// scope.$watch('tabletitlescfgs', function() { |
|
1037 |
// scope.$parent.table(); |
|
1038 |
// }); |
|
1039 |
//添加一个条件目录 |
|
1040 |
scope.addConditions = function() { |
|
1041 |
var index = _.cloneDeep(scope.expenseConditionsTitles).length; |
|
1042 |
for(i in scope.expensedata){ |
|
1043 |
var data = _.cloneDeep(scope.expensedata[i]); |
|
1044 |
var newdata = {}; |
|
1045 |
var num = -1; |
|
1046 |
for(j in scope.expensedata[i]){ |
|
1047 |
num++; |
|
1048 |
newdata[num] = _.cloneDeep(data[j]); |
|
1049 |
|
|
1050 |
if(j == (index-1)){ |
|
1051 |
num++; |
|
1052 |
newdata[num] = {"grant_value":[""]}; |
|
1053 |
}else if(j > (index-1)){ |
|
1054 |
newdata[num] = _.cloneDeep(data[j]); |
|
1055 |
} |
|
1056 |
} |
|
1057 |
scope.expensedata[i] = newdata; |
|
1058 |
} |
|
1059 |
scope.expenseConditionsTitles.push({ |
|
1060 |
enable: true |
|
1061 |
}); |
|
1062 |
}; |
|
1063 |
//添加一个标准目录 |
|
1064 |
scope.addCritera = function() { |
|
1065 |
var index1 = _.cloneDeep(scope.expenseConditionsTitles).length; |
|
1066 |
var index2 = _.cloneDeep(scope.expenseCtriteraTitles).length; |
|
1067 |
var index = index1+index2; |
|
1068 |
for(i in scope.expensedata){ |
|
1069 |
var data = _.cloneDeep(scope.expensedata[i]); |
|
1070 |
var newdata = {}; |
|
1071 |
var num = -1; |
|
1072 |
for(j in scope.expensedata[i]){ |
|
1073 |
num++; |
|
1074 |
newdata[num] = _.cloneDeep(data[j]); |
|
1075 |
|
|
1076 |
if(j == (index-1)){ |
|
1077 |
num++; |
|
1078 |
newdata[num] = {"grant_value":[""]}; |
|
1079 |
}else if(j > (index-1)){ |
|
1080 |
newdata[num] = _.cloneDeep(data[j]); |
|
1081 |
} |
|
1082 |
} |
|
1083 |
scope.expensedata[i] = newdata; |
|
1084 |
} |
|
1085 |
scope.expenseCtriteraTitles.push({ |
|
1086 |
enable: true |
|
1087 |
}); |
|
1088 |
// var sliceinfo = []; |
|
1089 |
// _.each(scope.allexpensedata,function(data){ |
|
1090 |
//// if(data.length > 1){ |
|
1091 |
// _.each(data,function(info,index){ |
|
1092 |
// for(i in info){ |
|
1093 |
// var infos = info[i]; |
|
1094 |
// info[2] = {'grant_value':['']} |
|
1095 |
// if(parseInt(i) > 2){ |
|
1096 |
//// info[i] = info[i+1]; |
|
1097 |
// sliceinfo.push(infos); |
|
1098 |
// } |
|
1099 |
// } |
|
1100 |
// }) |
|
1101 |
//// } |
|
1102 |
// }) |
|
1103 |
}; |
|
1104 |
|
|
1105 |
//添加一个横向显示的目录 |
|
1106 |
scope.addBudget = function() { |
|
1107 |
for(i in scope.expensedata){ |
|
1108 |
var data = _.cloneDeep(scope.expensedata[i]); |
|
1109 |
var num = -1; |
|
1110 |
for(j in scope.expensedata[i]){ |
|
1111 |
num++; |
|
1112 |
} |
|
1113 |
num++; |
|
1114 |
scope.expensedata[i][num] = {"grant_value":[""]}; |
|
1115 |
} |
|
1116 |
scope.expenseBudgetTitles.push({ |
|
1117 |
enable: true, |
|
1118 |
child: [{}] |
|
1119 |
}); |
|
1120 |
}; |
|
1121 |
//移出目录 |
|
1122 |
scope.rmTitle = function(title,indexs,type) { |
|
1123 |
var index1 = _.cloneDeep(scope.expenseConditionsTitles).length; |
|
1124 |
var index2 = _.cloneDeep(scope.expenseCtriteraTitles).length; |
|
1125 |
var index3 = _.cloneDeep(scope.expenseBudgetTitles).length; |
|
1126 |
var typeindex; |
|
1127 |
var index; |
|
1128 |
var childnum; |
|
1129 |
var thischildnum; |
|
1130 |
switch (type){ |
|
1131 |
case 1: |
|
1132 |
index = indexs+1; |
|
1133 |
typeindex = index1; |
|
1134 |
thischildnum = 1; |
|
1135 |
break; |
|
1136 |
case 2: |
|
1137 |
index = parseInt(index1)+indexs+1; |
|
1138 |
typeindex = index2; |
|
1139 |
thischildnum = 1; |
|
1140 |
break; |
|
1141 |
case 3: |
|
1142 |
index = parseInt(index1)+parseInt(index2); |
|
1143 |
typeindex = index3; |
|
1144 |
childnum = 0; |
|
1145 |
for(i in scope.expenseBudgetTitles){ |
|
1146 |
childnum += scope.expenseBudgetTitles[i].child.length; |
|
1147 |
if(scope.expenseBudgetTitles[i] == title){ |
|
1148 |
break; |
|
1149 |
} |
|
1150 |
} |
|
1151 |
// index += childnum; |
|
1152 |
thischildnum = title.child.length; |
|
1153 |
index = index + childnum - thischildnum +1; |
|
1154 |
break; |
|
1155 |
} |
|
1156 |
for(i in scope.expensedata){ |
|
1157 |
var data = _.cloneDeep(scope.expensedata[i]); |
|
1158 |
var newdata = {}; |
|
1159 |
var num = -1; |
|
1160 |
for(j in scope.expensedata[i]){ |
|
1161 |
// num++; |
|
1162 |
// if(index == 1){ |
|
1163 |
// newdata[j] = {"grant_value":[""]}; |
|
1164 |
// }else{ |
|
1165 |
// newdata[j] = _.cloneDeep(data[j]); |
|
1166 |
// } |
|
1167 |
num++; |
|
1168 |
if(j != (index-1)){ |
|
1169 |
if(data[num] != undefined){ |
|
1170 |
newdata[j] = _.cloneDeep(data[num]); |
|
1171 |
} |
|
1172 |
}else{ |
|
1173 |
if(typeindex != 1){ |
|
1174 |
num += thischildnum; |
|
1175 |
newdata[j] = _.cloneDeep(data[num]); |
|
1176 |
}else{ |
|
1177 |
newdata[j] = {"grant_value":[""]}; |
|
1178 |
if(type == 3){ |
|
1179 |
break; |
|
1180 |
} |
|
1181 |
} |
|
1182 |
} |
|
1183 |
} |
|
1184 |
scope.expensedata[i] = newdata; |
|
1185 |
} |
|
1186 |
|
|
1187 |
_.remove(scope.expenseConditionsTitles, function(item) { |
|
1188 |
if(title == item){ |
|
1189 |
_.extend(title,{"id":false}); |
|
1190 |
} |
|
1191 |
if(title == item && scope.expenseConditionsTitles.length === 1) { |
|
1192 |
_.extend(item, { |
|
1193 |
"mdId": "", |
|
1194 |
"mdDesc": "", |
|
1195 |
"mdName": "", |
|
1196 |
"mdType": "", |
|
1197 |
"mdCode":"" |
|
1198 |
}); |
|
1199 |
return false; |
|
1200 |
} |
|
1201 |
return item === title; |
|
1202 |
}); |
|
1203 |
_.remove(scope.expenseCtriteraTitles, function(item) { |
|
1204 |
if(title == item){ |
|
1205 |
_.extend(title,{"id":false}); |
|
1206 |
} |
|
1207 |
if(title == item && scope.expenseCtriteraTitles.length === 1) { |
|
1208 |
_.extend(item, { |
|
1209 |
"mdId": "", |
|
1210 |
"mdDesc": "", |
|
1211 |
"mdName": "", |
|
1212 |
"mdType": "", |
|
1213 |
"mdCode":"" |
|
1214 |
}); |
|
1215 |
return false; |
|
1216 |
} |
|
1217 |
return item === title; |
|
1218 |
}); |
|
1219 |
_.remove(scope.expenseBudgetTitles, function(item) { |
|
1220 |
if(title == item){ |
|
1221 |
_.extend(title,{"id":false}); |
|
1222 |
} |
|
1223 |
if(title == item && scope.expenseBudgetTitles.length === 1) { |
|
1224 |
item.child = [{}]; |
|
1225 |
_.extend(item, { |
|
1226 |
"child": [{}], |
|
1227 |
"mdId": "", |
|
1228 |
"mdDesc": "", |
|
1229 |
"mdName": "", |
|
1230 |
"mdType": "", |
|
1231 |
"mdCode":"" |
|
1232 |
}); |
|
1233 |
return false; |
|
1234 |
} |
|
1235 |
return item === title; |
|
1236 |
}); |
|
1237 |
}; |
|
1238 |
//关系选择 |
|
1239 |
scope.togle_relation = function(title,index,type){ |
|
1240 |
switch(type){ |
|
1241 |
case 1: |
|
1242 |
// |
|
1243 |
if(scope.expenseConditionsTitles[index]['asRelation'] != undefined && scope.expenseConditionsTitles[index]['asRelation'] == 0){ |
|
1244 |
scope.expenseConditionsTitles[index]['asRelation'] = 1; |
|
1245 |
}else{ |
|
1246 |
scope.expenseConditionsTitles[index]['asRelation'] = 0; |
|
1247 |
} |
|
1248 |
break; |
|
1249 |
case 2: |
|
1250 |
if(scope.expenseCtriteraTitles[index]['asRelation'] != undefined && scope.expenseCtriteraTitles[index]['asRelation'] == 0){ |
|
1251 |
scope.expenseCtriteraTitles[index]['asRelation'] = 1; |
|
1252 |
}else{ |
|
1253 |
scope.expenseCtriteraTitles[index]['asRelation'] = 0; |
|
1254 |
} |
|
1255 |
break; |
|
1256 |
} |
|
1257 |
} |
|
1258 |
// function refreshRowData() { |
|
1259 |
// scope.rowData = []; |
|
1260 |
// var conditionCfg = scope.expenseConditionsTitles; |
|
1261 |
// var criteriaCfg = scope.expenseCtriteraTitles; |
|
1262 |
// var budgetCfg = scope.expenseBudgetTitles; |
|
1263 |
// var i = 0; |
|
1264 |
// _.each(conditionCfg, function(cfg) { |
|
1265 |
// if(!cfg.mdId) { |
|
1266 |
// scope.rowData[i] = {}; |
|
1267 |
// } else { |
|
1268 |
// scope.rowData[i] = cfg; |
|
1269 |
// } |
|
1270 |
// i++; |
|
1271 |
// }); |
|
1272 |
// _.each(criteriaCfg, function(cfg) { |
|
1273 |
// if(!cfg.mdId) { |
|
1274 |
// scope.rowData[i] = {}; |
|
1275 |
// } else { |
|
1276 |
// scope.rowData[i] = cfg; |
|
1277 |
// } |
|
1278 |
// i++; |
|
1279 |
// }); |
|
1280 |
// _.each(budgetCfg, function(cfg) { |
|
1281 |
// _.each(cfg.child, function(sub_cfg) { |
|
1282 |
// if(!sub_cfg.code) { |
|
1283 |
// scope.rowData[i] = {}; |
|
1284 |
// } else { |
|
1285 |
// scope.rowData[i] = _.extend( |
|
1286 |
// sub_cfg, { |
|
1287 |
// 'mdId': cfg.mdId, |
|
1288 |
// 'mdDesc': cfg.mdDesc, |
|
1289 |
// 'mdCode': cfg.mdCode, |
|
1290 |
// 'mdName': cfg.mdName, |
|
1291 |
// 'mdType': cfg.mdType |
|
1292 |
// } |
|
1293 |
// ); |
|
1294 |
// } |
|
1295 |
// i++; |
|
1296 |
// }); |
|
1297 |
// }); |
|
1298 |
// _.each(scope.rowData, function(title) { |
|
1299 |
// if(!title.code && title.mdCode) { |
|
1300 |
// http_service.post('base/data/search', { "code": title.mdCode }, function(res) { |
|
1301 |
// title['values'] = res.data.data.child; |
|
1302 |
// title['elIden'] = res.data.data.elIden; |
|
1303 |
// }) |
|
1304 |
// }else{ |
|
1305 |
// title['values']=[] |
|
1306 |
// } |
|
1307 |
// }); |
|
1308 |
// } |
|
1309 |
// scope.$watch('tabletitlescfgs', function() { |
|
1310 |
// refreshRowData(); |
|
1311 |
// }, true); |
|
1312 |
scope.$watch('expenseBudgetTitles', function() { |
|
1313 |
var budgetSubTitles = []; |
|
1314 |
_.each(scope.expenseBudgetTitles, function(title) { |
|
1315 |
if(title.child && title.child.length !== 0){ |
|
1316 |
budgetSubTitles = budgetSubTitles.concat(title.child); |
|
1317 |
} |
|
1318 |
else{ |
|
1319 |
title.child = [{"value":title.mdName}]; |
|
1320 |
budgetSubTitles.push([{ |
|
1321 |
"child": [{}], |
|
1322 |
"mdId": "", |
|
1323 |
"mdDesc": "", |
|
1324 |
"mdName": "", |
|
1325 |
"mdType": "" |
|
1326 |
}]) |
|
1327 |
} |
|
1328 |
}); |
|
1329 |
|
|
1330 |
scope.budgetSubTitles = budgetSubTitles; |
|
1331 |
}, true); |
|
1332 |
|
|
1333 |
//添加数据 |
|
1334 |
scope.addRow = function() { |
|
1335 |
$('div.drop_down_sel').remove(); |
|
1336 |
var data = _.cloneDeep(scope.expensedata); |
|
1337 |
|
|
1338 |
_.each(data[0],function(exdata){ |
|
1339 |
exdata['grant_value'] = [""]; |
|
1340 |
if(exdata['sys_val'] && exdata['sys_val'].id != undefined){ |
|
1341 |
exdata['sys_val'] = {"show_sys_fx":exdata['sys_val'].name + "()"}; |
|
1342 |
} |
|
1343 |
}) |
|
1344 |
scope.expensedata.push(data[0]); |
|
1345 |
}; |
|
1346 |
|
|
1347 |
scope.selecttype = function($index) { |
|
1348 |
// TODO |
|
1349 |
scope.sstype = scope.ssTypeOptions[$index].mdCode; |
|
1350 |
scope.sstypename.push(scope.ssTypeOptions[$index].mdName); |
|
1351 |
} |
|
1352 |
|
|
1353 |
|
|
1354 |
scope.selectname = function($index) { |
|
1355 |
scope.ssname = scope.ssNameOptions[$index].cdCode; |
|
1356 |
scope.ssnamename = scope.ssNameOptions[$index].cdValue; |
|
1357 |
} |
|
1358 |
}, |
|
1359 |
post: function($scope, element, attrs) { |
|
1360 |
if(!$scope.expensedata.length){ |
|
1361 |
|
|
1362 |
$scope.expensedata.push({}); |
|
1363 |
} |
|
1364 |
|
|
1365 |
http_service.post('supp/search/money/type', {}, function(res) { |
|
1366 |
$scope.ssTypeOptions = res.data.data; |
|
1367 |
$scope.$watch(function(){ |
|
1368 |
return $scope.sstype |
|
1369 |
},function(){ |
|
1370 |
_.each($scope.ssTypeOptions,function(opt){ |
|
1371 |
if(opt.code == $scope.sstype){ |
|
1372 |
$scope.sstypename = opt.value; |
|
1373 |
} |
|
1374 |
}) |
|
1375 |
}) |
|
1376 |
$scope.$watch(function(){ |
|
1377 |
return $scope.ssname |
|
1378 |
},function(){ |
|
1379 |
if($scope.ssname != "222"){ |
|
1380 |
$timeout(function(){ |
|
1381 |
$scope.ssSubType = true; |
|
1382 |
$scope.ssRule = "0"; |
|
1383 |
},1) |
|
1384 |
} |
|
1385 |
_.each($scope.ssNameOptions,function(opt){ |
|
1386 |
if(opt.cdCode == $scope.ssname){ |
|
1387 |
$scope.ssnamename = opt.cdValue; |
|
1388 |
} |
|
1389 |
}) |
|
1390 |
}) |
|
1391 |
|
|
1392 |
|
|
1393 |
}); |
|
1394 |
// http_service.post('supp/search/const', { "cdType": "90" }, function(res) { |
|
1395 |
$scope.ssNameOptions = _.filter(cddata,function(o){ |
|
1396 |
return o.cdType == 90; |
|
1397 |
}) |
|
1398 |
// $scope.ssNameOptions = res.data.data; |
|
1399 |
$scope.$watch(function(){ |
|
1400 |
return $scope.$parent.ssSubTypes; |
|
1401 |
},function(){ |
|
1402 |
$scope.ssSubType = $scope.$parent.ssSubTypes[$scope.index]; |
|
1403 |
}) |
|
1404 |
$scope.$watch(function(){ |
|
1405 |
return $scope.ssSubType; |
|
1406 |
},function(){ |
|
1407 |
$scope.$parent.ssSubTypes[$scope.index] = $scope.ssSubType; |
|
1408 |
}) |
|
1409 |
|
|
1410 |
$scope.$watch(function(){ |
|
1411 |
return $scope.$parent.ssrules; |
|
1412 |
},function(){ |
|
1413 |
$scope.ssRule = $scope.$parent.ssrules[$scope.index]; |
|
1414 |
}) |
|
1415 |
|
|
1416 |
$scope.$watch(function(){ |
|
1417 |
return $scope.ssRule; |
|
1418 |
},function(){ |
|
1419 |
$scope.$parent.ssrules[$scope.index] = $scope.ssRule; |
|
1420 |
}) |
|
1421 |
// }); |
|
1422 |
// $(document).off('click').on('click',function(event){ |
|
1423 |
//// $scope.showname = false; |
|
1424 |
//// $scope.showclass = false; |
|
1425 |
// $('.showtype').hide(); |
|
1426 |
// $('.showname').hide(); |
|
1427 |
// event.stopPropagation() |
|
1428 |
// event.preventDefault() |
|
1429 |
// }) |
|
1430 |
// $scope.showtype = function(event){ |
|
1431 |
// $(event).closest('.select3-element').find('.showtype').show(); |
|
1432 |
//// $scope.showclass = true |
|
1433 |
// event.stopPropagation() |
|
1434 |
// event.preventDefault(); |
|
1435 |
// } |
|
1436 |
// $('.type').off('click').on('click',function(event){ |
|
1437 |
// $('.showtype.typeshow').show(); |
|
1438 |
// $(event.target).show(); |
|
1439 |
//// $scope.showtype = true |
|
1440 |
// event.stopPropagation(); |
|
1441 |
// }) |
|
1442 |
// $('.name').off('click').on('click',function(event){ |
|
1443 |
//// $('.showname.showtype').show(); |
|
1444 |
// $(event.target).show(); |
|
1445 |
//// $scope.showname = true |
|
1446 |
// event.stopPropagation(); |
|
1447 |
// }) |
|
1448 |
} |
|
1449 |
} |
|
1450 |
} |
|
1451 |
} |
|
1452 |
}]) |
|
1453 |
.controller('expendStandardCtrl', ['$scope', 'http_service', '$timeout','$rootScope', function($scope, http_service, $timeout,$rootScope) { |
|
1454 |
$scope.sstypes = ['']; |
|
1455 |
$scope.ssnames = ['']; |
|
1456 |
$scope.ssrules = ['0'];//最大、最小、平均、最先到达、最后到达、无 |
|
1457 |
$scope.ssSubTypes = ['1']; |
|
1458 |
$scope.allexpensedata = [ |
|
1459 |
[] |
|
1460 |
]; |
|
1461 |
$scope.tabletitlescfgs = [{ |
|
1462 |
"expenseConditionsTitles": [{}], |
|
1463 |
"expenseCtriteraTitles": [{}], |
|
1464 |
"expenseBudgetTitles": [{ "child": [{}] }] |
|
1465 |
}]; |
|
1466 |
|
|
1467 |
function refreshMas(obj) { |
|
1468 |
var title; |
|
1469 |
if(obj.type != 5){ |
|
1470 |
title = _.get(_.filter($scope.expense_titles, function(o) { |
|
1471 |
return o.mdCode === obj.mdCode; |
|
1472 |
}), 0); |
|
1473 |
}else{//系统变量回调 |
|
1474 |
|
|
1475 |
|
|
1476 |
title =_.cloneDeep(_.get(_.filter($scope.system_titles,function(o){ |
|
1477 |
return o.id == obj.id; |
|
1478 |
}), 0)) |
|
1479 |
if(title != undefined){ |
|
1480 |
if(obj.child != undefined && title.child != undefined){ |
|
1481 |
_.extend(title,{'children':title.child}); |
|
1482 |
title.child = [{'value':title.name}]; |
|
1483 |
} |
|
1484 |
|
|
1485 |
_.extend(title,{'mdName':title.name}); |
|
1486 |
|
|
1487 |
}else{ |
|
1488 |
title = {'mdName':'此系统变量已被删除','notFound':true}; |
|
1489 |
} |
|
1490 |
|
|
1491 |
} |
|
1492 |
_.extend(obj,title); |
|
1493 |
return obj; |
|
1494 |
} |
|
1495 |
|
|
1496 |
function refreshBudget(obj) { |
|
1497 |
if(obj.mdCode){ |
|
1498 |
http_service.post('base/data/search', { "code": obj.mdCode,"ceche":obj.mdCode }, function(res) { |
|
1499 |
if(!res.data.data) return false; |
|
1500 |
$timeout(function() { |
|
1501 |
obj.child = res.data.data.child; |
|
1502 |
obj.elIden = res.data.data.elIden; |
|
1503 |
}, 1); |
|
1504 |
},true); |
|
1505 |
} |
|
1506 |
|
|
1507 |
} |
|
1508 |
|
|
1509 |
function getTableCFG(data) { |
|
1510 |
//添加关系属性 |
|
1511 |
// |
|
1512 |
_.each(data.child,function(dt){ |
|
1513 |
if(dt.asRelation == undefined){ |
|
1514 |
dt['asRelation'] = 1; |
|
1515 |
} |
|
1516 |
}) |
|
1517 |
|
|
1518 |
var firstColumnDT = _.filter(data.child, function(dt) { |
|
1519 |
return dt.asRowNo === 0; |
|
1520 |
}); |
|
1521 |
var conditions = _.filter(firstColumnDT, function(dt) { |
|
1522 |
return dt.asType == 1; |
|
1523 |
}); |
|
1524 |
// var relations = _.filter(firstColumnDT, function(dt) { |
|
1525 |
// return dt.asDefType === 11; |
|
1526 |
// }); |
|
1527 |
conditions = _.sortBy(conditions, function(o) { |
|
1528 |
return o.asColNo; |
|
1529 |
}); |
|
1530 |
// relations = _.sortBy(relations, function(o) { |
|
1531 |
// return o.asColNo; |
|
1532 |
// }); |
|
1533 |
var criterias = _.filter(firstColumnDT, function(dt) { |
|
1534 |
return dt.asType == 2; |
|
1535 |
}); |
|
1536 |
criterias = _.sortBy(criterias, function(o) { |
|
1537 |
return o.asColNo; |
|
1538 |
}); |
|
1539 |
var budgets = _.filter(firstColumnDT, function(dt) { |
|
1540 |
return dt.asType == 3; |
|
1541 |
}); |
|
1542 |
budgets = _.groupBy(budgets, 'asMasDefineCode'); |
|
1543 |
var tableCFG = { |
|
1544 |
"expenseConditionsTitles": [{}], |
|
1545 |
"expenseCtriteraTitles": [{}], |
|
1546 |
"expenseBudgetTitles": [{ "child": [{}] }] |
|
1547 |
}; |
|
1548 |
var conditionCFG = []; |
|
1549 |
_.each(conditions, function(condition, k) { |
|
1550 |
if(condition.asDefType != 5){ |
|
1551 |
conditionCFG.push(refreshMas({ |
|
1552 |
"mdId": "", |
|
1553 |
"mdCode": condition.asMasDefineCode, |
|
1554 |
"mdName": "", |
|
1555 |
"mdDesc": "", |
|
1556 |
"mdType": "1", |
|
1557 |
"mdDef1": "", |
|
1558 |
"mdDef2": "", |
|
1559 |
"mdDef3": "", |
|
1560 |
"mdDef4": "", |
|
1561 |
"mdDef5": "", |
|
1562 |
"values": [], |
|
1563 |
"elIden": condition.asElIden, |
|
1564 |
"type": condition.asDefType, |
|
1565 |
"enable": !!k, |
|
1566 |
'asRelation':condition.asRelation, |
|
1567 |
'group':1 |
|
1568 |
})); |
|
1569 |
}else{ |
|
1570 |
conditionCFG.push(refreshMas({ |
|
1571 |
"elIden": condition.asElIden, |
|
1572 |
'id':condition.asMasDefineCode, |
|
1573 |
"type": condition.asDefType, |
|
1574 |
"enable": !!k, |
|
1575 |
'asRelation':condition.asRelation, |
|
1576 |
'group':1 |
|
1577 |
})); |
|
1578 |
} |
|
1579 |
|
|
1580 |
}); |
|
1581 |
// _.each(relations,function(relation,j){ |
|
1582 |
// if(relation.asDefType != 5){ |
|
1583 |
// conditionCFG.push(refreshMas({ |
|
1584 |
// "mdId": "", |
|
1585 |
// "mdCode": relation.asMasDefineCode, |
|
1586 |
// "mdName": "", |
|
1587 |
// "mdDesc": "", |
|
1588 |
// "mdType": "1", |
|
1589 |
// "mdDef1": "", |
|
1590 |
// "mdDef2": "", |
|
1591 |
// "mdDef3": "", |
|
1592 |
// "mdDef4": "", |
|
1593 |
// "mdDef5": "", |
|
1594 |
// "values": [], |
|
1595 |
// "elIden": relation.asElIden, |
|
1596 |
// "type": relation.asDefType, |
|
1597 |
// "enable": !!j, |
|
1598 |
// 'asRelation':relation.asRelation |
|
1599 |
// })); |
|
1600 |
// }else{ |
|
1601 |
// conditionCFG.push(refreshMas({ |
|
1602 |
// "id": relation.asMasDefineCode, |
|
1603 |
// "elIden": relation.asElIden, |
|
1604 |
// "type": relation.asDefType, |
|
1605 |
// "enable": !!j, |
|
1606 |
// 'asRelation':relation.asRelation |
|
1607 |
// })); |
|
1608 |
// } |
|
1609 |
// |
|
1610 |
// }) |
|
1611 |
tableCFG['expenseConditionsTitles'] = conditionCFG; |
|
1612 |
var criteriaCFG = []; |
|
1613 |
_.each(criterias, function(criteria, k) { |
|
1614 |
if(criteria.asDefType != 5){ |
|
1615 |
criteriaCFG.push(refreshMas({ |
|
1616 |
"mdId": "tmp", |
|
1617 |
"mdCode": criteria.asMasDefineCode, |
|
1618 |
"mdName": "", |
|
1619 |
"mdDesc": "", |
|
1620 |
"mdType": "1", |
|
1621 |
"mdDef1": "", |
|
1622 |
"mdDef2": "", |
|
1623 |
"mdDef3": "", |
|
1624 |
"mdDef4": "", |
|
1625 |
"mdDef5": "", |
|
1626 |
"values": [], |
|
1627 |
"elIden": criteria.asDefName, |
|
1628 |
"type": criteria.asDefType, |
|
1629 |
"enable": !!k, |
|
1630 |
'asRelation':criteria.asRelation, |
|
1631 |
'group':2 |
|
1632 |
})); |
|
1633 |
}else{ |
|
1634 |
criteriaCFG.push(refreshMas({ |
|
1635 |
"id": criteria.asMasDefineCode, |
|
1636 |
"elIden": criteria.asDefName, |
|
1637 |
"type": criteria.asDefType, |
|
1638 |
"enable": !!k, |
|
1639 |
'asRelation':criteria.asRelation, |
|
1640 |
'group':2 |
|
1641 |
})); |
|
1642 |
} |
|
1643 |
}); |
|
1644 |
tableCFG['expenseCtriteraTitles'] = criteriaCFG; |
|
1645 |
var budgetCFG = []; |
|
1646 |
|
|
1647 |
_.each(budgets, function(budget, k) { |
|
1648 |
budget = budget[0] |
|
1649 |
|
|
1650 |
if(budget.asDefType == 5){ |
|
1651 |
var cfg = refreshMas({ |
|
1652 |
"child": [], |
|
1653 |
"id": budget.asMasDefineCode, |
|
1654 |
"elIden": budget.asDefName, |
|
1655 |
"type": budget.asDefType, |
|
1656 |
'group':3 |
|
1657 |
}); |
|
1658 |
}else{ |
|
1659 |
var cfg = refreshMas({ |
|
1660 |
"child": [], |
|
1661 |
"mdId": "", |
|
1662 |
"mdCode": budget.asMasDefineCode, |
|
1663 |
"mdName": "", |
|
1664 |
"mdDesc": "", |
|
1665 |
"mdType": budget.asDefType, |
|
1666 |
"mdDef1": "", |
|
1667 |
"mdDef2": "", |
|
1668 |
"mdDef3": "", |
|
1669 |
"mdDef4": "", |
|
1670 |
"mdDef5": "", |
|
1671 |
"elIden": budget.asDefName, |
|
1672 |
'group':3 |
|
1673 |
}); |
|
1674 |
} |
|
1675 |
if(k > 0) { |
|
1676 |
cfg['enable'] = true; |
|
1677 |
} |
|
1678 |
|
|
1679 |
refreshBudget(cfg); |
|
1680 |
budgetCFG.push(cfg); |
|
1681 |
}); |
|
1682 |
tableCFG['expenseBudgetTitles'] = budgetCFG; |
|
1683 |
|
|
1684 |
return tableCFG; |
|
1685 |
}; |
|
1686 |
|
|
1687 |
function toRowData(data) { |
|
1688 |
var rowData = {}; |
|
1689 |
_.each(data, function(o, k) { |
|
1690 |
if(o['asDefValues'][0].indexOf('${') > -1){ |
|
1691 |
|
|
1692 |
var value = o['asDefValues'][0].match(/{(.*)} /)[1]; |
|
1693 |
var relate = o['asDefValues'][0].match(/} (.*) /)[1]; |
|
1694 |
var per = o['asDefValues'][0].match(/{(\d)}$/)[1]; |
|
1695 |
var pervalue; |
|
1696 |
switch(per){ |
|
1697 |
case "1": |
|
1698 |
pervalue = '天'; |
|
1699 |
break; |
|
1700 |
case "2": |
|
1701 |
pervalue = '小时'; |
|
1702 |
break; |
|
1703 |
case "3": |
|
1704 |
pervalue = '公里'; |
|
1705 |
break; |
|
1706 |
} |
|
1707 |
$rootScope.relate = relate; |
|
1708 |
$rootScope.pervalue = pervalue; |
|
1709 |
// http_service.post('supp/search/master', { "mdType": "2" }, function(res) { |
|
1710 |
_.each($scope.expense_titles_first.data.data,function(info){ |
|
1711 |
if(info.mdCode == value){ |
|
1712 |
o['asDefValues'] = [info.mdName +" "+ relate + " " + pervalue]; |
|
1713 |
rowData[o.asColNo] = { "grant_value": o['asDefValues'] } |
|
1714 |
} |
|
1715 |
}) |
|
1716 |
// }) |
|
1717 |
}else{ |
|
1718 |
if(o.asDefType == 5){//系统变量 回调 |
|
1719 |
var sys_back; |
|
1720 |
_.each($scope.system_titles,function(title){ |
|
1721 |
if(title.id == o.asMasDefineCode){ |
|
1722 |
sys_back = _.cloneDeep(title); |
|
1723 |
} |
|
1724 |
}); |
|
1725 |
if(sys_back != undefined){ |
|
1726 |
var sys_value = JSON.parse(o.asDefValues); |
|
1727 |
var sys_value_key = _.keys(sys_value); |
|
1728 |
_.each(sys_back.child,function(cd){//引用公式 回调 |
|
1729 |
if(cd.joinMathId){ |
|
1730 |
_.each($scope.system_titles,function(title){ |
|
1731 |
if(cd.joinMathId == title.id){ |
|
1732 |
_.extend(cd,{"joinchildren":_.cloneDeep(title.child)}) |
|
1733 |
} |
|
1734 |
}) |
|
1735 |
} |
|
1736 |
}) |
|
1737 |
_.each(sys_back.child,function(cd){ |
|
1738 |
_.each(sys_value_key,function(sk){ |
|
1739 |
|
|
1740 |
if(cd.pIndex == sk){ |
|
1741 |
if(cd.joinMathId == undefined){ |
|
1742 |
cd['val'] = sys_value[sk]; |
|
1743 |
}else{ |
|
1744 |
var sys_jval_key = _.keys(sys_value[sk]); |
|
1745 |
_.each(cd.joinchildren,function(jcd){ |
|
1746 |
_.each(sys_jval_key,function(jk){ |
|
1747 |
if(jk == jcd.pIndex){ |
|
1748 |
jcd['val'] = sys_value[sk][jk]; |
|
1749 |
} |
|
1750 |
}) |
|
1751 |
}) |
|
1752 |
} |
|
1753 |
} |
|
1754 |
}) |
|
1755 |
}) |
|
1756 |
_.extend(sys_back,{'children':sys_back.child,'show_sys_fx':o['asShowCount']}); |
|
1757 |
if(o.asCount){ |
|
1758 |
_.extend(sys_back,{'sys_count':o.asCount}); |
|
1759 |
} |
|
1760 |
if(o.asInverse != undefined){//正、反选属性回调 |
|
1761 |
rowData[o.asColNo] = { "grant_value": o['asShowCount'],"asInverse": o.asInverse,"sys_val":sys_back}; |
|
1762 |
}else{ |
|
1763 |
rowData[o.asColNo] = { "grant_value": o['asShowCount'],"asInverse": 1,"sys_val":sys_back} |
|
1764 |
} |
|
1765 |
}else{ |
|
1766 |
rowData[o.asColNo] = { "grant_value": o['asShowCount'],"asInverse": 1}; |
|
1767 |
} |
|
1768 |
|
|
1769 |
}else{ |
|
1770 |
if(o.asInverse != undefined){//正、反选属性回调 |
|
1771 |
rowData[o.asColNo] = { "grant_value": o['asDefValues'],"asInverse": o.asInverse}; |
|
1772 |
}else{ |
|
1773 |
rowData[o.asColNo] = { "grant_value": o['asDefValues'],"asInverse": 1 } |
|
1774 |
} |
|
1775 |
} |
|
1776 |
} |
|
1777 |
}); |
|
1778 |
// |
|
1779 |
return rowData; |
|
1780 |
} |
|
1781 |
|
|
1782 |
function getExpenseData(data) { |
|
1783 |
|
|
1784 |
var expense_data = data.child; |
|
1785 |
if(!expense_data.length) return false; |
|
1786 |
var expense_data_row_group = _.groupBy(expense_data, 'asRowNo'); |
|
1787 |
|
|
1788 |
function sortNumber(a,b) |
|
1789 |
{ |
|
1790 |
return a - b |
|
1791 |
} |
|
1792 |
var keys = _.keys(expense_data_row_group).sort(sortNumber); |
|
1793 |
|
|
1794 |
var tableData = []; |
|
1795 |
var rowData; |
|
1796 |
_.each(keys, function(i) { |
|
1797 |
var data = expense_data_row_group[i]; |
|
1798 |
rowData = toRowData(data); |
|
1799 |
tableData.push(rowData); |
|
1800 |
}); |
|
1801 |
|
|
1802 |
return tableData; |
|
1803 |
}; |
|
1804 |
|
|
1805 |
$scope.table = function(){ |
|
1806 |
expenseTableOnceMore() |
|
1807 |
} |
|
1808 |
|
|
1809 |
function expenseTableOnceMore() { |
|
1810 |
http_service.post('supp/search', {}, function(res) { |
|
1811 |
$scope.get_all_data = true; |
|
1812 |
var data_list = res.data.data; |
|
1813 |
|
|
1814 |
|
|
1815 |
var tableCFG = []; |
|
1816 |
_.each(data_list, function(data) { |
|
1817 |
tableCFG.push(getTableCFG(_.cloneDeep(data))); |
|
1818 |
}); |
|
1819 |
_.each(tableCFG, function(cfg, index) { |
|
1820 |
if($scope.tabletitlescfgs[index]) |
|
1821 |
_.each(cfg, function(v, k) { |
|
1822 |
_.extend($scope.tabletitlescfgs[index][k], v); |
|
1823 |
}); |
|
1824 |
else |
|
1825 |
$scope.tabletitlescfgs.push(cfg); |
|
1826 |
}); |
|
1827 |
// _.each($scope.tabletitlescfgs,function(cfg,index){ |
|
1828 |
// _.each(cfg,function(m,n){ |
|
1829 |
// if(m.length != 1){ |
|
1830 |
// } |
|
1831 |
// _.each(m,function(ms){ |
|
1832 |
// }) |
|
1833 |
// }) |
|
1834 |
// }) |
|
1835 |
var expenseData = []; |
|
1836 |
_.each(data_list, function(data) { |
|
1837 |
expenseData.push(getExpenseData(_.cloneDeep(data))); |
|
1838 |
}); |
|
1839 |
_.each(expenseData, function(cfg, index) { |
|
1840 |
if($scope.allexpensedata[index]){ |
|
1841 |
// _.each(cfg, function(v, k) { |
|
1842 |
// if($scope.allexpensedata[index][k]){ |
|
1843 |
// _.extend($scope.allexpensedata[index][k], v); |
|
1844 |
// } |
|
1845 |
// else{ |
|
1846 |
// $scope.allexpensedata[index].push(v); |
|
1847 |
// } |
|
1848 |
$scope.allexpensedata[index] = cfg |
|
1849 |
// }); |
|
1850 |
}else{ |
|
1851 |
$scope.allexpensedata.push(cfg); |
|
1852 |
} |
|
1853 |
}); |
|
1854 |
var sstypes = []; |
|
1855 |
// http_service.post('supp/search/master', { "mdType": "3" }, function(res) { |
|
1856 |
// var typedata = res.data.data; |
|
1857 |
// for(i in data_list){ |
|
1858 |
// var data = data_list[i] |
|
1859 |
// sstypes.push(data.ssType); |
|
1860 |
// http_service.post('supp/search/master', { "mdType": "3" }, function(res) { |
|
1861 |
// if(typedata.mdCode == data.ssType){ |
|
1862 |
// sstypenames.push(typedata.mdCode) |
|
1863 |
// } |
|
1864 |
// }); |
|
1865 |
// } |
|
1866 |
// }); |
|
1867 |
|
|
1868 |
http_service.post('supp/search/money/type', {}, function(res) { |
|
1869 |
for(i in data_list){ |
|
1870 |
var data = data_list[i] |
|
1871 |
sstypes.push(data.ssType); |
|
1872 |
var typedata = res.data.data; |
|
1873 |
if(typedata.code == data.ssType){ |
|
1874 |
sstypenames.push(typedata.code) |
|
1875 |
} |
|
1876 |
} |
|
1877 |
_.each(sstypes, function(type, index) { |
|
1878 |
if($scope.sstypes[index] === '') { |
|
1879 |
$scope.sstypes[index] = type; |
|
1880 |
} else { |
|
1881 |
$scope.sstypes.push(type); |
|
1882 |
} |
|
1883 |
}); |
|
1884 |
var ssnames = []; |
|
1885 |
_.each(data_list, function(data) { |
|
1886 |
ssnames.push(data.ssName); |
|
1887 |
}); |
|
1888 |
_.each(ssnames, function(name, index) { |
|
1889 |
if($scope.ssnames[index] === '') { |
|
1890 |
$scope.ssnames[index] = name; |
|
1891 |
} else { |
|
1892 |
$scope.ssnames.push(name); |
|
1893 |
} |
|
1894 |
}); |
|
1895 |
var ssSubTypes=[]; |
|
1896 |
$scope.ssSubTypes = []; |
|
1897 |
|
|
1898 |
_.each(data_list,function(data){ |
|
1899 |
ssSubTypes.push(data.ssSubType); |
|
1900 |
}) |
|
1901 |
|
|
1902 |
_.each(ssSubTypes,function(sub){ |
|
1903 |
if(sub == 0){ |
|
1904 |
|
|
1905 |
$scope.ssSubTypes.push(false); |
|
1906 |
}else{ |
|
1907 |
$scope.ssSubTypes.push(true); |
|
1908 |
} |
|
1909 |
}) |
|
1910 |
|
|
1911 |
$scope.ssrules = []; |
|
1912 |
|
|
1913 |
_.each(data_list,function(data){ |
|
1914 |
$scope.ssrules.push(data.ssRule); |
|
1915 |
}) |
|
1916 |
|
|
1917 |
//费用类型 |
|
1918 |
$scope.ssTypeOptions = res.data.data; |
|
1919 |
$scope.sstypename = []; |
|
1920 |
_.each($scope.sstypes,function(type){ |
|
1921 |
_.each($scope.ssTypeOptions,function(typeoption){ |
|
1922 |
if(type == typeoption.code){ |
|
1923 |
$scope.sstypename.push(typeoption.value); |
|
1924 |
} |
|
1925 |
}) |
|
1926 |
}) |
|
1927 |
//报销方式 |
|
1928 |
// http_service.post('supp/search/const', { "cdType": "90" }, function(res) { |
|
1929 |
$scope.ssNameOptions = _.filter(cddata,function(o){ |
|
1930 |
return o.cdType == 90; |
|
1931 |
}) |
|
1932 |
// $scope.ssNameOptions = res.data.data; |
|
1933 |
$scope.ssnamename = []; |
|
1934 |
_.each($scope.ssnames,function(name){ |
|
1935 |
_.each($scope.ssNameOptions, function(nameoption){ |
|
1936 |
if(name == nameoption.cdCode){ |
|
1937 |
$scope.ssnamename.push(nameoption.cdValue); |
|
1938 |
} |
|
1939 |
}) |
|
1940 |
}) |
|
1941 |
// }); |
|
1942 |
}); |
|
1943 |
|
|
1944 |
// for(i in data_list){ |
|
1945 |
// var data = data_list[i] |
|
1946 |
// sstypes.push(data.ssType); |
|
1947 |
// // sstypenames.push(data.ss) |
|
1948 |
// http_service.post('supp/search/money/type', {}, function(res) { |
|
1949 |
// var typedata = res.data.data; |
|
1950 |
// if(typedata.mdCode == data.ssType){ |
|
1951 |
// sstypenames.push(typedata.mdCode) |
|
1952 |
// } |
|
1953 |
// }); |
|
1954 |
//// }); |
|
1955 |
// } |
|
1956 |
|
|
1957 |
//费用类型 |
|
1958 |
// http_service.post('supp/search/money/type', {}, function(res) { |
|
1959 |
// $scope.ssTypeOptions = res.data.data; |
|
1960 |
// $scope.sstypename = []; |
|
1961 |
// _.each($scope.sstypes,function(type){ |
|
1962 |
// _.each($scope.ssTypeOptions,function(typeoption){ |
|
1963 |
// if(type == typeoption.mdCode){ |
|
1964 |
// $scope.sstypename.push(typeoption.mdName); |
|
1965 |
// } |
|
1966 |
// }) |
|
1967 |
// }) |
|
1968 |
// }); |
|
1969 |
}); |
|
1970 |
} |
|
1971 |
|
|
1972 |
//修改公式保存样式 |
|
1973 |
function change_relation_style(data){ |
|
1974 |
if(data != undefined){ |
|
1975 |
// if(data.length < 2){ |
|
1976 |
// return false; |
|
1977 |
// } |
|
1978 |
if(_.isArray(data)){ |
|
1979 |
data = data[0] |
|
1980 |
if(data.length <2){ |
|
1981 |
return false; |
|
1982 |
} |
|
1983 |
} |
|
1984 |
|
|
1985 |
var value = data.split(" "); |
|
1986 |
var per = value.slice(-1); |
|
1987 |
var percode; |
|
1988 |
switch(per[0]){ |
|
1989 |
case '天': |
|
1990 |
percode = 1; |
|
1991 |
break; |
|
1992 |
case '小时': |
|
1993 |
percode = 2; |
|
1994 |
break; |
|
1995 |
case '公里': |
|
1996 |
percode = 3; |
|
1997 |
break; |
|
1998 |
} |
|
1999 |
data = data.split(" ").slice(1,-1).join(" ")+" ${"+percode+"}"; |
|
2000 |
return data; |
|
2001 |
} |
|
2002 |
} |
|
2003 |
|
|
2004 |
|
|
2005 |
|
|
2006 |
//保存的格式 |
|
2007 |
function get_expense_standard_data(data, cfg, type, name,sub,rule) { |
|
2008 |
if(sub){ |
|
2009 |
sub = 1; |
|
2010 |
}else{ |
|
2011 |
sub = 0; |
|
2012 |
} |
|
2013 |
|
|
2014 |
var expenseStandardData = []; |
|
2015 |
var rowCfgs = []; |
|
2016 |
// |
|
2017 |
// |
|
2018 |
//删除关系属性 |
|
2019 |
cfg['expenseConditionsTitles'][cfg['expenseConditionsTitles'].length-1].asRelation = undefined; |
|
2020 |
cfg['expenseCtriteraTitles'][cfg['expenseCtriteraTitles'].length-1].asRelation = undefined; |
|
2021 |
_.each(cfg['expenseBudgetTitles'],function(cfg){ |
|
2022 |
cfg.asRelation = undefined; |
|
2023 |
}) |
|
2024 |
var expense_condtions = cfg['expenseConditionsTitles']; |
|
2025 |
var expense_criters = cfg['expenseCtriteraTitles']; |
|
2026 |
var expense_budgets = cfg['expenseBudgetTitles']; |
|
2027 |
//补助条件 |
|
2028 |
var m = 0; |
|
2029 |
|
|
2030 |
for(i in expense_condtions){ |
|
2031 |
var cfgItem = expense_condtions[i]; |
|
2032 |
if(!cfgItem.eleCode && cfgItem.id == undefined){ |
|
2033 |
_.each(data,function(ex_data){ |
|
2034 |
if(ex_data[m] == undefined){ |
|
2035 |
return false; |
|
2036 |
} |
|
2037 |
if(_.isArray(ex_data[m].grant_value)){ |
|
2038 |
ex_data[m].grant_value = ex_data[m].grant_value[0]; |
|
2039 |
} |
|
2040 |
cfgItem.grant_value = "${"+cfgItem.mdCode+ "} " + change_relation_style(ex_data[m].grant_value); |
|
2041 |
}) |
|
2042 |
// for(j in document.getElementsByClassName("fxinput")){ |
|
2043 |
// var fxinput = document.getElementsByClassName("fxinput"); |
|
2044 |
// if(change_relation_style(fxinput[j].value) !== undefined){ |
|
2045 |
// cfgItem.grant_value = "${"+cfgItem.mdCode+ "} " + change_relation_style(fxinput[m].value); |
|
2046 |
// m++; |
|
2047 |
// } |
|
2048 |
// } |
|
2049 |
rowCfgs.push(_.extend(cfgItem, { 'type': 11 ,'elIden': cfgItem['eleValue'] || '','code':cfgItem['elIden']||'','asType':1})); |
|
2050 |
break; |
|
2051 |
}else{ |
|
2052 |
rowCfgs.push(_.extend(cfgItem, { 'type': 1,'code':cfgItem['elIden'] || '','elIden': cfgItem['eleValue'] || '','asType':1})); |
|
2053 |
} |
|
2054 |
m++; |
|
2055 |
} |
|
2056 |
_.each(expense_criters, function(cfgItem) { |
|
2057 |
rowCfgs.push(_.extend(cfgItem, { 'type': 2 ,'elIden': cfgItem['eleValue'] || '','code':cfgItem['elIden'] || '' ,'asType':2})); |
|
2058 |
}); |
|
2059 |
_.each(expense_budgets, function(cfgItem) { |
|
2060 |
if(cfgItem.child && cfgItem.child.length) { |
|
2061 |
_.each(cfgItem.child, function(_cfgItem) { |
|
2062 |
if(cfgItem.id != undefined){ |
|
2063 |
rowCfgs.push(_.extend(_cfgItem, { 'type': 3, 'elIden': cfgItem['eleValue'] || '','code':_cfgItem['code'] || '' ,'mdCode':cfgItem['mdCode'] || $scope.types,"id":cfgItem.id,'asType':3})); |
|
2064 |
}else{ |
|
2065 |
rowCfgs.push(_.extend(_cfgItem, { 'type': 3, 'elIden': cfgItem['eleValue'] || '','code':_cfgItem['code'] || '' ,'mdCode':cfgItem['mdCode'] || $scope.types,'asType':3})); |
|
2066 |
} |
|
2067 |
|
|
2068 |
}); |
|
2069 |
} |
|
2070 |
}) |
|
2071 |
|
|
2072 |
_.each(rowCfgs,function(cfg){//系统变量处理 修改type |
|
2073 |
if(cfg.id != undefined && cfg.id != false){ |
|
2074 |
cfg['type'] = 5; |
|
2075 |
} |
|
2076 |
}) |
|
2077 |
|
|
2078 |
|
|
2079 |
_.each(rowCfgs, function(cfg, column) { |
|
2080 |
_.each(data, function(dtRow, row) { |
|
2081 |
var columnValue = dtRow[column]; |
|
2082 |
if(dtRow[column] != undefined){ |
|
2083 |
if(dtRow[column]['grant_value'] && dtRow[column]['grant_value'].length == 0){ |
|
2084 |
dtRow[column]['grant_value'] = [""]; |
|
2085 |
} |
|
2086 |
if(cfg.values && cfg.values.length == 0 && !cfg.is_org){ |
|
2087 |
if(change_relation_style(dtRow[column].grant_value) != false && cfg.mdCode){ |
|
2088 |
cfg['grant_value'] = "${"+cfg.mdCode+ "} " + change_relation_style(dtRow[column].grant_value); |
|
2089 |
}else{ |
|
2090 |
cfg['grant_value'] = ""; |
|
2091 |
} |
|
2092 |
} |
|
2093 |
} |
|
2094 |
if(!cfg.eleCode){//非下拉框 排除反选属性 |
|
2095 |
if(dtRow[column] != undefined){ |
|
2096 |
dtRow[column]["asInverse"] = undefined; |
|
2097 |
}else{ |
|
2098 |
dtRow[column] = {"asInverse":undefined}; |
|
2099 |
} |
|
2100 |
|
|
2101 |
} |
|
2102 |
if(cfg.type != 5){ |
|
2103 |
expenseStandardData.push({ |
|
2104 |
'asType':cfg.asType,//1:补助标准条件,2:补助标准结果,3:补助金额 |
|
2105 |
"asColNo": column, //列号 |
|
2106 |
"asDefName": cfg['elIden'], //主数据元素标识符 |
|
2107 |
"asDefType": cfg['type'], //1:补助标准条件,2:补助标准结果,3:补助金额,90:报销方式 |
|
2108 |
"asDefValues": cfg['grant_value'] || (dtRow && dtRow[column] && dtRow[column]['grant_value']) || [''], //主数据元素值code |
|
2109 |
// "group_id": dtRow && dtRow[column] && dtRow[column]['group_id'], //group id |
|
2110 |
"asElIden": cfg['code'], //暂时为空 |
|
2111 |
"asMasDefineCode": cfg['mdCode'], |
|
2112 |
"asRowNo": row, |
|
2113 |
'asRelation':cfg.asRelation, |
|
2114 |
'asInverse':dtRow[column]['asInverse'] |
|
2115 |
}); |
|
2116 |
}else{ |
|
2117 |
var sys_fx_val = {}; |
|
2118 |
var show_sys_val = ''; |
|
2119 |
|
|
2120 |
if(dtRow[column].sys_val){ |
|
2121 |
show_sys_val = dtRow[column].sys_val.show_sys_fx; |
|
2122 |
_.each(dtRow[column].sys_val.children,function(cd){ |
|
2123 |
if(cd.joinMathId == undefined){ |
|
2124 |
if(cd.val && cd.val != ""){ |
|
2125 |
sys_fx_val[cd.pIndex] = cd.val; |
|
2126 |
} |
|
2127 |
}else{ |
|
2128 |
var jval = {}; |
|
2129 |
_.each(cd.joinchildren,function(jcd){ |
|
2130 |
if(jcd.val && jcd.val != ""){ |
|
2131 |
jval[jcd.pIndex] = jcd.val; |
|
2132 |
} |
|
2133 |
}) |
|
2134 |
sys_fx_val[cd.pIndex] = jval; |
|
2135 |
} |
|
2136 |
}) |
|
2137 |
} |
|
2138 |
sys_fx_val = JSON.stringify(sys_fx_val); |
|
2139 |
expenseStandardData.push({ |
|
2140 |
'asType':cfg.asType,//1:补助标准条件,2:补助标准结果,3:补助金额 |
|
2141 |
"asColNo": column, //列号 |
|
2142 |
"asElIden": "", //暂时为空 |
|
2143 |
"asDefType": cfg['type'], //1:补助标准条件,2:补助标准结果,3:补助金额,90:报销方式 |
|
2144 |
"asDefValues": cfg.notFound?['{}']:sys_fx_val, |
|
2145 |
"asMasDefineCode": cfg['id'], |
|
2146 |
"asRowNo": row, |
|
2147 |
'asRelation':cfg.asRelation, |
|
2148 |
'asShowCount':show_sys_val, |
|
2149 |
"asCount":cfg.notFound?"":dtRow[column].sys_val.sys_count |
|
2150 |
}); |
|
2151 |
} |
|
2152 |
}); |
|
2153 |
}); |
|
2154 |
// |
|
2155 |
_.each(expenseStandardData,function(expense){ |
|
2156 |
if(expense.asRelation == undefined){ |
|
2157 |
delete expense.asRelation; |
|
2158 |
} |
|
2159 |
if(expense.asInverse == undefined){ |
|
2160 |
delete expense.asInverse; |
|
2161 |
} |
|
2162 |
}) |
|
2163 |
// |
|
2164 |
return { |
|
2165 |
"child": expenseStandardData, |
|
2166 |
"ssDispFun": "显示用逻辑公式", |
|
2167 |
"ssLogicFun": "计算用逻辑公式", |
|
2168 |
"ssName": name, |
|
2169 |
"ssSubType": sub, |
|
2170 |
"ssType": type, |
|
2171 |
"ssRule":rule |
|
2172 |
} |
|
2173 |
} |
|
2174 |
$scope.$on('$viewContentLoaded', function() { |
|
2175 |
var frm_height = $(document).height() - 52; |
|
2176 |
$('div.split_form').height(frm_height); |
|
2177 |
$(window).resize(function() { |
|
2178 |
var frm_height = $(document).height() - 52; |
|
2179 |
$('div.split_form').height(frm_height); |
|
2180 |
}); |
|
2181 |
}); |
|
2182 |
//新建表格 |
|
2183 |
$scope.create_expense_strd_table = function() { |
|
2184 |
$('div.drop_down_sel').remove(); |
|
2185 |
// $timeout(function(){ |
|
2186 |
$scope.allexpensedata.push([]); |
|
2187 |
$scope.tabletitlescfgs.push({ |
|
2188 |
"expenseConditionsTitles": [{}], |
|
2189 |
"expenseCtriteraTitles": [{}], |
|
2190 |
"expenseBudgetTitles": [{ "child": [{}] }] |
|
2191 |
}); |
|
2192 |
$scope.ssnames.push(''); |
|
2193 |
$scope.sstypes.push(''); |
|
2194 |
$scope.ssSubTypes.push(true); |
|
2195 |
// },1) |
|
2196 |
} |
|
2197 |
|
|
2198 |
//保存报销标准 |
|
2199 |
$scope.saveExpense = function() { |
|
2200 |
$('div.drop_down_sel').remove(); |
|
2201 |
var data = []; |
|
2202 |
var pst_dt = { "data": [] }; |
|
2203 |
_.each($scope.allexpensedata, function(dt, index) { |
|
2204 |
var cfg = _.cloneDeep($scope.tabletitlescfgs[index]); |
|
2205 |
var type = _.cloneDeep($scope.sstypes[index]); |
|
2206 |
var name = _.cloneDeep($scope.ssnames[index]); |
|
2207 |
var sub = _.cloneDeep($scope.ssSubTypes[index]); |
|
2208 |
var rule = _.cloneDeep($scope.ssrules[index]); |
|
2209 |
var expense_dt = get_expense_standard_data(dt, cfg, type, name,sub,rule); |
|
2210 |
pst_dt['data'].push(expense_dt); |
|
2211 |
}); |
|
2212 |
|
|
2213 |
http_service.post('supp/save', pst_dt, function(res) { |
|
2214 |
if(res.data.opState) { |
|
2215 |
//alert('保存补助标准成功。') |
|
2216 |
$scope.$parent.tsuccess( "保存补助标准成功!") |
|
2217 |
} else { |
|
2218 |
//alert('后台错误保存补助标准失败。') |
|
2219 |
$scope.$parent.terro("后台错误,保存补助标准失败。") |
|
2220 |
} |
|
2221 |
}); |
|
2222 |
|
|
2223 |
}; |
|
2224 |
|
|
2225 |
//切换补助标准内容 与 系统变量 |
|
2226 |
$scope.title_type = true;//默认显示补助标准内容 |
|
2227 |
|
|
2228 |
|
|
2229 |
http_service.post('supp/search/master', {"mdType":2}, function(res) { |
|
2230 |
if(res.data.data){ |
|
2231 |
_.each(res.data.data,function(title){ |
|
2232 |
//添加默认的关系属性 |
|
2233 |
// if(title.asRelation == undefined){ |
|
2234 |
// _.extend(title,{'asRelation':1}); |
|
2235 |
// } |
|
2236 |
}) |
|
2237 |
} |
|
2238 |
$scope.expense_titles_first = res; |
|
2239 |
var expense_titles = res.data.data; |
|
2240 |
$scope.expense_titles = expense_titles; |
|
2241 |
expense_titles = _.map(expense_titles, function(title, n) { |
|
2242 |
return { |
|
2243 |
'type': n, |
|
2244 |
'btn': '<div class="col-md-6"><button title="'+ title.mdName +'" class="btn btn-success btn-elb">' + title.mdName + '</button></div>', |
|
2245 |
'field': '<span style="display:none;">' + title.mdName + '</span>', |
|
2246 |
'data': title |
|
2247 |
} |
|
2248 |
}); |
|
2249 |
|
|
2250 |
var fb = new form_builder.create(); |
|
2251 |
fb.no_wrapper(false); |
|
2252 |
fb.add_elements(expense_titles); |
|
2253 |
fb.add_forms('td.expenseTitle'); |
|
2254 |
fb.add_elements_box('.expense_titles'); |
|
2255 |
fb.element_appended_before_allback(before_el_append); |
|
2256 |
fb.element_appended_callback(after_el_append); |
|
2257 |
fb.bootstrap(); |
|
2258 |
//将拖动的数据加入表格 |
|
2259 |
function after_el_append(title, holder) { |
|
2260 |
var this_title = title; |
|
2261 |
var title_data = arguments[0] && arguments[0][0] && arguments[0][0]['data']; |
|
2262 |
var $td_holder = $(arguments[2]); |
|
2263 |
var group = $td_holder.attr('group'); |
|
2264 |
var index = $td_holder.attr('index'); |
|
2265 |
var tableindex = $td_holder.attr('tableindex'); |
|
2266 |
var cellIndex = 0; |
|
2267 |
|
|
2268 |
// |
|
2269 |
// |
|
2270 |
// |
|
2271 |
// |
|
2272 |
// |
|
2273 |
switch(group) { |
|
2274 |
case 'condition': |
|
2275 |
var title = $scope.tabletitlescfgs[tableindex]['expenseConditionsTitles'][index]; |
|
2276 |
$timeout(function() { |
|
2277 |
_.extend(title_data, { |
|
2278 |
"asRelation": 1 |
|
2279 |
}); //默认关系属性 |
|
2280 |
for(var key in title){ |
|
2281 |
delete title[key]; |
|
2282 |
} |
|
2283 |
_.extend(title, title_data); |
|
2284 |
_.extend(title, {"group":1}); |
|
2285 |
|
|
2286 |
}, 1); |
|
2287 |
//单元格index |
|
2288 |
cellIndex = index; |
|
2289 |
break; |
|
2290 |
case 'criteria': |
|
2291 |
var title = $scope.tabletitlescfgs[tableindex]['expenseCtriteraTitles'][index]; |
|
2292 |
$timeout(function() { |
|
2293 |
for(var key in title){ |
|
2294 |
delete title[key]; |
|
2295 |
} |
|
2296 |
if(this_title[0].data.eleCode) { |
|
2297 |
_.extend(title_data, { |
|
2298 |
"asRelation": 1 |
|
2299 |
}); //默认关系属性 |
|
2300 |
_.extend(title, title_data); |
|
2301 |
_.extend(title, {"group":2}); |
|
2302 |
} else { |
|
2303 |
var errMsg = "补助标准不支持" + title_data.mdName + "控件"; |
|
2304 |
$scope.$parent.terro(errMsg); |
|
2305 |
if(!title.mdCode) { |
|
2306 |
_.extend(title, { |
|
2307 |
"enable": true |
|
2308 |
}); |
|
2309 |
} |
|
2310 |
} |
|
2311 |
}, 1); |
|
2312 |
//单元格index |
|
2313 |
cellIndex = $scope.tabletitlescfgs[tableindex]['expenseConditionsTitles'].length + parseInt(index); |
|
2314 |
break; |
|
2315 |
case 'expense': |
|
2316 |
var title = $scope.tabletitlescfgs[tableindex]['expenseBudgetTitles'][index]; |
|
2317 |
for(var key in title){ |
|
2318 |
delete title[key]; |
|
2319 |
} |
|
2320 |
$timeout(function() { |
|
2321 |
_.extend(title, title_data); |
|
2322 |
_.extend(title, {"group":3}); |
|
2323 |
}, 1); |
|
2324 |
//单元格index |
|
2325 |
cellIndex = $scope.tabletitlescfgs[tableindex]['expenseCtriteraTitles'].length + |
|
2326 |
$scope.tabletitlescfgs[tableindex]['expenseConditionsTitles'].length + |
|
2327 |
parseInt(index); |
|
2328 |
http_service.post('base/data/search', { |
|
2329 |
"code": title_data.mdCode, |
|
2330 |
"cache_id": title_data.mdCode |
|
2331 |
}, function(res) { |
|
2332 |
if(!res.data.data) return false; |
|
2333 |
$timeout(function() { |
|
2334 |
title.child = res.data.data.child; |
|
2335 |
title.elIden = res.data.data.elIden; |
|
2336 |
title.drag = true; |
|
2337 |
}, 1); |
|
2338 |
}, true); |
|
2339 |
break; |
|
2340 |
} |
|
2341 |
// var data_list = $scope.allexpensedata[tableindex]; |
|
2342 |
// var grant_val; |
|
2343 |
// _.each(data_list, function(data) { |
|
2344 |
// if(data[cellIndex]){ |
|
2345 |
// grant_val = data[cellIndex]['grant_value']; |
|
2346 |
// }else{ |
|
2347 |
// grant_val = ['']; |
|
2348 |
// } |
|
2349 |
// |
|
2350 |
// if(grant_val && _.isArray(grant_val)) { |
|
2351 |
// grant_val.splice(0, grant_val.length); |
|
2352 |
// } |
|
2353 |
// }); |
|
2354 |
if(cellIndex && (group === 'condition' || group === 'criteria')) { |
|
2355 |
var data_list = $scope.allexpensedata[tableindex]; |
|
2356 |
_.each(data_list, function(data) { |
|
2357 |
if(data && data[cellIndex]) { |
|
2358 |
if(this_title[0].data.eleCode != undefined && group != 'criteria') { |
|
2359 |
data[cellIndex]['grant_value'] = []; |
|
2360 |
} |
|
2361 |
data[cellIndex]['asInverse'] = 1; |
|
2362 |
} else { |
|
2363 |
var asobj = {}; |
|
2364 |
asobj[cellIndex] = { |
|
2365 |
'asInverse': 1 |
|
2366 |
} |
|
2367 |
_.extend(data, asobj); |
|
2368 |
} |
|
2369 |
// var grant_val = data[cellIndex]['grant_value']; |
|
2370 |
// if(grant_val && _.isArray(grant_val)) { |
|
2371 |
// grant_val.splice(0, grant_val.length); |
|
2372 |
// } |
|
2373 |
}); |
|
2374 |
} else if(cellIndex) { |
|
2375 |
var data_list = $scope.allexpensedata[tableindex]; |
|
2376 |
_.each(data_list, function(data) { |
|
2377 |
for(i in data) { |
|
2378 |
if(i >= cellIndex) { |
|
2379 |
data[i]['grant_value'] = []; |
|
2380 |
} |
|
2381 |
} |
|
2382 |
}); |
|
2383 |
} |
|
2384 |
|
|
2385 |
} |
|
2386 |
// $scope.$watch(function(){ |
|
2387 |
// return $scope.tabletitlescfgs.length |
|
2388 |
// },function(){ |
|
2389 |
// after_el_append() |
|
2390 |
// }) |
|
2391 |
|
|
2392 |
function before_el_append(title, holder) { |
|
2393 |
$(holder).find('span').remove(); |
|
2394 |
} |
|
2395 |
}); |
|
2396 |
http_service.post('systemMath/search/list', {}, function(response) { //获得系统变量 |
|
2397 |
var system_titles = response.data.data; |
|
2398 |
$scope.system_titles = system_titles; |
|
2399 |
$rootScope.system_titles = system_titles; |
|
2400 |
system_titles = _.map(system_titles, function(title, n) { |
|
2401 |
return { |
|
2402 |
'type': n, |
|
2403 |
'btn': '<div class="col-md-6"><button title="' + title.name + '" class="btn btn-success btn-elb">' + title.name + '</button></div>', |
|
2404 |
'field': '<span style="display:none;">' + title.name + '</span>', |
|
2405 |
'data': title |
|
2406 |
} |
|
2407 |
}); |
|
2408 |
|
|
2409 |
var sys = new form_builder_s.create(); |
|
2410 |
sys.no_wrapper(false); |
|
2411 |
sys.add_elements(system_titles); |
|
2412 |
sys.add_forms('td.expenseTitle'); |
|
2413 |
sys.add_elements_box('.system_titles'); |
|
2414 |
sys.element_appended_before_allback(before_el_append_s); |
|
2415 |
sys.element_appended_callback(after_el_append_s); |
|
2416 |
sys.bootstrap(); |
|
2417 |
|
|
2418 |
function after_el_append_s(title, holder) { |
|
2419 |
var this_title = title; |
|
2420 |
var title_data = arguments[0] && arguments[0][0] && arguments[0][0]['data']; |
|
2421 |
var $td_holder = $(arguments[2]); |
|
2422 |
var group = $td_holder.attr('group'); |
|
2423 |
var index = $td_holder.attr('index'); |
|
2424 |
var tableindex = $td_holder.attr('tableindex'); |
|
2425 |
var cellIndex = 0; |
|
2426 |
|
|
2427 |
|
|
2428 |
|
|
2429 |
_.extend(title_data,{'children':title_data.child}) |
|
2430 |
switch(group) { |
|
2431 |
case 'condition': |
|
2432 |
var title = $scope.tabletitlescfgs[tableindex]['expenseConditionsTitles'][index]; |
|
2433 |
for(var key in title){ |
|
2434 |
delete title[key]; |
|
2435 |
} |
|
2436 |
$timeout(function() { |
|
2437 |
_.extend(title_data, { |
|
2438 |
"asRelation": 1, |
|
2439 |
'mdName':title_data.name |
|
2440 |
}); //默认关系属性 |
|
2441 |
_.extend(title, title_data); |
|
2442 |
_.extend(title, {"group":1}); |
|
2443 |
}, 1); |
|
2444 |
//单元格index |
|
2445 |
cellIndex = index; |
|
2446 |
break; |
|
2447 |
case 'criteria': |
|
2448 |
var title = $scope.tabletitlescfgs[tableindex]['expenseCtriteraTitles'][index]; |
|
2449 |
for(var key in title){ |
|
2450 |
delete title[key]; |
|
2451 |
} |
|
2452 |
$timeout(function() { |
|
2453 |
_.extend(title_data, { |
|
2454 |
"asRelation": 1, |
|
2455 |
'mdName':title_data.name |
|
2456 |
}); //默认关系属性 |
|
2457 |
_.extend(title, title_data); |
|
2458 |
_.extend(title, {"group":2}); |
|
2459 |
}, 1); |
|
2460 |
//单元格index |
|
2461 |
cellIndex = $scope.tabletitlescfgs[tableindex]['expenseConditionsTitles'].length + parseInt(index); |
|
2462 |
break; |
|
2463 |
case 'expense': |
|
2464 |
var title = $scope.tabletitlescfgs[tableindex]['expenseBudgetTitles'][index]; |
|
2465 |
for(var key in title){ |
|
2466 |
delete title[key]; |
|
2467 |
} |
|
2468 |
$timeout(function() { |
|
2469 |
_.extend(title_data, { |
|
2470 |
'mdName':title_data.name |
|
2471 |
}); |
|
2472 |
_.extend(title, title_data); |
|
2473 |
_.extend(title, {"group":3}); |
|
2474 |
title.child = [{"value":title_data.name}]; |
|
2475 |
title.drag = true; |
|
2476 |
}, 1); |
|
2477 |
//单元格index |
|
2478 |
cellIndex = $scope.tabletitlescfgs[tableindex]['expenseCtriteraTitles'].length + |
|
2479 |
$scope.tabletitlescfgs[tableindex]['expenseConditionsTitles'].length + |
|
2480 |
parseInt(index); |
|
2481 |
|
|
2482 |
// http_service.post('base/data/search', { |
|
2483 |
// "code": title_data.mdCode, |
|
2484 |
// "cache_id": title_data.mdCode |
|
2485 |
// }, function(res) { |
|
2486 |
// if(!res.data.data) return false; |
|
2487 |
// $timeout(function() { |
|
2488 |
// title.child = res.data.data.child; |
|
2489 |
// title.elIden = res.data.data.elIden; |
|
2490 |
// title.drag = true; |
|
2491 |
// }, 1); |
|
2492 |
// }, true); |
|
2493 |
break; |
|
2494 |
} |
|
2495 |
if(cellIndex && (group === 'condition' || group === 'criteria')) { |
|
2496 |
var data_list = $scope.allexpensedata[tableindex]; |
|
2497 |
|
|
2498 |
_.each(data_list, function(data) { |
|
2499 |
if(data[cellIndex]) { |
|
2500 |
data[cellIndex]['grant_value'] = []; |
|
2501 |
data[cellIndex]['asInverse'] = 1; |
|
2502 |
} else { |
|
2503 |
var asobj = {}; |
|
2504 |
asobj[cellIndex] = { |
|
2505 |
'asInverse': 1 |
|
2506 |
} |
|
2507 |
_.extend(data, asobj); |
|
2508 |
} |
|
2509 |
data[cellIndex]['sys_val'] = {'show_sys_fx':title_data.name+"()"} |
|
2510 |
}); |
|
2511 |
} else if(cellIndex) { |
|
2512 |
|
|
2513 |
var data_list = $scope.allexpensedata[tableindex]; |
|
2514 |
|
|
2515 |
_.each(data_list, function(data) { |
|
2516 |
for(i in data) { |
|
2517 |
if(i >= cellIndex) { |
|
2518 |
data[i]['grant_value'] = []; |
|
2519 |
// data[i]['sys_val'] = {'show_sys_fx':title_data.name+"()"} |
|
2520 |
} |
|
2521 |
} |
|
2522 |
|
|
2523 |
data[cellIndex] ={'sys_val':{'show_sys_fx':title_data.name+"()"}} |
|
2524 |
}); |
|
2525 |
} |
|
2526 |
} |
|
2527 |
|
|
2528 |
function before_el_append_s(title, holder) { |
|
2529 |
$(holder).find('span').remove(); |
|
2530 |
} |
|
2531 |
$scope.table = function() { |
|
2532 |
expenseTableOnceMore(); |
|
2533 |
} |
|
2534 |
|
|
2535 |
$scope.$watch('tabletitlescfgs', function() { |
|
2536 |
expenseTableOnceMore(); |
|
2537 |
}); |
|
2538 |
}) |
|
2539 |
}]); |