|
@@ -1,382 +0,0 @@
|
|
|
-(function ($app) {
|
|
|
- $app.module('ylmis').provider('$employeeFind', function () {
|
|
|
- this.$get = function ($http, $filter, $q) {
|
|
|
- var empData = {
|
|
|
- departmentList: [],
|
|
|
- departmentTypeList: [],
|
|
|
- employeeTypeList: [],
|
|
|
- employeeTitleList: [],
|
|
|
- getDepartmentList: function () {
|
|
|
- $http({
|
|
|
- method: 'post',
|
|
|
- url: '../../api/salary/department/GetList'
|
|
|
- }).then(function (result) {
|
|
|
- empData.departmentList.length = 0;
|
|
|
- $app.forEach(result.data.Data, function (val) {
|
|
|
- empData.departmentList.push(val);
|
|
|
- });
|
|
|
-
|
|
|
- });
|
|
|
- },
|
|
|
- getDepartmentType: function () {
|
|
|
-
|
|
|
- $http({
|
|
|
- method: 'post', url: '../../api/systemsetting/dictionary/GetDicList', data: { code: 'DepartmentType' }
|
|
|
- }).then(function (result) {
|
|
|
- empData.departmentTypeList.length = 0;
|
|
|
- $app.forEach(result.data.Data, function (val) {
|
|
|
- empData.departmentTypeList.push(val);
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- getEmployeeType: function () {
|
|
|
-
|
|
|
- $http({
|
|
|
- method: 'post', url: '../../api/systemsetting/dictionary/GetDicList', data: { code: 'EmployeeType' }
|
|
|
- }).then(function (result) {
|
|
|
- empData.employeeTypeList.length = 0;
|
|
|
- $app.forEach(result.data.Data, function (val) {
|
|
|
- empData.employeeTypeList.push(val);
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- getEmployeeTitle: function () {
|
|
|
-
|
|
|
- $http({
|
|
|
- method: 'post', url: '../../api/systemsetting/dictionary/GetDicList', data: { code: 'Title' }
|
|
|
- }).then(function (result) {
|
|
|
- empData.employeeTitleList.length = 0;
|
|
|
- $app.forEach(result.data.Data, function (val) {
|
|
|
- empData.employeeTitleList.push(val);
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- setDataEmployeeDepartment: function (emp) {
|
|
|
- var list = $filter('filter')(empData.departmentList, function (x) {
|
|
|
- return x.DepartmentId == emp.DepartmentId;
|
|
|
- });
|
|
|
- if (list.length > 0) {
|
|
|
- emp.DataDepartment = list[0];
|
|
|
- } else {
|
|
|
- emp.DataDepartment = {};
|
|
|
- }
|
|
|
- }, setDataEmployeeTitle: function (emp) {
|
|
|
- var list = $filter('filter')(empData.employeeTitleList, function (x) {
|
|
|
- return x.Value == emp.Title;
|
|
|
- });
|
|
|
- if (list.length > 0) {
|
|
|
- emp.DataEmployeeTitle = list[0];
|
|
|
- } else {
|
|
|
- emp.DataEmployeeTitle = {};
|
|
|
- }
|
|
|
- },
|
|
|
- setDataEmployeeType: function (emp) {
|
|
|
- var list = $filter('filter')(empData.employeeTypeList, function (x) {
|
|
|
- return x.Value == emp.EmployeeTypeId;
|
|
|
- });
|
|
|
- if (list.length > 0) {
|
|
|
- emp.DataEmployeeType = list[0];
|
|
|
- } else {
|
|
|
- emp.DataEmployeeType = {};
|
|
|
- }
|
|
|
- },
|
|
|
- dataInit: function () {
|
|
|
-
|
|
|
- this.getDepartmentList();
|
|
|
- this.getDepartmentType();
|
|
|
- this.getEmployeeType();
|
|
|
- this.getEmployeeTitle();
|
|
|
-
|
|
|
- },
|
|
|
- loadEmployee: function (params) {
|
|
|
-
|
|
|
- {employeeTypeIds: ''
|
|
|
- employeeTitleIds: '',
|
|
|
- departmentIds: '',
|
|
|
- empId:''
|
|
|
- }
|
|
|
- */
|
|
|
- return $http({
|
|
|
- method: 'post', url: '../../api/administrasalary/Allowance/findEmployees',
|
|
|
- data: params
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- return empData;
|
|
|
- };
|
|
|
-
|
|
|
- }).directive('employeeFind', function ($http, $q, $filter, $ocLazyLoad, $employeeFind) {
|
|
|
-
|
|
|
- $ocLazyLoad.load(['home/employee_find.css?' + window.sysVersion]);
|
|
|
-
|
|
|
- var directiveObject = {
|
|
|
- restrict: 'ECA',
|
|
|
- templateUrl: 'home/employee_find.html',
|
|
|
- scope: {
|
|
|
- employees: '='
|
|
|
- },
|
|
|
- link: function (scope, element, attr, controller) {
|
|
|
-
|
|
|
- scope.departmentList = $employeeFind.departmentList;
|
|
|
- scope.departmentTypeList = $employeeFind.departmentTypeList;
|
|
|
- scope.employeeTypeList = $employeeFind.employeeTypeList;
|
|
|
- scope.employeeTitleList = $employeeFind.employeeTitleList;
|
|
|
-
|
|
|
-
|
|
|
- scope.selectAll = function (list, $event) {
|
|
|
- angular.forEach(list, function (val) {
|
|
|
- val.checked = $event.target.checked;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- scope.selectDepartment = function (dt, $event) {
|
|
|
-
|
|
|
- var dts = $filter('filter')(scope.$employeeFind.departmentList, { DepartmentTypeId: dt.Value });
|
|
|
-
|
|
|
- angular.forEach(dts, function (val) {
|
|
|
- val.checked = $event.target.checked;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- scope.loadData = function () {
|
|
|
-
|
|
|
- var typeIds = $.map($filter('filter')(scope.employeeTypeList, { checked: true }), function (x) { return x.Value; });
|
|
|
- var titleIds = $.map($filter('filter')(scope.employeeTitleList, { checked: true }), function (x) { return x.Value; });
|
|
|
- var depareIds = $.map($filter('filter')(scope.departmentList, { checked: true }), function (x) { return x.DepartmentId; });
|
|
|
-
|
|
|
- var params = {
|
|
|
- employeeTypeIds: typeIds.join(','),
|
|
|
- employeeTitleIds: titleIds.join(','),
|
|
|
- departmentIds: depareIds.join(',')
|
|
|
- };
|
|
|
- $employeeFind.loadEmployee(params).then(function (result) {
|
|
|
-
|
|
|
- scope.employees.splice(0, scope.employees.length);
|
|
|
- angular.forEach(result.data.Data, function (val) {
|
|
|
-
|
|
|
- scope.employees.push(val);
|
|
|
- });
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- $employeeFind.dataInit();
|
|
|
-
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- return directiveObject;
|
|
|
- }).provider('$department', function () {
|
|
|
-
|
|
|
- this.$get = function ($modal, $http, $filter, $employeeFind) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- var $depart = {
|
|
|
- selectDeparts: [],
|
|
|
- show: function (selectDatas) {
|
|
|
- $app.forEach(this.departmentList, function (x) {
|
|
|
- x.checked = false;
|
|
|
- });
|
|
|
- this.selectDeparts = selectDatas;
|
|
|
- modal.$promise.then(modal.show);
|
|
|
- },
|
|
|
- departmentList: [],
|
|
|
- departmentTypeList: [],
|
|
|
- getDepartment: function (id) {
|
|
|
- var dep = $filter('filter')(this.departmentList, { DepartmentId: id });
|
|
|
- if (dep.length > 0) {
|
|
|
- return dep[0];
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- var getDepartmentList = function () {
|
|
|
- $http({
|
|
|
- method: 'post',
|
|
|
- url: '../../api/salary/department/GetList'
|
|
|
- }).then(function (result) {
|
|
|
- $depart.departmentList = result.data.Data;
|
|
|
- }, function (resp) {
|
|
|
-
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- var getDepartmentType = function () {
|
|
|
-
|
|
|
- $http({
|
|
|
- method: 'post', url: '../../api/systemsetting/dictionary/GetDicList', data: { code: 'DepartmentType' }
|
|
|
- }).then(function (result) {
|
|
|
- $depart.departmentTypeList = result.data.Data;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- getDepartmentList();
|
|
|
- getDepartmentType();
|
|
|
-
|
|
|
- var ctrl = function ($scope) {
|
|
|
-
|
|
|
- $scope.title = '部门选择';
|
|
|
- $scope.departmentList = $depart.departmentList;
|
|
|
- $scope.departmentTypeList = $depart.departmentTypeList;
|
|
|
-
|
|
|
- $scope.selectAll = function (list, $event) {
|
|
|
- angular.forEach(list, function (val) {
|
|
|
- val.checked = $event.target.checked;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- $scope.selectDepartment = function (dt, $event) {
|
|
|
-
|
|
|
- var dts = $filter('filter')($scope.departmentList, function (x) {
|
|
|
-
|
|
|
- return x.DepartmentTypeId == dt.Value;
|
|
|
- });
|
|
|
-
|
|
|
- angular.forEach(dts, function (val) {
|
|
|
- val.checked = $event.target.checked;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- $app.forEach($depart.selectDeparts, function (val) {
|
|
|
- var departs = $filter('filter')($scope.departmentList, { DepartmentId: val.DepartmentId });
|
|
|
- if (departs.length > 0) {
|
|
|
- departs[0].checked = true;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $scope.depSelected = function () {
|
|
|
- $depart.selectDeparts.length = 0;
|
|
|
- var dlist = $filter('filter')($scope.departmentList, { checked: true });
|
|
|
-
|
|
|
- $app.forEach(dlist, function (val) {
|
|
|
- $depart.selectDeparts.push(val);
|
|
|
- });
|
|
|
-
|
|
|
- $scope.$hide();
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
- ctrl.$inject = ['$scope'];
|
|
|
-
|
|
|
- var modal = $modal({
|
|
|
- resolve: {
|
|
|
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
|
|
|
- $ocLazyLoad.load(['home/employee_find.css?' + window.sysVersion]);
|
|
|
- }]
|
|
|
- },
|
|
|
- controller: ctrl,
|
|
|
- templateUrl: 'home/m_department.html',
|
|
|
- show: false,
|
|
|
- animation: 'am-fade-and-slide-top'
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return $depart;
|
|
|
- }
|
|
|
- }).provider('$employee', function () {
|
|
|
-
|
|
|
- this.$get = function ($modal, $http, $filter, $q, $alert, $employeeFind) {
|
|
|
- var $empResult = {
|
|
|
- isMulti: true,
|
|
|
- $deferred: null,
|
|
|
- empId:'',
|
|
|
- selectedEmployee:function() {
|
|
|
-
|
|
|
- var deferred = $q.defer();
|
|
|
- this.$deferred = deferred;
|
|
|
- this.empId = '';
|
|
|
- modal.$promise.then(modal.show);
|
|
|
-
|
|
|
- return deferred.promise;
|
|
|
- },
|
|
|
- getEmployee: function (id) {
|
|
|
- if ($employeeFind.departmentList.length == 0) {
|
|
|
- $employeeFind.dataInit();
|
|
|
- }
|
|
|
- var deferred = $q.defer();
|
|
|
- var params = {
|
|
|
- employeeTypeIds: '',
|
|
|
- employeeTitleIds:'',
|
|
|
- departmentIds: '',
|
|
|
- empId: id
|
|
|
- };
|
|
|
- $employeeFind.loadEmployee(params).then(function (result) {
|
|
|
-
|
|
|
- if (result.data.IsSuccess && result.data.Data.length > 0) {
|
|
|
- var empEnt = result.data.Data[0];
|
|
|
- $employeeFind.setDataEmployeeDepartment(empEnt);
|
|
|
- $employeeFind.setDataEmployeeTitle(empEnt);
|
|
|
- $employeeFind.setDataEmployeeType(empEnt);
|
|
|
- deferred.resolve(empEnt);
|
|
|
- } else {
|
|
|
- deferred.reject(null);
|
|
|
- }
|
|
|
- });
|
|
|
- return deferred.promise;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- var ctrl = function ($scope) {
|
|
|
-
|
|
|
- $scope.title = '人员选择';
|
|
|
- $scope.$own = $empResult;
|
|
|
- $scope.$deferred = $empResult.$deferred;
|
|
|
- $scope.employeeIds = [];
|
|
|
-
|
|
|
- $scope.selectEmployee = function () {
|
|
|
-
|
|
|
- var employees = $filter('filter')($scope.employeeIds, { checked: true });
|
|
|
-
|
|
|
- if ((!$empResult.isMulti) && employees.length > 1) {
|
|
|
- $alert({
|
|
|
- title: '消息:',
|
|
|
- content: '只能选择一个员工!',
|
|
|
- placement: 'top',
|
|
|
- type: 'info',
|
|
|
- show: true,
|
|
|
- duration: 3,
|
|
|
- container:'#m_employee'
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $app.forEach(employees, function (val) {
|
|
|
- $employeeFind.setDataEmployeeDepartment(val);
|
|
|
- $employeeFind.setDataEmployeeTitle(val);
|
|
|
- $employeeFind.setDataEmployeeType(val);
|
|
|
- });
|
|
|
-
|
|
|
- $empResult.$deferred.resolve(employees);
|
|
|
- $scope.$hide();
|
|
|
- };
|
|
|
-
|
|
|
- if ($empResult.empId != '') {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
- ctrl.$inject = ['$scope'];
|
|
|
-
|
|
|
- var modal = $modal({
|
|
|
- resolve: {
|
|
|
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
|
|
|
-
|
|
|
- }]
|
|
|
- },
|
|
|
- controller: ctrl,
|
|
|
- templateUrl: 'home/m_employee.html',
|
|
|
- show: false,
|
|
|
- animation: 'am-fade-and-slide-top'
|
|
|
- });
|
|
|
-
|
|
|
- return $empResult;
|
|
|
- };
|
|
|
- });
|
|
|
-})(angular);
|