credit.js 5.61 KB
(function () {
    "use strict";


    /**
     *    支付渠道费日汇总报表
     */
    var setCreditController = function ($scope, $http, $modal, saleService, hrService, dialogService, wosaicustomizationService) {
        $scope.$emit('navShow', 3);

        $scope.vm = {
            pageNumber: 1,
            pageSize: 10,
        };
        //获取员工
        $scope.getEmployeeLists = function (backdata) {
            var param = {
                keyword: backdata.data.keyword,
                pageNumber: backdata.data.pageNumber,
                pageSize: backdata.data.pageSize
            };
            //获取法律实体
            hrService.apiHrEmployeeFindIndex(param).success(function (data) {
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                }
                else {
                    backdata.deferred.resolve({itemList: data.result, totalCount: data.totalCount});
                }
            });
        }
        //类型
        $scope.typeList = [{key: "AREA", val: "区域"}, {key: "CITY", val: "城市"}, {key: "BD", val: "业务拓展员"}];
        $scope.getList = function () {
            wosaicustomizationService.apiEmployeeCreditFind($scope.vm).success(function (data) {
                if (data.errors === null || data.errors.length > 0) {
                    dialogService.tip(data.errors, null, 0);
                } else {
                    $scope.employeeCreditList = data.result;
                    $scope.vm.totalCount = data.totalCount;

                }
            });
        }
        $scope.doFind = function () {
            $scope.vm.pageNumber = 1;
            $scope.vm.pageSize = 10;
            $scope.vm.employeeName = $scope.vm.employee ? $scope.vm.employee.name : null;
            $scope.vm.type = $scope.vm.type ? $scope.vm.type : null;
            $scope.getList();
        };
        //创建员工
        $scope.addEmployee = function () {
            var modalInstance = $modal.open({
                templateUrl: "addEmployee.htm",
                controller: addEmployeeController,
                size: "",
                resolve: {
                    items: function () {
                        return {operatingUnitList: $scope.operatingUnitList};
                    }
                }
            });
            modalInstance.result.then(function () {
                $scope.getList();
            });
        };

    };
    /**
     *   新增
     */
    var addEmployeeController = ["$scope", "$modalInstance", "items", "HrService", "SystemService", "dialogService","WosaicustomizationService",
        function ($scope, $modalInstance, items, HrService, SystemService, dialogService,wosaicustomizationService) {
            $scope.$emit('navShow', 3);

            $scope.vm = {
                pageNumber: 1,
                pageSize: 10,
            };
            //获取员工
            $scope.getEmployeeLists = function (backdata) {
                var param = {
                    keyword: backdata.data.keyword,
                    pageNumber: backdata.data.pageNumber,
                    pageSize: backdata.data.pageSize
                };
                //获取法律实体
                HrService.apiHrEmployeeFindIndex(param).success(function (data) {
                    if (data.errors == null || data.errors.length > 0) {
                        dialogService.tip(data.errors);
                    }
                    else {
                        backdata.deferred.resolve({itemList: data.result, totalCount: data.totalCount});
                    }
                });
            }
            $scope.employee = $scope.vm.employee;
            $scope.changeState = function (employee) {
                $scope.vm.organizationName = $scope.vm.employee ? $scope.vm.employee.organizationName : null;
            };
            $scope.$watch("vm.employee", function (employee) {
                $scope.vm.organizationName = $scope.vm.employee ? $scope.vm.employee.organizationName : null;
            }, true);

            //类型
            $scope.typeList = [{key: "AREA", val: "区域"}, {key: "CITY", val: "城市"}, {key: "BD", val: "业务拓展员"}];


            //保存
            $scope.ok = function () {
                if (!$scope.vm.employee) {
                    dialogService.tip([{message: "请填写员工!"}]);
                    return;
                }
                if (!$scope.vm.type) {
                    dialogService.tip([{message: "请填写类型!"}]);
                    return;
                }
                if (!$scope.vm.initCredit) {
                    dialogService.tip([{message: "请填写额度限制!"}]);
                    return;
                }
                $scope.vm.employeeName = $scope.vm.employee ? $scope.vm.employee.name : null;
                wosaicustomizationService.apiEmployeeCreditCreate($scope.vm).success(function (data) {
                    if (data.errors === null || data.errors.length > 0) {
                        dialogService.tip(data.errors, null, 0);
                    } else {
                        dialogService.tip([{"message": "添加成功!"}]);
                        $modalInstance.close();

                    }
                });
            };


            //关闭窗口
            $scope.cancel = function () {
                $modalInstance.dismiss('cancel');
            };
        }];

    angular.module("xn.page", [])

        .controller("SetCreditController", ["$scope", "$http", "$modal", "SaleService", "HrService", "dialogService", "WosaicustomizationService", setCreditController])

})();