angular.module('travel_expense_todos', []) .directive('travelExpenseTodosAll', ['http_service', '$compile','$rootScope', function(http_service, $compile,$rootScope){ return { restrict: "EACM", templateUrl: './static/templates/travel_expense_todos_all.html', scope: { todos: '=' }, link: function($scope, elemnet, attrs){ _.each($scope.todos, function(n, m){ $scope.todos[m] = (m==='all'); }); var get_headers = function(cfg, form_list){ var headers = []; var headers_label_key = []; if(form_list){ _.each(form_list.child, function(form_item){ _.each(cfg, function(cfg_item){ if(form_item['gcColName'] === cfg_item) { headers_label_key.push({'label': form_item['gcCpnAlias'], 'gcColName': cfg_item}); headers.push(form_item['gcCpnAlias']); } }); if(form_item.child){ if(form_item.child.length > 0) { _.each(cfg, function(_cfg_item){ _.each(form_item.child, function(_form_item){ if(_form_item['gcColName'] === _cfg_item) { headers_label_key.push({'label': _form_item['gcCpnAlias'], 'gcColName': _cfg_item}); headers.push(_form_item['gcCpnAlias']); } }) }); } } }); } return {'headers': headers, 'headers_label_key': headers_label_key}; }, get_data = function(headers_label_key, bill_data,type){ var data = []; var len = headers_label_key.length; var type_id; switch(type){ case 1: type_id = "bu_id"; break; case 2: type_id = "ap_id"; break; case 3: type_id = "ex_id"; break; } _.each(bill_data, function(data_item, i){ var _data = []; _.each(headers_label_key, function(cfg_item, n){ _data.push({"name":_.get(data_item, cfg_item.gcColName),"id":data_item[type_id]}); // if(n === len-1){ // var doc_id = _.get(data_item, 'bu_id') || _.get(data_item, 'ap_id') || _.get(data_item, 'ex_id'); // _data.push(doc_id); // } }); switch(parseInt(_.get(data_item,"flowStart"))){ // case 10: // _data.push({"name":"待提交","id":data_item[type_id]}); // break; // case 20: // _data.push({"name":"已提交","id":data_item[type_id]}); // break; // case 30: // _data.push({"name":"待审核","id":data_item[type_id]}); // break; // case 40: // _data.push({"name":"审核完成","id":data_item[type_id]}); // break; // case -1: // _data.push({"name":"驳回","id":data_item[type_id]}); // break; // case 100: // _data.push({"name":"已完成","id":data_item[type_id]}); // break; case 10: _data.push({"name":"已审核","id":data_item[type_id]}); break; case 20: _data.push({"name":"驳回","id":data_item[type_id]}); break; case 30: _data.push({"name":"已通过","id":data_item[type_id]}); break; case 50: _data.push({"name":"待审核","id":data_item[type_id]}); break; } data.push(_data); }); return data; }; $scope.budget_data = { "headers": [], "data": [] } function list_lock(list_data,type){//列表单据固化 var errInfo = ''; if(type === 10) { errInfo = 'buErrInfo'; } else if(type === 20) { errInfo = 'apErrInfo'; } else if(type === 30) { errInfo = 'exErrInfo'; } _.each(list_data,function(ldata){ if(ldata.canDel == 0 && ldata[errInfo] != undefined && ldata[errInfo] != ''){ var errInfo_data = JSON.parse(ldata[errInfo]).form_err_data; var new_data = {}; _.each(errInfo_data,function(itemdata){ if(itemdata.gcColName != undefined && itemdata.gcColName != ''){ if(itemdata.old_users_selected != undefined){ new_data[itemdata.gcColName] = itemdata.old_users_selected[0].personName; }else if(itemdata.select_value != undefined){ new_data[itemdata.gcColName] = itemdata.select_value; }else if(itemdata.render_value != undefined){ new_data[itemdata.gcColName] = itemdata.render_value; } } }); _.extend(ldata,new_data); } }); return list_data; } function get_budget_data() { // get budget bill data http_service.post('budget/search/waitHandle', {"num_per_page":20,"page_num":1}, function(res){ if(!res.data.opState){ return false; } $scope.$parent.$parent.budget_temp_num = res.data.rows; $scope.$parent.$parent.budget_temp_num_show = false; var bill_data = _.slice(res.data.data, 0, 3); bill_data = list_lock(bill_data,10);//列表单据固化 var headers = []; var data = []; http_service.post('showFieldCfg/list', { "sfCfgType":12 }, function(res){ if(!res.data.opState){ return false; } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":10, "cache_id":10 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; if(cfg.length == 0){ _.each(form_list.child,function(list){ if(list.gcCpnType != 10 && list.gcCpnType != 14 && list.gcCpnType != 9 && list.gcCpnType != 17 && list.gcCpnType != 0){ cfg.push(list.gcColName); } }) } headers = get_headers(cfg, form_list); // headers.headers.push("状态"); data = get_data(headers.headers_label_key, bill_data,1); $scope.budget_data = { headers: headers.headers, data: data }; },true); }); }); } function get_apply_data() { // get apply bill data http_service.post('apply/search/waitHandle', { "num_per_page":20,"page_num":1 }, function(res){ if(!res.data.opState){ return false; } $scope.$parent.$parent.apply_temp_num = res.data.rows; $scope.$parent.$parent.apply_temp_num_show = false; var bill_data = _.slice(res.data.data, 0, 3); bill_data = list_lock(bill_data,10);//列表单据固化 http_service.post('showFieldCfg/list', { "sfCfgType": 22 }, function(res){ var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType": 20, "cache_id":20 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; if(cfg.length == 0){ _.each(form_list.child,function(list){ if(list.gcCpnType != 10 && list.gcCpnType != 14 && list.gcCpnType != 9 && list.gcCpnType != 17 && list.gcCpnType != 0){ cfg.push(list.gcColName); } }) } headers = get_headers(cfg, form_list); // headers.headers.push("状态"); data = get_data(headers.headers_label_key, bill_data,2); $scope.apply_data = { headers: headers.headers, data: data }; },true); }); }); } function get_expend_data() { // get expend bill data http_service.post('expend/search/waitHandle', { "num_per_page":20,"page_num":1 }, function(res){ if(!res.data.opState){ return false; } $scope.$parent.$parent.expend_temp_num = res.data.rows; $scope.$parent.$parent.expend_temp_num_show = false; var bill_data = _.slice(res.data.data, 0, 3); bill_data = list_lock(bill_data,10);//列表单据固化 http_service.post('showFieldCfg/list', { "sfCfgType":32 }, function(res){ var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":30, "cache_id":30 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; if(cfg.length == 0){ _.each(form_list.child,function(list){ if(list.gcCpnType != 10 && list.gcCpnType != 14 && list.gcCpnType != 9 && list.gcCpnType != 17 && list.gcCpnType != 0){ cfg.push(list.gcColName); } }) } headers = get_headers(cfg, form_list); // headers.headers.push("状态"); data = get_data(headers.headers_label_key, bill_data,3); $scope.expend_data = { headers: headers.headers, data: data }; },true); }); }); } // $scope.doc_id = function(data_list){ // return _.slice(data_list, data_list.length - 1, data_list.length)[0]; // } // // $scope.sub_data = function(data_list){ // return _.slice(data_list, 0, data_list.length - 1); // } get_budget_data(); get_apply_data(); get_expend_data(); $rootScope.refer_data_all = function(){ get_budget_data(); get_apply_data(); get_expend_data(); } } } }]) .directive('travelExpenseTodosBudget', ['http_service', '$compile','$rootScope', function(http_service, $compile,$rootScope){ return { restrict: "EACM", templateUrl: './static/templates/travel_expense_todos_budget.html', scope: { todos: '=' }, link: function($scope, elemnet, attrs){ $scope.type = 10; _.each($scope.todos, function(n, m){ $scope.todos[m] = (m==='budget'); }); // $scope.selectstatus = function(){ // var statusobj = {}; // var statuscode = []; // if($scope.status){ // statusobj.selected = true; // statusobj.valueLeft = []; // statuscode.push($scope.code); // statusobj.valueLeft.push(statuscode); // } // $scope.searchlist.push(statusobj); // } var get_headers = function(cfg, form_list){ var headers = []; var headers_label_key = []; _.each(form_list.child, function(form_item){ _.each(cfg, function(cfg_item){ if(form_item['gcColName'] === cfg_item) { headers_label_key.push({'label': form_item['gcCpnAlias'], 'gcColName': cfg_item}); headers.push(form_item['gcCpnAlias']); } }); if(form_item.child != undefined){ if(form_item.child.length > 0) { _.each(cfg, function(_cfg_item){ _.each(form_item.child, function(_form_item){ if(_form_item['gcColName'] === _cfg_item) { headers_label_key.push({'label': _form_item['gcCpnAlias'], 'gcColName': _cfg_item}); headers.push(_form_item['gcCpnAlias']); } }) }); } } }); return {'headers': headers, 'headers_label_key': headers_label_key}; }, get_search_items = function(cfg, form_list){ var search_items = []; if(form_list){ _.each(form_list.child, function(form_item){ // 如果控件非分割线时 if(form_item['gcCpnType'] !== 9 && form_item['gcCpnType'] !== 10 &&form_item['gcCpnType'] !== 0 &&form_item['gcCpnType'] !== 14){ var item = { 'gc_cpn_alias': form_item['gcCpnAlias'], 'sfCfgType': 11, 'sfFieldName': form_item['gcColName'], 'gc_cpn_type': form_item['gcCpnType'], 'gcMeCode': form_item['gcMeCode'], // 关联查询页下拉框 'gcCpnMultiple': form_item['gcCpnMultiple'], // 关联查询页下拉框 'selected': true }; item.selected = _.includes(cfg, form_item['gcColName']); search_items.push(item); if(form_item.child != undefined){ if(form_item.child.length > 0) { _.each(form_item.child, function(form_item){ var _item = { 'sfCfgType': 11, 'gc_cpn_alias': form_item['gcCpnAlias'], 'sfFieldName': form_item['gcColName'], 'gc_cpn_type': form_item['gcCpnType'], 'gcMeCode': form_item['gcMeCode'], // 关联查询页下拉框 'gcCpnMultiple': form_item['gcCpnMultiple'], // 关联查询页下拉框 'selected': true } _item.selected = _.includes(cfg, form_item['gcColName']); search_items.push(_item); }); } } } }); } return {'search_items': search_items}; }, search_select = function() { var search_list = []; _.each($scope.searchlist, function(n, key) { if(n.selected == true && (n.valueLeft || n.valueRight)) { search_list.push({ "sfFieldName": n.sfFieldName, "gc_cpn_type": n.gc_cpn_type, "valueLeft": n.valueLeft, "valueRight": n.valueRight }); } }); if($scope.searchlist){ var data = _.assign({ 'num_per_page': $scope.num_per_page }, { 'page_num': $scope.page_num }, { 'search': search_list },{ 'flowStart':$scope.status }); }else{ var data = _.assign({ 'num_per_page': $scope.num_per_page }, { 'page_num': $scope.page_num },{ 'flowStart':$scope.status }); } return data; }, get_data = function(headers_label_key, bill_data){ var data = []; var len = headers_label_key.length; _.each(bill_data, function(data_item, i){ var _data = []; _.each(headers_label_key, function(cfg_item, n){ _data.push({"name":_.get(data_item, cfg_item.gcColName),"id":data_item.bu_id}); // if(n === len-1){ // var doc_id = _.get(data_item, 'bu_id') || _.get(data_item, 'ap_id') || _.get(data_item, 'ex_id'); // _data.push(doc_id); // } }); switch(parseInt(_.get(data_item,"flowStart"))){ case 10: _data.push({"name":"待提交","id":data_item.bu_id}); break; case 20: _data.push({"name":"已提交","id":data_item.bu_id}); break; case 30: _data.push({"name":"待审核","id":data_item.bu_id}); break; case 40: _data.push({"name":"审核完成","id":data_item.bu_id}); break; case -1: _data.push({"name":"驳回","id":data_item.bu_id}); break; case 100: _data.push({"name":"已完成","id":data_item.bu_id}); break; } data.push(_data); }); return data; }; // pager $scope.num_per_page = "20"; $scope.page_num = "1"; $scope.math_ceil = function(v){ if(v == 0){ $scope.page_num = 1; return 0; } if(!v){ return ''; } return Math.ceil(v); } $scope.pre_page = function(){ if($scope.page_num > 1){ $scope.page_num = $scope.page_num - 1; } search_budget_data(); } $scope.next_page = function(){ if($scope.page_num < Math.ceil($scope.budget_rows/ $scope.num_per_page)){ $scope.page_num = (parseInt($scope.page_num) + 1).toString(); } search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.change_page_num = function(){ search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.doc_id = function(data_list){ return _.slice(data_list, data_list.length - 1, data_list.length)[0]; } $scope.sub_data = function(data_list){ return _.slice(data_list, 0, data_list.length - 1); } $scope.data = []; function search_budget_data() { http_service.post('flow/budget/wait/handle', search_select(), function(res){ if(!res.data.opState){ return false; } $rootScope.search_hint(res.data.data,'arrary'); // $scope.$parent.$parent.budget_temp_num = res.data.rows; $scope.budget_rows = res.data.rows; // $scope.$parent.$parent.budget_temp_num_show = false; var bill_data = res.data.data; var headers = []; http_service.post('showFieldCfg/list', { "sfCfgType":12 }, function(res){ // if(res.data.data.length==0){ // return false; // } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":10, "cache_id":10 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; if(form_list == undefined){ return false; } headers = get_headers(cfg, form_list); $scope.data = get_data(headers.headers_label_key, bill_data); $scope.budget_data = { headers: headers.headers, data: _.slice($scope.data, 0, $scope.num_per_page * $scope.page_num - 1) }; },true); }); }); } search_budget_data(); _.extend($scope, { "searchlist": [], "visiblecolumns": [] }); http_service.post('showFieldCfg/list', { "sfCfgType":11 }, function(res){ // if(res.data.data.length==0){ // return false; // } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":10, "cache_id":10 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; var search_items = get_search_items(cfg, form_list); $scope.searchlist = search_items.search_items; },true); }); /* http_service.get('./static/js/data/travel_expense_list.json', function(res){ var data = res.data; $scope.searchlist = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '1'; }); $scope.visiblecolumns = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '2'; }); }); */ $scope.refreshdata = function(){ search_budget_data(); } $rootScope.refer_data_budget = function(){ $scope.refreshdata(); } $scope.show_search_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; $scope.show_conent_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; } } }]) .directive('travelExpenseTodosRequest', ['http_service', '$compile','$rootScope', function(http_service, $compile,$rootScope){ return { restrict: "EACM", templateUrl: './static/templates/travel_expense_todos_request.html', scope: { todos: '=' }, link: function($scope, elemnet, attrs){ $scope.type = 20; _.each($scope.todos, function(n, m){ $scope.todos[m] = (m==='request'); }); var get_headers = function(cfg, form_list){ var headers = []; var headers_label_key = []; _.each(form_list.child, function(form_item){ _.each(cfg, function(cfg_item){ if(form_item['gcColName'] === cfg_item) { headers_label_key.push({'label': form_item['gcCpnAlias'], 'gcColName': cfg_item}); headers.push(form_item['gcCpnAlias']); } }); if(form_item.child != undefined){ if(form_item.child.length > 0) { _.each(cfg, function(_cfg_item){ _.each(form_item.child, function(_form_item){ if(_form_item['gcColName'] === _cfg_item) { headers_label_key.push({'label': _form_item['gcCpnAlias'], 'gcColName': _cfg_item}); headers.push(_form_item['gcCpnAlias']); } }) }); } } }); return {'headers': headers, 'headers_label_key': headers_label_key}; }, get_search_items = function(cfg, form_list){ var search_items = []; if(form_list){ _.each(form_list.child, function(form_item){ // 如果控件非分割线时 if(form_item['gcCpnType'] !== 9 && form_item['gcCpnType'] !== 10 &&form_item['gcCpnType'] !== 0 &&form_item['gcCpnType'] !== 14){ var item = { 'gc_cpn_alias': form_item['gcCpnAlias'], 'sfCfgType': 21, 'sfFieldName': form_item['gcColName'], 'gc_cpn_type': form_item['gcCpnType'], 'gcMeCode': form_item['gcMeCode'], // 关联查询页下拉框 'gcCpnMultiple': form_item['gcCpnMultiple'], // 关联查询页下拉框 'selected': true }; item.selected = _.includes(cfg, form_item['gcColName']); search_items.push(item); if(form_item.child != undefined){ if(form_item.child.length > 0) { _.each(form_item.child, function(form_item){ var _item = { 'sfCfgType': 21, 'gc_cpn_alias': form_item['gcCpnAlias'], 'sfFieldName': form_item['gcColName'], 'gc_cpn_type': form_item['gcCpnType'], 'gcMeCode': form_item['gcMeCode'], // 关联查询页下拉框 'gcCpnMultiple': form_item['gcCpnMultiple'], // 关联查询页下拉框 'selected': true } _item.selected = _.includes(cfg, form_item['gcColName']); search_items.push(_item); }); } } } }); } return {'search_items': search_items}; }, search_select = function() { var search_list = []; _.each($scope.searchlist, function(n, key) { if(n.selected == true && (n.valueLeft || n.valueRight)) { search_list.push({ "sfFieldName": n.sfFieldName, "gc_cpn_type": n.gc_cpn_type, "valueLeft": n.valueLeft, "valueRight": n.valueRight }); } }); if($scope.searchlist){ var data = _.assign({ 'num_per_page': $scope.num_per_page }, { 'page_num': $scope.page_num }, { 'search': search_list },{ 'flowStart':$scope.status }); }else{ var data = _.assign({ 'num_per_page': $scope.num_per_page }, { 'page_num': $scope.page_num },{ 'flowStart':$scope.status }); } return data; }, get_data = function(headers_label_key, bill_data){ var data = []; var len = headers_label_key.length; _.each(bill_data, function(data_item, i){ var _data = []; _.each(headers_label_key, function(cfg_item, n){ _data.push({"name":_.get(data_item, cfg_item.gcColName),"id":data_item.ap_id}); // if(n === len-1){ // var doc_id = _.get(data_item, 'bu_id') || _.get(data_item, 'ap_id') || _.get(data_item, 'ex_id'); // _data.push(doc_id); // } }); switch(parseInt(_.get(data_item,"flowStart"))){ case 10: _data.push({"name":"待提交","id":data_item.ap_id}); break; case 20: _data.push({"name":"已提交","id":data_item.ap_id}); break; case 30: _data.push({"name":"待审核","id":data_item.ap_id}); break; case 40: _data.push({"name":"审核完成","id":data_item.ap_id}); break; case -1: _data.push({"name":"驳回","id":data_item.ap_id}); break; case 100: _data.push({"name":"已完成","id":data_item.ap_id}); break; } data.push(_data); }); return data; }; // pager $scope.num_per_page = "20"; $scope.page_num = "1"; $scope.math_ceil = function(v){ if(v == 0){ $scope.page_num = 1; return 0; } if(!v){ return ''; } return Math.ceil(v); } $scope.pre_page = function(){ if($scope.page_num > 1){ $scope.page_num = $scope.page_num - 1; } search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.next_page = function(){ if($scope.page_num < Math.ceil($scope.apply_rows / $scope.num_per_page)){ $scope.page_num = (parseInt($scope.page_num) + 1).toString(); } search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.change_page_num = function(){ search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.doc_id = function(data_list){ return _.slice(data_list, data_list.length - 1, data_list.length)[0]; } $scope.sub_data = function(data_list){ return _.slice(data_list, 0, data_list.length - 1); } $scope.data = []; function search_budget_data(){ http_service.post('flow/apply/wait/handle', search_select(), function(res){ // $scope.$parent.$parent.apply_temp_num = res.data.rows; // $scope.$parent.$parent.apply_temp_num_show = false; $rootScope.search_hint(res.data.data,'arrary'); $scope.apply_rows = res.data.rows; var bill_data = res.data.data; var headers = []; http_service.post('showFieldCfg/list', { "sfCfgType":22 }, function(res){ // if(res.data.data.length==0){ // return false; // } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":20, "cache_id":20 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; if(form_list == undefined){ return false; } headers = get_headers(cfg, form_list); $scope.data = get_data(headers.headers_label_key, bill_data); $scope.budget_data = { headers: headers.headers, data: _.slice($scope.data, 0, $scope.num_per_page * $scope.page_num - 1) }; },true); }); }); } search_budget_data(); _.extend($scope, { "searchlist": [], "visiblecolumns": [] }); http_service.post('showFieldCfg/list', { "sfCfgType":21 }, function(res){ // if(res.data.data.length==0){ // return false; // } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":20, "cache_id":20 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; var search_items = get_search_items(cfg, form_list); $scope.searchlist = search_items.search_items; },true); }); /* http_service.get('./static/js/data/travel_expense_list.json', function(res){ var data = res.data; $scope.searchlist = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '1'; }); $scope.visiblecolumns = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '2'; }); }); */ $scope.refreshdata = function(){ search_budget_data(); } $rootScope.refer_data_apply = function(){ $scope.refreshdata(); } $scope.show_search_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; $scope.show_conent_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; } } }]) .directive('travelExpenseTodosRebuise', ['http_service', '$compile','$rootScope', function(http_service, $compile,$rootScope){ return { restrict: "EACM", templateUrl: './static/templates/travel_expense_todos_rebuise.html', scope: { todos: '=' }, link: function($scope, elemnet, attrs){ $scope.type = 30; _.each($scope.todos, function(n, m){ $scope.todos[m] = (m==='rebuise'); }); var get_headers = function(cfg, form_list){ var headers = []; var headers_label_key = []; _.each(cfg, function(cfg_item){ _.each(form_list.child, function(form_item){ if(form_item['gcColName'] === cfg_item) { headers_label_key.push({'label': form_item['gcCpnAlias'], 'gcColName': cfg_item}); headers.push(form_item['gcCpnAlias']); } if(form_item.child != undefined){ if(form_item.child.length > 0) { _.each(cfg, function(_cfg_item){ _.each(form_item.child, function(form_item){ if(form_item['gcColName'] === _cfg_item) { headers_label_key.push({'label': form_item['gcCpnAlias'], 'gcColName': _cfg_item}); headers.push(form_item['gcCpnAlias']); } }) }); } } }); }); return {'headers': headers, 'headers_label_key': headers_label_key}; }, get_search_items = function(cfg, form_list){ var search_items = []; if(form_list){ _.each(form_list.child, function(form_item){ // 如果控件非分割线时 if(form_item['gcCpnType'] !== 9 && form_item['gcCpnType'] !== 10 &&form_item['gcCpnType'] !== 0 &&form_item['gcCpnType'] !== 14){ var item = { 'gc_cpn_alias': form_item['gcCpnAlias'], 'sfCfgType': 31, 'sfFieldName': form_item['gcColName'], 'gc_cpn_type': form_item['gcCpnType'], 'gcMeCode': form_item['gcMeCode'], // 关联查询页下拉框 'gcCpnMultiple': form_item['gcCpnMultiple'], // 关联查询页下拉框 'selected': true }; item.selected = _.includes(cfg, form_item['gcColName']); search_items.push(item); if(form_item.child != undefined){ if(form_item.child.length > 0) { _.each(form_item.child, function(form_item){ var _item = { 'sfCfgType': 31, 'gc_cpn_alias': form_item['gcCpnAlias'], 'sfFieldName': form_item['gcColName'], 'gc_cpn_type': form_item['gcCpnType'], 'gcMeCode': form_item['gcMeCode'], // 关联查询页下拉框 'gcCpnMultiple': form_item['gcCpnMultiple'], // 关联查询页下拉框 'selected': true } _item.selected = _.includes(cfg, form_item['gcColName']); search_items.push(_item); }); } } } }); } return {'search_items': search_items}; }, search_select = function() { var search_list = []; _.each($scope.searchlist, function(n, key) { if(n.selected == true && (n.valueLeft || n.valueRight)) { search_list.push({ "sfFieldName": n.sfFieldName, "gc_cpn_type": n.gc_cpn_type, "valueLeft": n.valueLeft, "valueRight": n.valueRight }); } }); if($scope.searchlist){ var data = _.assign({ 'num_per_page': $scope.num_per_page }, { 'page_num': $scope.page_num }, { 'search': search_list },{ 'flowStart':$scope.status }); }else{ var data = _.assign({ 'num_per_page': $scope.num_per_page }, { 'page_num': $scope.page_num },{ 'flowStart':$scope.status }); } return data; }, get_data = function(headers_label_key, bill_data){ var data = []; var len = headers_label_key.length; _.each(bill_data, function(data_item, i){ var _data = []; _.each(headers_label_key, function(cfg_item, n){ _data.push({"name":_.get(data_item, cfg_item.gcColName),"id":data_item.ex_id}); // if(n === len-1){ // var doc_id = _.get(data_item, 'bu_id') || _.get(data_item, 'ap_id') || _.get(data_item, 'ex_id'); // _data.push(doc_id); // } }); switch(parseInt(_.get(data_item,"flowStart"))){ case 10: _data.push({"name":"待提交","id":data_item.ex_id}); break; case 20: _data.push({"name":"已提交","id":data_item.ex_id}); break; case 30: _data.push({"name":"待审核","id":data_item.ex_id}); break; case 40: _data.push({"name":"审核完成","id":data_item.ex_id}); break; case -1: _data.push({"name":"驳回","id":data_item.ex_id}); break; case 100: _data.push({"name":"已完成","id":data_item.ex_id}); break; } data.push(_data); }); return data; }; // pager $scope.num_per_page = "20"; $scope.page_num = "1"; $scope.math_ceil = function(v){ if(v == 0){ $scope.page_num = 1; return 0; } if(!v){ return ''; } return Math.ceil(v); } $scope.pre_page = function(){ if($scope.page_num > 1){ $scope.page_num = $scope.page_num - 1; } search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.next_page = function(){ if($scope.page_num < Math.ceil($scope.expend_rows / $scope.num_per_page)){ $scope.page_num = (parseInt($scope.page_num) + 1).toString(); } search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.change_page_num = function(){ search_budget_data(); // $scope.budget_data['data'] = _.slice($scope.data, $scope.num_per_page * ($scope.page_num-1), $scope.num_per_page * $scope.page_num - 1); } $scope.doc_id = function(data_list){ return _.slice(data_list, data_list.length - 1, data_list.length)[0]; } $scope.sub_data = function(data_list){ return _.slice(data_list, 0, data_list.length - 1); } $scope.data = []; function search_budget_data(){ http_service.post('flow/expend/wait/handle', search_select(), function(res){ // $scope.$parent.$parent.expend_temp_num = res.data.rows; // $scope.$parent.$parent.expend_temp_num_show = false; $rootScope.search_hint(res.data.data,'arrary'); $scope.expend_rows = res.data.rows; var bill_data = res.data.data; var headers = []; http_service.post('showFieldCfg/list', { "sfCfgType":32 }, function(res){ // if(res.data.data.length==0){ // return false; // } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":30, "cache_id":30 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; if(form_list == undefined){ return false; } headers = get_headers(cfg, form_list); $scope.data = get_data(headers.headers_label_key, bill_data); $scope.budget_data = { headers: headers.headers, data: _.slice($scope.data, 0, $scope.num_per_page * $scope.page_num - 1) }; },true); }); }); } search_budget_data(); _.extend($scope, { "searchlist": [], "visiblecolumns": [] }); http_service.post('showFieldCfg/list', { "sfCfgType":31 }, function(res){ // if(res.data.data.length==0){ // return false; // } var cfg = _.map(res.data.data, function(res){ return res['sfFieldName']; }); http_service.post('form/list', { "guTempType":30, "cache_id":30 }, function(res){ if(!res.data.opState){ return false; } var form_list = res.data.data; var search_items = get_search_items(cfg, form_list); $scope.searchlist = search_items.search_items; },true); }); /* http_service.get('./static/js/data/travel_expense_list.json', function(res){ var data = res.data; $scope.searchlist = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '1'; }); $scope.visiblecolumns = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '2'; }); }); */ $scope.refreshdata = function(){ search_budget_data(); } $rootScope.refer_data_expend = function(){ $scope.refreshdata(); } $scope.show_search_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; $scope.show_conent_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; } } }]) .controller('travelExpenseTodosCtrl', ['$scope','$routeParams', '$route', '$compile', 'http_service',"$rootScope","$location", function($scope, $routeParams, $route, $compile, http_service,$rootScope,$location){ //由于设置高度产生滚动条,注释之 //$scope.$on('$viewContentLoaded', function() { // $('div.split_form').height($(document).height() - 52); // $(window).resize(function(){ // $('div.split_form').height($(document).height() - 52); // }); //}); $scope.type = $routeParams.type; _.extend($scope, { "searchlist": [], "visiblecolumns": [] }); $scope.expend_code = 20; $scope.apply_code = 30; $scope.budget_code = 10; // $scope.budget_temp_num = ""; // $scope.expend_temp_num = ""; // $scope.apply_temp_num = ""; $scope.budget_temp_num_show = true; $scope.expend_temp_num_show = true; $scope.apply_temp_num_show = true; /* http_service.get('./static/js/data/travel_expense_list.json', function(res){ var data = res.data; $scope.searchlist = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '1'; }); $scope.visiblecolumns = _.filter(res.data.data, function(t){ var type = t.sfCfgType, len = t.sfCfgType.length; return type.substring(len-1, len) === '2'; }); }); */ $scope.more_form = function(url){ $rootScope.my_form_type = 2; $location.path(url); } $scope.show_search_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; $scope.show_conent_dropdown = function(e){ $('div.drop_down_sel').remove(); var $element = $(''); $('body').append($element); $compile($element)($scope); $element.css({ 'top': e.pageY + 5, 'right': 80 }); e.stopPropagation(); }; $scope.todos = { 'all': true, 'budget': false, 'request': false, 'rebuise': false } }]);