var filed = "";
|
var appId = '';//租户公司下业务系统的Id
|
var permissionlist = "";
|
var guide_info = "";
|
var cddata = "";
|
var app_userinfo = "";
|
var all_formula = "";
|
var register_url = "";//"http://csza.chfcloud.com/";
|
var work_flow_url = "";//"http://ubpyq.chfcloud.com:8087/";
|
var userPermission_url = "";
|
var userPermission_method = "";
|
|
// var iframe_url = register_url;
|
var iframe_url = register_url;
|
var key = "dec";
|
|
|
// usr/local/nginx 前端部署目录
|
// $.ajax({
|
// type:"get",
|
// url:"./static/js/qxv2.json",
|
// async:false,
|
// success:function(res){
|
// }
|
// });
|
|
|
var app = angular.module('app', [
|
'ngRoute',
|
'business',
|
'billing_cfg_guide',
|
'budget_form_customize',
|
'budget_froms',
|
'http_module',
|
'saved_form_directive',
|
'cfg_center',
|
'system_cfg',
|
'travel_expense',
|
'travel_expense_todos',
|
'templates_center',
|
'messages_center',
|
'user_forms_center',
|
'expend_standard',
|
'registry_module',
|
'work_flow_module'
|
])
|
.service('global_service', function() {
|
this.set_indus = function(indus) {
|
window.localStorage.indus = indus;
|
}
|
this.get_indus = function() {
|
return window.localStorage.indus;
|
}
|
})
|
.controller('appCtrl', [
|
'$scope',
|
'$location',
|
'global_service',
|
'$http',
|
'http_service',
|
'$rootScope',
|
function($scope, $location, global_service,$http,http_service,$rootScope) {
|
$scope.theme = "theme1";
|
$scope.indus = '';
|
$scope.$on('$locationChangeStart', function(event) {
|
$scope.url_change_start = true;
|
});
|
$scope.$on('$routeChangeSuccess', function() {
|
$scope.url_change_start = false;
|
var path = $location.path();
|
$scope.indus = global_service.get_indus();
|
if(!$scope.indus && path === '/cfg_center') {
|
sweetAlert("请选择行业信息", "", "error");
|
//alert('请先选择行业信息。');
|
$location.path('/business');
|
}
|
});
|
|
$scope.btncolor = function() {
|
var rgb = $('#top').css('background-color');
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
function hex(x) {
|
return("0" + parseInt(x).toString(16)).slice(-2);
|
}
|
rgb = "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
return rgb;
|
};
|
$rootScope.swalWhether = function(obj, fun) {
|
swal({
|
title: obj.title || "确定删除?",
|
text: obj.text,
|
type: obj.type || "warning",
|
showCancelButton: true,
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
closeOnConfirm: false,
|
confirmButtonColor: $scope.btncolor(),
|
html:true
|
}, fun);
|
}
|
$rootScope.swalsuccess = function(obj, fun) {
|
$scope.superSWal({
|
title: "完成",
|
text: obj.text || "",
|
type: "success",
|
confirmButtonColor: $scope.btncolor(),
|
html:true
|
}, fun);
|
}
|
$rootScope.swalerror = function(obj) {
|
$scope.superSWal({
|
title: "错误",
|
text: obj.text || "",
|
type: "error",
|
confirmButtonColor: $scope.btncolor(),
|
html:true
|
})
|
}
|
$scope.swalwarning = function(obj) {
|
$scope.superSWal({
|
title: "警告",
|
text: obj.text || "",
|
type: "warning",
|
confirmButtonColor: $scope.btncolor(),
|
html:true
|
})
|
}
|
$scope.superSWal = function(obj) {
|
swal({
|
title: obj.title,
|
text: obj.text,
|
type: obj.type,
|
confirmButtonColor: $scope.btncolor(),
|
confirmButtonText: "确定",
|
html:true
|
})
|
}
|
$scope.toastrapi=function(){
|
toastr.options = {
|
"closeButton": false, //是否显示关闭按钮
|
"debug": false, //是否使用debug模式
|
"positionClass": "toast-top-center", //弹出窗的位置
|
"preventDuplicates":true,//控制弹出是否可以重复弹出
|
"showDuration": "300", //显示的动画时间
|
"hideDuration": "1000", //消失的动画时间
|
"timeOut": "3000", //展现时间
|
"extendedTimeOut": "500", //加长展示时间
|
"showEasing": "swing", //显示时的动画缓冲方式
|
"hideEasing": "linear", //消失时的动画缓冲方式
|
"showMethod": "fadeIn", //显示时的动画方式
|
"hideMethod": "fadeOut" //消失时的动画方式
|
};
|
}
|
$rootScope.tsuccess = function(obj){
|
$scope.tsuccess(obj);
|
}
|
$scope.tsuccess = function(obj) {
|
$scope.toastrapi();
|
toastr.success(obj||"","操作成功");
|
}
|
$scope.tinfo = function(obj,type) {
|
$scope.toastrapi();
|
if(type){
|
toastr.info(obj||"","提示");//提示
|
}else{
|
toastr.info(obj||"","提醒");//提示
|
}
|
|
}
|
$scope.twarning = function(obj) {
|
$scope.toastrapi();
|
toastr.warning(obj||"","警告");//警告
|
}
|
$rootScope.twarning = function(obj){
|
$scope.twarning(obj);
|
}
|
$rootScope.terro = function(obj,type){
|
$scope.terro(obj,type);
|
}
|
$scope.terro = function(obj,type) {
|
$scope.toastrapi();
|
if(type == true){
|
toastr.error(obj||"","提示");//提示
|
}else{
|
toastr.error(obj||"","错误");//错误
|
}
|
|
}
|
//查询结果为空提示
|
$rootScope.search_hint = function(value,type,str){
|
switch(type){
|
case "string":
|
if(value == ""){
|
if(str != undefined){
|
$scope.tinfo(str,true);
|
}else{
|
$scope.twarning("没有返回数据");
|
}
|
}
|
break;
|
case "object":
|
if($.isEmptyObject(value)){
|
if(str != undefined){
|
$scope.tinfo(str,true);
|
}else{
|
$scope.twarning("没有返回数据");
|
}
|
}
|
break;
|
case "arrary":
|
if(value.length == 0){
|
if(str != undefined){
|
$scope.tinfo(str,true);
|
}else{
|
$scope.twarning("没有返回数据");
|
}
|
}
|
break;
|
}
|
}
|
$scope.redirect_to = function(path) {
|
if(path.indexOf(path,'travel_expense') != -1){
|
$rootScope.my_form_type = 1;
|
}
|
$location.path(path);
|
};
|
$scope.redirect_to_args = function() {
|
$location.path([].slice.call(arguments).join('/'));
|
};
|
$rootScope.getNewDate = function(str){
|
if(str != undefined && _.isString(str) && str.indexOf("-") != -1){
|
return new Date(str.replace(/-/g,"/"));
|
}else if(str != undefined){
|
return new Date(str);
|
}else{
|
return new Date();
|
}
|
|
}
|
angular.element(document).ready(function() {
|
$http({
|
url:"./static/js/config.json",//请求配置文件
|
method:"GET",
|
data:token
|
}).then(function(res){
|
var config = res.data.config;
|
appId = strDec(config.appId,key);
|
userPermission_url = strDec(config.userPermission_url,key);
|
userPermission_method = strDec(config.userPermission_method,key);
|
register_url = strDec(config.register_url,key);
|
work_flow_url = strDec(config.work_flow_url,key);
|
iframe_url = register_url;
|
})
|
|
|
function setCookie(cname,cvalue,exdays){
|
var d = $rootScope.getNewDate();
|
d.setTime(d.getTime()+(exdays*24*60*60*1000));
|
var expires = "expires="+d.toGMTString();
|
document.cookie = cname + "=" + cvalue + "; " + expires;
|
}
|
function getCookie(cname){
|
var name = cname + "=";
|
var ca = document.cookie.split(';');
|
for(var i=0; i<ca.length; i++) {
|
var c = ca[i].trim();
|
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
|
}
|
return "";
|
}
|
|
function getQueryString(name) { //获取url参数的值
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
var r = window.location.search.substr(1).match(reg);
|
if (r != null) return unescape(r[2]); return null;
|
}
|
if (sessionStorage.getItem("referrer") == "" || sessionStorage.getItem("referrer") == null) {
|
sessionStorage.setItem("referrer",document.referrer);
|
}
|
|
// if (sessionStorage.getItem("referrer").indexOf("sunscloud") < 0 && getQueryString("origin_change") != 1) {//新旧域名转换页跳转可以进入系统
|
// // $rootScope.terro("登录异常!");
|
// window.location.href = register_url;
|
// }
|
if(window.location.href.indexOf("=") != -1){
|
setCookie("token",getQueryString("token"),3000);
|
var csc_compid = getQueryString("csc_compid");
|
var csc_comp_code = getQueryString("csc_comp_code");
|
var tenantId = getQueryString("tenantId");
|
var companyRowId = getQueryString("companyRowId");
|
setCookie("csc_compid",csc_compid,30000);
|
setCookie("csc_comp_code",csc_comp_code,30000);
|
setCookie("tenantId",tenantId,30000);
|
setCookie("companyRowId",companyRowId,30000);
|
if(window.location.href.indexOf("epc.changhong") != -1){// 新旧域名装换 0113
|
window.location.href = "https://travel.sunscloud.com/origin_change.html?token="+getQueryString("token")+"&csc_compid="+csc_compid+"&csc_comp_code="+
|
csc_comp_code+"&tenantId="+tenantId+"&companyRowId="+companyRowId;
|
}
|
}
|
|
// 获取用户信息
|
http_service.post('permission/search/userInfo',{},function(response){
|
if(response.data.opState == false){
|
var href_str = register_url + "index.html"
|
window.location.href = href_str;
|
return false;
|
}
|
app_userinfo = response.data.data;
|
$scope.app_userinfo = app_userinfo;
|
//采集布码
|
window["_BFD"] = window["_BFD"] || {};
|
_BFD.BFD_INFO = {
|
"user_id": app_userinfo.openId?app_userinfo.openId:0, //当前用户 openid,如果未登录就为0
|
"page_type": "homepage" //当前页面标识,请勿修改
|
};
|
_BFD.script = document.createElement("script");
|
_BFD.script.type = "text/javascript";
|
_BFD.script.async = true;
|
_BFD.script.charset = "utf-8";
|
_BFD.script.src = "https://dcjscdn.chiq-cloud.com/ds/ysx/ysxcl.cdn.min-1.0.0.js";//这里是各系统分配的JS代码
|
document.getElementsByTagName("head")[0].appendChild(_BFD.script);
|
//采集布码
|
});
|
var token = {"token":getCookie("token")};
|
|
//向导判断
|
function guide_check(){
|
if($location.path() == ""){
|
if(guide_info == undefined){
|
$location.path("/travel_expense_todos/");//暂时跳转到此页
|
return false;
|
}
|
var guide = guide_info;
|
if(guide == "" ){
|
$location.path("/guide");
|
}else if(guide[0].gcPcsStep == 0){
|
$location.path("/travel_expense_todos/");
|
}else{
|
$location.path("/billing_cfg_guide/"+guide[0].gcInCode+"/"+(parseInt(guide[0].gcPcsCode)-10)/10);
|
}
|
}
|
}
|
//系统配置 启用预算、申请、报销
|
http_service.post('syscfg/list', {}, function(res) {
|
var data = res.data.data;
|
_.each(data, function(obj) {
|
// var val_txt = obj['scValue'];
|
switch(obj.scName){
|
case "budget_open":
|
$rootScope.budget_open = obj.scValue;
|
break;
|
case "apply_open":
|
$rootScope.apply_open = obj.scValue;
|
break;
|
case "expend_open":
|
$rootScope.expend_open = obj.scValue;
|
break;
|
}
|
});
|
});
|
|
//获取向导信息
|
$http({
|
url:"./travel-web/guiCfg/search",
|
method:"POST",
|
data:token
|
}).then(function(res){
|
guide_info = res.data.data;
|
if(guide_info != undefined) {
|
if(guide_info && guide_info.length != 0){
|
global_service.set_indus(guide_info[0].gcInCode);
|
}
|
}
|
// 获取权限列表
|
$http({
|
// url:"./travel-web/permission/search/userPermission", //正式
|
// method:"POST", // 正式
|
// url:"./static/js/userPermission.json",//假数据1
|
url:userPermission_url,//测试
|
method:userPermission_method,//测试
|
data:token
|
}).then(function(res){
|
// permissionlist = res.data.data;//假数据1
|
// permissionlist = res.data.value.functionPermissionSet;///
|
permissionlist = res.data.data.value.functionPermissionSet; // 正式
|
// if(res.data.data){
|
// permissionlist = res.data.data.resources;
|
// }
|
var guide_flag = false;
|
//权限递归 判断
|
function permission_judge(list){
|
_.each(list,function(_list){
|
if(_list.name == '/guide'){
|
guide_flag = true;
|
return guide_flag;
|
}else if(!_.isNull(_list.children)){
|
return permission_judge(_list.children);
|
}
|
})
|
}
|
permission_judge(permissionlist)
|
// _.each(permissionlist,function(_list){
|
// if(_list.url == "/guide"){
|
// guide_flag =true;
|
// }
|
// })
|
if(guide_flag){
|
guide_check();
|
}else{
|
$location.path("/travel_expense_todos/");
|
}
|
},function(err){
|
//弹窗
|
});
|
},function(err){
|
//弹窗
|
})
|
//获取主数据信息
|
http_service.post('supp/search/elField', {}, function(res) {
|
filed = res.data.data.field;
|
cddata = res.data.data.data;
|
appId = res.data.data.appId;
|
})
|
$('ul.navbar-nav li.dropdown').on('mouseenter', function(event) {
|
$(this).closest('li.dropdown').addClass('open');
|
}).on('mouseleave', function() {
|
$('li.dropdown').removeClass('open');
|
});
|
});
|
|
//权限判断方法 (修改)
|
$scope.permission_check = function(code,urls){
|
//权限递归 找parent
|
// function permission_find(list,judge){
|
// _.each(list,function(_list){
|
// if(judge.indexOf(_list.name) != -1){
|
// code += _list.name;
|
// list_data = list;
|
// return list;
|
// }else if(!_.isNull(_list.children)){
|
// return permission_find(_list.children,judge);
|
// }
|
// })
|
// }
|
//权限递归 判断
|
// function permission_judge(list,judge){
|
// _.each(list,function(_list){
|
// if(judge == _list.name){
|
// flag = true;
|
// }else if(!_.isNull(_list.children)){
|
// return permission_judge(_list.children,judge);
|
// }
|
// })
|
// }
|
var flag = false;
|
var parentId;
|
if(urls == 1){
|
if(code == "editbtn" || code == "backbtn"){
|
if($location.path() == "/travel_expense_todos/"){
|
return true;
|
}
|
}
|
if(code == "edit_template" && $location.path() == "/templates_center"){
|
code = "edit_template_center";
|
}
|
|
var path;
|
if($location.path().indexOf("/budget_froms/") != -1){
|
path = $location.path();
|
path = path.slice(-3);
|
path = path.replace("/","");
|
path = "/budget_froms/"+path+"/";
|
}else{
|
path = $location.path();
|
}
|
var list_data = undefined;
|
|
// permission_find(permissionlist,path);
|
// if(list_data != undefined){
|
// permission_judge(list_data,code);
|
// }
|
_.each(permissionlist,function(_perlist){
|
if(path.indexOf(_perlist.name) != -1){
|
code += _perlist.name;
|
}
|
});
|
_.each(permissionlist,function(_list){
|
if(_list.name == code){
|
flag = true;
|
}
|
})
|
}else if(urls == 2){
|
if($location.path() == "/travel_expense_todos/"){
|
return true;
|
}
|
if(code == "提交"){
|
code = "commitbtn";
|
}else{
|
code = "auditbtn";
|
}
|
// var list_data = undefined;
|
// permission_find(permissionlist,path);
|
// if(list_data != undefined){
|
// permission_judge(list_data,code);
|
// }
|
_.each(permissionlist,function(_perlist){
|
if($location.path().indexOf(_perlist.name) != -1){
|
code += _perlist.name;
|
}
|
});
|
_.each(permissionlist,function(_list){
|
if(_list.name == code){
|
flag = true;
|
}
|
})
|
}else if(urls == 3){
|
switch(code){
|
case 10:
|
code = "termination_budget";
|
break;
|
case 20:
|
code = "termination_apply";
|
break;
|
case 30:
|
code = "termination_expend";
|
break;
|
}
|
_.each(permissionlist,function(_list){
|
if(_list.name == code){
|
flag = true;
|
}
|
})
|
}else if(urls == 4){
|
switch(code){
|
case 10:
|
code = "search_budget";
|
break;
|
case 20:
|
code = "search_apply";
|
break;
|
case 30:
|
code = "search_expend";
|
break;
|
}
|
|
_.each(permissionlist,function(_list){
|
if(_list.name == code){
|
flag = true;
|
}
|
})
|
}else{
|
_.each(permissionlist,function(_list){
|
if(_list.name == code){
|
flag = true;
|
}
|
})
|
}
|
return flag;
|
}
|
$rootScope.permission_check = function(code,urls){
|
return $scope.permission_check(code,urls);
|
|
}
|
}
|
])
|
|
.controller('guideCtrl', ['$scope', '$location','http_service', function($scope, $location,http_service) {
|
$scope.business_select_phase = function() {
|
http_service.post('guiCfg/create',{},function(res){
|
if(res.data.opState){
|
$location.path('/business');
|
}
|
})
|
}
|
$scope.registry_model = function() {
|
$location.path('/registry');
|
}
|
}])
|
.config(['$sceDelegateProvider',function($sceDelegateProvider) {
|
// var self_str = register_url + "**";
|
var self_str = iframe_url + "**";
|
$sceDelegateProvider.resourceUrlWhitelist([
|
'self',self_str]);
|
}])
|
.config(['$routeProvider', '$locationProvider', '$compileProvider', function($routeProvider, $locationProvider, $compileProvider) {
|
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/);
|
$routeProvider
|
.when('/guide', {
|
templateUrl: './static/templates/guide.html',
|
controller: 'guideCtrl'
|
})
|
.when('/business', {
|
templateUrl: './static/templates/business.html',
|
controller: 'businessCtrl'
|
})
|
.when('/registry', {
|
templateUrl: './static/templates/registry.html',
|
controller: 'registryCtrl'
|
})
|
.when('/billing_cfg_guide/:business/:step', {
|
templateUrl: './static/templates/billing_cfg_guide.html',
|
controller: 'billingCfgGuideCtrl'
|
})
|
.when('/budget_froms/:business/:type/', {
|
templateUrl: './static/templates/budget_forms.html',
|
controller: 'budgetFormsCtrl'
|
})
|
.when('/budget_froms/:type/', {
|
templateUrl: './static/templates/budget_forms.html',
|
controller: 'budgetFormsCtrl'
|
})
|
.when('/budget_form_customize/:type/:business/:id?/:action?', {
|
templateUrl: './static/templates/budget_form_customize.html',
|
controller: 'budgetFormCustomizeCtrl'
|
})
|
.when('/cfg_center/', {
|
templateUrl: './static/templates/config_center.html',
|
controller: 'cfgCenterCtrl'
|
})
|
.when('/system_config', {
|
templateUrl: './static/templates/system_config.html',
|
controller: 'systemCfgCtrl'
|
})
|
.when('/travel_expense/:type?', {
|
templateUrl: './static/templates/travel_expense.html',
|
controller: 'travelExpenseCtrl'
|
})
|
.when('/travel_expense_todos/', {
|
templateUrl: './static/templates/travel_expense_todos.html',
|
controller: 'travelExpenseTodosCtrl'
|
})
|
.when('/user_forms_center/:type', {
|
templateUrl: './static/templates/forms_center.html',
|
controller: 'userFormsCenterCtrl'
|
})
|
.when('/templates_center', {
|
templateUrl: './static/templates/templates_center.html',
|
controller: 'templatesCenterCtrl'
|
})
|
.when('/messages_center',{
|
templateUrl: './static/templates/messages_center.html',
|
controller: 'messageCenterCtrl'
|
})
|
.when('/expend_standard', {
|
templateUrl: './static/templates/expend_standard.html',
|
controller: 'expendStandardCtrl'
|
})
|
.when('/work_flow', {
|
templateUrl: './static/templates/work_flow.html',
|
controller: 'workflowCtrl'
|
})
|
.when('/no_permission', {
|
templateUrl: './static/templates/no_permission.html'
|
})
|
.when('**', {
|
templateUrl: './static/templates/404.html'
|
})
|
}])
|
|
.run(['$rootScope','$location',"$routeParams",function($rootScope,$location,$routeParams){
|
$rootScope.$on('$routeChangeStart', function(evt, next, current){
|
//权限递归 判断
|
// function permission_judge(list,judge){
|
// _.each(list,function(_list){
|
// if(judge.indexOf(_list.name) != -1){
|
// permission_flag = true;
|
// }else if(!_.isNull(_list.children)){
|
// return permission_judge(_list.children,judge);
|
// }
|
// })
|
// }
|
function setCookie(cname,cvalue,exdays){
|
var d = $rootScope.getNewDate();
|
d.setTime(d.getTime()+(exdays*24*60*60*1000));
|
var expires = "expires="+d.toGMTString();
|
document.cookie = cname + "=" + cvalue + "; " + expires;
|
}
|
function getQueryString(name) { //获取url参数的值
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
var r = window.location.search.substr(1).match(reg);
|
if (r != null) return unescape(r[2]); return null;
|
}
|
if(window.location.href.indexOf("?") != -1){
|
var token = getQueryString("token");
|
var csc_compid = getQueryString("csc_compid");
|
var csc_comp_code = getQueryString("csc_comp_code");
|
var tenantId = getQueryString("tenantId");
|
|
setCookie("token",token,30000);
|
setCookie("csc_compid",csc_compid,30000);
|
setCookie("csc_comp_code",csc_comp_code,30000);
|
setCookie("tenantId",tenantId,30000);
|
// $location.path('/no_permission');
|
}
|
$rootScope.exitLogin=function(){
|
var keys=document.cookie.match(/[^ =;]+(?=\=)/g);
|
if (keys) {
|
for (var i = keys.length; i--;)
|
document.cookie=keys[i]+'=0;expires=' + $rootScope.getNewDate( 0).toUTCString()
|
}
|
var href_str = register_url + "index.html";
|
window.location.href=register_url;
|
}
|
var permission_flag = false;
|
var path;
|
if($location.path().indexOf("/budget_froms/") != -1){
|
path = $location.path();
|
if(path.length > 17){//行业精选
|
path = path.slice(-3);
|
path = path.replace("/","");
|
path = "/budget_froms/*/"+path+"/";
|
}else{
|
path = path.slice(-3);
|
path = path.replace("/","");
|
path = "/budget_froms/"+path+"/";
|
}
|
}else{
|
path = $location.path();
|
}
|
_.each(permissionlist,function(_list){
|
if(path.indexOf(_list.name) != -1){
|
permission_flag = true;
|
}
|
});
|
// permission_judge(permissionlist,path)
|
if(permissionlist == ""){
|
permission_flag = true;
|
}
|
|
// if($location.path().indexOf("messages_center") != -1){// 韩蓉消息中心 权限
|
// permission_flag = true;
|
// }
|
if(!permission_flag){
|
$location.path('/no_permission');
|
}
|
|
});
|
$rootScope.$on("$routeChangeSuccess",function(){
|
if($location.path() == "/expend_standard"){
|
|
var reloadnum = sessionStorage.getItem("reloadnum");
|
if(reloadnum == undefined){
|
sessionStorage.setItem("reloadnum",0);
|
reloadnum = sessionStorage.getItem("reloadnum");
|
}else if(reloadnum == 0){
|
sessionStorage.setItem("reloadnum",1);
|
}else{
|
sessionStorage.setItem("reloadnum",0);
|
}
|
if(reloadnum == 0){
|
location.reload(true);
|
}
|
}
|
})
|
}]);
|