123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- (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 a = $scope.employeeIds;
- 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) {
- //$ocLazyLoad.load(['home/employee_find.css?' + window.sysVersion]);
- }]
- },
- controller: ctrl,
- templateUrl: 'home/m_employee.html',
- show: false,
- animation: 'am-fade-and-slide-top'
- });
- return $empResult;
- };
- });
- })(angular);
|