angular.module('saved_form_directive', [])
|
.factory("myServeice", ['http_service', '$timeout', function(http_service, $timeout) {
|
return {
|
parentitem: [],
|
users_selected: [],
|
type: "",
|
setpd: function(parentitem, users_selected, type) {
|
this.parentitem = parentitem;
|
this.users_selected = users_selected;
|
this.type = type;
|
},
|
setuser:function(users_selected){
|
this.users_selected = users_selected;
|
},
|
getparentitem: function() {
|
return this.parentitem;
|
},
|
getusers_selected: function() {
|
return this.users_selected;
|
},
|
gettype: function() {
|
return this.type;
|
}
|
}
|
}])
|
.directive('formItem', ['$rootScope', function($rootScope) {
|
return {
|
restrict: 'EACM',
|
templateUrl: './static/templates/form_item.html',
|
replace: true,
|
scope: {
|
|
},
|
link: function($scope, element, attrs) {
|
|
}
|
}
|
}])
|
.directive('date', ['$timeout','$rootScope', function($timeout,$rootScope) {
|
return {
|
scope: {
|
item: "@",
|
edit:"=",
|
editflag:"@",
|
realitem:"="
|
},
|
link: function(scope, element, attrs) {
|
var editflag,editflag_class;
|
if(scope.editflag == 1){
|
editflag = true;
|
editflag_class = "abled_time";
|
}else{
|
editflag = false;
|
editflag_class = "disabled_time";
|
}
|
scope.$watch(function(){
|
return scope.realitem;
|
},function(){
|
if(scope.realitem.sys_value != undefined){
|
if(scope.realitem.render_value != scope.realitem.sys_value){
|
scope.realitem["sys_red"] = true;
|
}else{
|
scope.realitem["sys_red"] = false;
|
}
|
}
|
});
|
var fp;
|
$timeout(function(){
|
fp = new Flatpickr($(element)[0], {
|
enableTime: false,
|
altInput: false,
|
altFormat: "Y-m-d",
|
clickOpens:editflag,
|
altInputClass:editflag_class,
|
defaultDate: $(element).val(),
|
onClose:function(){
|
$timeout(function(){
|
if($rootScope.sort_bytime){
|
var time_item = JSON.parse(scope.item);
|
time_item.render_value = $(element).val();
|
$rootScope.sort_bytime(time_item);
|
}
|
},1)
|
}
|
});
|
},1)
|
$(element).click(function(){
|
fp.open();
|
fp.setDate($(element).val());
|
})
|
|
// scope.$watch(function() {
|
// return $(element).val();
|
// }, function() {
|
// if($(element).val() == ""){
|
// $(element).flatpickr({
|
// // enableTime: true,
|
// altInput: true,
|
// altFormat: "Y-m-d",
|
// enableTime:false,
|
// clickOpens:editflag,
|
// altInputClass:editflag_class,
|
// defaultDate: $(element).val()
|
// });
|
// }
|
// });
|
// $(element).change(function() {
|
// scope.$parent.$parent.$parent.check_data(scope.edit);
|
// var time = $(this).val();
|
// _.extend(scope.$parent.$parent.item, { "render_value": time });
|
// if(scope.item) {
|
// _.extend(scope.$parent.$parent.$parent._item, { "render_value": time });
|
// }
|
// });
|
}
|
}
|
|
}])
|
|
.directive('time', ['$timeout','$rootScope', function($timeout,$rootScope) {
|
return {
|
scope: {
|
item: "@",
|
edit:"=",
|
realitem:"="
|
},
|
link: function(scope, element, attrs) {
|
var editflag,editflag_class;
|
if(scope.editflag == 1){
|
editflag = true;
|
editflag_class = "abled_time";
|
}else{
|
editflag = false;
|
editflag_class = "disabled_time";
|
}
|
scope.$watch(function(){
|
return scope.realitem;
|
},function(){
|
if(scope.realitem.sys_value != undefined){
|
if(scope.realitem.render_value != scope.realitem.sys_value){
|
scope.realitem["sys_red"] = true;
|
}else{
|
scope.realitem["sys_red"] = false;
|
}
|
}
|
});
|
var fp;
|
$timeout(function(){
|
fp = new Flatpickr($(element)[0], {
|
enableTime: true,
|
altInput: false,
|
altFormat: "h:i",
|
clickOpens:editflag,
|
altInputClass:editflag_class,
|
defaultDate: $(element).val(),
|
time_24hr:true,
|
onClose:function(){
|
$timeout(function(){
|
if($rootScope.sort_bytime){
|
var time_item = JSON.parse(scope.item);
|
time_item.render_value = $(element).val();
|
$rootScope.sort_bytime(time_item);
|
}
|
},1)
|
}
|
});
|
},1)
|
$(element).click(function(){
|
fp.open();
|
fp.setDate($(element).val());
|
})
|
|
// scope.$watch(function() {
|
// return $(element).val();
|
// }, function() {
|
// if($(element).val() == ""){
|
// $(element).flatpickr({
|
// // enableTime: true,
|
// altInput: true,
|
// altFormat: "h:i",
|
// enableTime:false,
|
// clickOpens:editflag,
|
// altInputClass:editflag_class,
|
// defaultDate: $(element).val()
|
// });
|
// }
|
// });
|
// $(element).change(function() {
|
// scope.$parent.$parent.$parent.check_data(scope.edit);
|
// var time = $(this).val();
|
// _.extend(scope.$parent.$parent.item, { "render_value": time });
|
// if(scope.item) {
|
// _.extend(scope.$parent.$parent.$parent._item, { "render_value": time });
|
// }
|
// });
|
}
|
}
|
}])
|
|
.directive('datetime', ['$timeout','$rootScope', function($timeout,$rootScope) {
|
return {
|
scope: {
|
item: "@",
|
edit:"=",
|
editflag:"@",
|
realitem:"="
|
},
|
link: function(scope, element, attrs) {
|
var editflag,editflag_class;
|
if(scope.editflag == 1){
|
editflag = true;
|
editflag_class = "abled_time";
|
}else{
|
editflag = false;
|
editflag_class = "disabled_time";
|
}
|
var fp;
|
scope.$watch(function(){
|
return scope.realitem;
|
},function(){
|
if(scope.realitem.sys_value != undefined){
|
if(scope.realitem.render_value != scope.realitem.sys_value){
|
scope.realitem["sys_red"] = true;
|
}else{
|
scope.realitem["sys_red"] = false;
|
}
|
}
|
});
|
$timeout(function(){
|
fp = new Flatpickr($(element)[0], {
|
enableTime: true,
|
altInput: false,
|
altFormat: "Y-m-d h:i",
|
clickOpens:editflag,
|
altInputClass:editflag_class,
|
defaultDate: $(element).val(),
|
time_24hr:true,
|
onClose:function(){
|
$timeout(function(){
|
// _.each($scope.)
|
if($rootScope.sort_bytime){
|
var time_item = JSON.parse(scope.item);
|
time_item.render_value = $(element).val();
|
$rootScope.sort_bytime(time_item);
|
}
|
},1)
|
}
|
});
|
},1)
|
$(element).click(function(){
|
fp.open();
|
fp.setDate($(element).val());
|
})
|
// scope.$watch(function() {
|
// return $(element).val();
|
// }, function() {
|
// if($(element).val() == ""){
|
// $(element).flatpickr({
|
// // enableTime: true,
|
// altInput: true,
|
// altFormat: "Y-m-d h:i",
|
// enableTime:false,
|
// clickOpens:editflag,
|
// altInputClass:editflag_class,
|
// defaultDate: $(element).val()
|
// });
|
// }
|
// });
|
// $(element).change(function() {
|
// scope.$parent.$parent.$parent.check_data(scope.edit);
|
// var time = $(this).val();
|
// _.extend(scope.$parent.$parent.item, { "render_value": time });
|
// if(scope.item) {
|
// _.extend(scope.$parent.$parent.$parent._item, { "render_value": time });
|
// }
|
// });
|
}
|
}
|
|
}])
|
|
.filter('cityfilter', function() {
|
return function(value, cityList) {
|
var flag = false;
|
for(i in cityList) {
|
if(value == cityList[i]) {
|
flag = true;
|
}
|
}
|
return flag;
|
}
|
})
|
|
.filter('citycode', function() {
|
return function(value) {
|
|
}
|
})
|
|
//选择城市的控件
|
.directive('selectCity', function() {
|
return {
|
restrict: 'ACEM',
|
templateUrl: './static/templates/city.html',
|
controller: ['http_service', '$scope', '$timeout', function(http_service, $scope, $timeout) {
|
//获取城市
|
$scope.cityList = [];
|
http_service.post('base/data/search/city', {}, function(response) {
|
$scope.provinces = response.data.data;
|
_.each($scope.form_items, function(item) {
|
if(item.gcCpnType == 11) {
|
$scope.$watch(function() {
|
return item.render_value;
|
}, function() {
|
if(item.render_value){
|
$scope.ccode = item.render_value.split(",");
|
}
|
_.each($scope.ccode, function(code) {
|
_.each($scope.provinces, function(citycode) {
|
_.each(citycode.child, function(citylistcode) {
|
if(citylistcode.code == code) {
|
$scope.cityList.push(citylistcode.value);
|
}
|
})
|
});
|
})
|
|
})
|
}
|
});
|
});
|
$scope.firstcitys = [];
|
$scope.secondcitys = [];
|
$scope.thirdcitys = [];
|
|
//存储选中的一级城市
|
// if(localStorage.getItem("selectedcity")) {
|
// $scope.cityList = localStorage.getItem("selectedcity");
|
// $scope.cityList = $scope.cityList.split(",");
|
// } else {
|
// $scope.cityList = [];
|
// }
|
//
|
// if(localStorage.getItem("selectedcitycode")) {
|
// $scope.citycode = localStorage.getItem("selectedcitycode");
|
// $scope.citycode = $scope.citycode.split(",");
|
// } else {
|
// $scope.citycode = [];
|
// }
|
|
//点击省份响应事件
|
$scope.selecthot = function($index) {
|
$scope.citys = $scope.provinces[$index].child;
|
|
$scope.firstcitys.splice(0, $scope.firstcitys.length);
|
$scope.secondcitys.splice(0, $scope.secondcitys.length);
|
$scope.thirdcitys.splice(0, $scope.thirdcitys.length);
|
for(i in $scope.citys) {
|
if($scope.citys[i].level == '2') {
|
$scope.firstcitys.push($scope.citys[i]);
|
}
|
if($scope.citys[i].level == '3') {
|
$scope.secondcitys.push($scope.citys[i]);
|
}
|
if($scope.citys[i].level == '4') {
|
$scope.thirdcitys.push($scope.citys[i]);
|
}
|
}
|
$scope.citys = $scope.firstcitys;
|
$scope.firstcity = function() {
|
$scope.citys = $scope.firstcitys;
|
}
|
$scope.secondcity = function() {
|
$scope.citys = $scope.secondcitys;
|
}
|
$scope.thirdcity = function() {
|
$scope.citys = $scope.thirdcitys;
|
}
|
}
|
|
$scope.hidecity = function() {
|
$scope.city = false;
|
$(".citybtn").text($scope.cityList.join(",") || "请选择城市");
|
}
|
$scope.citybtn = function() {
|
$scope.city = $scope.edit;
|
}
|
$scope.selectcity = function($event, $index) {
|
if($event.target.checked) {
|
$scope.cityList.push($scope.citys[$index].value);
|
$scope.citycode.push($scope.citys[$index].code);
|
} else {
|
for(i in $scope.cityList) {
|
if($scope.citys[$index].value == $scope.cityList[i]) {
|
$scope.cityList.splice(i, 1);
|
$scope.citycode.splice(i, 1);
|
}
|
}
|
}
|
// localStorage.setItem("selectedcity", $scope.cityList + "");
|
// localStorage.setItem("selectedcitycode", $scope.citycode);
|
}
|
|
//删除某个选中城市,改变多选框状态的同时,已选城市列表删除此城市
|
$scope.deletecity = function($index) {
|
for(j in $scope.citys) {
|
if($scope.citys[j].value == $scope.cityList[$index]) {
|
$(".citycontent input")[j].checked = false;
|
}
|
}
|
$scope.cityList.splice($index, 1);
|
$scope.citycode.splice($index, 1);
|
// localStorage.setItem("selectedcitycode", $scope.citycode);
|
// localStorage.setItem("selectedcity", $scope.cityList + "");
|
}
|
|
//保存输入框中的城市,若存在则加入选中城市
|
$scope.saveflag = true;
|
$scope.savecity = function() {
|
for(i in $scope.provinces) {
|
for(j in $scope.provinces[i].child) {
|
if($scope.provinces[i].child[j].value.indexOf($scope.somecity) >= 0) {
|
$scope.cityList.push($scope.provinces[i].child[j].value);
|
$scope.citycode.push($scope.provinces[i].child[j].code);
|
$scope.saveflag = false;
|
}
|
}
|
}
|
if($scope.saveflag) {
|
//alert("抱歉,无此城市");
|
// swal({
|
// title: "警告",
|
// text: "抱歉,无此城市!",
|
// type: "warning",
|
// confirmButtonText: "确定",
|
// })
|
$scope.$parent.tinfo("抱歉,无此城市!")
|
|
}
|
}
|
}]
|
}
|
})
|
.filter('colorfilter', function() {
|
return function(value, color) {
|
switch(value) {
|
case 10:
|
color = '#39beb5';
|
break;
|
case 20:
|
color = '#FFCC00';
|
break;
|
case 30:
|
color = '#73ff96';
|
break;
|
default:
|
color = '#ccc';
|
break;
|
}
|
return color;
|
}
|
})
|
.filter('statusfilter', function() {
|
return function(value) {
|
var slogan = ""
|
switch(value) {
|
case 10:
|
slogan = "./static/img/yes.png";
|
break;
|
case 20:
|
slogan = "./static/img/no.png";
|
break;
|
case 30:
|
slogan = "./static/img/yes.png";
|
break;
|
default:
|
slogan = "./static/img/continue.png";
|
break;
|
|
}
|
return slogan;
|
}
|
})
|
.filter('borderfilter', function() {
|
return function(border) {
|
switch(border) {
|
case 10:
|
border = "#999";
|
break;
|
|
case 20:
|
border = "#999";
|
break;
|
|
case 30:
|
border = "#fff";
|
break;
|
|
default:
|
border = "#fff";
|
break;
|
}
|
return border;
|
}
|
})
|
.filter('borderfilt', function() {
|
return function(edit) {
|
switch(edit) {
|
case false:
|
edit = "#ccc";
|
break;
|
|
case true:
|
edit = "#fff";
|
break;
|
|
default:
|
edit = "#fff";
|
break;
|
}
|
return edit;
|
}
|
})
|
.filter('stepfilter', function() {
|
return function(step) {
|
switch(step) {
|
case 10:
|
step = "已处理";
|
break;
|
|
case 20:
|
step = "退回";
|
break;
|
|
case 30:
|
step = "已完成";
|
break;
|
|
default:
|
step = "待处理";
|
break;
|
}
|
return step;
|
}
|
})
|
.directive('userSelector', ['$rootScope', 'http_service', '$compile', '$timeout', 'myServeice', function($rootScope, http_service, $compile, $timeout, myServeice) {
|
return {
|
restrict: 'EACM',
|
scope: {
|
item: '=',
|
parentitem: '=',
|
type: '='
|
},
|
template: '<div class="user_element">' +
|
'<label>' +
|
'{{item.gcCpnAlias}}' +
|
'<text class="manadatory_ifd" ng-if="item.gcInputMust==1">*</text>'+
|
'</label>' +
|
'<span name="user_el_content" gcColName="{{item.gcColName}}" user_selected="{{item.render_value}}" >' +
|
'<span class="user_name" ng-repeat="user in users_selected" >' +
|
'{{user.personName}} <a ng-href="javascript:void(0)" ng-click="remove_user(user);"><i class="fa fa-times" aria-hidden="true" style="color:#fff;"></i></a>' +
|
'</span>' +
|
' <a class="btn_user_el_add_user" href="javascript:void(0);" ng-click="select_user($event);" >选择人员</a>' +
|
'</span>' +
|
'</div>',
|
replace: true,
|
controller: ['$scope', '$element', function($scope, $element) {
|
$scope.users_selected = [];
|
$scope.users_selecting = {};
|
$scope.journel_budget_list = [];
|
$scope.departments_selected = [];
|
|
$scope.$watch('parentitem', function() {
|
var budget_list = $scope.parentitem.budget_list;
|
var user_ids = _.map(budget_list, function(budget) {
|
|
return budget['userId'];
|
})
|
if(user_ids && user_ids.length) {
|
http_service.post('personnel/search/personns', { "pdIds": user_ids }, function(res) {
|
$scope.users_selected = res.data.data;
|
});
|
}
|
}, true);
|
$scope.rm_sel_user = function(user) {
|
$scope.users_selected = _.filter($scope.users_selected, function(_user) {
|
return _user.personCode !== user.personCode;
|
})
|
$scope.query_journel_budget();
|
};
|
$scope.select_user = function(e) {
|
if($rootScope.close_expend_select){
|
$rootScope.close_expend_select();
|
}
|
if($rootScope.close_apply_select){
|
$rootScope.close_apply_select();
|
}
|
$('div[name="user_selector_popup"]').remove();
|
var activeclass = "{true:'hr_name',false:'hr_name_selected'}[user.state]";
|
var pop_element = $('<div' +
|
' name="user_selector_popup"' +
|
' class="user_select_popup col-md-12"' +
|
'onMouseOver ="$(this).draggable();event.stopPropagation();"' +
|
'>' +
|
'<div class="user_sel_form">' +
|
'<div class="row btn_cls user_sel_form_close">' +
|
'<a ng-href="javascript:void(0);"><i class="fa fa-times main_close" aria-hidden="true" ng-click="close();"></i></a>' +
|
'</div>' +
|
'<div class="main">' +
|
'<div class="center_area">' +
|
'<div class="area_title">' +
|
'<label>选择人员</label>' +
|
'<span><input type="text" ng-click="stop_prg($event);" ng-change="get_users()" value="" ng-model="user_filter" /></span>' +
|
'</div>' +
|
'<div class="area_body">' +
|
'<div ng-repeat="(first_letter, users) in users_selecting track by $index">' +
|
'<label class="label_letter_group">{{first_letter}}</label>' +
|
'<ul>' +
|
// '<a class="hr_gp_title" >人员{{$index+1}}</a>' +
|
'<li ng-repeat="user in users" >' +
|
'<div>' +
|
'<a ng-class="' + activeclass + '" ng-href="javascript:void(0);" ng-model="user.personName">{{user.personName}}</a>' +
|
'<button class="hr_name_addbtn" ng-click="add_user(user);">{{user.state|selected_flag}}</button>' +
|
'</div>' +
|
'</li>' +
|
'</ul>' +
|
'</div>' +
|
'</div>' +
|
'</div>' +
|
'</div>' +
|
'<div class="hr_tree left ztree" id="tree" style="overflow:auto;">' + '</div>' +
|
'<div class="right">' +
|
'<div class="right_area">' +
|
'<div class="area_title selected_personnel">' +
|
'<label>已选人员</label>' +
|
'<span class="float_right">' +
|
'<a ng-href="javascript:void(0);" class="clear_selected_users" ng-click="clear_selected_users();" ><i class="fa fa-trash-o" aria-hidden="true"></i></a>' +
|
'</span>' +
|
'</div>' +
|
|
'<div class="area_body">' +
|
'<ul ng-repeat="user in departments_selected">' +
|
'<div class="gp_title" dep_show="true" ng-click="show_department(event);">' +
|
'<i class="fa fa-caret-right" style="margin-left:3px" aria-hidden="true"></i>' +
|
'<a class="hr_gp_title" title="{{user.orgName}}[{{user.user_info.length}}]">{{user.orgName}}[{{user.user_info.length}}]</a>' + '<i class="fa fa-times department_close" ng-click="remove_department(user);" aria-hidden="true"></i>' +
|
'</div>' +
|
'<div>' +
|
'<li ng-repeat="user_info in user.user_info">' +
|
'<div>' +
|
'<a class="hr_name" ng-href="javascript:void(0);">{{user_info.personName}}</a>' +
|
'<button class="hr_name_addbtn" ng-click="remove_user(user_info);">-</button>' +
|
'</div>' +
|
'</li>' +
|
'</div>' +
|
'</ul>' +
|
'</div>' +
|
'</div>' +
|
'</div>' +
|
'</div>' +
|
'</div>');
|
$($element).append(pop_element);
|
$compile(pop_element)($scope);
|
$scope.init_tree();
|
var form_el_div = $($element).closest('div.sub_form_container').children('div').not('[name="journel_budget"]');
|
form_el_div.find('input, select').off('change').on('change', function() {
|
$scope.query_journel_budget();
|
});
|
e.stopPropagation();
|
};
|
}],
|
link: function($scope, element, attrs) {
|
$scope.user_filter = "";
|
$scope.stop_prg = function(event) {
|
event.stopPropagation();
|
};
|
|
$scope.user_filter_func = function() {
|
var users_selecting = {};
|
_.each($scope.users_selecting_cache, function(users, name) {
|
var users_filtered = _.filter(users, function(user) {
|
return user.perOrgCode.indexOf($scope.user_filter) > -1;
|
});
|
if(users_filtered.length > 0) {
|
users_selecting[name] = users_filtered;
|
}
|
});
|
$scope.users_selecting = users_selecting;
|
}
|
|
//搜索人员
|
$scope.get_users = function() {
|
$scope.users_selecting = {};
|
if($scope.user_filter !== ""){
|
http_service.post('base/data/search/personData',{'personName':$scope.user_filter},function(res){
|
|
_.each(res.data.data,function(user_data){
|
var user_fristname = user_data.perFirstName;
|
if($scope.users_selected.length > 0 && $scope.users_selected[0].personCode == user_data.personCode){
|
user_data['state'] = false;
|
}else{
|
user_data['state'] = true;
|
}
|
|
$scope.users_selecting[user_fristname] = [user_data];
|
})
|
})
|
}
|
};
|
$scope.clear_selected_users = function() {
|
$scope.users_selected = [];
|
$scope.departments_selected = [];
|
};
|
$rootScope.close_user_selector = function(){
|
$scope.close();
|
}
|
$scope.close = function() {
|
$('div[name="user_selector_popup"]').remove();
|
myServeice.setpd($scope.parentitem, $scope.users_selected, $scope.type);
|
// $scope.query_journel_budget();
|
};
|
$scope.query_journel_budget = function() {
|
var children = $scope.parentitem.child;
|
var pd = {
|
"type": $scope.type,
|
"journeyInfo": [],
|
"child": []
|
}
|
_.each(children, function(child) {
|
pd['journeyInfo'].push({
|
"gcElIden": child['gcElIden'],
|
"gcColName": child['gcColName'],
|
"gcVal": $(element).closest('div.sub_form').find('*[gccolname="' + child['gcColName'] + '"]').val()
|
});
|
});
|
|
_.each($scope.users_selected, function(user) {
|
pd['child'].push({
|
"userId": user.pdId
|
});
|
});
|
|
http_service.post('apply/userMoney', pd, function(res) {
|
var journel_budget_list = res.data.data;
|
$timeout(function() {
|
// $scope.parentitem.budget_list = journel_budget_list;
|
// $scope.item.budget_list = journel_budget_list;
|
$scope.item_budget_list = journel_budget_list;
|
}, 1);
|
|
});
|
};
|
//公式联动
|
function formula_computing(formula,usercode,this_item,parent_item){
|
if($rootScope.stepCode == 30 || $rootScope.stepCode == 10){// 已完成/审核中 表单 不计算
|
return false;
|
}
|
//判断公式应用于哪个表单
|
// var travelType = formula.travelType;//获取公对应的表单
|
// var account_flag =false;//控制是否计算
|
// if(travelType == $scope.type){
|
// account_flag = true;
|
// }else if(travelType == 0){
|
// account_flag = true;
|
// }
|
// if(account_flag == false){
|
// return false;
|
// }
|
|
//判断此控件是否在子表单中
|
var is_child = true;
|
var child_item;
|
if(this_item == parent_item){
|
is_child = false;
|
}
|
//解析公式
|
var target_code = formula.child[0];
|
var org_code = formula.child[1];
|
//判断是否执行此公式
|
if(org_code.pMdCode != this_item.gcMeCode){
|
return false;
|
}
|
var post_data = {
|
"code":org_code.pMdCode,
|
"views":[org_code.pMeCode],
|
"criteria":[{
|
"key":"code",
|
"val":usercode
|
}]
|
}
|
http_service.post("base/data/getVals",post_data,function(res){
|
var res_data = res.data.data;
|
if(res_data != undefined && res_data.length != 0){
|
if(is_child){
|
_.each($scope.$parent.form_items,function(form){
|
if(form.child && form.child.length != 0 && form == parent_item){
|
_.each(form.child,function(cd){
|
if(cd.gcMeCode == target_code.pMdCode){
|
if(formula.child.length <= 2){
|
|
$rootScope.formula_num_id.push(formula.id)//前端公式计数
|
$rootScope.formula_num++;
|
|
cd.render_value = res_data[0][org_code.pMeCode];
|
}
|
if($rootScope.change_apmonut){
|
$timeout(function(){
|
$rootScope.change_apmonut(cd);
|
},10)
|
}
|
}
|
})
|
}
|
})
|
}else{
|
_.each($scope.$parent.form_items,function(form){
|
if(form.gcCpnType != 10 && form.gcCpnType != 17 ){
|
if(form.gcMeCode == target_code.pMdCode){
|
//
|
//
|
if(formula.child.length <= 2){
|
|
$rootScope.formula_num_id.push(formula.id)//前端公式计数
|
$rootScope.formula_num++;
|
|
form.render_value = res_data[0][org_code.pMeCode];
|
}
|
if($rootScope.change_apmonut){
|
$timeout(function(){
|
$rootScope.change_apmonut(form);
|
},10)
|
}
|
}
|
}else{
|
_.each(form.child,function(cd){
|
if(cd.gcMeCode == target_code.pMdCode){
|
//
|
//
|
if(formula.child.length <= 2){
|
|
$rootScope.formula_num_id.push(formula.id)//前端公式计数
|
$rootScope.formula_num++;
|
|
cd.render_value = res_data[0][org_code.pMeCode];
|
}
|
if($rootScope.change_apmonut){
|
$timeout(function(){
|
$rootScope.change_apmonut(cd);
|
},10)
|
}
|
}
|
})
|
}
|
})
|
}
|
}
|
if(res_data != undefined && res_data.length == 0 && org_code.pMeCode != 'code'){
|
|
$rootScope.formula_num_id.push(formula.id)//前端公式计数
|
$rootScope.formula_num++;
|
|
}
|
},false,function(){
|
|
$rootScope.formula_num_id.push(formula.id)//前端公式计数
|
$rootScope.formula_num++;
|
|
});
|
}
|
$rootScope.formula_computing_user = function(formula,value,this_item,parent_item){
|
formula_computing(formula,value,this_item,parent_item);
|
}
|
//根据部门code找部门name
|
function get_orgname(user,cd){
|
_.each(cd,function(hr_data){
|
if(hr_data.orgCode == user.perOrgCode){
|
user['orgName'] = hr_data.orgName;
|
}else if(hr_data.child && hr_data.child.length > 0){
|
get_orgname(user,hr_data.child);
|
}
|
});
|
}
|
//人员变更清空申请选择
|
// function clear_apply(){
|
// _.each($scope.$parent.form_items,function(form){
|
// if(form.gcCpnType == 14){//申请选择
|
// $rootScope.expend_number_info = null;
|
// form.render_value = "";
|
// $scope.$parent.$parent.$parent.expend_heads = [];
|
// $scope.$parent.$parent.$parent.expend_selectinfo = [];
|
// $scope.$parent.$parent.$parent.expend_thshow = false;
|
// }
|
// });
|
// $scope.$parent.form_items = _.remove($scope.$parent.form_items,function(form){
|
// return form.gcCpnType == 10 && form.deleteflag_jour;
|
// });
|
// //添加行程按钮显示
|
// $rootScope.show_add_jour();
|
// }
|
//添加已选人员
|
$scope.add_user = function(user, event) {
|
if(!user.state){//若为“-” 则执行删除
|
$scope.remove_user(user);
|
return false;
|
}
|
if($scope.users_selected.length == 0){//只能选择一个人员
|
if(user.orgName == undefined){
|
get_orgname(user,$scope.hr_data_str);
|
}
|
var department_filter = _.filter($scope.departments_selected, function(_department) {
|
return _department.orgName === user.orgName;
|
});
|
if(!!!department_filter.length) {
|
$scope.departments_selected.push({
|
"orgName": user.orgName,
|
"user_info": []
|
});
|
}
|
for(i in $scope.departments_selected) {
|
if($scope.departments_selected[i].orgName == user.orgName) {
|
var user_filter = _.filter($scope.departments_selected[i].user_info, function(_user) {
|
return _user.personCode === user.personCode;
|
});
|
if(!!!user_filter.length) {
|
$scope.departments_selected[i].user_info.push(user);
|
}
|
}
|
}
|
var user_filter = _.filter($scope.users_selected, function(_user) {
|
return _user.personCode === user.personCode;
|
});
|
if(!!!user_filter.length) {
|
$scope.users_selected.push(user);
|
}
|
user.state = false;
|
$scope.item.render_value = user.personCode;
|
|
//匹配控件 并进行公式计算
|
_.each($scope.$parent.formula,function(formula){
|
// _.each(formula.child,function(_formula){
|
// if(formula.mathFormat != "select"){//排除无效公式
|
formula_computing(formula,user.personCode,$scope.item,$scope.parentitem);
|
// }
|
// });
|
});
|
|
$scope.close();
|
}
|
$rootScope.change_apmonut($scope.item);
|
|
$rootScope.check_bill_user();//验证报销人信息
|
};
|
$scope.remove_user = function(user_info) {
|
if($scope.item == $scope.parentitem && $scope.type == 30){
|
$rootScope.clear_apply();
|
}
|
if(user_info.orgName == undefined){
|
get_orgname(user_info,$scope.hr_data_str);
|
}
|
_.each($scope.users_selecting,function(user){
|
user[0].state = true;
|
})
|
for(i in $scope.users_selecting_cache) {
|
var data = $scope.users_selecting_cache[i];
|
for(m in data) {
|
if(data[m].personCode == user_info.personCode) {
|
data[m].state = true;
|
}
|
}
|
}
|
for(i in $scope.departments_selected) {
|
if(user_info.orgName == $scope.departments_selected[i].orgName) {
|
for(m in $scope.departments_selected[i].user_info) {
|
if($scope.departments_selected[i].user_info[m].personCode == user_info.personCode) {
|
$scope.departments_selected[i].user_info.splice(m, 1);
|
if($scope.departments_selected[i].user_info.length == 0) {
|
$scope.departments_selected.splice(i, 1);
|
}
|
}
|
}
|
}
|
}
|
for(i in $scope.users_selected) {
|
if($scope.users_selected[i].personCode == user_info.personCode) {
|
$scope.users_selected.splice(i, 1);
|
}
|
}
|
$scope.item.render_value = "";
|
$rootScope.check_bill_user();//验证报销人信息
|
};
|
$scope.remove_department = function(user) {
|
for(i in $scope.departments_selected) {
|
if($scope.departments_selected[i] == user) {
|
$scope.departments_selected.splice(i, 1);
|
}
|
}
|
var arr = [];
|
for(i in $scope.users_selected) {
|
if($scope.users_selected[i].orgName != user.orgName) {
|
arr.push($scope.users_selected[i]);
|
}
|
}
|
$scope.users_selected = arr;
|
for(i in $scope.users_selecting) {
|
if($scope.users_selecting[i][0].orgName == user.orgName) {
|
$scope.users_selecting[i][0].state = true;
|
}
|
}
|
};
|
$scope.show_department = function(event) {
|
var event = window.event || event;
|
if(event.target.getAttribute("dep_show") == "true") {
|
event.target.nextSibling.style.display = "none";
|
event.target.setAttribute("dep_show", false);
|
} else {
|
event.target.nextSibling.style.display = "block";
|
event.target.setAttribute("dep_show", true);
|
}
|
|
}
|
$scope.show_department = function(event) {
|
var event = window.event || event;
|
if(event.target.getAttribute("dep_show") == "true") {
|
event.target.nextSibling.style.display = "none";
|
event.target.setAttribute("dep_show", false);
|
} else {
|
event.target.nextSibling.style.display = "block";
|
event.target.setAttribute("dep_show", true);
|
}
|
|
}
|
$scope.init_tree = function() {
|
$scope.user_filter = "";
|
http_service.post('base/data/search/institutionData', {}, function(res) {
|
if(res.data.opState){
|
$scope.hr_data_str = res.data.data;
|
var hr_data_str = JSON.stringify(res.data.data).replace(/child/g, 'children').replace(/orgName/g, 'name');
|
var hr_data_json = JSON.parse(hr_data_str);
|
var setting = {
|
'callback': {
|
'onClick': function(event, treeId, treeNode) {
|
var orgName = treeNode.name;
|
var md_id = treeNode.orgCode;
|
if(md_id) {
|
http_service.post('base/data/search/personData', { 'perOrgCode': md_id }, function(res) {
|
var users = res.data.data;
|
_.each(users, function(user) {
|
if($scope.users_selected.length > 0 && $scope.users_selected[0].personCode == user.personCode){
|
_.extend(user, { 'orgName': orgName, "state": false });
|
}else{
|
_.extend(user, { 'orgName': orgName, "state": true });
|
}
|
});
|
if(users && users.length) {
|
var grouped_users = _.groupBy(users, function(user) {
|
// return user.pdFirstName;
|
return user.perFirstName;
|
});
|
$scope.users_selecting_cache = grouped_users;
|
} else {
|
$scope.users_selecting_cache = {}
|
}
|
$scope.user_filter_func();
|
});
|
}
|
}
|
}
|
};
|
$.fn.zTree.init($("div.hr_tree"), setting, hr_data_json);
|
var treeObj = $.fn.zTree.getZTreeObj("tree");
|
treeObj.expandAll(true);
|
}else{
|
$scope.$parent.$parent.$parent.$parent.$parent.terro(res.data.errMsg)
|
}
|
|
});
|
|
|
}
|
var per_num = 0;
|
// if($scope.$parent.isbill == "false"){
|
// per_num = 1;
|
// }else{
|
// per_num = 0;
|
// }
|
$scope.$watch(function(){// 用于保存过去信息
|
return $scope.users_selected;
|
},function(){
|
if($scope.users_selected != undefined && $scope.users_selected.length != 0){
|
$scope.item['old_users_selected'] = $scope.users_selected;
|
}
|
})
|
$scope.$watch(function() { return $scope.item.render_value }, function() {
|
|
if($rootScope.stepCode == undefined || ($rootScope.stepCode != 30 && $rootScope.stepCode != 10)){
|
if($scope.item.render_value) {
|
per_num++;
|
var arr = [$scope.item.render_value]
|
http_service.post('base/data/search/personData', { "personCode": arr[0] }, function(res) {
|
$scope.users_selected = res.data.data;
|
$timeout(function(){//用于检测显示是否完全
|
$scope.item['inited'] = true;
|
},1);
|
if($scope.users_selected.length != 0){//非空验证
|
|
myServeice.setpd($scope.parentitem, $scope.users_selected, $scope.type);
|
http_service.post('base/data/search/institutionData', {}, function(res) {
|
console.log('5555555555');
|
var users = $scope.users_selected;
|
var orgs = res.data.data[0].child;
|
var orgName;
|
_.each(orgs,function(org){
|
if(org.orgCode == users[0].perOrgCode){
|
orgName = org.orgName;
|
}
|
})
|
$scope.departments_selected = [{ "orgName": orgName, "user_info": [$scope.users_selected[0]] }];
|
_.each(users, function(user) {
|
if(user.personCode != $scope.users_selected[0].personCode) {
|
_.extend(user, { 'orgName': orgName, "state": true });
|
} else {
|
_.extend(user, { 'orgName': orgName, "state": false });
|
}
|
|
});
|
if(users && users.length) {
|
var grouped_users = _.groupBy(users, function(user) {
|
// return user.pdFirstName;
|
return user.perFirstName;
|
});
|
$scope.users_selecting_cache = grouped_users;
|
} else {
|
$scope.users_selecting_cache = {}
|
}
|
$scope.user_filter_func();
|
});
|
}
|
//匹配控件 并进行公式计算 无论请求返回是否为空 都要进行公式计算
|
_.each($scope.$parent.formula,function(formula){
|
formula_computing(formula,$scope.item.render_value,$scope.item,$scope.parentitem);
|
});
|
});
|
// $scope.users_selected = [{
|
// "personCode": "1001",
|
// "perFirstName": "Z",
|
// "orgName": "总务部",
|
// "perOrgCode": "001",
|
// "state": false,
|
// "personName": "张总"
|
// }];
|
|
}else{
|
$timeout(function(){//用于检测显示是否完全
|
$scope.item['inited'] = true;
|
},1);
|
}
|
}else{
|
$timeout(function(){//用于检测显示是否完全
|
$scope.item['inited'] = true;
|
},1);
|
if($scope.item.old_users_selected != undefined){
|
$scope.users_selected = $scope.item.old_users_selected;
|
}
|
}
|
|
|
});
|
// var timer = setInterval(function(){
|
// if($scope.item.render_value){
|
// var arr = [$scope.item.render_value]
|
//// http_service.post('personnel/search/personns', { "pdIds": arr }, function(res) {
|
//// $scope.users_selected = res.data.data;
|
//// });
|
// $scope.users_selected = [{"code": "1001",
|
// "firstName": "Z",
|
// "group_name": "总务部",
|
// "perOrgCode": "001",
|
// "state": false,
|
// "value": "张总"}];
|
// $scope.departments_selected = [{"group_name":$scope.users_selected[0].group_name,"user_info":[$scope.users_selected[0]]}];
|
// http_service.post('base/data/search/personData', {'perOrgCode': $scope.users_selected[0].perOrgCode}, function(res){
|
// var users = res.data.data;
|
// _.each(users, function(user){
|
// if(user.code != $scope.users_selected[0].code){
|
// _.extend(user, {'group_name': $scope.users_selected[0].group_name,"state":true});
|
// }else{
|
// _.extend(user, {'group_name': $scope.users_selected[0].group_name,"state":false});
|
// }
|
//
|
// });
|
// if(users && users.length){
|
// var grouped_users = _.groupBy(users, function(user){
|
//// return user.pdFirstName;
|
// return user.firstName;
|
// });
|
// $scope.users_selecting_cache = grouped_users;
|
// }else{
|
// $scope.users_selecting_cache = {}
|
// }
|
// $scope.user_filter_func();
|
// });
|
// clearInterval(timer);
|
// }
|
// },10);
|
}
|
}
|
}])
|
.directive('orgSelector', ['$rootScope', 'http_service', '$compile', '$timeout', 'myServeice', function($rootScope, http_service, $compile, $timeout, myServeice) {
|
return {
|
restrict: 'EACM',
|
scope: {
|
item: '=',
|
parentitem: '=',
|
type: '='
|
},
|
template: '<div class="user_element">' +
|
'<label>' +
|
'{{item.gcCpnAlias}}' +
|
'</label>' +
|
'<span name="user_el_content" gcColName="{{item.gcColName}}" org_selected="{{item.render_value}}">' +
|
'<span class="user_name" ng-repeat="org in org_selected" >' +
|
'{{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>' +
|
'</span>' +
|
' <a class="btn_user_el_add_user" href="javascript:void(0);" ng-click="select_org($event);" >选择组织机构</a>' +
|
'</span>' +
|
'</div>',
|
replace: true,
|
controller: ['$scope', '$element', function($scope, $element) {
|
$scope.org_selected = [];
|
|
$scope.select_org = function(e) {
|
$('div[name="org_select_popup"]').remove();
|
var activeclass = "{true:'hr_name',false:'hr_name_selected'}[user.state]";
|
var pop_element = $('<div' +
|
' name="org_select_popup"' +
|
' class="org_select_popup col-md-12"' +
|
'onMouseOver ="$(this).draggable();event.stopPropagation();"' +
|
'>' +
|
'<div class="org_sel_form">' +
|
'<div class="row btn_cls org_sel_form_close">' +
|
'<a ng-href="javascript:void(0);"><i class="fa fa-times main_close" aria-hidden="true" ng-click="close();"></i></a>' +
|
'</div>' +
|
'<div class="hr_tree left ztree" style="overflow:auto;">' + '</div>' +
|
'<div class="right">' +
|
'<div class="right_area">' +
|
'<div class="area_title selected_personnel">' +
|
'<label>已选人员</label>' +
|
'<span class="float_right">' +
|
'<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>' +
|
'</span>' +
|
'</div>' +
|
|
'<div class="area_body">' +
|
'<ul>'+
|
'<li ng-repeat="org in org_selected">'+
|
'<div class="area_content">'+
|
'<a class="hr_name" ng-href="javascript:void(0);" href="javascript:void(0);">{{org.orgName}}</a>'+
|
'<button class="hr_name_addbtn" ng-click="remove_org(org);">-</button>'+
|
'</div>'+
|
'</li>'+
|
'</ul>'+
|
'</div>' +
|
'</div>' +
|
'</div>' +
|
'</div>' +
|
'</div>');
|
$($element).append(pop_element);
|
$compile(pop_element)($scope);
|
$scope.init_tree();
|
var form_el_div = $($element).closest('div.sub_form_container').children('div').not('[name="journel_budget"]');
|
e.stopPropagation();
|
};
|
}],
|
link: function($scope, element, attrs) {
|
$scope.stop_prg = function(event) {
|
event.stopPropagation();
|
};
|
|
$scope.close = function() {
|
$('div[name="org_select_popup"]').remove();
|
myServeice.setpd($scope.parentitem, $scope.users_selected, $scope.type);
|
// $scope.query_journel_budget();
|
};
|
//清除选择
|
$scope.clear_org = function(){
|
$scope.org_selected = [];
|
$scope.item.render_value = "";
|
}
|
//选择组织机构
|
$scope.add_org = function(orgName, orgCode) {
|
var org_selecting = {
|
"orgName":orgName,
|
"orgCode":orgCode
|
};
|
var push_flag = true;
|
|
_.each($scope.org_selected,function(_org){
|
if(_org.orgCode == org_selecting.orgCode){
|
push_flag = false;
|
}
|
});
|
if(push_flag){
|
$scope.org_selected.push(org_selecting);
|
var selected_code = [];
|
_.each($scope.org_selected,function(_org){
|
selected_code.push(_org.orgCode);
|
});
|
$scope.item.render_value = selected_code.join(",");
|
}
|
};
|
$scope.remove_org = function(org) {
|
_.remove($scope.org_selected,function(n){
|
return n == org;
|
});
|
var selected_code = [];
|
_.each($scope.org_selected,function(_org){
|
selected_code.push(_org.orgCode);
|
});
|
$scope.item.render_value = selected_code.join(",");
|
};
|
function get_org(data,arr){
|
_.each(data,function(_data){
|
if(_data.orgCode == arr){
|
$scope.org_selected.push({
|
"orgName":_data.orgName,
|
"orgCode":_data.orgCode
|
})
|
}
|
});
|
if(data.child){
|
get_org(data.child,arr);
|
}
|
}
|
$scope.init_tree = function() {
|
http_service.post('base/data/search/institutionData', {}, function(res) {
|
if(res.data.opState){
|
console.log(111111111);
|
var hr_data_str = JSON.stringify(res.data.data).replace(/child/g, 'children').replace(/orgName/g, 'name');
|
var hr_data_json = JSON.parse(hr_data_str);
|
// if($scope.item.render_value && $scope.item.render_value != ""){
|
// var org_arr = $scope.item.render_value.split(",");
|
// _.each(org_arr,function(_arr){
|
// _.each(res.data.data,function(data){
|
// get_org(data.child,_arr);
|
// })
|
// })
|
// }
|
var setting = {
|
'callback': {
|
'onClick': function(event, treeId, treeNode) {
|
var orgName = treeNode.name;
|
var md_id = treeNode.orgCode;
|
if(treeNode.level > 0){
|
$scope.add_org(orgName,md_id);
|
}
|
}
|
}
|
};
|
console.log('1113');
|
$.fn.zTree.init($("div.hr_tree"), setting, hr_data_json);
|
}else{
|
$scope.$parent.$parent.$parent.$parent.$parent.terro(res.data.errMsg)
|
}
|
|
});
|
}
|
$scope.init_org = function(){
|
http_service.post('base/data/search/institutionData', {}, function(res) {
|
console.log('666666');
|
if(res.data.opState){
|
if($scope.item.render_value && $scope.item.render_value != ""){
|
var org_arr = $scope.item.render_value.split(",");
|
_.each(org_arr,function(_arr){
|
_.each(res.data.data,function(data){
|
get_org(data.child,_arr);
|
})
|
})
|
}
|
}
|
});
|
};
|
$scope.init_org();
|
}
|
}
|
}])
|
.directive('savedForm', ['$rootScope', 'http_service', '$location', '$compile', 'myServeice', '$timeout','$interval', function($rootScope, http_service, $location, $compile, myServeice, $timeout,$interval) {
|
return {
|
restrict: 'EACM',
|
templateUrl: './static/templates/saved_form.html?v=201801031718',
|
scope: {
|
business: '=',
|
type: '=',
|
templateid: '=',
|
action: '=',
|
isbill: '@',
|
billid: '=',
|
edit: '=',
|
btnflag: "=",
|
unedit:"=",
|
isguide:"="
|
},
|
compile: function() {
|
return {
|
pre: function($scope, element, attrs, controller) {
|
/*
|
http_service.get('http://apis.map.qq.com/ws/district/v1/list?key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77', function(res){
|
});
|
*/
|
if($rootScope.update_speical != undefined){//系统变量公式监听初始化
|
$rootScope.update_speical();
|
}
|
$rootScope.update_speical = undefined;
|
if($rootScope.update_speical_formula != undefined){//前端公式监听初始化
|
$rootScope.update_speical_formula();
|
}
|
$rootScope.update_speical_formula = undefined;
|
$rootScope.save_form_uid = _.uuid();
|
$scope.sys_num_check = 0;
|
$rootScope.formula_num = 0;
|
$rootScope.formula_num_id = [];//查询详情时初始化需要进行请求的前端公式 计数变量
|
$rootScope.close_lock = false;//初始化关闭状态
|
$scope.sysSearchFinsh = undefined;
|
$rootScope.stepCode = undefined// 初始化流程状态
|
$rootScope.version = undefined//初始化版本号
|
$rootScope.lock = undefined//锁头初始化
|
$scope.maindata_err_sys = [];
|
myServeice.setpd("", "", "");
|
$scope.test = "disabled";
|
$scope.cost_err = [];
|
$rootScope.budget_selected = "";//初始化选择的预算 的单号
|
$rootScope.expend_number_info = "";//初始化选择的申请 的单号
|
$scope.tap_type = 10;//默认显示子表单选项卡
|
//切换选项卡
|
$scope.toggle_tap = function(tap_type){
|
$scope.tap_type = tap_type;
|
}
|
//去除空白
|
$scope.form_show = function(item){
|
var show_flag = true;
|
if(item.gcCpnType == 10 && item.gcCpnType != $scope.tap_type){
|
show_flag = false;
|
}
|
if(item.gcCpnType == 17 && item.gcCpnType != $scope.tap_type){
|
show_flag = false;
|
}
|
return show_flag;
|
}
|
//数据校验
|
$scope.check_data = function(edit){
|
// if(edit){
|
// $scope.$parent.checkdata();
|
// }
|
}
|
//改变字的颜色
|
$scope.changclass = function(item,_item){
|
var thisval;
|
var classname;
|
_.each(item.money,function(money){
|
if(money.jp_cd_code == _item.gcMeCode){
|
thisval = money.jp_amount;
|
if(parseFloat(thisval) > parseFloat(_item.render_value) || _item.render_value == ""){
|
classname = "jp_normal";
|
}else{
|
classname = "jp_active";
|
}
|
}
|
})
|
return classname;
|
}
|
//绑定input的value值
|
$scope.input_change = function(item,event){
|
item['render_value'] = $(event).val();
|
}
|
$scope.enable_templates = function(business, type, guId, action) {
|
http_service.post('template/cpn/search', { "gcTempId": guId }, function(res) {
|
var templates = res.data.data;
|
res.data.data.cache_id = res.data.data.guTempType;
|
var tempdata = _.extend(res.data.data,{'gcStart':1})
|
if(templates) {
|
http_service.post('form/save', tempdata, function(res) {
|
if(res.data.opState) {
|
$rootScope.swalsuccess({
|
"text": "模板启用成功!"
|
}, function() {
|
$timeout(function() {
|
$scope.redirect_to_args('budget_froms', type);
|
}, 1)
|
});
|
} else {
|
$rootScope.swalerror({ "text": "模板启用失败!" })
|
}
|
})
|
}
|
});
|
}
|
//按公式计算结果
|
function count_by_formula(formula,code_arr,child_num){
|
var formula_str;
|
if(child_num != undefined){
|
var sum = 0;
|
var is_count = false;
|
for(i=0;i<child_num;i++){
|
formula_str = formula.mCount;
|
_.each(code_arr,function(code,j){
|
var restr = "{"+(j+1)+"}";
|
if(_.isArray(code.value)){
|
var val_code = code.value[i];
|
if(_.isNumber(val_code)){
|
formula_str = formula_str.replace(restr,val_code);
|
}else{
|
if(val_code != 0 && val_code !== "" && val_code != undefined){
|
if(val_code.indexOf("-") != -1){
|
var datestr = "'"+val_code+"'";
|
formula_str = formula_str.replace(restr,datestr);
|
}else{
|
formula_str = formula_str.replace(restr,code.value[i]);
|
}
|
}else{
|
formula_str = formula_str.replace(restr,code.value[i]);
|
}
|
|
}
|
|
}else{
|
var val_code = code.value;
|
if(_.isNumber(val_code)){
|
formula_str = formula_str.replace(restr,code.value);
|
}else{
|
if(val_code != 0 && val_code !== "" && val_code != undefined){
|
if(val_code.indexOf("-") != -1){
|
var datestr = "'"+code.value+"'";
|
formula_str = formula_str.replace(restr,datestr);
|
}else{
|
formula_str = formula_str.replace(restr,code.value);
|
}
|
}else{
|
formula_str = formula_str.replace(restr,code.value);
|
}
|
}
|
}
|
})
|
if(formula_str.indexOf("{") != -1){
|
sum = NaN;
|
}else{
|
if(formula.mResultFromat){
|
var formula_result = eval(formula_str);
|
var val = formula_result;
|
var result_str = formula.mResultFromat.replace("{val}","("+formula_result+")");
|
if(_.isNaN(eval(result_str)) == false){
|
is_count = true;
|
sum += eval(result_str);
|
}
|
}else{
|
if(_.isNaN(eval(formula_str)) == false){
|
is_count = true;
|
sum += eval(formula_str);
|
}
|
}
|
// if(formula_str.indexOf("toFixed") != -1){
|
// sum += Number(eval(formula_str));
|
// }else{
|
// sum += eval(formula_str);
|
// }
|
}
|
}
|
if(is_count){
|
if(_.isNumber(sum)){
|
return sum;
|
}else{
|
sum = sum.substring(1);
|
return sum;
|
}
|
}else{
|
return NaN;
|
}
|
|
}else{
|
formula_str = formula.mCount;
|
_.each(code_arr,function(code,i){
|
var restr = "{"+(i+1)+"}";
|
if(code.isDate){
|
var datestr = "'"+code.value+"'";
|
formula_str = formula_str.replace(restr,datestr);
|
}else{
|
formula_str = formula_str.replace(restr,code.value);
|
}
|
|
})
|
if(formula_str.indexOf("{") != -1){
|
return NaN
|
}else{
|
if(formula.mResultFromat){
|
var formula_result = eval(formula_str);
|
var result_str = formula.mResultFromat.replace("{val}","("+formula_result+")");
|
return eval(result_str);
|
}else{
|
return eval(formula_str);
|
}
|
}
|
|
}
|
}
|
//公式计算
|
function formula_computing(formula,form_items){
|
if($scope.stepCode == 30 || $scope.stepCode == 10){// 已完成/审核中 表单 不计算
|
return false;
|
}
|
//判断公式应用于哪个表单
|
// var travelType = formula.travelType;//获取公对应的表单
|
// var account_flag =false;//控制是否计算
|
// if(travelType == $scope.type){
|
// account_flag = true;
|
// }else if(travelType == 0){
|
// account_flag = true;
|
// }
|
// if(account_flag == false){
|
// return false;
|
// }
|
//解析公式
|
var code_arr = [];
|
var target_code;
|
_.each(formula.child,function(_formula,i){
|
|
if(i == 0){//获取被关联控件的主数据code
|
target_code = _formula['pMdCode'];
|
}else{
|
code_arr.push(_formula);
|
}
|
});
|
//排除既为结果 又为条件的公式
|
// if(item.gcMeCode == target_code){
|
// return false;
|
// }
|
_.each($scope.form_items,function(item){
|
if(item.gcCpnType != 10 && item.gcCpnType != 17){
|
if(item.gcMeCode == target_code){
|
if(item.gcCpnType == 12){//人员关联公式 不计算
|
return false;
|
}
|
var child_num,child_num_pay;
|
var is_normal_child = true;//普通子表单
|
var is_select = false;
|
_.each(code_arr,function(code){
|
var is_child = true;
|
_.each(form_items,function(_item){
|
if(code.pMdCode == _item.gcMeCode){
|
is_child = false;
|
if(_item.render_value != undefined && _item.render_value !== ""){
|
if(_item.gcCpnType == 7){
|
_.extend(code,{"value":Number(_item.render_value)});
|
}else if(_item.gcCpnType == 5){
|
_.extend(code,{"value":_item.render_value,"isDate":true});
|
}
|
else if((_item.gcCpnType == 6 || _item.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}
|
else{
|
_.extend(code,{"value":_item.render_value});
|
}
|
}else{
|
if(_item.gcCpnType == 7){
|
_.extend(code,{"value":0});
|
}else if(_item.gcCpnType == 5){
|
_.extend(code,{"value":code.pDefVal,"isDate":true});
|
}else if(_item.gcCpnType == 6){
|
// is_select = true;
|
}else{
|
_.extend(code,{"value":""});
|
}
|
}
|
}
|
})
|
if(is_child){
|
child_num = 0;
|
child_num_pay = 0;
|
var all_sum = [];
|
var is_Number = false;
|
_.each(form_items,function(_forms){
|
if(_forms.gcCpnType == 10){
|
child_num++;
|
_.each(_forms.child,function(_cd){
|
if(_cd.gcMeCode == code.pMdCode){
|
if((_cd.gcCpnType == 6 || _cd.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}
|
if(_cd.render_value != undefined && _cd.render_value !== ""){
|
if(_cd.gcCpnType == 7){
|
is_Number = true;
|
all_sum.push(Number(_cd.render_value));
|
}else{
|
all_sum.push(_cd.render_value);
|
}
|
}else{
|
if(_cd.gcCpnType == 7){
|
is_Number = true;
|
all_sum.push(0);
|
}else{
|
all_sum.push(code.pDefVal);
|
}
|
}
|
}
|
});
|
}else if(_forms.gcCpnType == 17){
|
child_num_pay++;
|
_.each(_forms.child,function(_cd){
|
if(_cd.gcMeCode == code.pMdCode){
|
is_normal_child = false;
|
if((_cd.gcCpnType == 6 || _cd.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}
|
if(_cd.render_value != undefined && _cd.render_value !== ""){
|
if(_cd.gcCpnType == 7){
|
is_Number = true;
|
all_sum.push(Number(_cd.render_value));
|
}else{
|
all_sum.push(_cd.render_value);
|
}
|
}else{
|
if(_cd.gcCpnType == 7){
|
is_Number = true;
|
all_sum.push(0);
|
}else{
|
all_sum.push(code.pDefVal);
|
}
|
}
|
}
|
});
|
}
|
});
|
if(is_Number){
|
_.extend(code,{"value":all_sum,"isNumber":true});
|
}else{
|
_.extend(code,{"value":all_sum});
|
}
|
}
|
});
|
//计算结果
|
var goal;
|
if(is_select == false){
|
if(child_num != undefined && child_num_pay != undefined){
|
if(is_normal_child){
|
goal = count_by_formula(formula,code_arr,child_num);
|
}else{
|
goal = count_by_formula(formula,code_arr,child_num_pay);
|
}
|
|
}else{
|
goal = count_by_formula(formula,code_arr);
|
}
|
if(_.isNaN(goal) == false){
|
$timeout(function(){
|
item.render_value = goal;
|
$scope.change_apmonut(item);
|
},1)
|
}
|
|
}
|
}
|
}else{
|
_.each(item.child,function(cd){
|
if(cd.gcMeCode == target_code){
|
if(cd.gcCpnType == 12){//人员关联公式 不计算
|
return false;
|
}
|
var is_select = false;
|
_.each(code_arr,function(code){
|
var in_child = false;
|
_.each(item.child,function(_cd){
|
if(code.pMdCode == _cd.gcMeCode){
|
in_child = true;
|
if(_cd.render_value != undefined && _cd.render_value !== ""){
|
if(_cd.gcCpnType == 7){
|
_.extend(code,{"value":Number(_cd.render_value)});
|
}else if(_cd.gcCpnType == 5){
|
_.extend(code,{"value":_cd.render_value,"isDate":true});
|
}
|
else if((_cd.gcCpnType == 6 || _cd.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}
|
else{
|
_.extend(code,{"value":_cd.render_value});
|
}
|
}else{
|
if(_cd.gcCpnType == 7){
|
_.extend(code,{"value":0});
|
}else if(_cd.gcCpnType == 5){
|
_.extend(code,{"value":code.pDefVal,"isDate":true});
|
}else if((_cd.gcCpnType == 6 || _cd.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}else{
|
_.extend(code,{"value":""});
|
}
|
}
|
}
|
});
|
if(in_child == false){
|
_.each(form_items,function(_form){
|
if(_form.gcMeCode == code.pMdCode){
|
if(_form.render_value != undefined && _form.render_value !== ""){
|
if(_form.gcCpnType == 7){
|
_.extend(code,{"value":Number(_form.render_value)});
|
}else if(_form.gcCpnType == 5){
|
_.extend(code,{"value":_form.render_value,"isDate":true});
|
}
|
else if((_form.gcCpnType == 6 || _form.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}
|
else{
|
_.extend(code,{"value":_form.render_value});
|
}
|
|
}else{
|
if(_form.gcCpnType == 7){
|
_.extend(code,{"value":0});
|
}else if(_form.gcCpnType == 5){
|
_.extend(code,{"value":code.pDefVal,"isDate":true});
|
}
|
else if((_form.gcCpnType == 6 || _form.gcCpnType == 12) && code_arr.length == 1){
|
is_select = true;
|
}
|
else{
|
_.extend(code,{"value":""});
|
}
|
}
|
}
|
});
|
}
|
});
|
|
//计算结果
|
if(is_select == false){
|
var goal = count_by_formula(formula,code_arr);
|
if(_.isNaN(goal) == false){
|
// $timeout(function(){
|
cd.render_value = goal;
|
$scope.change_apmonut(cd,item);
|
// },10)
|
}
|
}
|
}
|
})
|
}
|
|
})
|
}
|
$scope.formula_computing = function(formula,form_items){
|
formula_computing(formula,form_items);
|
}
|
//子表单按时间排序
|
function sort_fun(a,b){
|
console.log('-------1111------');
|
console.log(a);
|
console.log(b);
|
if(a.time_type.length > 10 && b.time_type.length > 10){
|
console.log('----------:if');
|
return a.time - b.time;
|
}else if(a.time_type.substring(0,10) == b.time_type.substring(0,10)){
|
console.log('--------------:else if');
|
var from_code,to_code;
|
_.each(filed,function(_filed){
|
switch(_filed.busCode){
|
case "From":
|
from_code = _filed.mdCode;
|
break;
|
case "To":
|
to_code = _filed.mdCode;
|
break;
|
}
|
})
|
var a_from,a_to,b_from,b_to;
|
_.each(a.jour.child,function(cd){
|
console.log('each1');
|
console.log('cd.gcMeCode'+cd.gcMeCode);
|
console.log('from_code'+from_code);
|
if(cd.gcMeCode == from_code){
|
a_from = cd.render_value;
|
}else if(cd.gcMeCode == to_code){
|
a_to = cd.render_value;
|
}
|
console.log('a_from'+a_from);
|
console.log('a_to'+a_to);
|
})
|
_.each(b.jour.child,function(cd){
|
console.log('each2');
|
console.log('cd.gcMeCode'+cd.gcMeCode);
|
console.log('from_code'+from_code);
|
if(cd.gcMeCode == from_code){
|
b_from = cd.render_value;
|
}else if(cd.gcMeCode == to_code){
|
b_to = cd.render_value;
|
}
|
console.log('b_from'+b_from);
|
console.log('b_to'+b_to);
|
})
|
if(a_from != "" && a_from != undefined && b_from != "" && b_from != undefined && a_to != "" && a_to != undefined && b_to != "" && b_to != undefined){
|
if(a_from == b_to){
|
return -1;
|
}else if(a_to == b_from){
|
return 1;
|
}else{
|
return 0;
|
}
|
}else{
|
return 0;
|
}
|
}else{
|
console.log('--------------:else');
|
return a.time - b.time;
|
}
|
}
|
function sort_bytime(item){
|
var formDate,toDate;
|
_.each(filed,function(_filed){
|
switch (_filed.busCode){
|
case 'FromDate':
|
formDate = _filed.mdCode;
|
break;
|
case 'ToDate':
|
toDate = _filed.mdCode;
|
break;
|
}
|
});
|
|
|
|
if(item != undefined){
|
if(item.gcMeCode != formDate && item.gcMeCode != toDate){
|
return false;
|
}
|
}
|
var new_jour = [];
|
var oder_index = [];
|
console.log('-------1114------');
|
console.log($scope.form_items);
|
_.each($scope.form_items,function(form,i){
|
if(form.gcCpnType == 10){
|
var date_flag = true;
|
_.each(form.child,function(cd){
|
var sort_time;
|
if(cd.gcMeCode == formDate){
|
console.log('----------cd.gcMeCode:'+cd.gcMeCode);
|
console.log('----------formDate:'+formDate);
|
date_flag = false;
|
sort_time = $rootScope.getNewDate(cd.render_value);
|
if(cd.render_value == ''){
|
sort_time = undefined;
|
}
|
new_jour.push({'jour':_.cloneDeep(form),'time':sort_time,"time_type":cd.render_value});
|
oder_index.push(i);
|
}
|
})
|
if(date_flag){//没有出发日期则找到达日期
|
_.each(form.child,function(cd){
|
var sort_time;
|
console.log('cd.render_value:'+cd.render_value);
|
if(cd.gcMeCode == toDate){
|
sort_time = $rootScope.getNewDate(cd.render_value);
|
console.log('sort_time:'+sort_time);
|
if(cd.render_value == ''){
|
sort_time = undefined;
|
}
|
console.log(new_jour);
|
new_jour.push({'jour':_.cloneDeep(form),'time':sort_time,"time_type":cd.render_value});
|
console.log(oder_index);
|
oder_index.push(i);
|
}
|
});
|
}
|
}
|
});
|
new_jour.sort(sort_fun);
|
console.log('-------1117------');
|
console.log(new_jour);
|
$rootScope.new_jour = new_jour;
|
// new_jour = _.sortBy(new_jour,function(o){
|
// return o.time;
|
// })
|
$timeout(function(){
|
|
_.each(oder_index,function(index,k){
|
$scope.form_items[index] = new_jour[k].jour;
|
})
|
$scope.count_number()//计算子表单序号
|
show_other_cost()//其它费用提示(必须在排序后)
|
},1)
|
}
|
$rootScope.sort_bytime = function(item){
|
sort_bytime(item);
|
}
|
|
function sys_formula_data(condition_code,target_ischild,child_item){//递归 从控件上取值
|
if(target_ischild){
|
_.each($scope.form_items,function(form){
|
if(form == child_item){
|
_.each(condition_code,function(cond){
|
if(cond.joinMathId && cond.systemMathEntity){
|
return sys_formula_data(cond.systemMathEntity.child,target_ischild,child_item);
|
}else{
|
_.each(form.child,function(cd){
|
if(cd.gcMeCode == cond.mdCode){
|
cond['val'] = cd.render_value;
|
}
|
})
|
}
|
});
|
_.each(condition_code,function(cond){
|
if(cond.joinMathId && cond.systemMathEntity){
|
return sys_formula_data(cond.systemMathEntity.child,target_ischild,child_item);
|
}else{
|
_.each($scope.form_items,function(_form){
|
if(_form.gcMeCode == cond.mdCode){
|
cond['val'] = _form.render_value;
|
}
|
})
|
}
|
});
|
}
|
})
|
}else{
|
_.each(condition_code,function(cond){
|
if(cond.joinMathId && cond.systemMathEntity){
|
return sys_formula_data(cond.systemMathEntity.child,target_ischild,child_item);
|
}else{
|
_.each($scope.form_items,function(_form){
|
if(_form.gcMeCode == cond.mdCode){
|
cond['val'] = _form.render_value;
|
}
|
})
|
}
|
});
|
}
|
return condition_code;
|
}
|
function sys_formula_post(condition_code,post_data){//递归获得 请求参数
|
_.each(condition_code,function(cond){
|
if(cond.joinMathId && cond.systemMathEntity){
|
post_data.values.push({
|
'countCpnMath':{"mathId":cond.joinMathId,"values":[]}
|
});
|
return sys_formula_post(cond.systemMathEntity.child,post_data.values[(post_data.values.length - 1)].countCpnMath);
|
}else{
|
if(cond.val != undefined && _.trim(cond.val) != ''){
|
post_data.values.push({"mdCode":cond.mdCode,"meVal":cond.val});
|
}
|
}
|
})
|
return post_data;
|
}
|
function sys_formula_computing(sys_formula,child_item,isfrist){
|
if($scope.stepCode == 30 || $scope.stepCode == 10){// 已完成/审核中 表单 不计算
|
return false;
|
}
|
if($scope.sysSearchFinsh == undefined && $scope.billid){
|
return false;
|
}
|
if($scope.sys_begin != undefined){
|
$scope.sys_begin++;
|
if($scope.sys_num_check <= $scope.sys_begin){
|
if(isfrist != true && $scope.edit != true){//编辑时 不拦截
|
return false;
|
}
|
}
|
}
|
function sys_formula_check(post_data){//检查请求参数 有无空值
|
if(post_data.values.length == 0){
|
post_flag = false
|
}
|
_.each(post_data.values,function(_data){
|
if(_data.countCpnMath){
|
return sys_formula_check(_data.countCpnMath);
|
}else{
|
if(_data.meVal == undefined || _.trim(_data) == ''){
|
post_flag = false
|
}
|
}
|
});
|
}
|
|
|
var condition_code = [];
|
_.each(sys_formula.formula.child,function(_formula){
|
condition_code.push(_formula);
|
});
|
var target_ischild = true;
|
var target_index;
|
if(child_item){
|
if(child_item.num == undefined || child_item.num == ""){
|
target_index = 0;
|
}else{
|
target_index = child_item.num - 1;
|
}
|
}
|
_.each($scope.form_items,function(form){
|
if(sys_formula.target == form.gcMeCode){
|
target_ischild = false;
|
}
|
});
|
condition_code = sys_formula_data(condition_code,target_ischild,child_item);
|
// if(target_ischild){
|
// _.each($scope.form_items,function(form){
|
// if(form == child_item){
|
// _.each(condition_code,function(cond){
|
// _.each(form.child,function(cd){
|
// if(cd.gcMeCode == cond.mdCode){
|
// cond['val'] = cd.render_value;
|
// }
|
// })
|
// });
|
// _.each(condition_code,function(cond){
|
// _.each($scope.form_items,function(_form){
|
// if(_form.gcMeCode == cond.mdCode){
|
// cond['val'] = _form.render_value;
|
// }
|
// })
|
// });
|
// }
|
// })
|
// }else{
|
// _.each(condition_code,function(cond){
|
// _.each($scope.form_items,function(_form){
|
// if(_form.gcMeCode == cond.mdCode){
|
// cond['val'] = _form.render_value;
|
// }
|
// })
|
// });
|
// }
|
|
var post_data = {
|
"mathId":sys_formula.mathId,
|
"values":[]
|
}
|
var post_flag = true;
|
// _.each(condition_code,function(cond){
|
// if(cond.val){
|
// post_data.values.push({"mdCode":cond.mdCode,"meVal":cond.val});
|
// }else{
|
// post_flag = false;
|
// }
|
// })
|
sys_formula_post(condition_code,post_data);
|
sys_formula_check(post_data);
|
|
var useful_length = 0;
|
|
_.each(sys_formula.formula.child,function(fcd){
|
if(fcd.mdCode != undefined){
|
_.each($scope.form_items,function(form){
|
if(form.gcMeCode == fcd.mdCode){
|
useful_length++;
|
}
|
});
|
if($scope.form_jour && $scope.form_jour.child){
|
_.each($scope.form_jour.child,function(jour){
|
if(jour.gcMeCode == fcd.mdCode){
|
useful_length++;
|
}
|
});
|
}
|
if($scope.form_pay && $scope.form_pay.child){
|
_.each($scope.form_pay.child,function(pay){
|
if(pay.gcMeCode == fcd.mdCode){
|
useful_length++;
|
}
|
})
|
}
|
}else{
|
useful_length++;
|
}
|
})
|
if(sys_formula.mathId == 38){
|
//
|
//
|
//
|
}
|
|
|
|
if(post_flag && useful_length == post_data.values.length){
|
//改变传值参数 开始
|
var post_data_real = getquery_pd();
|
if(target_ischild){
|
_.extend(post_data_real,{"index":target_index,"mathId":sys_formula.mathId});
|
}else{
|
var has_jour = false;
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
has_jour = true;
|
}
|
})
|
if(has_jour == false){
|
var empty_jour = _.cloneDeep($scope.form_jour);
|
_.each(empty_jour.child,function(ej){
|
ej.render_value = "";
|
})
|
post_data_real = getquery_pd(empty_jour);
|
_.extend(post_data_real,{"mathId":sys_formula.mathId});
|
}else{
|
_.extend(post_data_real,{"mathId":sys_formula.mathId});
|
}
|
}
|
//改变传值参数 结束
|
|
http_service.post("form/constCpn",post_data_real,function(res){
|
// if(res.data.data.defErr == undefined){
|
if(target_ischild){
|
_.each($scope.form_items,function(form){
|
if(form == child_item){
|
_.each(form.child,function(cd){
|
if(cd.gcMeCode == sys_formula.target && res.data.data.data != "NaN"){
|
if(res.data.data.data != undefined){
|
cd['sys_value'] = res.data.data.data;
|
}else{
|
cd['sys_value'] = "";
|
}
|
if(cd.gcEditFlag != 1){// 只有不可编辑或为空时 才填到控件中去
|
cd.render_value = res.data.data.data;
|
}else if(cd.render_value == undefined || _.trim(cd.render_value) == ""){
|
cd.render_value = res.data.data.data;
|
}
|
$scope.$watch(function(){
|
return cd.render_value;
|
},function(){
|
//
|
if(cd.sys_value != "" && cd.sys_value != undefined && cd.sys_value != cd.render_value){
|
cd['sys_red'] = true;
|
}else{
|
cd['sys_red'] = false;
|
}
|
})
|
$scope.change_apmonut(cd);
|
}
|
})
|
}
|
})
|
}else{
|
_.each($scope.form_items,function(form){
|
if(form.gcMeCode == sys_formula.target && res.data.data.data != "NaN"){
|
if(res.data.data.data != undefined){
|
form['sys_value'] = res.data.data.data;
|
}else{
|
form['sys_value'] = "";
|
}
|
if(form.gcEditFlag != 1) { // 只有不可编辑或为空时 才填到控件中去
|
form.render_value = res.data.data.data;
|
} else if(form.render_value == undefined || _.trim(form.render_value) == "") {
|
form.render_value = res.data.data.data;
|
}
|
$scope.$watch(function() {
|
return form.render_value;
|
}, function() {
|
if(form.sys_value != "" && form.sys_value != undefined && form.sys_value != form.render_value) {
|
form['sys_red'] = true;
|
} else {
|
form['sys_red'] = false;
|
}
|
})
|
$scope.change_apmonut(form);
|
}
|
})
|
}
|
if(res.data.data.defErr != undefined){
|
|
$scope.maindata_isright_sys = false;
|
if($scope.maindata_err_sys == undefined){
|
$scope.maindata_err_sys = [];
|
$scope.maindata_err_sys.push(res.data.data.defErr);
|
}else{
|
$scope.maindata_err_sys.push(res.data.data.defErr);
|
}
|
}
|
if(isfrist){
|
$scope.sys_num++;
|
}
|
},false,function(){
|
if(isfrist){
|
$scope.sys_num++;
|
}
|
})
|
}else{
|
if(isfrist){
|
$scope.sys_num++;
|
}
|
}
|
}
|
$rootScope.sys_formula_computing = function(sys_formula,child_item){
|
sys_formula_computing(sys_formula,child_item);
|
}
|
//绑定控件 计算总金额
|
$rootScope.change_apmonut = function(item){
|
$scope.change_apmonut(item)
|
}
|
$scope.change_apmonut = function(item,child_item){
|
eachMoney_check();//费用类型 金额验证
|
$scope.bill_data_check();//获取详情数据后 验证
|
|
|
|
//匹配控件 并进行公式计算
|
_.each($scope.formula,function(formula){
|
_.each(formula.child,function(_formula,i){
|
if(i > 0){
|
if(_formula.pMdCode == item.gcMeCode){
|
formula_computing(formula,$scope.form_items);
|
}
|
}
|
|
});
|
})
|
|
|
|
//匹配控件 并进行系统变量公式计算
|
_.each($scope.sys_formula,function(sformula){
|
// _.each(sformula.formula.child,function(_formula){
|
//递归检查 是否进行系统变量公式计算
|
function sys_count_flag(sformula){
|
_.each(sformula.child,function(_formula){
|
if(_formula.joinMathId){
|
return sys_count_flag(_formula.systemMathEntity,sys_flag);
|
}else{
|
if(_formula.mdCode == item.gcMeCode){
|
sys_flag = true;
|
}
|
}
|
});
|
}
|
var sys_flag = false;
|
sys_count_flag(sformula.formula);
|
//
|
//
|
//
|
if(sys_flag){
|
if(child_item){
|
sys_formula_computing(sformula,child_item);
|
}else{
|
sys_formula_computing(sformula);
|
}
|
}
|
|
// });
|
})
|
//子表单按时间排序
|
if(item.gcCpnType != 5){
|
sort_bytime(item);
|
}
|
show_other_cost()//其它费用提示(必须在排序后)
|
}
|
// })
|
|
//显示费用类型错误信息
|
function cost_err_check(){
|
$scope.show_cost_err = false;
|
var cost_err = [];
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10 && form.eachMoney && form.eachMoney.length > 0){
|
cost_err.journame = form.gcCpnAlias + form.num;
|
_.each(form.eachMoney,function(money){
|
if(money.errorMsg.length != 0){
|
$scope.show_cost_err = true;
|
_.each(money.errorMsg,function(msg){
|
var normName = [];
|
_.each(msg.normCode,function(_norm){
|
normName.push(_norm.name);
|
});
|
var normStr = normName.join(",");
|
if(form.num){
|
cost_err.push({
|
"journame":form.gcCpnAlias + form.num,
|
"errinfo":"费用类型--"+msg.costTypeName+",报销方式--"+msg.expendWayName+",错误提示--"+normStr+msg.errMsg
|
});
|
}else{
|
cost_err.push({
|
"journame":form.gcCpnAlias,
|
"errinfo":"费用类型--"+msg.costTypeName+",报销方式--"+msg.expendWayName+",错误提示--"+normStr+msg.errMsg
|
});
|
}
|
|
})
|
}
|
})
|
}
|
|
})
|
$scope.cost_err = cost_err;
|
$scope.$parent.cost_err = cost_err;
|
}
|
$rootScope.query_journel_budget = function(formtype,callback,isfirst){
|
$scope.query_journel_budget(formtype,callback,isfirst);
|
}
|
function getquery_pd(empty_jour){
|
var pd;
|
if($scope.$parent.exCouldNumber){
|
pd = {
|
"orderCode":$scope.$parent.exCouldNumber,
|
"joumeyInfo": []
|
}
|
}else{
|
pd = {
|
"joumeyInfo": []
|
}
|
}
|
|
var mdtype_arr = [];
|
_.each($scope.form_items,function(_item){
|
if(_item.gcMeCode != undefined){//计算费用表单信息全部传递
|
if(_item['bhValue'] != undefined){
|
mdtype_arr.push({
|
"meCode": _item['gcElIden'],
|
"mdCode": _item['gcMeCode'],
|
"meVal": _item['bhValue']
|
});
|
}else{
|
mdtype_arr.push({
|
"meCode": _item['gcElIden'],
|
"mdCode": _item['gcMeCode'],
|
"meVal": _item['render_value'] ? _item['render_value'] : _item['gcDefVal']
|
});
|
}
|
}
|
})
|
if(empty_jour){
|
var pdarr = {
|
"journeyId":"",
|
"journeyInfo":[]
|
};
|
var beginTime,endTime;
|
_.each(filed,function(_filed){
|
switch(_filed.busCode){
|
case "FromDate":
|
beginTime = _filed.mdCode;
|
break;
|
case "ToDate":
|
endTime = _filed.mdCode;
|
break;
|
}
|
})
|
_.each(empty_jour.child, function(child) {
|
if(child.gcCpnType != 9) { //过滤掉分割线
|
if(child['bhValue'] != undefined){
|
pdarr.journeyInfo.push({
|
"meCode": child['gcElIden'],
|
"mdCode": child['gcMeCode'],
|
"meVal": child['bhValue']
|
});
|
}else{
|
pdarr.journeyInfo.push({
|
"meCode": child['gcElIden'],
|
"mdCode": child['gcMeCode'],
|
"meVal": child['render_value']!=undefined ? child['render_value'] : child['gcDefVal']
|
});
|
}
|
|
if(child.gcMeCode == beginTime){
|
beginTime = child.render_value;
|
}
|
if(child.gcMeCode == endTime){
|
endTime = child.render_value;
|
}
|
}
|
});
|
_.each(mdtype_arr,function(madtype){
|
pdarr.journeyInfo.push(madtype);
|
})
|
|
if(empty_jour.aj_id){
|
pdarr.journeyId = empty_jour.aj_id;
|
}
|
if(empty_jour.ej_id){
|
pdarr.journeyId = empty_jour.ej_id;
|
}
|
if(empty_jour.ej_days != undefined){
|
_.extend(pdarr,{'journeyDays':empty_jour.ej_days});
|
// pdarr['journeyDays'] = _item.ej_days;
|
}
|
if(empty_jour.ej_hours != undefined){
|
_.extend(pdarr,{'journeyTime':empty_jour.ej_hours});
|
// pdarr['journeyTime'] = _item.ej_hours;
|
}
|
if(empty_jour.ej_kms != undefined){
|
_.extend(pdarr,{'journeyKM':empty_jour.ej_kms});
|
// pdarr['journeyKM'] = _item.ej_kms;
|
}
|
// if(_item.span_night != undefined){
|
// _.extend(pdarr,{'spanNight':_item.span_night});
|
// }
|
if(endTime!=undefined&&endTime!==""&&beginTime!=undefined&&beginTime!==""){
|
var span_night = ($rootScope.getNewDate(endTime) - $rootScope.getNewDate(beginTime))/(24*60*60*1000);
|
_.extend(pdarr,{'spanNight':span_night});
|
}
|
pd.joumeyInfo.push(pdarr);
|
}else{
|
_.each(_.cloneDeep($scope.form_items),function(_item){
|
var pdarr = {
|
"journeyId":"",
|
"journeyInfo":[]
|
};
|
if(_item.gcCpnType == 10){
|
var beginTime,endTime;
|
_.each(filed,function(_filed){
|
switch(_filed.busCode){
|
case "FromDate":
|
beginTime = _filed.mdCode;
|
break;
|
case "ToDate":
|
endTime = _filed.mdCode;
|
break;
|
}
|
})
|
_.each(_item.child, function(child) {
|
if(child.gcCpnType != 9) { //过滤掉分割线
|
if(child['bhValue'] != undefined){
|
pdarr.journeyInfo.push({
|
"meCode": child['gcElIden'],
|
"mdCode": child['gcMeCode'],
|
"meVal": child['bhValue']
|
});
|
}else{
|
pdarr.journeyInfo.push({
|
"meCode": child['gcElIden'],
|
"mdCode": child['gcMeCode'],
|
"meVal": child['render_value']!=undefined ? child['render_value'] : child['gcDefVal']
|
});
|
}
|
if(child.gcMeCode == 'F116'){
|
}
|
if(child.gcMeCode == beginTime){
|
beginTime = child.render_value;
|
}else{
|
beginTime = undefined;
|
}
|
if(child.gcMeCode == endTime){
|
endTime = child.render_value;
|
}else{
|
endTime = undefined;
|
}
|
}
|
});
|
_.each(mdtype_arr,function(madtype){
|
pdarr.journeyInfo.push(madtype);
|
})
|
|
if(_item.aj_id){
|
pdarr.journeyId = _item.aj_id;
|
}
|
if(_item.ej_id){
|
pdarr.journeyId = _item.ej_id;
|
}
|
if(_item.ej_days != undefined){
|
_.extend(pdarr,{'journeyDays':_item.ej_days});
|
// pdarr['journeyDays'] = _item.ej_days;
|
}
|
if(_item.ej_hours != undefined){
|
_.extend(pdarr,{'journeyTime':_item.ej_hours});
|
// pdarr['journeyTime'] = _item.ej_hours;
|
}
|
if(_item.ej_kms != undefined){
|
_.extend(pdarr,{'journeyKM':_item.ej_kms});
|
// pdarr['journeyKM'] = _item.ej_kms;
|
}
|
// if(_item.span_night != undefined){
|
// _.extend(pdarr,{'spanNight':_item.span_night});
|
// }
|
if(endTime!=undefined&&endTime!==""&&beginTime!=undefined&&beginTime!==""){
|
var span_night = ($rootScope.getNewDate(endTime) - $rootScope.getNewDate(beginTime))/(24*60*60*1000);
|
_.extend(pdarr,{'spanNight':span_night});
|
}
|
pd.joumeyInfo.push(pdarr);
|
}
|
})
|
}
|
return pd;
|
}
|
$scope.query_journel_budget = function(formtype,callback,isfirst) {//计算费用
|
if(isfirst != true){
|
$rootScope.formula_num = 0;
|
$rootScope.formula_num_id = [];//非自动计算 则将前端公式计数清零
|
}
|
$rootScope.isfirst = isfirst;
|
$scope.$parent.save_btn_flag= false;//计算费用中不可提交、保存
|
//参数设置,若用默认值可以省略以下面代
|
toastr.options = {
|
"closeButton": false, //是否显示关闭按钮
|
"debug": false, //是否使用debug模式
|
"positionClass": "toast-top-center",//弹出窗的位置
|
"showDuration": "300",//显示的动画时间
|
"hideDuration": "3000",//消失的动画时间
|
"timeOut": "500000", //展现时间
|
"extendedTimeOut": "1000",//加长展示时间
|
"showEasing": "swing",//显示时的动画缓冲方式
|
"hideEasing": "linear",//消失时的动画缓冲方式
|
"showMethod": "fadeIn",//显示时的动画方式
|
"hideMethod": "fadeOut" //消失时的动画方式
|
};
|
|
if(isfirst == false){
|
toastr.info('计算费用中');
|
}
|
var moneyUrl;
|
if(formtype == 20){
|
moneyUrl = "apply/userMoney";
|
}else if(formtype == 30){
|
moneyUrl = "expend/userMoney";
|
}
|
var parentitem = myServeice.getparentitem();
|
var users_selected = myServeice.getusers_selected();
|
var type = myServeice.gettype();
|
var children = parentitem.child;
|
var pd = getquery_pd();
|
|
if($scope.billid){
|
_.extend(pd,{"billId":$scope.billid});
|
}
|
|
http_service.post(moneyUrl, pd, function(res){
|
toastr.clear();
|
var journel_budget_list = res.data.data;
|
$rootScope.version = res.data.data.version;//初始化版本号
|
if(formtype == 20){//申请单计算费用
|
$timeout(function(){
|
var child_item = [];
|
var main_item = [];
|
_.each($scope.form_items, function(_item){
|
if(_item.gcCpnType == 10){
|
child_item.push(_item);
|
}else{
|
main_item.push(_item);
|
}
|
});
|
var allcost = 0;
|
for(i in journel_budget_list.eachMoney){
|
var eachMoney = journel_budget_list.eachMoney[i].money;
|
if(child_item[i].budget_list&&child_item[i].budget_list.length!=0){
|
child_item[i].budget_list[0].child = eachMoney;
|
}else{
|
_.extend(child_item[i],{"budget_list":[{"child":eachMoney}]});
|
}
|
_.each(child_item[i].child,function(cd){
|
_.each(eachMoney,function(data){
|
if(data.jp_cd_code == cd.gcMeCode){
|
// cd.standard_money = data.jp_amount;
|
// cd['standard_show'] = true;
|
if(cd.gcEditFlag != 1){
|
cd.render_value = data.jp_amount;
|
// $scope.change_apmonut(cd);
|
}else if(cd.render_value == undefined || cd.render_value == ""){
|
cd.render_value = data.jp_amount;
|
// $scope.change_apmonut(cd);
|
}
|
if(cd.render_value != undefined){
|
allcost += parseFloat(cd.render_value);
|
}
|
}
|
})
|
});
|
}
|
_.each(child_item,function(cd){
|
main_item.push(cd);
|
})
|
$timeout(function(){
|
$scope.form_items = main_item;
|
},1)
|
//将总金额显示在申请金额里
|
// _.each(filed, function(_filed) {
|
// if(_filed.busCode == "applyMoney") {
|
// _.each($scope.form_items, function(_form) {
|
// if(_form.gcMeCode == _filed.mdCode) {
|
// $timeout(function(){
|
// _form.render_value = allcost;
|
// _form.gcDefVal = allcost;
|
// },1)
|
// }
|
// })
|
// }
|
// });
|
}, 1);
|
}else if(formtype == 30){//报销单计算费用
|
var form_list = _.cloneDeep($scope.form_list);
|
var err_list = [];
|
if(journel_budget_list.noJoinBill != undefined){
|
$scope.unjoin_bill = journel_budget_list.noJoinBill;
|
if(journel_budget_list.noJoinBill.child.length != 0){
|
$scope.unjoin_bill_show = true;
|
}
|
_.each(filed,function(_filed){
|
if(_filed.busCode == "noJoinBill"){//无票据金额
|
_.each($scope.form_items,function(item){
|
if(item.gcMeCode == _filed.mdCode){
|
if((item.render_value == "" || item.render_value == undefined) && journel_budget_list.noJoinBill.sum != 0){//(item.render_value == "" || parseInt(item.render_value) == 0)
|
item.render_value = journel_budget_list.noJoinBill.sum;
|
}
|
item['expend_standard'] = journel_budget_list.noJoinBill.sum;
|
item['billMoney'] = journel_budget_list.noJoinBill.sum;//无行程票据 的 票据金额
|
item['expend_standard_sp'] = 0;
|
// item['expend_standard_show'] = true;
|
$scope.$watch(function(){//实时验证
|
return item.render_value;
|
},function(){
|
if(item.render_value != undefined && item.render_value != '' && item.render_value > 0){
|
item['is_red'] = true;
|
}else{
|
item['is_red'] = false;
|
}
|
// var flag;
|
// if(item.render_value == "" || parseInt(item.render_value) == 0){
|
// flag = true;
|
// }else{
|
// flag = false;
|
// }
|
// if(flag && journel_budget_list.noJoinBill.sum <= 0){
|
// item['is_red'] = false;
|
// }else{
|
// item['is_red'] = true;
|
// }
|
})
|
}
|
})
|
}
|
})
|
}else{
|
$scope.unjoin_bill_show = false;
|
}
|
|
var eachmonety_err = [];
|
var child_item = [];
|
var bill_type_code;
|
_.each(cddata,function(_cd){//获取定额包干的code
|
if(_cd.cdType == 90 && _cd.cdName == "0002"){
|
bill_type_code = _cd.cdCode;
|
}
|
})
|
var main_item = [];
|
_.each($scope.form_items, function(_item){
|
if(_item.gcCpnType == 10){
|
child_item.push(_item);
|
}else{
|
main_item.push(_item);
|
}
|
});
|
var allcost = 0;
|
_.each(journel_budget_list.eachMoney,function(eachMoney,i){
|
// var eachMoney = journel_budget_list.eachMoney[i];
|
var eachmonety_err_child = [];
|
if(child_item[i].budget_list&&child_item[i].budget_list.length!=0){
|
child_item[i].budget_list[0].child = eachMoney.money;
|
}else{
|
_.extend(child_item[i],{"budget_list":[{"child":eachMoney.money}]});
|
}
|
var otherMoney = 0;
|
var otherMoney_bill = 0;
|
_.each(eachMoney.money,function(data){
|
var find_item = false;
|
// if(child_item[i] == undefined){
|
// return false;
|
// }
|
_.each(child_item[i].child,function(cd){
|
|
if(data.jp_cd_code == cd.gcMeCode){
|
// 找到了
|
eachmonety_err_child.push(data);
|
if(data.billMoney != undefined){//票据金额
|
cd['billMoney'] = data.billMoney;
|
}else{
|
cd['billMoney'] = 0;
|
}
|
if(cd.gcEditFlag != 1){
|
cd.render_value = data.jp_amount;
|
// $scope.change_apmonut(cd);
|
}else if(cd.render_value == undefined || cd.render_value == "" || cd.render_value == 0){
|
cd.render_value = data.jp_amount;
|
// $scope.change_apmonut(cd);
|
}
|
cd.expend_standard = data.jp_amount;
|
// if(bill_type_code == data.expendWay){//暂时不做是否为定额包干判断
|
// cd.expend_standard ="标准:" + data.jp_amount;
|
// }else{
|
// cd.expend_standard ="票据:" + data.jp_amount;
|
// }
|
cd['expend_standard_show'] = true;
|
if(cd.render_value != undefined){
|
allcost += parseFloat(cd.render_value);
|
}
|
find_item = true;
|
}
|
});
|
// 未找到
|
if(!find_item){
|
otherMoney += data.jp_amount;
|
if(data.billMoney != undefined){//其他费用 票据金额
|
otherMoney_bill += data.billMoney;
|
}
|
}
|
});
|
//计算其他费用 将值显示到其它费用里
|
otherMoney += eachMoney.otherMoney;//增加其他费用
|
otherMoney_bill += eachMoney.otherMoney;//增加其他费用 票据金额
|
_.each(filed, function(_filed) {
|
if(_filed.busCode == "otherMoneyType") {
|
if(child_item[i] == undefined){
|
return false;
|
}
|
_.each(child_item[i].child, function(cd) {
|
if(cd.gcMeCode == _filed.mdCode) {
|
cd['billMoney'] = otherMoney_bill;
|
if((cd.render_value == "" || cd.render_value == undefined) && otherMoney != 0){//(cd.render_value == "" || parseInt(cd.render_value) == 0)
|
cd.render_value = otherMoney;
|
}
|
cd.expend_standard = otherMoney;
|
// cd['expend_standard_show'] = true;
|
cd['expend_standard_sp'] = 0;
|
$scope.$watch(function(){//实时验证
|
return cd.render_value;
|
},function(){
|
if(cd.render_value != '' && cd.render_value != undefined && cd.render_value > 0){//if(cd.render_value != otherMoney)修改前
|
cd['is_red'] = true;
|
}else{
|
cd['is_red'] = false;
|
}
|
})
|
}
|
})
|
}
|
})
|
eachmonety_err.push(eachmonety_err_child);
|
if(child_item[i]){
|
child_item[i]['eachMoney'] = eachmonety_err_child;
|
}
|
})
|
//存储错误信息
|
$scope.eachmonety_err = eachmonety_err;
|
_.each(child_item,function(cd){
|
main_item.push(cd);
|
})
|
$timeout(function(){
|
$scope.form_items = main_item;
|
},1)
|
//将总金额显示在报销金额里
|
// _.each(filed, function(_filed) {
|
// if(_filed.busCode == "expendMoney") {
|
// _.each($scope.form_items, function(_form) {
|
// if(_form.gcMeCode == _filed.mdCode) {
|
// $timeout(function(){
|
// if(isfirst){
|
// if(_form.render_value == undefined || _form.render_value === ""){
|
// _form.render_value = allcost;
|
// _form.gcDefVal = allcost;
|
// }
|
// }else{
|
// _form.render_value = allcost;
|
// _form.gcDefVal = allcost;
|
// }
|
// },1)
|
// }
|
// })
|
// }
|
// });
|
|
// 显示费用类型错误信息
|
cost_err_check();
|
}
|
|
if(isfirst){//详情页 计算费用时才进行主数据验证
|
$scope.maindata_isright_query = true;//计算费用 主数据检查状态 true 代表无错误
|
$scope.maindata_err_query = [];//计算费用 主数据错误信息
|
$scope.maindata_err_sys=[];//系统变量 主数据错误信息
|
$scope.maindata_isright_sys= true;//系统变量 主数据错误状态 true 代表无错误
|
_.each(journel_budget_list.eachMoney,function(list){//获得主数据错误数据
|
_.each(list.money,function(money){
|
if(money.defErr != undefined && money.defErr.length != 0){
|
$scope.maindata_isright_query = false;
|
_.each(money.defErr,function(err){
|
$scope.maindata_err_query.push(err);
|
})
|
}
|
})
|
});
|
}
|
|
//匹配控件 并进行公式计算
|
$timeout(function(){
|
$scope.formula_num_check = 0;
|
_.each($scope.formula,function(formula){
|
// _.each(formula.child,function(_formula,i){
|
// if(i > 0){
|
// if(_formula.pMdCode == item.gcMeCode){
|
formula_computing(formula,$scope.form_items);
|
// }
|
// }
|
|
// });
|
_.each(formula.child, function(fcd){
|
if(fcd.pMeCode != undefined && fcd.pMeCode != '' && fcd.pMeCode != 'code'){
|
_.each($scope.form_items,function(form){
|
var break_flag = false;
|
if(form.gcCpnType != 10 && form.gcCpnType != 17){
|
if(form.gcMeCode == fcd.pMdCode){
|
$scope.formula_num_check++;
|
break_flag = true;
|
return false;
|
}
|
}else{
|
_.each(form.child,function(cd){
|
if(cd.gcMeCode == fcd.pMdCode){
|
$scope.formula_num_check++;
|
break_flag = true;
|
return false;
|
}
|
});
|
}
|
if(break_flag){
|
return false;
|
}
|
})
|
}
|
})
|
})
|
if(isfirst){
|
$rootScope.update_speical_formula = $scope.$watch(function() {
|
return $rootScope.formula_num;
|
}, function() {
|
|
|
|
|
if(_.uniq($rootScope.formula_num_id).length >= $scope.formula_num_check) {
|
$rootScope.update_speical_formula();
|
//匹配控件 并进行系统变量公式计算
|
$scope.sys_num = 0;
|
$scope.sys_num_check = 0;
|
$scope.sys_begin = 0;
|
_.each($scope.sys_formula, function(sformula) {
|
_.each($scope.form_items, function(form) {
|
if(form.gcCpnType != 10) {
|
if(form.gcMeCode == sformula.target) {
|
sys_formula_computing(sformula, undefined, true);
|
$scope.sys_num_check++;
|
}
|
} else {
|
_.each(form.child, function(cd) {
|
if(cd.gcMeCode == sformula.target) {
|
sys_formula_computing(sformula, form, true);
|
$scope.sys_num_check++;
|
}
|
})
|
}
|
})
|
})
|
var save_form_uid = $rootScope.save_form_uid;
|
$rootScope.update_speical = $scope.$watch(function(){
|
return $scope.sys_num;
|
},function(){
|
|
|
if(save_form_uid != $rootScope.save_form_uid){
|
return false;
|
}
|
if($scope.sys_num == $scope.sys_num_check){
|
|
if($rootScope.isfirst){
|
var bill_state_update_flag = true;
|
var check_data = auto_save();
|
if($scope.sys_num_check == 0 && (check_data.child == undefined || check_data.child.length == 0)){
|
bill_state_update_flag = false;
|
}
|
|
|
|
|
if($rootScope.close_lock == true){
|
$rootScope.update_speical_formula();
|
return false;
|
}
|
$scope.$parent.save_btn_flag= true;//自动更新前才可提交、保存
|
$rootScope.save_post(auto_save());//报销单详情自动更新 暂时 去除自动更新
|
//显示主数据错误信息
|
$scope.maindata_err = [];
|
_.each($scope.maindata_err_query,function(err){
|
// $scope.maindata_err.push(err);// 暂时不显示 主数据缺失
|
})
|
$scope.maindata_err_sys = _.uniqBy($scope.maindata_err_sys,"eViewMsg");
|
_.each($scope.maindata_err_sys,function(err){
|
// $scope.maindata_err.push(err);// 暂时不显示 主数据缺失
|
})
|
if($scope.maindata_isright_query && $scope.select_isright && $scope.maindata_isright_sys && $scope.billState == 10 && $scope.exCouldNumber !='' && $scope.exCouldNumber != undefined){//如果报销单为自动审单中,且都不缺失主数据,向后端发送修改订单状态请求
|
|
|
http_service.post("errmsg/update/updateBillStart",{"oCode":$scope.exCouldNumber},function(res){
|
|
})
|
}
|
}
|
$timeout(function(){//前端公式并且系统变量公式算完后 再保存表单 李伟民 12-29
|
|
if(isfirst == false){
|
callback($rootScope.version);
|
}
|
},100);
|
$timeout(function(){
|
$rootScope.checkdata();//计算完费用且算完公式后 进行规则校验
|
},10)
|
$rootScope.update_speical();
|
}
|
})
|
}
|
});
|
}else{
|
//匹配控件 并进行系统变量公式计算
|
$scope.sys_num = 0;
|
$scope.sys_num_check = 0;
|
$scope.sys_begin = 0;
|
_.each($scope.sys_formula, function(sformula) {
|
_.each($scope.form_items, function(form) {
|
if(form.gcCpnType != 10) {
|
if(form.gcMeCode == sformula.target) {
|
sys_formula_computing(sformula, undefined, true);
|
$scope.sys_num_check++;
|
}
|
} else {
|
_.each(form.child, function(cd) {
|
if(cd.gcMeCode == sformula.target) {
|
sys_formula_computing(sformula, form, true);
|
$scope.sys_num_check++;
|
}
|
})
|
}
|
})
|
})
|
$rootScope.update_speical = $scope.$watch(function(){
|
return $scope.sys_num;
|
},function(){
|
if($scope.sys_num == $scope.sys_num_check){
|
$timeout(function(){//前端公式并且系统变量公式算完后 再保存表单 李伟民 12-29
|
|
if(isfirst == false){
|
callback($rootScope.version);
|
}
|
},100);
|
$timeout(function(){
|
$rootScope.checkdata();//计算完费用且算完公式后 进行规则校验
|
},10)
|
$rootScope.update_speical();
|
}
|
})
|
}
|
|
|
// if(isfirst){
|
// $rootScope.save_post(auto_save());//报销单详情自动更新
|
// }
|
// $rootScope.checkdata();//计算完费用且算完公式后 进行规则校验
|
},100);
|
show_other_cost()//其它费用提示
|
if(isfirst != true){
|
$scope.$parent.save_btn_flag= true;//计算费用后才可提交、保存
|
}
|
});
|
};
|
//自动更新获取控件数据
|
function auto_save(){
|
var auto_post_data = {};
|
var child_data = [];
|
var child_data_f = [];
|
_.each($scope.form_items,function(form){
|
if(form.child == undefined || form.child.length == 0){
|
if(form.gcColName != "ex_number"){// 自动更新 不传报销单号
|
auto_post_data[form.gcColName] = form.render_value;
|
}
|
}else if(form.gcCpnType == 10){
|
var single_child = {'child':[]};
|
_.each(form.child,function(cd){
|
single_child[cd.gcColName] = cd.render_value;
|
});
|
if(form.ej_id){
|
single_child['ej_id'] = form.ej_id;
|
}
|
child_data.push(single_child)
|
}else if(form.gcCpnType == 17){
|
var single_child_f = {'child':[]};
|
_.each(form.child,function(cd){
|
single_child_f[cd.gcColName] = cd.render_value;
|
});
|
if(form.ef_id){
|
single_child_f['ef_id'] = form.ef_id;
|
}
|
child_data_f.push(single_child_f)
|
}
|
})
|
_.extend(auto_post_data,{'child':child_data,'fchild':child_data_f});
|
if($scope.expned_id != undefined){
|
_.extend(auto_post_data,{'ex_id':$scope.expned_id});
|
}
|
|
return auto_post_data;
|
}
|
//计算费用后 验证费用
|
function eachMoney_check(){
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType ==10){
|
if(form.eachMoney){
|
_.each(form.eachMoney,function(each){
|
_.each(form.child,function(cd){
|
if(each.jp_cd_code == cd.gcMeCode){
|
// cd['nobill_cd'] = true;//默认报红
|
// if(each.billMust && each.billMust == 0){//非票据必须的费用类型不进行无票据信息验证
|
// cd['nobill_cd'] = false;
|
// }
|
// if(each.billMust && each.billMust == 1 && each.jp_amount > 0){//票据必须且金额大于0的费用类型不进行无票据信息验证
|
// cd['nobill_cd'] = false;
|
// }
|
if(each.jp_amount != cd.render_value){
|
cd['is_red'] = true;
|
}else{
|
cd['is_red'] = false;
|
}
|
}
|
})
|
})
|
}
|
|
}
|
});
|
$scope.have_err();
|
}
|
// $scope.$watch(function(){
|
// return $scope.form_items;
|
// },function(){
|
// eachMoney_check();
|
// });
|
|
$scope.check_item = function(item, opt) {
|
if(opt == undefined){
|
return false;
|
}
|
if(_.isArray(item.render_value)) {
|
if(_.indexOf(item.render_value, opt.value) > -1) {
|
return true;
|
}
|
} else {
|
if(item.render_value === opt.value) {
|
return true;
|
}
|
}
|
return false;
|
};
|
|
$scope.goto_pre_page = function() {
|
window.history.go(-1);
|
};
|
|
$scope.item_column = function(item) {
|
var item_class = '';
|
if(item) {
|
if(item.gcCpnType == 10 || item.gcCpnType == 12 || item.gcCpnType == 0){
|
item_class = 'col-md-12';
|
}else{
|
switch(item.gcCpnInCol){
|
case 2:
|
item_class = 'col-md-12';
|
break;
|
case 1:
|
item_class = 'col-md-6 column_cfg';
|
break;
|
case 3:
|
item_class = 'col-md-3 column_cfg';
|
break;
|
case 4:
|
item_class = 'col-md-2 column_cfg';
|
break;
|
}
|
}
|
}
|
if(!$scope.form_show(item)){//被隐藏的子表单不占位
|
item_class += " null_form";
|
}
|
return item_class;
|
// if(item.gcCpnInCol == '1' && item.gcCpnType !== 10 && item.gcCpnType !== 12 && item.gcCpnType !== 0) {
|
// return 'col-md-6 column_cfg';
|
// } else {
|
// return 'col-md-12';
|
// }
|
};
|
|
$scope.redirect_to_args = function() {
|
$location.path([].slice.call(arguments).join('/'));
|
};
|
|
//计算子表单序号
|
$scope.count_number = function(){
|
var num = 0;//子表单
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
num++;
|
form['num'] = num;
|
}
|
});
|
if(num <= 1){
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
form['num'] = "";
|
}
|
});
|
}
|
|
var num_pay = 0;//支付方式子表单
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 17){
|
num_pay++;
|
form['num'] = num_pay;
|
}
|
});
|
if(num_pay <= 1){
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 17){
|
form['num'] = "";
|
}
|
});
|
}
|
}
|
//其他费用及无票据行程金额提示
|
function show_other_cost(){
|
var otherMoneyType_code;
|
var nobill_money_code;
|
$scope.other_cost = [];
|
$scope.nobill_money_hint = '';
|
_.each(filed,function(_filed){
|
if(_filed.busCode == 'otherMoneyType'){
|
otherMoneyType_code = _filed.mdCode;
|
}
|
if(_filed.busCode == 'noJoinBill'){
|
nobill_money_code = _filed.mdCode;
|
}
|
})
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
_.each(form.child,function(cd){
|
if(cd.gcMeCode == otherMoneyType_code){
|
if(cd.render_value != undefined && cd.render_value != "" && (cd.render_value > 0 || cd.expend_standard > 0)){
|
if(form.num){
|
$scope.other_cost.push({"journame":form.gcCpnAlias+form.num,"bill_money":cd.render_value,"expend_money":cd.expend_standard})
|
}else{
|
$scope.other_cost.push({"journame":form.gcCpnAlias,"bill_money":cd.render_value,"expend_money":cd.expend_standard})
|
}
|
}
|
}
|
})
|
}else if(form.gcMeCode == nobill_money_code){
|
if(form.render_value != undefined && form.render_value != "" && (form.render_value > 0 || form.expend_standard > 0)){
|
$scope.nobill_money_hint = {"nobill_money":form.render_value,"expend_money":form.expend_standard}
|
}
|
}
|
})
|
}
|
//加子表单
|
var num = 2;
|
var onceflag = true;
|
$scope.duplicate_sub_form = function(item) {
|
if(item.gcCpnType == 10){
|
var form_items = [];
|
for(i in $scope.form_items) {
|
$scope.form_items[0].num = 1;
|
if($scope.form_items[i] && item.gcCpnAlias === $scope.form_items[i].gcCpnAlias) {
|
$scope.number = $scope.form_items[i].num;
|
$scope.form_items[i].num = num++;
|
var obj = _.cloneDeep($scope.form_items[i]);
|
obj.budget_list = [];
|
var newchild = [];
|
_.each(obj.child, function(_obj) {
|
_obj = _.omit(_obj, "render_value");
|
if(_obj != undefined) {
|
newchild.push(_obj);
|
}
|
})
|
obj.child = newchild;
|
obj['deleteflag_jour'] = false;
|
form_items.push(_.cloneDeep($scope.form_jour));//修改后的添加方式
|
$scope.form_items[i].num = $scope.number;
|
$scope.form_items.push(form_items[0]);
|
break;
|
}
|
};
|
}else if(item.gcCpnType == 17){
|
$scope.form_items.push(_.cloneDeep($scope.form_pay));
|
}
|
|
$scope.count_number();
|
$scope.$parent.form_data['child'] = $scope.form_items;
|
cost_err_check()//增加完后重新调用显示费用类型错误信息方法
|
show_other_cost()//其它费用提示
|
|
_.each($scope.formula,function(formula){
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 12 && formula.child[1].pMdCode == form.gcMeCode){
|
$rootScope.formula_computing_user(formula,form.render_value,form,form);
|
}
|
})
|
})
|
|
};
|
//删除子表单
|
$scope.rm_sub_form = function(item) {
|
var form_items = [];
|
if(item.billInfos != undefined && item.billInfos.length != 0){//有票据信息时 不可删除子表单
|
$rootScope.twarning("不可删除有票据信息的行程");
|
return false;
|
}
|
_.remove($scope.form_items,function(form){
|
return form == item;
|
})
|
// _.each($scope.form_items, function(_item) {
|
// if(item !== _item) {
|
// form_items.push(_item);
|
// }
|
// });
|
// $scope.form_items = form_items;
|
//若无行程 则显示添加行程按钮 无支付方式 显示添加支付方式
|
var jour_num = 0;
|
var pay_num = 0;
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
jour_num++;
|
}else if(form.gcCpnType == 17){
|
pay_num++;
|
}
|
})
|
if(jour_num == 0){
|
$scope.add_jour_show = true;
|
}
|
if(pay_num == 0){
|
$scope.add_pay_show = true;
|
}
|
$scope.count_number();
|
$scope.$parent.form_data['child'] = $scope.form_items;
|
//匹配控件 并进行公式计算
|
|
$scope.$parent.save_btn_flag= false;
|
|
_.each($scope.formula,function(formula){
|
_.each(formula.child,function(_formula){
|
// if(formula.mathFormat != "select"){//排除下拉框联动的公式
|
if($scope.add_jour_show){//无行程时 公式计算
|
var new_form = _.cloneDeep($scope.form_items);
|
new_form.push($scope.form_jour);
|
formula_computing(formula,new_form);
|
}else{
|
formula_computing(formula,$scope.form_items);
|
}
|
|
// }
|
});
|
});
|
$scope.$parent.save_btn_flag = true;
|
sort_bytime();//子表单按时间排序
|
cost_err_check()//删除完后重新调用显示费用类型错误信息方法
|
show_other_cost()//其它费用提示
|
};
|
//添加行程按钮(支付方式)显示
|
$rootScope.show_add_jour = function(){
|
var jour_num = 0;
|
var pay_num = 0;
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
jour_num++;
|
}else if(form.gcCpnType == 17){
|
pay_num++;
|
}
|
})
|
if(jour_num == 0){
|
$scope.add_jour_show = true;
|
}
|
if(pay_num == 0){
|
$scope.add_pay_show = true;
|
}
|
}
|
//添加行程按钮
|
$scope.add_jour = function(){//
|
$scope.form_items.push(_.cloneDeep($scope.form_jour));
|
$scope.$parent.form_data.child = $scope.form_items;
|
$scope.add_jour_show = false;
|
}
|
//添加支付方式按钮
|
$scope.add_pay = function(){//add_pay
|
$scope.form_items.push(_.cloneDeep($scope.form_pay));
|
$scope.$parent.form_data.child = $scope.form_items;
|
$scope.add_pay_show = false;
|
}
|
$scope.math_ceil = function(v) {
|
if(!v) {
|
return '';
|
}
|
return Math.ceil(v);
|
}
|
//获取分页及查询信息
|
function select_info(){
|
var search = $("#apply_search").val();
|
if(search!=undefined && search !== ""){
|
return {
|
"num_per_page": $scope.page_number,
|
"page_num": $scope.pages,
|
"queryName": search
|
}
|
}else{
|
return {
|
"num_per_page": $scope.page_number,
|
"page_num": $scope.pages
|
}
|
}
|
|
}
|
//获取选择预算横向信息
|
function get_budget_info(pages,page_num){
|
var parameter = select_info();
|
|
if ($scope.type === 10) {
|
orgCode = $scope.budgetOrgCode;
|
} else if ($scope.type === 20) {
|
orgCode = $scope.appleOrgCode;
|
}
|
|
if (orgCode) {
|
parameter.data = orgCode;
|
parameter.type = $scope.type;
|
}
|
http_service.post('budget/pass/budgetInfo',parameter,function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
// $scope.budget_info = res.data.data;
|
// $scope.rows = res.data.rows;
|
$scope.rows = res.data.data.length;//前端分页
|
if(pages*parseInt(page_num)<= $scope.rows){
|
$scope.budget_info = res.data.data.slice((pages-1)*page_num,page_num*pages);
|
}else{
|
$scope.budget_info = res.data.data.slice((pages-1)*page_num);
|
}
|
});
|
}
|
//点击查询
|
$scope.apply_search_info = function(){
|
$scope.pages = 1;
|
$scope.page_number = "5";
|
get_budget_info($scope.pages,$scope.page_number);
|
}
|
//按回车键则查询
|
$scope.apply_search_info_keydown = function(event){
|
if(event.keyCode == 13){
|
$scope.apply_search_info();
|
}
|
}
|
//点击上一页
|
$scope.pre_page = function(){
|
if($scope.pages > 1){
|
$scope.pages = parseInt($scope.pages)-1;
|
// get_budget_info();
|
//前端分页
|
get_budget_info($scope.pages,$scope.page_number);
|
}
|
}
|
//点击下一页
|
$scope.next_page = function(){
|
if($scope.pages < Math.ceil($scope.rows/$scope.page_number)){
|
$scope.pages = parseInt($scope.pages)+1;
|
// get_budget_info();
|
//前端分页
|
get_budget_info($scope.pages,$scope.page_number);
|
}
|
}
|
//改变一页显示条数
|
$scope.change_page_number = function(){
|
// get_budget_info();
|
//前端分页
|
get_budget_info($scope.pages,$scope.page_number);
|
}
|
//显示申请单选择预算并获得数据
|
// TODO
|
$scope.show_apply_select = function(edit){
|
if($rootScope.close_user_selector){
|
$rootScope.close_user_selector();
|
}
|
if(!edit){
|
return false;
|
}
|
var orgCode = "";
|
var gcCpnAlias = "";
|
_.each(filed,function(_field){
|
if (_field.busCode === "orgCode") {
|
_.each($scope.form_items,function(_form_items){
|
if (_form_items.gcMeCode === _field.mdCode) {
|
//$('*[gccolname="' + _form_items.gcColName + '"]').val();
|
orgCode = $('*[gccolname="' + _form_items.gcColName + '"]').attr("value");
|
gcCpnAlias = _form_items.gcCpnAlias;
|
if ($scope.type === 10) {
|
$scope.budgetOrgCode = orgCode;
|
} else if ($scope.type === 20) {
|
$scope.appleOrgCode = orgCode;
|
}
|
}
|
})
|
}
|
})
|
if (!orgCode) {
|
if (edit) {
|
$scope.$parent.$parent.tinfo("请先选择"+gcCpnAlias+"!");
|
} else {
|
$scope.$parent.tinfo("请先选择"+gcCpnAlias+"!");
|
}
|
return false;
|
}
|
$scope.apply_select_show = true;
|
$scope.pages = 1;
|
$scope.page_number = "5";
|
//获取表头信息
|
http_service.post('form/search/showTables',{},function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
$scope.heads = res.data.data;
|
// $scope.heads = res.data.data.cpnInfo;
|
})
|
//获取横向信息 前端分页
|
get_budget_info($scope.pages,$scope.page_number);
|
};
|
//将选择的数据保存到数组内
|
$scope.selected_budget = function(data){
|
$scope.thshow = true;
|
$scope.close_apply_select();
|
$rootScope.budget_selected = data.bu_number;
|
$rootScope['child_money'] = data.child_money;
|
$scope.selectinfo = [];
|
$scope.info = {};
|
$scope.sumMoney = "";
|
$scope.orgName = "";
|
var startTime,endTime;
|
_.each($scope.heads,function(hd){
|
_.each(filed,function(_filed){
|
if(hd.gcMeCode == _filed.mdCode){
|
if(data[hd.gcColName]){
|
$scope.info[hd.gcColName] = data[hd.gcColName]
|
switch(_filed.busCode){
|
case "sumMoney"://预算金额
|
$scope.sumMoney = "【"+hd.gcCpnAlias+"】 "+data[hd.gcColName]+" ";
|
$scope.info[hd.gcColName] = $scope.sumMoney;
|
break;
|
case "beginCalendar":
|
startTime = data[hd.gcColName];
|
$scope.info[hd.gcColName] = startTime;
|
break;
|
case "endCalendar":
|
endTime = data[hd.gcColName];
|
$scope.info[hd.gcColName] = endTime;
|
break;
|
case "orgName"://组织机构
|
$scope.orgName = data[hd.gcColName];
|
$scope.info[hd.gcColName] = $scope.orgName;
|
break;
|
}
|
}
|
}
|
});
|
});
|
if(startTime&&endTime){
|
$scope.time = "【预算时间】"+startTime+"~"+endTime;
|
$rootScope.startTime = startTime;
|
$rootScope.endTime = endTime;
|
}
|
$rootScope.sumMoney_budget = data.bu_money;
|
$scope.info['bu_number'] = data.bu_number;
|
$scope.info['bu_money'] = data.bu_money;
|
$scope.selectinfo.push($scope.info);
|
}
|
//关闭申请单选择预算
|
$rootScope.close_apply_select = function(){
|
$scope.close_apply_select();
|
}
|
$scope.close_apply_select = function(){
|
$scope.apply_select_show = false;
|
}
|
// 我是分割线----------------------------------------------------------------------
|
//人员选择下拉框
|
$scope.expend_search = {};
|
|
_.each(filed,function(_filed){
|
if(_filed.busCode == "PersonalName"){
|
$scope.expend_search = {"gcMeCode":_filed.mdCode};
|
}
|
});
|
//获取申请单分页及查询信息
|
function expend_select_info(){
|
var search = $(".expend_search").find(".select-container").attr('value');
|
if(search==undefined){
|
search="";
|
}
|
if(search == ""){
|
return {
|
"num_per_page": $scope.expend_page_number,
|
"page_num": $scope.expend_pages
|
}
|
}else{
|
return {
|
"num_per_page": $scope.expend_page_number,
|
"page_num": $scope.expend_pages,
|
"queryName": search
|
}
|
}
|
|
}
|
//申请单选择点击查询
|
$scope.expend_search_info = function(){
|
$scope.expend_pages = 1;
|
// $scope.page_number = "5";
|
get_expend_info($scope.expend_pages,$scope.expend_page_number);
|
}
|
//点击上一页
|
$scope.expend_pre_page = function(){
|
if($scope.expend_pages > 1){
|
$scope.expend_pages = parseInt($scope.expend_pages)-1;
|
// get_expend_info();
|
//前端分页
|
get_expend_info($scope.expend_pages,$scope.expend_page_number);
|
}
|
}
|
//点击下一页
|
$scope.expend_next_page = function(){
|
if($scope.expend_pages < Math.ceil($scope.expend_rows/$scope.expend_page_number)){
|
$scope.expend_pages = parseInt($scope.expend_pages)+1;
|
// get_expend_info();
|
//前端分页
|
get_expend_info($scope.expend_pages,$scope.expend_page_number);
|
}
|
}
|
//改变一页显示条数
|
$scope.expend_change_page_number = function(){
|
// get_expend_info();
|
//前端分页
|
$timeout(function(){
|
get_expend_info($scope.expend_pages,$scope.expend_page_number);
|
},1);
|
}
|
//获取选择申请横向信息
|
function get_expend_info(pages,page_num){
|
var parameter = expend_select_info();
|
if ($scope.expendPersonCode) {
|
parameter.type = $scope.type;
|
parameter.queryName = $scope.expendPersonCode;
|
}
|
http_service.post('apply/pass/applyInfo',parameter,function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
// $scope.expend_info = res.data.data;
|
// $scope.expend_rows = res.data.rows;
|
$scope.expend_rows = res.data.data.length;//前端分页
|
if(pages*parseInt(page_num)<= $scope.expend_rows){
|
$scope.expend_info = res.data.data.slice((pages-1)*page_num,page_num*pages);
|
}else{
|
$scope.expend_info = res.data.data.slice((pages-1)*page_num);
|
}
|
});
|
}
|
|
//显示报销单选择申请并获得数据
|
$scope.show_expend_select = function(edit){
|
if($rootScope.close_user_selector){
|
$rootScope.close_user_selector();
|
}
|
if(!edit){
|
return false;
|
}
|
|
var personCode = "";
|
var gcCpnAlias = "";
|
_.each(filed,function(_field){
|
if (_field.busCode === "personCode") {
|
_.each($scope.form_items,function(_form_items){
|
if (_form_items.gcMeCode === _field.mdCode) {
|
personCode = _form_items.render_value;
|
gcCpnAlias = _form_items.gcCpnAlias;
|
$scope.expendPersonCode = personCode;
|
}
|
})
|
}
|
})
|
if (!personCode) {
|
if (edit) {
|
$scope.$parent.$parent.tinfo("请先选择"+gcCpnAlias+"!");
|
} else {
|
$scope.$parent.tinfo("请先选择"+gcCpnAlias+"!");
|
}
|
return false;
|
}
|
|
$scope.expend_select_show = true;
|
$scope.expend_pages = 1;
|
$scope.expend_page_number = "5";
|
//获取表头信息
|
http_service.post('form/search/apply/showTables',{},function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
$scope.expend_heads = res.data.data;
|
// $scope.heads = res.data.data.cpnInfo;
|
})
|
//获取横向信息 前端分页
|
get_expend_info($scope.expend_pages,$scope.expend_page_number);
|
};
|
//关闭报销申请单选择申请
|
$rootScope.close_expend_select = function(){
|
$scope.close_expend_select();
|
}
|
$scope.close_expend_select = function(){
|
$scope.expend_select_show = false;
|
}
|
//点击空白关闭
|
$(".body").on("click",function(event){
|
event.preventDefault();
|
if($(".apply_control").has(event.target).length === 0){
|
$timeout(function(){
|
$scope.expend_select_show = false;
|
$scope.apply_select_show = false;
|
},1)
|
}
|
})
|
//匹配显示
|
function expend_reflect_bill(data){
|
var post_form_data;
|
if($scope.billid){
|
post_form_data = {"guTempType": 20,"cache_id":20,"tId":$scope.billid};
|
}else{
|
post_form_data = {"guTempType": 20,"cache_id":20};
|
}
|
http_service.post("form/list",post_form_data,function(res){
|
if(!res.data.opState){
|
return false;
|
}
|
var apply_form = res.data.data;
|
var expend_arr = [];
|
var expend_child = [];
|
var expend_child_arr = {
|
"child":[]
|
};
|
_.each(apply_form.child,function(_apply){
|
var id = _apply['gcColName'];
|
if(_apply.gcCpnType != 10){
|
if(data[id] != undefined){
|
expend_arr.push({"gcMeCode":_apply.gcMeCode,"render_value":data[id]});
|
}
|
}else{
|
_.each(data.child,function(_dcd){
|
expend_child = [];
|
_.each(_apply.child,function(_acd){
|
var cid = _acd['gcColName'];
|
if(_dcd[cid] != undefined){
|
expend_child.push({"gcMeCode":_acd.gcMeCode,"render_value":_dcd[cid]});
|
}
|
})
|
expend_child_arr.child.push(expend_child);
|
})
|
}
|
})
|
var FromCode,ToCode;
|
var new_expend_child_arr = [];
|
var new_expend_child_arr_yes = [];
|
_.each(filed,function(_filed){//找到出发地与结束地的主数据定义code
|
switch(_filed.busCode){
|
case "From":
|
FromCode = _filed.mdCode;
|
break;
|
case "To":
|
ToCode = _filed.mdCode;
|
break;
|
}
|
});
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType != 10){//非子表单
|
_.each(expend_arr,function(_earr){
|
if(form.gcMeCode == _earr.gcMeCode){
|
if(form['render_value'] == undefined || form['render_value'] == ""){
|
form['render_value'] = _earr.render_value;
|
_.extend(form,{"deleteflag_jour":true});//添加可删除状态
|
}
|
}
|
})
|
}else{//子表单
|
// var Fromland,Toland,Fromland_e,Toland_e;
|
// _.each(form.child,function(_fcd){
|
// if(_fcd.gcMeCode == FromCode){
|
// Fromland = _fcd['render_value'];
|
// }else if(_fcd.gcMeCode == ToCode){
|
// Toland = _fcd['render_value'];
|
// }
|
// })
|
// _.each(expend_child_arr.child,function(_eca){
|
// _.each(_eca,function(_ecd){
|
// if(_ecd.gcMeCode == FromCode){
|
// Fromland_e = _ecd.render_value;
|
// }else if(_ecd.gcMeCode == ToCode){
|
// Toland_e = _ecd.render_value;
|
// }
|
// });
|
// if(Fromland==Fromland_e&&Toland==Toland_e&&Fromland!=undefined&&Toland!=undefined){
|
// _.each(form.child,function(_fcd){
|
// _.each(_eca,function(_ecd){
|
// if(_fcd.gcMeCode == _ecd.gcMeCode){
|
// if(_fcd['render_value'] == undefined || _fcd['render_value'] == ""){
|
// $timeout(function(){
|
// _fcd['render_value'] = _ecd.render_value;
|
// },1)
|
// }
|
// }
|
// });
|
// });
|
// new_expend_child_arr_yes.push(_eca);
|
// }
|
//// else{
|
//// new_expend_child_arr.push(_eca);
|
//// }
|
// });
|
}
|
});
|
// function removeByValue(arr, val) {
|
// for(var i=0; i<arr.length; i++) {
|
// if(arr[i] == val) {
|
// arr.splice(i, 1);
|
// break;
|
// }
|
// }
|
// }
|
//
|
// _.each(new_expend_child_arr_yes,function(_new){
|
// removeByValue(expend_child_arr.child,_new);
|
// });
|
// new_expend_child_arr = expend_child_arr.child;
|
// var new_form_child;
|
// _.each($scope.form_list,function(_list){
|
// if(_list.gcCpnType == 10){
|
// new_form_child = _.cloneDeep(_list);
|
// }
|
// })
|
// var new_form_child_arr = [];
|
// _.each(new_expend_child_arr,function(_eca){
|
// _.each(new_form_child.child,function(_newcd){
|
// _.each(_eca,function(_ecd){
|
// if(_newcd.gcMeCode == _ecd.gcMeCode){
|
// _newcd['render_value'] = _ecd.render_value;
|
// }
|
// })
|
// })
|
// new_form_child_arr.push(_.cloneDeep(new_form_child));
|
// });
|
// var null_form = [];
|
// _.each($scope.form_items,function(form){
|
// if(form.gcCpnType == 10){
|
// var isnull = true;
|
// _.each(form.child,function(fcd){
|
// if(fcd['render_value'] != undefined && fcd['render_value'] != ""){
|
// isnull = false;
|
// }
|
// })
|
// if(isnull){
|
// null_form.push(form);
|
// }
|
// }
|
// })
|
// _.each(null_form,function(nform){
|
// removeByValue($scope.form_items,nform);
|
// })
|
// _.each(new_form_child_arr,function(newarr){
|
// _.extend(newarr,{"deleteflag_jour":true});//添加可删除状态
|
// $scope.form_items.push(newarr);
|
// });
|
// //添加行程按钮
|
// var jour_num = 0;
|
// _.each($scope.form_items, function(form) {
|
// if(form.gcCpnType == 10) {
|
// jour_num++;
|
// }
|
// });
|
// if(jour_num != 0) {
|
// $scope.add_jour_show = false;
|
// } else {
|
// $scope.add_jour_show = true;
|
// }
|
// new_form_child_arr = [];
|
$scope.expend_select_show = false;//关闭窗口
|
$scope.count_number();
|
})
|
}
|
//清空申请选择
|
$rootScope.clear_apply = function(){
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 14){//申请选择
|
$rootScope.expend_number_info = null;
|
form.render_value = "";
|
$scope.expend_heads = [];
|
$scope.expend_selectinfo = [];
|
$scope.expend_thshow = false;
|
}else if(form.gcCpnType != 10){
|
form.render_value = '';
|
}
|
});
|
_.remove($scope.form_items,function(form){
|
return form.gcCpnType == 10 && form.deleteflag_jour;
|
});
|
$scope.count_number();
|
//添加行程按钮显示
|
$rootScope.show_add_jour();
|
}
|
//点击选择按钮
|
$scope.selected_expend = function(data,thisitem){
|
$scope.expend_number = data.ap_number;
|
thisitem['render_value'] = data.ap_number;
|
$rootScope.expend_number_info = data.ap_number;
|
$scope.expend_selectinfo = [data];
|
$scope.expend_thshow = true;
|
http_service.post("apply/selectOne",{"apId":data.AP_ID},function(res){
|
expend_reflect_bill(res.data.data);
|
sort_bytime();//子表单按时间排序
|
});
|
}
|
},
|
post: function($scope, element, attrs) {
|
function get_user_budget_list(user_detail) {
|
var bugets_item = [];
|
_.each(user_detail, function(v) {
|
bugets_item.push({
|
'userId': v['an_user_id'],
|
'child': v['child']
|
});
|
});
|
return bugets_item;
|
}
|
|
if($scope.templateid) {
|
http_service.post('template/cpn/search', {
|
"gcTempId": $scope.templateid
|
}, function(res) {
|
complete(res.data);
|
});
|
} else {
|
var post_form_data;
|
if($scope.billid){
|
post_form_data = {
|
"guTempType":parseInt($scope.type),
|
"cache_id":parseInt($scope.type),
|
"tId":$scope.billid
|
}
|
}else{
|
post_form_data = {
|
"guTempType":parseInt($scope.type),
|
"cache_id":parseInt($scope.type)
|
}
|
}
|
http_service.post('form/list',post_form_data, function(res) {
|
if(!res.data.opState){
|
return false;
|
}
|
if($rootScope.close_lock == true){//页面关闭则不做后续操作
|
return false;
|
}
|
complete(res.data);
|
classify();
|
});
|
}
|
//判断预算分类
|
// TODO
|
function classify() {
|
// _.each(filed, function(item) {
|
// if(item.busCode == 'budgetType') {
|
// $scope.typecode = item.mdCode;
|
// _.each($scope.form_items, function(info) {
|
// _.each(filed,function(_filed){
|
// switch (_filed.busCode){
|
// case "project":
|
// if(_filed.mdCode == info.gcMeCode){
|
// info['typeshow'] = 1;
|
// }
|
// break;
|
//// case "orgCode":
|
//// if(_filed.mdCode == info.gcMeCode){
|
//// info['typeshow'] = 1;
|
//// }
|
//// break;
|
// }
|
// })
|
// if(info.gcMeCode == $scope.typecode) {
|
// $scope.$watch(function() {
|
// return info.render_value;
|
// }, function() {
|
//// http_service.post('base/data/search',{'code':$scope.typecode},function(res){
|
//// var types = res.data.data.child;
|
//// _.each(types,function(type){
|
//
|
// _.each(cddata,function(data){
|
// if(data.cdName == 'orgBudget'){
|
// if(info.render_value == data.cdCode){
|
// info.select_value = '预算部门';
|
// deptbudget();
|
// }
|
// if(!info.render_value){
|
// info.render_value = data.cdCode
|
// info.select_value = '预算部门';
|
// deptbudget();
|
// }
|
// }else if(data.cdName == 'projectBudget'){
|
// if(info.render_value == data.cdCode){
|
// info.select_value = '预算项目';
|
// programbudget();
|
// }
|
// }
|
// })
|
//
|
//// if(info.render_value == '002') {
|
//// info.select_value = '预算部门';
|
//// deptbudget();
|
//// } else if(info.render_value == '001') {
|
//// info.select_value = '预算项目';
|
//// programbudget();
|
//// }else{
|
//// info.render_value = '002';
|
//// info.select_value = '预算部门';
|
//// deptbudget();
|
//// // info.render_value = '001';
|
//// // info.select_value = '预算项目';
|
//// // programbudget();
|
//// }
|
// $rootScope.select_value = info.render_value;
|
// })
|
//// })
|
////
|
//// })
|
// }
|
// })
|
// }
|
// })
|
}
|
//判断是否进行报销人验证
|
function is_check_bill_user(name,callback){
|
var post_data;
|
var moneyTypeValiPersion,moneyTypeName;
|
_.each(filed,function(_filed){
|
switch(_filed.busCode){
|
case "moneyTypeValiPersion":
|
moneyTypeValiPersion = _filed;
|
break;
|
case "moneyTypeName":
|
moneyTypeName = _filed;
|
break;
|
}
|
})
|
post_data = {
|
"code":moneyTypeValiPersion.mdCode,
|
"criteria":[{
|
"key":moneyTypeName.elIden,
|
"val":name
|
}],
|
"views":[moneyTypeValiPersion.elIden]
|
};
|
http_service.post("base/data/getVals",post_data,function(res){
|
var data = res.data.data[0];
|
if(data != undefined && data[moneyTypeValiPersion.elIden] != undefined && data[moneyTypeValiPersion.elIden] !== ""){
|
callback(true);
|
}else{
|
callback(false);
|
}
|
})
|
}
|
//提取表单错误数据
|
$rootScope.get_all_err_data = function(){
|
return $scope.get_all_err_data();
|
}
|
$scope.get_all_err_data = function(){
|
var all_err_data = {'form_err_data':[]};
|
// all_err_data.form_err_data = _.cloneDeep($scope.form_items);
|
_.each($scope.form_items,function(form){// 获取标签上红字
|
if(form.gcCpnType != 10 && form.gcCpnType != 17){
|
var new_form;
|
var expend_standard = form.expend_standard;
|
var expend_standard_sp = form.expend_standard_sp;
|
var billMoney = form.billMoney;
|
var bhName = form.bhName;
|
var bbName = form.bbName;
|
var sys_value = form.sys_value;
|
var standard_money = form.standard_money;
|
var is_red = form.is_red;
|
var nobill_cd = form.nobill_cd;
|
var sys_red = form.sys_red;
|
var gcShowFlag = form.gcShowFlag;//用以单据固化后隐藏控件
|
new_form = {'gcMeCode':form.gcMeCode};
|
//保存校验规则
|
// var rule_err = $('i[gcname="' + form.gcColName + '"]');
|
// if(rule_err.length != 0){
|
// _.extend(new_form,{'rule_err':rule_err.html()});
|
// }
|
//保存校验规则 end
|
//保存老数据
|
_.extend(new_form,{'render_value':form.render_value,'gcColName':form.gcColName});
|
if(form.gcCpnType == 12){
|
_.extend(new_form,{'old_users_selected':form.old_users_selected})
|
}else if(form.gcCpnType == 6){
|
_.extend(new_form,{'select_value':form.select_value});
|
}
|
//保存老数据 end
|
|
if(expend_standard != undefined){
|
_.extend(new_form,{'expend_standard':expend_standard});
|
}
|
if(expend_standard_sp != undefined){
|
_.extend(new_form,{'expend_standard_sp':expend_standard_sp});
|
}
|
if(billMoney != undefined){
|
_.extend(new_form,{'billMoney':billMoney});
|
}
|
if(bhName != undefined){
|
_.extend(new_form,{'bhName':bhName});
|
}
|
if(bbName != undefined){
|
_.extend(new_form,{'bbName':bbName});
|
}
|
if(sys_value != undefined){
|
_.extend(new_form,{'sys_value':sys_value});
|
}
|
if(standard_money != undefined){
|
_.extend(new_form,{'standard_money':standard_money});
|
}
|
if(is_red != undefined){
|
_.extend(new_form,{'is_red':is_red});
|
}
|
if(nobill_cd != undefined){
|
_.extend(fonew_formrm,{'nobill_cd':nobill_cd});
|
}
|
if(sys_red != undefined){
|
_.extend(new_form,{'sys_red':sys_red});
|
}
|
if(gcShowFlag != undefined){//用以单据固化后隐藏控件
|
_.extend(new_form,{'gcShowFlag':gcShowFlag});
|
}
|
all_err_data.form_err_data.push(new_form);
|
}else{
|
var new_form;
|
var is_nobill = form.is_nobill;
|
var bill_user_err = form.bill_user_err;
|
if(form.num == undefined){
|
new_form = {'num':'','child':[],'gcCpnType':form.gcCpnType};
|
}else{
|
new_form = {'num':form.num,'child':[],'gcCpnType':form.gcCpnType};
|
}
|
if(is_nobill != undefined){
|
_.extend(new_form,{'is_nobill':is_nobill,'nobill_red':true});
|
}
|
if(bill_user_err != undefined && bill_user_err != ""){
|
_.extend(new_form,{'bill_user_err':bill_user_err,'nobill_red':true});
|
}
|
_.each(form.child,function(cd){
|
var new_cd;
|
var expend_standard = cd.expend_standard;
|
var expend_standard_sp = cd.expend_standard_sp;
|
var billMoney = cd.billMoney;
|
var bhName = cd.bhName;
|
var bbName = cd.bbName;
|
var sys_value = cd.sys_value;
|
var standard_money = cd.standard_money;
|
var is_red = cd.is_red;
|
var nobill_cd = cd.nobill_cd;
|
var sys_red = cd.sys_red;
|
var gcShowFlag = cd.gcShowFlag//用以单据固化后隐藏控件
|
new_cd = {'gcMeCode':cd.gcMeCode};
|
//保存校验规则
|
// if(form.num == undefined){
|
// var rule_err = $('i[gcname="' + cd.gcColName + '"][gcnum="0"]');
|
// }else{
|
// var rule_err = $('i[gcname="' + cd.gcColName + '"][gcnum="' + (form.num - 1) + '"]');
|
// }
|
// if(rule_err.length != 0){
|
// _.extend(new_cd,{'rule_err':rule_err.html()});
|
// }
|
//保存校验规则 end
|
//保存老数据
|
_.extend(new_cd,{'render_value':cd.render_value,'gcColName':cd.gcColName});
|
if(cd.gcCpnType == 12){
|
_.extend(new_cd,{'old_users_selected':cd.old_users_selected})
|
}else if(cd.gcCpnType == 6){
|
_.extend(new_cd,{'select_value':cd.select_value});
|
}
|
//保存老数据 end
|
|
if(expend_standard != undefined){
|
_.extend(new_cd,{'expend_standard':expend_standard});
|
}
|
if(expend_standard_sp != undefined){
|
_.extend(new_cd,{'expend_standard_sp':expend_standard_sp});
|
}
|
if(billMoney != undefined){
|
_.extend(new_cd,{'billMoney':billMoney});
|
}
|
if(bhName != undefined){
|
_.extend(new_cd,{'bhName':bhName});
|
}
|
if(bbName != undefined){
|
_.extend(new_cd,{'bbName':bbName});
|
}
|
if(sys_value != undefined){
|
_.extend(new_cd,{'sys_value':sys_value});
|
}
|
if(standard_money != undefined){
|
_.extend(new_cd,{'standard_money':standard_money});
|
}
|
if(is_red != undefined){
|
_.extend(new_cd,{'is_red':is_red});
|
}
|
if(nobill_cd != undefined){
|
_.extend(new_cd,{'nobill_cd':nobill_cd});
|
}
|
if(sys_red != undefined){
|
_.extend(new_cd,{'sys_red':sys_red});
|
}
|
if(gcShowFlag != undefined){//用以单据固化后隐藏控件
|
_.extend(new_cd,{'gcShowFlag':gcShowFlag});
|
}
|
new_form.child.push(new_cd);
|
});
|
all_err_data.form_err_data.push(new_form);
|
}
|
});
|
//获取下方错误信息
|
if($scope.cost_err != undefined && $scope.cost_err.length > 0){// 获取费用不符合标准提示信息
|
_.extend(all_err_data,{"cost_err":_.cloneDeep($scope.cost_err)});
|
}
|
if($scope.rule_bill != undefined && $scope.rule_bill.length > 0){// 获取票据内容错误信息
|
_.extend(all_err_data,{"rule_bill":_.cloneDeep($scope.rule_bill)});
|
}
|
if($scope.unjoin_bill != undefined && $scope.unjoin_bill.child.length > 0){// 获取未关联到行程的票据错误信息
|
_.extend(all_err_data,{"unjoin_bill":_.cloneDeep($scope.unjoin_bill)});
|
}
|
if($scope.other_cost != undefined && $scope.other_cost.length > 0){// 获取其它费用提示
|
_.extend(all_err_data,{"other_cost":_.cloneDeep($scope.other_cost)});
|
}
|
if($scope.maindata_err != undefined && $scope.maindata_err.length > 0){// 获取主数据缺失信息
|
_.extend(all_err_data,{"maindata_err":_.cloneDeep($scope.maindata_err)});
|
}
|
_.extend(all_err_data,{"all_err_show":_.cloneDeep($scope.all_err_show)});
|
_.extend(all_err_data,{"show_cost_err":_.cloneDeep($scope.show_cost_err)});
|
_.extend(all_err_data,{"rule_bill_show":_.cloneDeep($scope.rule_bill_show)});
|
_.extend(all_err_data,{"unjoin_bill_show":_.cloneDeep($scope.unjoin_bill_show)});
|
_.extend(all_err_data,{"nobill_money_hint":_.cloneDeep($scope.nobill_money_hint)});
|
//
|
return all_err_data;
|
}
|
//reflect bill data
|
$rootScope.reflect_bill = function(){
|
reflect_bill();
|
}
|
//改变订单状态
|
$rootScope.change_orderstatus = function(orderstatus_text){
|
$scope.orderstatus = orderstatus_text;
|
}
|
function reflect_bill() {
|
if($rootScope.close_lock == true){
|
return false;
|
}
|
$rootScope.formula_num = 0;
|
$rootScope.formula_num_id = [];//查询详情时初始化需要进行请求的前端公式 计数变量
|
var get_bill_data_url = '';
|
var post_data = {};
|
var order_number;
|
if($scope.type === 10) {
|
get_bill_data_url = 'budget/selectOne';
|
post_data = { "buId": $scope.billid };
|
order_number = "bu_number";
|
} else if($scope.type === 20) {
|
get_bill_data_url = 'apply/selectOne';
|
post_data = { "apId": $scope.billid };
|
order_number = "ap_number";
|
} else if($scope.type === 30) {
|
get_bill_data_url = 'expend/selectOne';
|
post_data = { "exId": $scope.billid };
|
order_number = "ex_number";
|
}
|
|
http_service.post(get_bill_data_url, post_data, function(res) {
|
var data = res.data.data;
|
var sub_frms_data = [];
|
var sub_frms = [];
|
var frm_items = [];
|
$scope.billState = data.billState;//报销单状态
|
$scope.exCouldNumber = data.exCouldNumber//云单编号
|
$scope.stepCode = data.stepCode;// 流程状态
|
$rootScope.stepCode = data.stepCode;
|
$rootScope.lock = data.lock//锁头
|
$rootScope.form_id = $scope.billid//表单ID
|
//云单编号
|
if(data.exCouldNumber){
|
$scope.$parent.exCouldNumber = data.exCouldNumber;
|
}
|
|
// 订单状态为审单成功 并且未提交流程的 显示重新审单
|
if ($scope.billState) {
|
if ((!data.stepCode || data.stepCode == 20) && ($scope.billState == 15 || $scope.billState == 19)){
|
$scope.$parent.restart_review_show = true;
|
}
|
}
|
|
|
if(data.billState) {
|
$scope.$parent.billState = data.billState;//报销单状态
|
}
|
//重新纠偏按钮显示
|
if(data.stepCode == undefined || data.stepCode == ""){
|
$scope.$parent.rectification_show = true;
|
}
|
//票据内容错误信息
|
$scope.err_bill = res.data.data.errMsg;
|
if($scope.err_bill != undefined && $scope.err_bill.length != 0){
|
$scope.err_bill_show = true;
|
}else{
|
$scope.err_bill_show = false;
|
}
|
// if(data.stepCode != 30 && data.stepCode != 10){// 已完成/审核中 表单 不进行任何红字验证 和公式计算
|
//错误信息提示
|
$scope.rule_bill = res.data.data.ruleMsg;
|
$scope.$parent.submit_Pors=true;
|
if($scope.rule_bill != undefined && $scope.rule_bill.length != 0) {
|
$scope.rule_bill_show = true;
|
_.each($scope.rule_bill, function(rule) {
|
if(rule.ruLevel == 30) {
|
$scope.$parent.submit_Pors=false;
|
}
|
});
|
} else {
|
$scope.rule_bill_show = false;
|
}
|
// }
|
if(data.billState == 49){
|
$scope.$parent.re_account_show = true;
|
$scope.$parent.re_account_exid = data.ex_id;
|
}else{
|
$scope.$parent.re_account_show = false;
|
}
|
sub_frms_data = data.child;
|
//若无行程信息 则显示添加行程按钮
|
if(data.child == undefined || data.child.length == 0){
|
$scope.add_jour_show = true;
|
}
|
if(data.fchild == undefined || data.fchild.length == 0){
|
$scope.add_pay_show = true;
|
}
|
$scope.selectinfo = [];
|
$scope.createtime = data.insT;
|
//显示订单号
|
$scope.$parent.order_number = data[order_number];
|
var statuslist = [];
|
_.each(cddata,function(item){
|
if(item.cdType == 10){
|
statuslist.push(item)
|
}
|
})
|
_.each(statuslist,function(list){
|
if(list.cdCode == data.billState){
|
$scope.orderstatus = list.cdName
|
}
|
})
|
//自动审单中(票据处理中)不可编辑
|
if(data.billState == 10){
|
$scope.$parent.editflag = false;
|
}
|
//票据处理中或失败 不能提交
|
if(data.billState == 10 || data.billState == 19){
|
$scope.$parent.commitflag_bill = false;
|
}
|
//票据处理中或完成 不能删除
|
if(data.billState == 10 || data.billState == 15){
|
$scope.$parent.deleteflag = false;
|
}
|
if(data.billState == 19){//票据处理失败 显示重新上传按钮
|
$scope.$parent.re_upload = true;
|
$scope.$parent.bill_commit_text = "重新上传";
|
}else if(data.billState == 20){//无票据 显示票据上传按钮
|
$scope.$parent.re_upload = true;
|
$scope.$parent.bill_commit_text = "票据上传";
|
}else{
|
$scope.$parent.re_upload = false;
|
}
|
//assign plugin value
|
$rootScope.budget_back = true;
|
_.each($scope.form_items, function(item){
|
var id = item['gcColName'];
|
if(id && data[id]){
|
if(item.gcCpnType == 0){//找到占用预算控件
|
//占用预算控件回调
|
$rootScope.budget_selected = data[id];
|
http_service.post('budget/pass/budgetInfo',{"buNumber":data[id],"type":$scope.type},function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
if(!res.data.opState){
|
return false;
|
}
|
var budget_info = res.data.data[0];
|
//获取表头信息
|
|
http_service.post('form/search/showTables',{},function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
$scope.heads = res.data.data;
|
var startTime,endTime;
|
|
$scope.info = {};
|
$scope.sumMoney = "";
|
startTime = "";
|
endTime = "";
|
$scope.orgName = "";
|
_.each($scope.heads,function(hd){
|
_.each(filed,function(_filed){
|
if(hd.gcMeCode == _filed.mdCode){
|
if(budget_info == undefined){
|
return false;
|
}
|
if(budget_info[hd.gcColName]){
|
$scope.info[hd.gcColName] = budget_info[hd.gcColName];
|
switch(_filed.busCode){
|
case "sumMoney"://预算金额
|
$scope.sumMoney = "【"+hd.gcCpnAlias+"】 "+budget_info[hd.gcColName]+" ";
|
$scope.info[hd.gcColName] = $scope.sumMoney;
|
break;
|
case "beginCalendar":
|
startTime = budget_info[hd.gcColName];
|
$scope.info[hd.gcColName] = startTime;
|
break;
|
case "endCalendar":
|
endTime = budget_info[hd.gcColName];
|
$scope.info[hd.gcColName] = endTime;
|
break;
|
case "orgName"://组织机构
|
$scope.orgName = budget_info[hd.gcColName];
|
$scope.info[hd.gcColName] = $scope.orgName;
|
break;
|
}
|
}
|
}
|
});
|
});
|
if(startTime&&endTime){
|
$scope.time = "【预算时间】"+startTime+"~"+endTime;
|
$rootScope.startTime = startTime;
|
$rootScope.endTime = endTime;
|
}
|
if(budget_info){
|
$rootScope.sumMoney_budget = budget_info.bu_money;
|
$rootScope['child_money'] = budget_info.child_money;
|
$scope.thshow = true;
|
$scope.info['bu_number'] = budget_info.bu_number;
|
$scope.info['bu_money'] = budget_info.bu_money;
|
$scope.selectinfo.push($scope.info);
|
}
|
})
|
});
|
}else if(item.gcCpnType == 14){//选择申请回调
|
item['render_value'] = data[id];
|
$rootScope.expend_number_info = data[id];
|
http_service.post('apply/pass/applyInfo',{"apNumber":data[id],"type":$scope.type},function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
if(!res.data.opState){
|
return false;
|
}
|
$scope.expend_selectinfo = res.data.data;
|
//获取表头信息
|
|
http_service.post('form/search/apply/showTables',{},function(res){
|
$rootScope.search_hint(res.data.data,'arrary');
|
$scope.expend_heads = res.data.data;
|
$scope.expend_thshow = true;
|
})
|
});
|
}else{
|
item['render_value'] = data[id];
|
}
|
}
|
});
|
var pay_child = [];
|
_.each($scope.form_items, function(item){//支付方式子表单回调 step1
|
if(item.gcCpnType == 17){
|
_.each(data.fchild,function(fcd){
|
_.each(item.child,function(pay){
|
var pay_id = pay['gcColName'];
|
if(pay_id && fcd[pay_id]){
|
pay.render_value = fcd[pay_id];
|
}
|
})
|
_.extend(item,{"ef_id":fcd.ef_id});
|
pay_child.push(_.cloneDeep(item));
|
})
|
}
|
})
|
_.remove($scope.form_items,function(o){
|
return o.gcCpnType == 17;
|
})
|
_.each(pay_child, function(item){//支付方式子表单回调 step3
|
$scope.form_items.push(item);
|
})
|
|
_.each($scope.form_items, function(item) {//保存人员信息
|
if(item['gcCpnType'] == 12) {
|
var user = [{
|
"personCode":item.render_value
|
}];
|
myServeice.setuser(user);
|
}
|
});
|
|
_.each($scope.form_items, function(item) {
|
if(item['gcCpnType'] == 10) {
|
_.each(sub_frms_data, function(v, k) {
|
var _item = _.cloneDeep(item);
|
frm_items.push(_item);
|
sub_frms.push(_item);
|
})
|
} else {
|
frm_items.push(item);
|
}
|
});
|
_.each(sub_frms_data, function(sub_frm_data, k) {
|
|
var bugets_item = get_user_budget_list(sub_frm_data['child']);
|
sub_frms[k]['budget_list'] = bugets_item;
|
sub_frms[k]['money'] = sub_frms_data[k]['money'];
|
sub_frms[k]['aj_id'] = sub_frms_data[k]['aj_id'];
|
sub_frms[k]['ej_id'] = sub_frms_data[k]['ej_id'];
|
sub_frms[k]['ej_days'] = sub_frms_data[k]['ej_days'];
|
sub_frms[k]['ej_hours'] = sub_frms_data[k]['ej_hours'];
|
sub_frms[k]['ej_kms'] = sub_frms_data[k]['ej_kms'];
|
sub_frms[k]['span_night'] = sub_frms_data[k]['span_night'];
|
if(sub_frms_data[k]['billInfos'] != undefined){
|
sub_frms[k]['billInfos_str'] = sub_frms_data[k]['billInfos'];
|
sub_frms[k]['billInfos'] = [JSON.parse(sub_frms_data[k]['billInfos'])];
|
}
|
var sub_frms_child = sub_frms[k].child;
|
_.each(sub_frms_child, function(child) {
|
var sfc_key = child['gcColName'];
|
if(sfc_key && sub_frm_data[sfc_key]) {
|
child['render_value'] = sub_frm_data[sfc_key];
|
}
|
});
|
});
|
$scope.form_items = frm_items;
|
|
$scope.sysSearchFinsh = true;
|
//
|
$scope.$parent.form_data['child'] = $scope.form_items;
|
if(data['ex_id'] != undefined){
|
$scope.expned_id = data['ex_id'];
|
}
|
$scope.$parent.form_data['ap_id'] = data['ap_id'] || data['bu_id'] || data['ex_id'];
|
|
console.log($scope.form_items);
|
console.log(JSON.stringify($scope.form_items));
|
//监听显示是否完成
|
var inited_flag = $interval(function(){
|
|
var fiished = true;
|
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 12 || form.gcCpnType == 6){
|
// if(form.inited != true){
|
// console.log(form.inited);
|
fiished = true;
|
// }
|
}else if(form.gcCpnType == 10 || form.gcCpnType == 17){
|
_.each(form.child,function(cd){
|
if(cd.gcCpnType == 12 || cd.gcCpnType == 6){
|
if(cd.inited != true){
|
fiished = false;
|
}
|
}
|
})
|
}
|
});
|
// console.log('emmmmmmm');
|
if(fiished == true){
|
$scope.$parent.init_btn_flag = true;
|
$interval.cancel(inited_flag);
|
inited_flag = undefined;
|
}else{
|
$scope.$parent.init_btn_flag = false;
|
}
|
},1000);
|
|
//跨行程验证开始时间
|
$rootScope.check_data_cross();
|
//报销单计算费用
|
if($scope.type == 30){
|
if(data.stepCode != 30 && data.stepCode != 10){// 已完成/审核中 表单 不进行任何验证 和计算
|
//格式化报销人验证 信息
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
if(form.billInfos){
|
var bill_user_check = [];
|
var bill_user_info = [];
|
bill_user_check.push(bill_user_info);
|
_.each(form.billInfos,function(bill){
|
var fromDate_value = "";//出发日期特殊处理 = 出发日期加时间
|
_.each(bill.map,function(_map){
|
if(_map.bhKey == "FromDate"){
|
fromDate_value += _map.bhValue;
|
}
|
});
|
_.each(bill.map,function(_map){
|
if(_map.bhKey == "FromTime"){
|
fromDate_value += " " + _map.bhValue;
|
}
|
});
|
_.each(bill.map,function(_map){
|
if(_map.bhKey == "FromDate"){
|
_map.bhValue = fromDate_value;
|
_map.bhName = fromDate_value;
|
}
|
})//特殊处理结束
|
// var fromDate_value_cd = "";//出发日期特殊处理 = 出发日期加时间
|
// _.each(bill.child,function(bd){
|
// if(bd.bbKey == "FromDate"){
|
// fromDate_value_cd += bd.bbValue;
|
// }
|
// });
|
// _.each(bill.child,function(bd){
|
// if(bd.bbKey == "FromTime"){
|
// fromDate_value_cd += " " + bd.bbValue;
|
// }
|
// });
|
// _.each(bill.child,function(bd){
|
// if(bd.bbKey == "FromDate"){
|
// bd.bbValue = fromDate_value_cd;
|
// bd.bbName = fromDate_value_cd;
|
// }
|
// });//特殊处理结束
|
|
var bill_info_data = {};
|
var PersonalName,persionCode
|
, billTypeName, billTypeCode;
|
_.each(bill.map,function(_bmap){
|
|
if(_bmap.bhKey == "PersonalName"){
|
PersonalName = _bmap.bhName;
|
persionCode = _bmap.bhValue;
|
}
|
|
if(_bmap.bhKey == "billType"){
|
billTypeName = _bmap.bhName;
|
billTypeCode = _bmap.bhValue;
|
}
|
});
|
if(PersonalName && persionCode && billTypeName && billTypeCode){
|
is_check_bill_user(billTypeName,function(flag){
|
if(flag){
|
_.extend(bill_info_data,{
|
"typeName":billTypeName,
|
"typeCode":billTypeCode,
|
"PersonalName":PersonalName,
|
"persionCode":persionCode
|
})
|
bill_user_info.push(bill_info_data);
|
form['bill_user_check'] = bill_user_check;
|
$rootScope.check_bill_user();
|
}
|
})
|
|
}
|
});
|
}
|
}
|
});
|
}
|
|
if(data.stepCode != 30 && data.stepCode != 10){// 已完成/审核中 表单 不进行任何验证 和计算
|
$scope.bill_data_check();//获取详情数据后 验证
|
|
if($scope.billState == 10){//报销单状态为自动审单中状态,则发送验证是否存在主数据缺失
|
if($scope.exCouldNumber != ""){//无云单编号 不进行主数据缺失验证
|
_.each($scope.formula,function(formula){//验证前先计算前端公式
|
$scope.formula_computing(formula,$scope.form_items);
|
});
|
|
http_service.post("errmsg/search/checkBillInfo",{"oCode":data.exCouldNumber},function(res){//发送验证请求
|
if(res.data.opState){
|
$scope.select_isright = res.data.data;//true 为没有主数据缺失 false为有缺失
|
}
|
$scope.query_journel_budget($scope.type,function(){},true);//验证完后计算 前端公式 },5000);
|
})
|
}
|
}else{
|
$scope.query_journel_budget($scope.type,function(){},true);
|
}
|
}
|
|
|
//若不是本人的报销单 则不能编辑和删除
|
if(data.insP != app_userinfo.userId){
|
$scope.$parent.editflag = false;
|
$scope.$parent.deleteflag = false;
|
}
|
|
|
}
|
//获取费用类型数据
|
http_service.post("supp/search/master", { "mdType": 1 }, function(res) {
|
$scope.cost_type = res.data.data;
|
_.each($scope.form_items, function(cd) {
|
if(cd.budget_list && cd.budget_list.length != 0) {
|
_.each($scope.cost_type, function(type) {
|
_.each(cd.budget_list[0].child, function(_list) {
|
if(_list.jp_cd_code == type.mdCode) {
|
_.extend(type, { "jp_amount": _list.jp_amount, "jp_cd_code": _list.jp_cd_code });
|
}
|
})
|
})
|
cd.budget_list[0].child = $scope.cost_type;
|
}
|
})
|
});
|
|
|
$scope.count_number();
|
|
if(data.errInfo != undefined && JSON.parse(data.errInfo) != undefined && (data.stepCode != undefined && (data.stepCode == 30|| data.stepCode == 10))){// 显示 已完成/审核中 表单的错误信息
|
//
|
data.errInfo = JSON.parse(data.errInfo)
|
_.each($scope.form_items,function(form){
|
_.each(data.errInfo.form_err_data,function(form_err){
|
if(form.gcCpnType != 10 && form.gcCpnType != 17){
|
if(form.gcMeCode != undefined && form.gcMeCode == form_err.gcMeCode){
|
_.extend(form,form_err);
|
}
|
}else{
|
if(form.num == undefined){
|
form.num = "";
|
}
|
var fnum = form.num?(form.num - 1):0;
|
if(form.num == form_err.num && form.gcCpnType == form_err.gcCpnType){
|
if(form_err.is_nobill != undefined){
|
_.extend(form,{'is_nobill':form_err.is_nobill});
|
}
|
if(form_err.bill_user_err != undefined && form_err.bill_user_err != ""){
|
_.extend(form,{'bill_user_err':form_err.bill_user_err});
|
}
|
if(form_err.nobill_red != undefined){
|
_.extend(form,{'nobill_red':form_err.nobill_red});
|
}
|
_.each(form.child,function(cd){
|
_.each(form_err.child,function(e_cd){
|
if(cd.gcMeCode != undefined && cd.gcMeCode == e_cd.gcMeCode){
|
_.extend(cd,e_cd);
|
// if(e_cd.rule_err != undefined){
|
//
|
//
|
// if(cd.gcCpnType == 6){
|
//
|
// $timeout(function(){
|
// $('*[gccolname="' + cd.gcColName + '"]:eq(' + fnum + ')').closest('.select').append("<i class='errinfo_point' gcname="+cd.gcColName+" gcnum="+fnum+" style='position:absolute;margin-top:4px;'>" + e_cd.rule_err +"</i>");
|
// },10)
|
//
|
// }else if(cd.gcCpnType == 5){
|
// $timeout(function(){
|
// $("<i class='errinfo_point' gcname="+cd.gcColName+" gcnum="+fnum+">" + e_cd.rule_err + "</i>").appendTo($('*[gccolname="' + cd.gcColName + '"]:eq(' + fnum + ')').closest(".timeinfo"));
|
// },10)
|
//
|
// }else{
|
//
|
// }
|
// }
|
}
|
});
|
});
|
}
|
}
|
});
|
});
|
if(data.errInfo.all_err_show != undefined){
|
$scope.all_err_show = data.errInfo.all_err_show;
|
}
|
if(data.errInfo.show_cost_err != undefined){
|
$scope.show_cost_err = data.errInfo.show_cost_err;
|
}
|
if(data.errInfo.rule_bill_show != undefined){
|
$scope.rule_bill_show = data.errInfo.rule_bill_show;
|
}
|
if(data.errInfo.unjoin_bill_show != undefined){
|
$scope.unjoin_bill_show = data.errInfo.unjoin_bill_show;
|
}
|
if(data.errInfo.nobill_money_hint != undefined){
|
$scope.nobill_money_hint = data.errInfo.nobill_money_hint;
|
}
|
if(data.errInfo.maindata_err != undefined){
|
$scope.maindata_err = data.errInfo.maindata_err;
|
}
|
if(data.errInfo.other_cost != undefined){
|
$scope.other_cost = data.errInfo.other_cost;
|
}
|
if(data.errInfo.unjoin_bill != undefined){
|
$scope.unjoin_bill = data.errInfo.unjoin_bill;
|
}
|
if(data.errInfo.rule_bill != undefined){
|
$scope.rule_bill = data.errInfo.rule_bill;
|
}
|
if(data.errInfo.cost_err != undefined){
|
$scope.cost_err = data.errInfo.cost_err;
|
}
|
$timeout(function(){
|
$rootScope.checkdata();//已完成/审核中单子 进行规则校验
|
},10)
|
}
|
|
});
|
}
|
//验证报销人信息
|
$rootScope.check_bill_user = function(){
|
//找到人员控件
|
var now_user;
|
_.each($scope.form_items,function(item){
|
if(item.gcCpnType == 12){
|
now_user = item.render_value;
|
}
|
});
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
if(form.bill_user_check){
|
var bill_user_err = [];
|
_.each(form.bill_user_check,function(bill){
|
_.each(bill,function(info){
|
var err;
|
if(info.persionCode){
|
if(info.persionCode != now_user){
|
err = info.typeName + " '"+info.PersonalName + "' 与单据人员不符";
|
bill_user_err.push(err);
|
}
|
}else{
|
err = info.typeName + " '"+info.PersonalName + "' 与单据人员不符";
|
bill_user_err.push(err);
|
}
|
})
|
});
|
if(bill_user_err.length != 0){
|
form['is_red'] = true;
|
form['nobill_red'] = true;
|
form['bill_user_err'] = bill_user_err.join(",");
|
}else{
|
form['is_red'] = false;
|
form['nobill_red'] = false;
|
form['bill_user_err'] = "";
|
}
|
}
|
}
|
});
|
$scope.have_err();
|
}
|
//获取详情数据后 验证
|
$scope.bill_data_check = function(){
|
if($scope.stepCode == 30 || $scope.stepCode == 10){// 已完成/审核中 表单 不验证
|
return false;
|
}
|
if($scope.type != 30){
|
return false; // 非报销单 不进行票据信息验证
|
}
|
//将城市间交通费 放在最后
|
// _.each($scope.form_items, function(form){
|
// if(form.gcCpnType == 10){
|
// if(form.billInfos != undefined && form.billInfos.length != 0){
|
// var city_to_tity = [];
|
// _.each(form.billInfos, function(bill){
|
// _.each(bill.map, function(map){
|
// if(map.bhName == "城市间交通费" && map.bhKey == "billType"){
|
// city_to_tity.push(bill);
|
// }
|
// });
|
// });
|
// _.pullAllBy(form.billInfos,city_to_tity,"bhBillCode");
|
// form.billInfos.push(city_to_tity[0]);
|
// }
|
// }
|
// });
|
|
//获取离开日期控件的主数据code 和要进行无票信息验证的控件的主数据code
|
var journeyEndDate_code;
|
var nobill_data_check = [];
|
_.each(filed,function(_filed){
|
if(_filed.busCode == 'journeyEndDate'){
|
journeyEndDate_code = _filed.mdCode;
|
}
|
if(_filed.mappingIden && _filed.mappingIden == 'billInfo'){
|
nobill_data_check.push(_filed.mdCode);
|
}
|
})
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
if(form.billInfos){
|
if(form.billInfos.length == 0){
|
form['is_nobill'] = "无票据行程";
|
form['nobill_red'] = true;
|
}
|
_.each(form.billInfos,function(bill){
|
_.each(form.child,function(cd){
|
|
if(cd.nobill_cd == undefined && _.indexOf(nobill_data_check,cd.gcMeCode) != -1){//无票据信息验证 只验证一次
|
if(cd.gcMeCode != journeyEndDate_code){//有票据信息的行程 控件 默认为红色 除了离开日期控件
|
cd['nobill_cd'] = true;
|
}
|
if(cd.joinMath.length > 0){//自动计算的控件 不进行无票据信息验证
|
cd['nobill_cd'] = false;
|
}
|
}
|
|
_.each(bill.map,function(_map){
|
if(_map.bhName == undefined || _map.bhName == "" && _map.bhKey != "ToDate"){//若为空 则默认为无
|
_map['bhName'] = '无';
|
}
|
_.each(filed,function(_filed){
|
if(_map.bhKey == "ToDate" && _filed.busCode == _map.bhKey && cd.gcMeCode == _filed.mdCode){//到达日期 不验证
|
//
|
cd['nobill_cd'] = false;
|
cd['is_red'] = false;
|
return false;
|
}
|
if(_filed.busCode == _map.bhKey && cd.gcMeCode == _filed.mdCode){
|
cd['nobill_cd'] = false;
|
cd.bhName = _map.bhName;
|
cd.bhValue = _map.bhValue;
|
if(cd.render_value == "" || cd.render_value == undefined){
|
cd['is_red'] = true;
|
}else if(_map.bhValue != cd.render_value || _map.bhName == '无'){
|
cd['is_red'] = true;
|
}else{
|
cd['is_red'] = false;
|
}
|
return false;
|
}
|
})
|
});
|
|
// _.each(bill.child,function(bd){
|
// if(bd.bbName == undefined || bd.bbName == "" && bd.bbKey != "ToDate"){//若为空 则默认为无
|
// bd['bbName'] = "无";
|
// }
|
// _.each(filed,function(_filed){
|
// if(bd.bbKey == "ToDate" && _filed.busCode == bd.bbKey && cd.gcMeCode == _filed.mdCode){//到达日期 不验证
|
// cd['nobill_cd'] = false;
|
// cd['is_red'] = false;
|
// return false;
|
// }
|
// if(_filed.busCode == bd.bbKey && cd.gcMeCode == _filed.mdCode){
|
// cd.bbName = bd.bbName;
|
// if(cd.render_value == "" || cd.render_value == undefined){
|
// cd['is_red'] = true;
|
// }else if(bd.bbValue != cd.render_value || bd.bbName == '无'){
|
// cd['is_red'] = true;
|
// }else{
|
// cd['is_red'] = false;
|
// }
|
// return false;
|
// }
|
// })
|
// });
|
})
|
|
})
|
}else{
|
form['is_nobill'] = "无票据行程";
|
form['nobill_red'] = true;
|
}
|
}
|
});
|
$scope.have_err();
|
}
|
//判断是否显示错误提示
|
$scope.have_err = function(){
|
var err_flag = false;
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 10){
|
_.each(form.child,function(cd){
|
if(cd.is_red){
|
err_flag = true;
|
}
|
});
|
}else{
|
if(form.is_red){
|
err_flag = true;
|
}
|
}
|
})
|
$scope.all_err_show = err_flag;
|
}
|
// http_service.post('syscfg/search/budegtTypes', {}, function(res) {
|
// $scope.deptbudgetflag = res.data.data[0];
|
// $scope.programbudgetflag = res.data.data[1];
|
// //添加默认
|
// if($scope.type == 10 && $scope.deptbudgetflag && $scope.programbudgetflag) {
|
// $scope.classify = '部门预算';
|
// deptbudget();
|
// } else if($scope.type == 10 && $scope.deptbudgetflag) {
|
// $scope.classify = '部门预算';
|
// deptbudget();
|
// } else if($scope.type == 10 && $scope.programbudgetflag) {
|
// $scope.classify = "项目预算";
|
// programbudget();
|
// }
|
// })
|
// $scope.programbudget = function() {
|
// if($scope.type == 10) {
|
// programbudget();
|
// }
|
// }
|
// $scope.deptbudget = function() {
|
// if($scope.type == 10) {
|
// deptbudget();
|
// }
|
// }
|
$scope.checkshow = function(item) {
|
if(item.gcCpnType != 90) {
|
if($scope.type == 10){
|
if(item.typeshow){
|
if(item.typeshow == 0){
|
return true;
|
}else{
|
return false;
|
}
|
}else{
|
return true;
|
}
|
}else{
|
return true;
|
}
|
|
}
|
// if($scope.type == 10 && $scope.isbill) {
|
// //判断是项目预算还是部门预算
|
// if($scope.select_value == '002'){
|
// deptbudget();
|
// }else{
|
// programbudget();
|
// }
|
// return true;
|
// }
|
}
|
|
// for(i in filed) {
|
// if(filed[i].busCode == 'orgCode') {
|
// http_service.post('base/data/search', { code: filed[i].mdCode }, function(response) {
|
// $scope.options = response.data.data.child;
|
// programbudget();
|
// })
|
// break;
|
// }
|
// }
|
// for(i in filed) {
|
// if(filed[i].busCode == 'orgCode') {
|
// http_service.post('base/data/search', { code: filed[i].mdCode }, function(response) {
|
// $scope.sel_val_lst = response.data.data.child;
|
// })
|
// break;
|
// }
|
// }
|
//项目预算分类
|
function programbudget() {
|
//点击项目预算,展示部门(多选)及项目
|
// _.each(filed, function(item) {
|
// if(item.busCode == 'orgCode') {
|
// $scope.thecode = item.mdCode;
|
// _.each($scope.form_items, function(items) {
|
// if($rootScope.mustscode == items.gcMeCode) {
|
// items['typeshow'] = 1;
|
// }
|
// if(items.gcMeCode == $scope.thecode) {
|
// items['typeshow'] = 0;
|
//// items.gcCpnMultiple = 1;
|
//// $rootScope.multiple = true;
|
// $timeout(function(){
|
// items.ismultiple = true;
|
// },1)
|
//
|
// }
|
// })
|
// }
|
// if(item.busCode == 'project') {
|
// $scope.thepcode = item.mdCode;
|
// _.each($scope.form_items, function(iteminfo) {
|
// if($rootScope.mustscode == iteminfo.gcMeCode) {
|
// iteminfo['typeshow'] = 1;
|
// }
|
// if(iteminfo.gcMeCode == $scope.thepcode) {
|
// $rootScope.mustprocode = $scope.thepcode;
|
// iteminfo['typeshow'] = 0;
|
// }
|
// })
|
// }
|
// //上级管控
|
// if(item.busCode == 'superBudget') {
|
// $scope.thescode = item.mdCode;
|
// _.each($scope.form_items, function(itemsuper) {
|
// if(itemsuper.gcMeCode == $scope.thescode) {
|
// itemsuper['typeshow'] = 1;
|
// }
|
// })
|
// }
|
// })
|
}
|
|
|
|
|
// TODO
|
//部门预算分类
|
function deptbudget() {
|
//选择部门预算出现预算部门和上级预算管控控件,显示这两个控件
|
// _.each(filed, function(item) {
|
// if(item.busCode == 'orgCode') {
|
// $scope.thedcode = item.mdCode;
|
// _.each($scope.form_items, function(itemdept) {
|
// if(($rootScope.mustscode == itemdept.gcMeCode) || ($rootScope.mustprocode == itemdept.gcMeCode)) {
|
// itemdept['typeshow'] = 1;
|
// }
|
// if(itemdept.gcMeCode == $scope.thedcode) {
|
// $rootScope.mustccode = $scope.thecode;
|
//// itemdept.gcCpnMultiple = 0;
|
// itemdept['typeshow'] = 0;
|
//// $rootScope.multiple = false;
|
// itemdept.ismultiple = false;
|
// }
|
// })
|
// }
|
// //上级管控
|
// if(item.busCode == 'superBudget') {
|
// $scope.thescode = item.mdCode;
|
// _.each($scope.form_items, function(itemsuper) {
|
// if(itemsuper.gcMeCode == $scope.thescode) {
|
// $scope.mustscode = $scope.thescode;
|
// itemsuper['typeshow'] = 0;
|
// }
|
// })
|
// }
|
// })
|
}
|
|
|
function complete(res) {
|
var data = res.data;
|
var select_arr;
|
if(!data) {
|
return false;
|
}
|
//获取公式数据 、系统变量公式数据
|
$scope.formula = [];
|
$scope.sys_formula = [];
|
_.each(data.child,function(item){
|
if(item.gcCpnType != 10 && item.gcCpnType != 17){
|
if(item.gcDefVal != undefined && $scope.isbill == "false"){//新增时才添加默认值
|
if(item.gcCpnType == 5 && item.gcDefVal == '10'){//默认时间为当前时间
|
var now_date = $rootScope.getNewDate();
|
item.gcDefVal = now_date.getFullYear()+"-"+(now_date.getMonth()+1)+"-"+now_date.getDate();
|
}else if(item.gcCpnType == 5 && item.gcDefVal != '10'){
|
item.gcDefVal = '';
|
}
|
item['render_value'] = item.gcDefVal;
|
}
|
if(item.joinMath){
|
if(item.joinMath.length > 0){
|
_.each(item.joinMath,function(join){
|
if(join.cpnMath){
|
if(join.cpnMath.child.length > 1){
|
$scope.formula.push(join.cpnMath);
|
}
|
}
|
})
|
}
|
}
|
if(item.systemMathEntity != undefined){//系统变量公式
|
$scope.sys_formula.push({
|
"target":item.gcMeCode,
|
"formula":item.systemMathEntity,
|
"mathId":item.gcMathId
|
});
|
}
|
}else{
|
_.each(item.child,function(cd){
|
if(cd.gcDefVal != undefined && $scope.isbill == "false"){//新增时才添加默认值
|
if(cd.gcCpnType == 5 && cd.gcDefVal == '10'){//默认时间为当前时间
|
var now_date = $rootScope.getNewDate();
|
cd.gcDefVal = now_date.getFullYear()+"-"+(now_date.getMonth()+1)+"-"+now_date.getDate();
|
}else if(cd.gcCpnType == 5 && cd.gcDefVal != '10'){
|
cd.gcDefVal = '';
|
}
|
cd['render_value'] = cd.gcDefVal;
|
}
|
if(cd.joinMath){
|
if(cd.joinMath.length > 0){
|
_.each(cd.joinMath,function(join){
|
if(join.cpnMath){
|
if(join.cpnMath.child.length > 1){
|
$scope.formula.push(join.cpnMath);
|
}
|
}
|
})
|
}
|
}
|
if(cd.systemMathEntity != undefined){//系统变量公式
|
$scope.sys_formula.push({
|
"target":cd.gcMeCode,
|
"formula":cd.systemMathEntity,
|
"mathId":cd.gcMathId
|
});
|
}
|
});
|
}
|
});
|
//
|
//保存行程控件信息
|
_.each(data.child,function(item){
|
if(item.gcCpnType == 10){
|
$scope.form_jour = _.cloneDeep(item);
|
}
|
if(item.gcCpnType == 17){
|
$scope.form_pay = _.cloneDeep(item);
|
}
|
})
|
$scope.template_name = data.guTempName;
|
$scope.template_desc = data.guTempDisc;
|
$scope.form_items = data.child;
|
//新增时默认无行程
|
if($scope.isbill == "false"){
|
var new_form = [];
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType != 10){
|
new_form.push(form);
|
}
|
});
|
$scope.form_items = new_form;
|
$scope.add_jour_show = true;
|
}
|
$scope.form_list = _.cloneDeep(data.child);
|
// _.each($scope.form_items, function(_item) {
|
// if(_item.gcCpnType == 6) {
|
// http_service.post('base/data/search', { "code": _item.gcMeCode }, function(result) {
|
// var arr = [];
|
// _.each(result.data.data.child, function(_res) {
|
//// if(_item.render_value) {
|
//// if(_item.render_value.indexOf(",") > -1){
|
//// select_arr = _item.render_value.split(",");
|
//// if(select_arr.length > 1) {
|
//// select_arr.pop();
|
//// }
|
//// }else{
|
//// select_arr = _item.render_value.split("");
|
//// }
|
////
|
//// for(i in select_arr) {
|
//// if(_res.code == select_arr[i]) {
|
//// arr.push(_res.value);
|
//// }
|
//// }
|
//// if(arr.length != 0) {
|
//// _item = _.extend(_item, { "select_value": arr.join(",") });
|
//// }
|
////
|
//// }else {
|
//// var timer = setInterval(function() {
|
//// if(_item.render_value) {
|
////
|
//// if(_res.code == _item.render_value) {
|
////
|
//// _item = _.extend(_item, { "select_value": _res.value });
|
//// }
|
//// clearInterval(timer);
|
//// }
|
//// }, 1);
|
//// }
|
// $scope.$watch(function(){
|
// return _item.render_value
|
// },function(){
|
// if(_item.render_value != undefined) {
|
// if(_item.render_value.indexOf(",") != -1){
|
// select_arr = _item.render_value.split(",");
|
// if(select_arr.length > 1) {
|
// select_arr.pop();
|
// }
|
// }else{
|
// select_arr = [_item.render_value];
|
// }
|
// for(i in select_arr) {
|
// if(_res.code == select_arr[i]) {
|
// arr.push(_res.value);
|
// }
|
// }
|
// if(arr.length != 0) {
|
// _item = _.extend(_item, { "select_value": arr.join(",") });
|
// }
|
//
|
// }else {
|
// var timer = setInterval(function() {
|
// if(_item.render_value) {
|
//
|
// if(_res.code == _item.render_value) {
|
//
|
// _item = _.extend(_item, { "select_value": _res.value });
|
// }
|
// clearInterval(timer);
|
// }
|
// }, 1);
|
// }
|
// })
|
// })
|
// });
|
// }
|
// });
|
$scope.guId = data.guId;
|
$scope.$parent.form_data = data;
|
$scope.$parent.form_data.child = $scope.form_items;
|
//新增时默认添加用户信息
|
if($scope.isbill == "false"){
|
_.each($scope.form_items,function(form){
|
if(form.gcCpnType == 12){
|
form.render_value = app_userinfo.empCode;
|
$rootScope.change_apmonut(form);
|
}
|
})
|
}
|
|
|
|
if($scope.billid) {
|
reflect_bill();
|
}
|
}
|
|
}
|
}
|
}
|
}
|
}])
|
.filter("selected_flag", function() {
|
return function(input) {
|
if(input) {
|
return "+";
|
} else {
|
return "-";
|
}
|
}
|
})
|
.filter("getamount",function(){
|
return function(inputs,parmas){
|
var value;
|
_.each(inputs.money,function(money){
|
if(money.jp_cd_code == parmas.gcMeCode){
|
value = money.jp_amount;
|
}
|
})
|
return value;
|
}
|
})
|
.filter("getall", function() {
|
return function(input, params) {
|
var allcost = 0;
|
_.each(input, function(cost) {
|
if(cost != undefined) {
|
if("budget_list" in cost) {
|
if(cost.budget_list.length != 0) {
|
if('child' in cost.budget_list[0]) {
|
_.each(cost.budget_list[0].child, function(spell) {
|
if(params != 0) {
|
if(spell.jp_cd_code == params) {
|
allcost += spell.jp_amount;
|
}
|
} else {
|
allcost += spell.jp_amount;
|
}
|
|
});
|
}
|
}
|
}
|
}
|
});
|
return allcost;
|
}
|
});
|