rule-enginee-custome-table.js 2.54 KB
systemConfigurationModule.directive('ruleEngineeTable', ['$log','ruleEngineOp','$rootScope','$timeout',
    function ($log, ruleEngineOp,$rootScope,$timeout) {
        return {
            restrict: 'E',
            templateUrl: '/app/admin/systemConfiguration/ruleEngineeConfiguration/vatRuleEnginee/rule-enginee-custome-table.html' + '?_=' + Math.random(),
            replace: true,
            
            scope: {
                taxBasisId: '@',//公式显示组件的id
                isEdit: '=',//是否是可编辑
                defaultEdit:'=',//默认税基是否可编辑
                orgs:'=',//机构下拉列表
                keyCodes:'=',//all key code
                editModel: '=', //所有改组件需要显示的数据来源,
                selectedOrgs: '=',
                operation:'=',
                // editModel={ defaultTaxBase:'xxx',defulatTaxRate:'yyyy',id:'zzzz',
                // exceptions:[{companies:'aaa',taxBase:'bbbb',taxRate:'ccc'}]}
            },
            controller: 'ruleEngineeTableController',
            link: function (scope, element, attr) {
                scope.keyCodesC = angular.copy(scope.keyCodes);

                var currentException;
                $rootScope.$on('orgsChanged', function (event, orgs) {
                    if (currentException !== undefined) {
                        currentException.orgs = orgs;
                    }
                });

                scope.addException = function () {
                    var newException = { id: 0, GroupName: scope.editModel.groupName, name: scope.editModel.name, isNotPersistent: true, taxBase: '', editKey: +new Date() };
                    scope.editModel.taxRuleSettingsExceptions.push(newException);
                };

                scope.delete = function (exception) {
                    var index = scope.editModel.taxRuleSettingsExceptions.indexOf(exception);
                    if (index !== -1) {
                        if (exception.editKey == null) {
                            exception.editKey = +new Date();
                        }
                        scope.editModel.taxRuleSettingsExceptions.splice(index, 1);
                    }
                };

                scope.openRuleEngineSelectorModel = function (exception) {
                    if (scope.isEdit === true) {
                        scope.operation = { type: 'open' };
                        currentException = exception;
                        scope.selectedOrgs = exception.orgs;
                    }
                };
            }
        }
    }]);