|
@@ -0,0 +1,606 @@
|
|
|
+starter.controller('ErpBxCtrl', function ($rootScope, $scope, $state, $window, $ionicPopover, global, ErpBx) {
|
|
|
+ var beforeEnter = $scope.$on("$ionicView.beforeEnter", function (event, data) {
|
|
|
+ global.fetch_user().then(function () {
|
|
|
+ gettaxrtodata();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ global.fetch_user().then(function () {
|
|
|
+ getrecorddata();
|
|
|
+ });
|
|
|
+
|
|
|
+ $ionicPopover.fromTemplateUrl('templates/paymenu.html', {
|
|
|
+ scope: $scope
|
|
|
+ }).then(function (popover) {
|
|
|
+ $scope.popover = popover;
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.torecord = function (record) {
|
|
|
+ if (record) {
|
|
|
+ ErpBx.recordItem = record;
|
|
|
+ $state.go('erpbx-record', {
|
|
|
+ id: record.id
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.popover.hide();
|
|
|
+ $state.go('erpbx-record', {
|
|
|
+ id: -1
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.toaudit = function () {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.tobill = function () {
|
|
|
+ $scope.popover.hide();
|
|
|
+ $state.go('erpbx-bill', {
|
|
|
+ id: -1
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.doRefresh = function () {
|
|
|
+ getrecorddata();
|
|
|
+ }
|
|
|
+
|
|
|
+ function gettaxrtodata() {
|
|
|
+ ErpBx.linkerBX('GetTaxRto').get(function (data) {
|
|
|
+ ErpBx.taxrto = data.taxrto;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function getrecorddata() {
|
|
|
+ ErpBx.linkerBX('GetBX').query(function (data) {
|
|
|
+ $scope.records = data;
|
|
|
+ ErpBx.recordlist = 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 RecordListDoRefresh = $rootScope.$on('RecordListDoRefresh', function (event ,data) {
|
|
|
+ getrecorddata();
|
|
|
+ })
|
|
|
+
|
|
|
+ $scope.$on('$destroy', function () {
|
|
|
+ RecordListDoRefresh();
|
|
|
+ beforeEnter();
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+.controller('ErpBxRecordCtrl', function ($rootScope, $scope, $state, $cordovaDatePicker, $ionicHistory, $cordovaDialogs, global, showPopup, ErpBx, Tool, formatFilter, cfg) {
|
|
|
+ $scope.recordid = $state.params['id'];
|
|
|
+ $scope.taxCategory = ['', '不计税', '税内含', '税外加'];
|
|
|
+ $scope.deleteimage_list = [];
|
|
|
+
|
|
|
+ var watch = null;
|
|
|
+ showPopup.modalTemplate('templates/modal-selecttax.html', 'slide-in-right', $scope).then(function (modal) {
|
|
|
+ $scope.select_tax_modal = modal;
|
|
|
+ });
|
|
|
+ showPopup.modalTemplate('templates/modal-selecttype.html', 'slide-in-right', $scope).then(function (modal) {
|
|
|
+ $scope.select_type_modal = modal;
|
|
|
+ });
|
|
|
+ var isModified = false;
|
|
|
+ $scope.language = global.language;
|
|
|
+
|
|
|
+ global.fetch_user().then(function () {
|
|
|
+ if ($scope.recordid == -1) {
|
|
|
+ gettypedata();
|
|
|
+ $scope.record = {
|
|
|
+ fee_id: null,
|
|
|
+ fee_name: null,
|
|
|
+ fee_eng_name: null,
|
|
|
+ tax_id: 1,
|
|
|
+ amt: null,
|
|
|
+ tax_rto: ErpBx.taxrto,
|
|
|
+ tax: null,
|
|
|
+ inv_no: null,
|
|
|
+ bx_dd: new Date(),
|
|
|
+ rem: null,
|
|
|
+ uni_no_pay: null,
|
|
|
+ files: []
|
|
|
+ };
|
|
|
+ } else if ($scope.recordid == 0){
|
|
|
+ $scope.record = angular.copy(ErpBx.tfitem);
|
|
|
+ } else {
|
|
|
+ gettypedata();
|
|
|
+ ErpBx.linkerBX('GetOneBX').get({id :$scope.recordid}, function (data) {
|
|
|
+ $scope.record = data;
|
|
|
+ _.each($scope.record.files, function (item) {
|
|
|
+ item.file_thumbnail_path = formatFilter('{0}ext_erp/{1}', cfg.api, item.url);
|
|
|
+ item.file_full_path = formatFilter('{0}ext_erp/{1}', cfg.api, item.url);
|
|
|
+ });
|
|
|
+ watch = $scope.$watch('record', function (n, o) {
|
|
|
+ if (n == o)
|
|
|
+ return;
|
|
|
+ isModified = true;
|
|
|
+ }, true);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.doRefresh = function () {
|
|
|
+ gettypedata();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.loadMore = function () {
|
|
|
+ if ($scope.types != undefined && $scope.types.next != null) {
|
|
|
+ Tool.get($scope.types.next).then(function (data) {
|
|
|
+ $scope.types.Data = $scope.types.Data.concat(data.Data);
|
|
|
+ $scope.types.next = data.next;
|
|
|
+ $scope.types.previous = data.previous;
|
|
|
+ }).finally(function () {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.moreCanBeLoaded = function () {
|
|
|
+ return $scope.types != undefined && $scope.types.next != null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.showModal = function (type) {
|
|
|
+ if ($scope.recordid == 0) return;
|
|
|
+ if (type == 'tax') {
|
|
|
+ $scope.select_tax_modal.show();
|
|
|
+ $rootScope.commons.modal = $scope.select_tax_modal;
|
|
|
+ } else if (type == 'type') {
|
|
|
+ $scope.select_type_modal.show();
|
|
|
+ $rootScope.commons.modal = $scope.select_type_modal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.closeModal = function (item) {
|
|
|
+ $scope.record.fee_name = item.name;
|
|
|
+ $scope.record.fee_eng_name = item.eng_name;
|
|
|
+ $rootScope.commons.modal.hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.selectDate = function () {
|
|
|
+ if ($scope.recordid == 0) return;
|
|
|
+ var options = {
|
|
|
+ mode: 'date',
|
|
|
+ date: new Date($scope.record.bx_dd),
|
|
|
+ androidTheme: 3
|
|
|
+ };
|
|
|
+ $cordovaDatePicker.show(options).then(function (date) {
|
|
|
+ if (date == undefined) return;
|
|
|
+ $scope.record.bx_dd = date;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.saverecord = function () {
|
|
|
+ if ($scope.recordid == 0) return;
|
|
|
+ if ($scope.record.amt == null) {
|
|
|
+ showPopup.PopupWindow(0, "请填写金额", false);
|
|
|
+ return
|
|
|
+ } else if ($scope.record.fee_id == null) {
|
|
|
+ showPopup.PopupWindow(0, "请选择消费类型", false);
|
|
|
+ return
|
|
|
+ } else if ($scope.language == 'zh-TW') {
|
|
|
+ if (!$scope.record.inv_no || $scope.record.inv_no == '') {
|
|
|
+ showPopup.PopupWindow(0, "请填写发票号码", false);
|
|
|
+ return
|
|
|
+ } else if ($scope.record.inv_no && $scope.record.inv_no.length != 14) {
|
|
|
+ showPopup.PopupWindow(0, "请核对发票号码", false);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!$scope.record.uni_no_pay || $scope.record.uni_no_pay == '') {
|
|
|
+ showPopup.PopupWindow(0, "请填写统一编号", false);
|
|
|
+ return
|
|
|
+ } else if ($scope.record.uni_no_pay && $scope.record.uni_no_pay.length != 20) {
|
|
|
+ showPopup.PopupWindow(0, "请核对统一编号", false);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showPopup.showLoading(1, '正在提交', true);
|
|
|
+ if ($scope.recordid == -1) {
|
|
|
+ ErpBx.linkerBX('PostBx').save($scope.record, function (data) {
|
|
|
+ var imagefiles = _.pluck($scope.record.files, 'file_full_path');
|
|
|
+ postImgae(imagefiles);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (isModified) {
|
|
|
+ ErpBx.linkerBX('PutBX').update($scope.record, function (data) {
|
|
|
+ _.each($scope.deleteimage_list, function (image) {
|
|
|
+ ErpBx.image('DelFile').delete({id: image.id, filename:image.filename, table:'LINKERBX_FILE'});
|
|
|
+ });
|
|
|
+ var imagefiles = [];
|
|
|
+ _.each($scope.record.files, function (image) {
|
|
|
+ if (!image.id)
|
|
|
+ imagefiles.push(image.file_full_path);
|
|
|
+ });
|
|
|
+ postImgae(imagefiles);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ showPopup.hideLoading();
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.deleteRecord = function () {
|
|
|
+ if ($scope.recordid == 0) return;
|
|
|
+ $cordovaDialogs.confirm('是否删除该消费记录?', '提示', ['是','否']).then(function(buttonIndex) {
|
|
|
+ if (res) {
|
|
|
+ showPopup.showLoading(1, '删除中', true);
|
|
|
+ ErpBx.linkerBX('DeleteBX').delete({id: $scope.recordid}, function (data) {
|
|
|
+ $scope.$emit('RecordListDoRefresh');
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ showPopup.hideLoading();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function postImgae(imagefiles) {
|
|
|
+ if (imagefiles.length > 0) {
|
|
|
+ ErpBx.uploadImage(imagefiles, 'LINKERBX_FILE', $scope.record.id).then(function (data) {
|
|
|
+ $scope.$emit('RecordListDoRefresh');
|
|
|
+ showPopup.hideLoading();
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $scope.$emit('RecordListDoRefresh');
|
|
|
+ showPopup.hideLoading();
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function gettypedata() {
|
|
|
+ if (global.user.token != "") {
|
|
|
+ ErpBx.query('GetData').get({table: 'EXPENSE', page: 1}, function (data) {
|
|
|
+ $scope.types = data;
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ $scope.$broadcast('scroll.refreshComplete');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.isCheck = function () {
|
|
|
+ return $scope.recordid == 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.$on('$destroy', function () {
|
|
|
+ $scope.select_tax_modal.remove();
|
|
|
+ $scope.select_type_modal.remove();
|
|
|
+ if ($scope.recordid != -1 && $scope.recordid != 0) {
|
|
|
+ watch();
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+.controller('ErpBxBillCtrl', function ($rootScope, $scope, $state, $cordovaDatePicker, $ionicHistory, $cordovaDialogs, global, ErpBx, showPopup, Tool, formatFilter, cfg) {
|
|
|
+ $scope.select_record_modal = showPopup.modalTemplate('templates/modal-selectrecord.html', 'slide-in-right', $scope);
|
|
|
+ showPopup.modalTemplate('templates/modal-selectdept.html', 'slide-in-right', $scope).then(function (modal) {
|
|
|
+ $scope.select_dept_modal = modal;
|
|
|
+ });
|
|
|
+ $scope.billid = $state.params['id'];
|
|
|
+ $scope.recordlist = angular.copy(ErpBx.recordlist);
|
|
|
+ $scope.amountSum = 0;
|
|
|
+ var isModified = false;
|
|
|
+ var isFirst = false;
|
|
|
+ var watch = null;
|
|
|
+
|
|
|
+ global.fetch_user().then(function () {
|
|
|
+ getdeptdata();
|
|
|
+ if ($scope.billid == -1) {
|
|
|
+ $scope.bill = {
|
|
|
+ bx_no: null,
|
|
|
+ bx_dd: new Date(),
|
|
|
+ dep: null,
|
|
|
+ depname: null,
|
|
|
+ chk_man: null,
|
|
|
+ bxlist:[]
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.select_record_modal.then(function (modal) {
|
|
|
+ isFirst = true;
|
|
|
+ $scope.select_record_modal = modal;
|
|
|
+ $rootScope.commons.modal = modal;
|
|
|
+ $scope.select_record_modal.show();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.select_record_modal.then(function (modal) {
|
|
|
+ $scope.select_record_modal = modal;
|
|
|
+ });
|
|
|
+ ErpBx.MFBX('GetMFBX').get({bxno :$scope.billid}, function (data) {
|
|
|
+ $scope.bill = data;
|
|
|
+ _.each($scope.bill.bxlist, function (item) {
|
|
|
+ $scope.amountSum += item.amt;
|
|
|
+ $scope.recordlist.splice(0, 0, item);
|
|
|
+ item.selected = true;
|
|
|
+ _.each(item.files, function (file) {
|
|
|
+ file.file_thumbnail_path = formatFilter('{0}ext_erp/{1}', cfg.api, file.url);
|
|
|
+ file.file_full_path = formatFilter('{0}ext_erp/{1}', cfg.api, file.url);
|
|
|
+ })
|
|
|
+ });
|
|
|
+ $scope.bxlist_old = _.map(data.bxlist, function (item) {
|
|
|
+ return {id: item.id}
|
|
|
+ });
|
|
|
+ watch = $scope.$watch('bill', function (n, o) {
|
|
|
+ if (n == o)
|
|
|
+ return;
|
|
|
+ isModified = true;
|
|
|
+ }, true);
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.doRefresh = function () {
|
|
|
+ getdeptdata();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.loadMore = function () {
|
|
|
+ if ($scope.department != undefined && $scope.department.next != null) {
|
|
|
+ Tool.get($scope.department.next).then(function (data) {
|
|
|
+ $scope.department.Data = $scope.department.Data.concat(data.Data);
|
|
|
+ $scope.department.next = data.next;
|
|
|
+ $scope.department.previous = data.previous;
|
|
|
+ }).finally(function () {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.moreCanBeLoaded = function () {
|
|
|
+ return $scope.department != undefined && $scope.department.next != null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.selectRecord = function (recorditem) {
|
|
|
+ if (recorditem.selected) {
|
|
|
+ $scope.amountSum = parseFloat($scope.amountSum) + parseFloat(recorditem.amt);
|
|
|
+ } else {
|
|
|
+ $scope.amountSum = parseFloat($scope.amountSum) - parseFloat(recorditem.amt);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.toEditRecord = function () {
|
|
|
+ $scope.select_record_modal.show();
|
|
|
+ $rootScope.commons.modal = $scope.select_record_modal;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.selectDate = function () {
|
|
|
+ var options = {
|
|
|
+ mode: 'date',
|
|
|
+ date: new Date($scope.bill.bx_dd),
|
|
|
+ androidTheme: 3
|
|
|
+ };
|
|
|
+ $cordovaDatePicker.show(options).then(function (date) {
|
|
|
+ if (date == undefined) return;
|
|
|
+ $scope.bill.bx_dd = date;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.ok = function () {
|
|
|
+ if (isFirst) {
|
|
|
+ isFirst = false;
|
|
|
+ }
|
|
|
+ $scope.bill.bxlist = _.filter($scope.recordlist, function (item) {
|
|
|
+ return item.selected;
|
|
|
+ })
|
|
|
+ $rootScope.commons.modal.hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ goback();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.showModal = function () {
|
|
|
+ $scope.select_dept_modal.show();
|
|
|
+ $rootScope.commons.modal = $scope.select_dept_modal;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.closeModal = function (item) {
|
|
|
+ $scope.bill.dep = item.no;
|
|
|
+ $scope.bill.depname = item.name;
|
|
|
+ $rootScope.commons.modal.hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ $rootScope.commons.fun = function () {
|
|
|
+ goback();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.savebill = function () {
|
|
|
+ if ($scope.bill.dep == null) {
|
|
|
+ showPopup.PopupWindow(0, "请选择部门", false);
|
|
|
+ return
|
|
|
+ } else if ($scope.bill.bxlist.length == 0) {
|
|
|
+ showPopup.PopupWindow(0, "请选择消费记录", false);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var data = angular.copy($scope.bill);
|
|
|
+ data.bxlist = _.map(data.bxlist, function (item) {
|
|
|
+ return {id: item.id}
|
|
|
+ });
|
|
|
+ data = _.omit(data, 'depname');
|
|
|
+ showPopup.showLoading(1, '正在提交', true);
|
|
|
+ if ($scope.billid == -1) {
|
|
|
+ ErpBx.MFBX('PostMFBX').save(data, function (data) {
|
|
|
+ $scope.$emit('RecordListDoRefresh');
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ showPopup.hideLoading();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (isModified) {
|
|
|
+ var addlist = _.difference(_.map(data.bxlist, function (item) {
|
|
|
+ return item.id
|
|
|
+ }), _.map($scope.bxlist_old, function (item) {
|
|
|
+ return item.id
|
|
|
+ }));
|
|
|
+ var deletelist = _.difference(_.map($scope.bxlist_old, function (item) {
|
|
|
+ return item.id
|
|
|
+ }), _.map(data.bxlist, function (item) {
|
|
|
+ return item.id
|
|
|
+ }));
|
|
|
+ _.each(addlist, function (additem) {
|
|
|
+ var item = _.find(data.bxlist, function (item) {
|
|
|
+ return additem == item.id
|
|
|
+ });
|
|
|
+ item.tfbx_status = 'A'
|
|
|
+ });
|
|
|
+ data.bxlist = data.bxlist.concat(_.map(deletelist, function (item) {
|
|
|
+ return {id: item, tfbx_status: 'D'}
|
|
|
+ }));
|
|
|
+ ErpBx.MFBX('PutMFBX').update(data, function (data) {
|
|
|
+ $scope.$emit('BillListDoRefresh');
|
|
|
+ $scope.$emit('RecordListDoRefresh');
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ showPopup.hideLoading();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ showPopup.hideLoading();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.deletebill = function () {
|
|
|
+ $cordovaDialogs.confirm('是否删除该报销单?', '提示', ['是','否']).then(function(buttonIndex) {
|
|
|
+ if (buttonIndex == 1) {
|
|
|
+ showPopup.showLoading(1, '删除中', true);
|
|
|
+ ErpBx.MFBX('DeleteMFBX').delete({key: $scope.billid, modifydd: $scope.bill.modify_dd ? $scope.bill.modify_dd : ''}, function (data) {
|
|
|
+ $scope.$emit('BillListDoRefresh');
|
|
|
+ $scope.$emit('RecordListDoRefresh');
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ showPopup.hideLoading();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.totfdetail = function (item) {
|
|
|
+ ErpBx.tfitem = item;
|
|
|
+ $state.go('erpbx-record', {
|
|
|
+ id: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function goback() {
|
|
|
+ if (isFirst) {
|
|
|
+ $ionicHistory.goBack();
|
|
|
+ }
|
|
|
+ if ($rootScope.commons.modal) {
|
|
|
+ $rootScope.commons.modal.hide();
|
|
|
+ $rootScope.commons.modal = undefined;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function getdeptdata() {
|
|
|
+ if (global.user.token != "") {
|
|
|
+ ErpBx.query('GetData').get({table: 'DEPT', page: 1}, function (data) {
|
|
|
+ $scope.department = data;
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ $scope.$broadcast('scroll.refreshComplete');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.$on("$destroy", function () {
|
|
|
+ $scope.select_record_modal.remove();
|
|
|
+ $scope.select_dept_modal.remove();
|
|
|
+ if ($scope.billid != -1) {
|
|
|
+ watch();
|
|
|
+ }
|
|
|
+ });
|
|
|
+})
|
|
|
+
|
|
|
+.controller('ErpBxListCtrl', function ($rootScope, $scope, $state, global, Tool, ErpBx, showPopup) {
|
|
|
+ showPopup.modalTemplate('templates/modal-selectdate.html', 'slide-in-right', $scope).then(function (modal) {
|
|
|
+ $scope.select_date_modal = modal;
|
|
|
+ });
|
|
|
+ $scope.chkdd_tv_arr = ErpBx.chkdd_tv_arr;
|
|
|
+ $scope.chkdd_tv = 0;
|
|
|
+
|
|
|
+ global.fetch_user().then(function () {
|
|
|
+ getbilldata();
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.doRefresh = function () {
|
|
|
+ getbilldata();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.todetail = function (id) {
|
|
|
+ $state.go('erpbx-bill', {
|
|
|
+ id:id
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.showModal = function (type) {
|
|
|
+ $scope.select_date_modal.show();
|
|
|
+ $rootScope.commons.modal = $scope.select_date_modal;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.closeModal = function (index) {
|
|
|
+ $scope.chkdd_tv = index;
|
|
|
+ getbilldata();
|
|
|
+ $rootScope.commons.modal.hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.loadMore = function () {
|
|
|
+ if ($scope.billlist != undefined && $scope.billlist.next != null) {
|
|
|
+ Tool.get($scope.billlist.next).then(function (data) {
|
|
|
+ $scope.billlist.Data = $scope.billlist.Data.concat(data.Data);
|
|
|
+ $scope.billlist.next = data.next;
|
|
|
+ $scope.billlist.previous = data.previous;
|
|
|
+ }).finally(function () {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.moreCanBeLoaded = function () {
|
|
|
+ return $scope.billlist != undefined && $scope.billlist.next != null;
|
|
|
+ }
|
|
|
+
|
|
|
+ function getbilldata() {
|
|
|
+ if ($scope.billlist == undefined) {
|
|
|
+ $scope.loading = true;
|
|
|
+ }
|
|
|
+ ErpBx.query('GetDatabyDate').get({table: 'MF_BX', page:1 ,condi: $scope.chkdd_tv}, function (data) {
|
|
|
+ $scope.billlist = data;
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ }).$promise.finally(function () {
|
|
|
+ $scope.$broadcast('scroll.refreshComplete');
|
|
|
+ $scope.loading = false;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ var BillListDoRefresh = $rootScope.$on('BillListDoRefresh', function (event ,data) {
|
|
|
+ getbilldata();
|
|
|
+ })
|
|
|
+
|
|
|
+ $scope.$on('$destroy', function () {
|
|
|
+ $scope.select_date_modal.remove();
|
|
|
+ BillListDoRefresh();
|
|
|
+ })
|
|
|
+})
|