commonModule.directive('previewAccountVoucher', ['$log', 'browserService', '$translate', function ($log, browserService, $translate) { $log.debug('previewAccountVoucher.ctor()...'); return { restrict: 'E', templateUrl: '/app/common/controls/preview-account-voucher/preview-account-voucher.html' + '?_=' + Math.random(), scope: { isFromReMapping: '@', reMappId: '@', isEdit: '@', enterpriseCode: '=?', selectedVouchers: "=?", project: '=?', month:'=?', }, controller: 'previewAccountVoucherController', link: function ($scope, element) { // ************************************************************************************************ // Perform Data filter $scope.doDataFilter = function (removeData) { $scope.filterData.periodFrom = $scope.monthFrom.selected.id; $scope.filterData.periodTo = $scope.monthTo.selected.id; if ($scope.filterData.periodFrom > $scope.filterData.periodTo) { $scope.filterData.periodTo = $scope.filterData.periodFrom; } if (removeData !== "") { $scope.openFilterPopup(); var textBoxNames = removeData.split("|"); for (var i = 0; i < textBoxNames.length; i++) $("#" + textBoxNames[i]).val(""); } $scope.filterData = { periodFrom: $scope.filterData.periodFrom, periodTo: $scope.filterData.periodTo, accountCode: $("#accountCode").val().trim(), accountName: $("#accountName").val().trim(), debitOpeningBalanceFrom: $("#debitOpeningBalanceFrom").val().trim(), debitOpeningBalanceTo: $("#debitOpeningBalanceTo").val().trim(), creditOpeningBalanceFrom: $("#creditOpeningBalanceFrom").val().trim(), creditOpeningBalanceTo: $("#creditOpeningBalanceTo").val().trim(), accumulatedDebitAmountFrom: $("#accumulatedDebitAmountFrom").val().trim(), accumulatedDebitAmountTo: $("#accumulatedDebitAmountTo").val().trim(), accumulatedCreditAmountFrom: $("#accumulatedCreditAmountFrom").val().trim(), accumulatedCreditAmountTo: $("#accumulatedCreditAmountTo").val().trim(), debitClosingBalanceFrom: $("#debitClosingBalanceFrom").val().trim(), debitClosingBalanceTo: $("#debitClosingBalanceTo").val().trim(), creditClosingBalanceFrom: $("#creditClosingBalanceFrom").val().trim(), creditClosingBalanceTo: $("#creditClosingBalanceTo").val().trim() }; //******************************************************************************** // add to Criteria List for display on top of the grid: var crits = $scope.filterData; $scope.criteriaList = []; var crit = []; if (crits.accountCode !== "null" && crits.accountCode.length > 0) { crit = new Object; crit.name = $translate.instant('AccountCode'); crit.valueFrom = crits.accountCode; crit.propertyName = "accountCode"; $scope.criteriaList.push(crit); } if (crits.accountName !== "null" && crits.accountName.length > 0) { crit = new Object; crit.name = $translate.instant('AccountName'); crit.valueFrom = crits.accountName; crit.propertyName = "accountName"; $scope.criteriaList.push(crit); } if (crits.debitOpeningBalanceFrom !== "null" && crits.debitOpeningBalanceFrom.length > 0 || crits.debitOpeningBalanceTo !== "null" && crits.debitOpeningBalanceTo.length) { crit = new Object; crit.name = $translate.instant('DebitOpeningBalance'); crit.valueFrom = crits.debitOpeningBalanceFrom; crit.valueTo = crits.debitOpeningBalanceTo; crit.propertyName = "debitOpeningBalanceFrom|debitOpeningBalanceTo"; $scope.criteriaList.push(crit); } if (crits.creditOpeningBalanceFrom !== "null" && crits.creditOpeningBalanceFrom.length > 0 || crits.creditOpeningBalanceTo !== "null" && crits.creditOpeningBalanceTo.length) { crit = new Object; crit.name = $translate.instant('CreditOpeningBalance'); crit.valueFrom = crits.creditOpeningBalanceFrom; crit.valueTo = crits.creditOpeningBalanceTo; crit.propertyName = "creditOpeningBalanceFrom|creditOpeningBalanceTo"; $scope.criteriaList.push(crit); } if (crits.accumulatedDebitAmountFrom !== "null" && crits.accumulatedDebitAmountFrom.length > 0 || crits.accumulatedDebitAmountTo !== "null" && crits.accumulatedDebitAmountTo.length) { crit = new Object; crit.name = $translate.instant('AccumulatedDebitAmount'); crit.valueFrom = crits.accumulatedDebitAmountFrom; crit.valueTo = crits.accumulatedDebitAmountTo; crit.propertyName = "accumulatedDebitAmountFrom|accumulatedDebitAmountTo"; $scope.criteriaList.push(crit); } if (crits.accumulatedCreditAmountFrom !== "null" && crits.accumulatedCreditAmountFrom.length > 0 || crits.accumulatedCreditAmountTo !== "null" && crits.accumulatedCreditAmountTo.length) { crit = new Object; crit.name = $translate.instant('AccumulatedCreditAmount'); crit.valueFrom = crits.accumulatedCreditAmountFrom; crit.valueTo = crits.accumulatedCreditAmountTo; crit.propertyName = "accumulatedCreditAmountFrom|accumulatedCreditAmountTo"; $scope.criteriaList.push(crit); } if (crits.debitClosingBalanceFrom !== "null" && crits.debitClosingBalanceFrom.length > 0 || crits.debitClosingBalanceTo !== "null" && crits.debitClosingBalanceTo.length) { crit = new Object; crit.name = $translate.instant('DebitClosingBalance'); crit.valueFrom = crits.debitClosingBalanceFrom; crit.valueTo = crits.debitClosingBalanceTo; crit.propertyName = "debitClosingBalanceFrom|debitClosingBalanceTo"; $scope.criteriaList.push(crit); } if (crits.creditClosingBalanceFrom !== "null" && crits.creditClosingBalanceFrom.length > 0 || crits.creditClosingBalanceTo !== "null" && crits.creditClosingBalanceTo.length) { crit = new Object; crit.name = $translate.instant('CreditClosingBalance'); crit.valueFrom = crits.creditClosingBalanceFrom; crit.valueTo = crits.creditClosingBalanceTo; crit.propertyName = "creditClosingBalanceFrom|creditClosingBalanceTo"; $scope.criteriaList.push(crit); } // add to Criteria List for display on top of the grid: //******************************************************************************** var criteria = JSON.stringify($scope.filterData); if (browserService.isIE() || browserService.isEdge()) criteria = encodeURIComponent(criteria); $scope.getDataFromDatabase($scope.currentCategory, $scope.filterData.periodFrom, $scope.filterData.periodTo, criteria); $('.justPopMeOver').popover("hide"); }; // Perform Data filter // ************************************************************************************************ $scope.openFilterPopup = function () { $("#accountCode").val($scope.filterData.accountCode); $("#accountName").val($scope.filterData.accountName); $("#debitOpeningBalanceFrom").val($scope.filterData.debitOpeningBalanceFrom); $("#debitOpeningBalanceTo").val($scope.filterData.debitOpeningBalanceTo); $("#creditOpeningBalanceFrom").val($scope.filterData.creditOpeningBalanceFrom); $("#creditOpeningBalanceTo").val($scope.filterData.creditOpeningBalanceTo); $("#accumulatedDebitAmountFrom").val($scope.filterData.accumulatedDebitAmountFrom); $("#accumulatedDebitAmountTo").val($scope.filterData.accumulatedDebitAmountTo); $("#accumulatedCreditAmountFrom").val($scope.filterData.accumulatedCreditAmountFrom); $("#accumulatedCreditAmountTo").val($scope.filterData.accumulatedCreditAmountTo); $("#debitClosingBalanceFrom").val($scope.filterData.debitClosingBalanceFrom); $("#debitClosingBalanceTo").val($scope.filterData.debitClosingBalanceTo); $("#creditClosingBalanceFrom").val($scope.filterData.creditClosingBalanceFrom); $("#creditClosingBalanceTo").val($scope.filterData.creditClosingBalanceTo); }; $scope.isFromReMapping = false; $scope.$watch("enterpriseCode", function (newValue, oldValue) { //选择不同COA时,初始化搜索条件 if ($scope.isFromReMapping) { $log.debug("start vat-preview-accountVoucher.js watching enterpriseCode"); //设置科目代码 $("#coaAutoComplete").dxAutocomplete("instance").option("value", newValue); if (!_.isUndefined(newValue) && !_.isUndefined(oldValue)) { if (!_.isEqual(newValue, oldValue)) { $scope.voucherDataList = []; $('#gridContainer').dxDataGrid('instance').option("dataSource", $scope.voucherDataList); //切换不同的COA时,查询界面重置为空 $scope.queryString = ''; //查询条件汇总 $scope.vIDCount = 0;//凭证数 $scope.itemIDCount = 0;//分路数 $scope.debitSum = 0;//借方金额 $scope.creditSum = 0;//贷方金额 } } } }); $scope.$watch("isEdit", function (newValue, oldValue) { $log.debug("start vat-preview-accountVoucher.js watching isEdit"); $log.debug($scope.enterpriseCode); $log.debug($scope.selectedVouchers); $log.debug($scope.isEdit); if ($scope.isFromReMapping) { $("#coaAutoComplete").dxAutocomplete("instance").option("value", $scope.enterpriseCode); $scope.voucherDataList = []; $('#gridContainer').dxDataGrid('instance').option("dataSource", $scope.voucherDataList); //切换不同的COA时,查询界面重置为空 $scope.queryString = ''; //查询条件汇总 $scope.vIDCount = 0;//凭证数 $scope.itemIDCount = 0;//分路数 $scope.debitSum = 0;//借方金额 $scope.creditSum = 0;//贷方金额 //当凭证重对应点击编辑按钮时,调用查询 if (!_.isNull($scope.selectedVouchers) && $scope.isEdit === "true") { $log.debug("start vat-preview-accountVoucher.js watching selectVoucher "); $scope.selectVoucher(); } } }); } }; } ]); commonModule.directive('convertToNumber', function () { return { require: 'ngModel', link: function (scope, element, attrs, ngModel) { ngModel.$parsers.push(function (val) { return val != null ? parseInt(val, 10) : null; }); ngModel.$formatters.push(function (val) { return val != null ? '' + val : null; }); } }; });