123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- starter.controller('AuditCtrl', function ($rootScope, $scope, $state, $ionicActionSheet, $window, $timeout, Audit, global, formatFilter) {
- var beforeEnter = $scope.$on("$ionicView.beforeEnter", function (event, data) {
- global.fetch_user().then(function () {
- getcountdata();
- });
- });
- $scope.doRefresh = function () {
- getcountdata();
- }
- $scope.show = function () {
- $ionicActionSheet.show({
- buttons: [
- {text: '过滤条件'}
- ],
- titleText: '设置',
- cancelText: '取消',
- buttonClicked: function (index) {
- if (index == 0)
- $state.go('audit-filter');
- }
- });
- };
- function getcountdata() {
- if (global.user.token != "") {
- Audit.Audit('GetAuditCounts').save(Audit.getFilter(), function (data) {
- $scope.count = data;
- }, function (err) {
- if (err.status == 401 && _.has(err.data, 'IsAuth'))
- $window.location.href = formatFilter("http://" + $window.location.host + "/apps/authuser/index.html");
- }).$promise.finally(function () {
- $scope.$broadcast('scroll.refreshComplete');
- });
- }
- }
- var CountDoRefresh = $rootScope.$on('CountDoRefresh', function (event ,data) {
- getcountdata();
- })
- $scope.$on('$destroy', function () {
- beforeEnter();
- CountDoRefresh();
- })
- })
- .controller('FilterCtrl', function ($rootScope, $scope, $state, Audit, showPopup) {
- showPopup.modalTemplate('templates/modal-selectdate.html', 'slide-in-right', $scope).then(function (modal) {
- $scope.select_date_modal = modal;
- });
- $scope.filter = Audit.getFilter();
- $scope.chkdd_tv_arr = Audit.chkdd_tv_arr;
- $scope.clearLocalStorage = function () {
- window.localStorage.clear();
- $scope.filter = Audit.getFilter();
- }
- $scope.showModal = function () {
- $scope.select_date_modal.show();
- $rootScope.commons.modal = $scope.select_date_modal;
- }
- $scope.closeModal = function () {
- Audit.setFilter($scope.filter);
- $rootScope.commons.modal.hide();
- }
- var watchFilter = $scope.$watch('filter.substitutechk', function (n, o) {
- if (n == o)
- return;
- Audit.setFilter($scope.filter);
- });
- $scope.$on('$destroy', function () {
- if ($rootScope.commons.modal)
- $rootScope.commons.modal = null;
- $scope.select_date_modal.remove();
- watchFilter();
- })
- })
- .controller('ListCtrl', function ($rootScope, $scope, $state, $stateParams, Audit, global, Tool) {
- $scope.QueryID = $stateParams.QueryID;
- global.fetch_user().then(function () {
- getlistdata();
- });
- $scope.doRefresh = function () {
- getlistdata();
- }
- $scope.todetails = function (item) {
- $state.go('audit-detail', {
- QueryID: $scope.QueryID,
- BIL_ID: item.bil_id,
- BIL_NO: item.no,
- BIL_ITM: item.bil_itm,
- IsAuditCall: 'T',
- CheckInAudit: 'T'
- })
- }
- $scope.loadMore = function () {
- if ($scope.list != undefined && $scope.list.next != null) {
- Tool.get($scope.list.next).then(function (data) {
- $scope.list.Data = $scope.list.Data.concat(data.Data);
- $scope.list.next = data.next;
- $scope.list.previous = data.previous;
- }).finally(function () {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- $scope.loading = false;
- });
- } else {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- }
- $scope.moreCanBeLoaded = function () {
- return $scope.list != undefined && $scope.list.next != null;
- }
- function getlistdata() {
- if (global.user.token != "") {
- if ($scope.list == undefined) {
- $scope.loading = true;
- }
- Audit.Audit('GetAuditLists').save({QueryID: $scope.QueryID, page: 1}, Audit.getFilter(), function (data) {
- $scope.list = data;
- }, function (err) {
- alert(JSON.stringify(err));
- }).$promise.finally(function () {
- $scope.$broadcast('scroll.refreshComplete');
- $scope.loading = false;
- });
- }
- }
- var ListDoRefresh = $rootScope.$on('ListDoRefresh', function (event ,data) {
- getlistdata();
- })
- $scope.$on('$destroy', function () {
- ListDoRefresh();
- })
- })
- .controller('DetailHeadCtrl', function ($rootScope, $scope, $state, $stateParams, $cordovaDialogs, $ionicModal, global, cfg, Audit, showPopup, formatFilter) {
- $scope.QueryID = $stateParams.QueryID;
- $scope.BIL_ID = $stateParams.BIL_ID;
- $scope.BIL_NO = $stateParams.BIL_NO;
- $scope.BIL_ITM = $stateParams.BIL_ITM;
- $scope.IsAuditCall = $stateParams.IsAuditCall;
- $scope.CheckInAudit = $stateParams.CheckInAudit;
- showPopup.modalTemplate('templates/modal-routeaudit.html', 'slide-in-right', $scope).then(function (modal) {
- $scope.route_audit_modal = modal;
- });
- showPopup.modalTemplate('templates/modal-imagepopover.html', 'slide-in-right', $scope).then(function (modal) {
- $scope.image_popover_modal = modal;
- });
- global.fetch_user().then(function () {
- getbilldata();
- });
- $scope.goBack = function () {
- global.goBack();
- }
- $scope.tobody = function (name) {
- if (name != 'BODY_COUNT')
- return;
- Audit.body = $scope.detail.body;
- $state.go('audit-detail-body');
- }
- $scope.audit = function (op) {
- $scope.data = {};
- if (op == 1 && $scope.QueryID == 1) {
- setPopup('同意', '请输入备注(选填)', op);
- } else if (op == 2 && $scope.QueryID == 1) {
- setPopup('驳回', '请输入驳回理由(必填)', op);
- } else if (op == 3 && $scope.QueryID == 2) {
- setPopup('反审批', '请输入备注(选填)', op);
- } else if (op == 4 && $scope.QueryID == 1) {
- postAudit($scope.data);
- }
- }
- $scope.doRefresh = function () {
- getbilldata();
- }
- $scope.showImages = function (index, event) {
- $scope.activeSlide = index;
- $scope.image_popover_modal.show();
- $rootScope.commons.modal = $scope.image_popover_modal;
- }
- function getbilldata() {
- if (global.user.token != "") {
- if ($scope.detail == undefined) {
- $scope.loading = true;
- }
- Audit.Bills('GetBilHeadDetails').get({
- QueryID: $scope.QueryID,
- BIL_ID: $scope.BIL_ID,
- BIL_NO: $scope.BIL_NO,
- BIL_ITM: $scope.BIL_ITM,
- IsAuditCall: $scope.IsAuditCall,
- CheckInAudit: $scope.CheckInAudit
- }, function (data) {
- $scope.detail = data;
- $scope.detail.group = _.values(_.groupBy(data.Data, function (item) {
- return item.GROUPID;
- }));
- getshlcdata();
- Audit.Bills('GetBilAttrFileList').get({BIL_ID: $scope.BIL_ID, BIL_NO: $scope.BIL_NO}, function (data) {
- $scope.detail.files = data;
- $scope.detail.imagefiles = _.filter($scope.detail.files.Data, function (item) {
- return item.FILE_TYPE == '.BMP' || item.FILE_TYPE == '.JPEG' || item.FILE_TYPE == '.JPG' || item.FILE_TYPE == '.GIF' || file.FILE_TYPE != '.PNG'
- });
- _.each($scope.detail.imagefiles, function (item) {
- item.url = formatFilter('{0}ext_erp/{1}', cfg.api, item.FILE_URL);
- })
- }, function (err) {
- alert(JSON.stringify(err));
- });
- Audit.Bills('GetBilBodyDetails').get({BIL_ID: $scope.BIL_ID, BIL_NO: $scope.BIL_NO, BIL_ITM: $scope.BIL_ITM}, function (data) {
- $scope.detail.body = data;
- }, function (err) {
- alert(JSON.stringify(err));
- });
- }, function (err) {
- alert(JSON.stringify(err));
- }).$promise.finally(function () {
- $scope.$broadcast('scroll.refreshComplete');
- $scope.loading = false;
- });
- }
- }
- function getshlcdata() {
- Audit.Audit('GetAuditSHLC').get({BIL_ID: $scope.BIL_ID, BIL_NO: $scope.BIL_NO, BIL_ITM: $scope.BIL_ITM}, function (data) {
- $scope.detail.shlc = data;
- }, function (err) {
- alert(JSON.stringify(err));
- });
- }
- function setPopup(title, placeholdertext, op) {
- $cordovaDialogs.prompt(placeholdertext, title, ['确定', '取消']).then(function (result) {
- var input = result.input1;
- var btnIndex = result.buttonIndex;
- if (btnIndex == 1) {
- if ( op == 2 && (input == '' || input == null)) {
- $cordovaDialogs.alert('请填写驳回理由', '提示', '确定');
- } else {
- $scope.data = {
- PROCID: op,
- BIL_ID: $scope.BIL_ID,
- BIL_NO: $scope.BIL_NO,
- BIL_ITM: $scope.BIL_ITM,
- REM_SH: input == '' || input == null ? null : input,
- NodeIndex: null
- }
- showPopup.showLoading(1, '正在提交');
- postAudit($scope.data);
- }
- }
- });
- }
- function postAudit(data) {
- Audit.Audit('ExecuteAudit').save(data, function (data) {
- $scope.nodeData = data.NodeData;
- if (data.hasExistsNode == 'T') {
- $scope.route_audit_modal.show();
- $rootScope.commons.modal = $scope.route_audit_modal;
- } else {
- $scope.$emit('ListDoRefresh');
- $scope.$emit('CountDoRefresh');
- getshlcdata();
- }
- }, function (err) {
- showPopup.PopupWindow(0, err.message)
- }).$promise.finally(function () {
- showPopup.hideLoading();
- })
- }
- $scope.$on('$destroy', function () {
- if ($rootScope.commons.modal)
- $rootScope.commons.modal = null;
- $scope.route_audit_modal.remove();
- })
- })
- .controller('DetailBodyCtrl', function ($scope, $state, Audit) {
- $scope.body = angular.copy(Audit.body);
- $scope.toitem = function (item) {
- Audit.bodyitem = item;
- $state.go('audit-body-data');
- }
- })
- .controller('BodyDataCtrl', function ($scope, Audit) {
- $scope.bodyitem = _.values(_.groupBy(angular.copy(Audit.bodyitem), function (item) {
- return item.GROUPID;
- }));
- })
|