123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- app.controller('incidentRequestMobileCtrl', ["$rootScope", "$scope", "i18nService", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_solution", "api_bpm_domain", "api_bpm_data", "$aside", function($rootScope, $scope, i18nService, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_solution, api_bpm_domain, api_bpm_data, $aside) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- var pdKey = $state.current.pdKey;
- // $rootScope.app.topTitle = '事件列表';
- var incidentListMobileParameter = {
- 'assignee': loginUser.account,
- 'idx': 0,
- 'sum': 10,
- 'status': '',
- 'count': 0,
- 'currentPage': 1,
- 'endPage': 0,
- 'pages': []
- }
- //本地数据初始化
- sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
- if ($rootScope.user.group) {
- if ($rootScope.user.group.length == 0) {
- SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
- } else {
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- angular.extend(filterData, { "candidateGroups": $rootScope.user.group[0].id, });
- sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- }
- }
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD ');
- }
- $scope.transferStatus = function(status) {};
- $scope.paginationList = {};
- //新增数据
- $scope.addData = function() {
- var data = JSON.parse(sessionStorage.incidentListMobileParameter);
- if (data.formUiEdit) {
- var formUiEdit = data.formUiEdit;
- };
- if (data.formUiName) {
- var formUiName = data.formUiName;
- };
- if (data.processKey) {
- var pdKey = data.processKey;
- };
- if (data.formUiStart) {
- var formUiStart = data.formUiStart;
- };
- if (pdKey) {
- $state.go('app.inspectionMobile.inspectionEditorMobile', {
- 'pdKey': pdKey,
- 'formUiEdit': formUiEdit,
- 'formUiName': formUiName,
- 'formUiStart': formUiStart,
- 'userId': data.status
- });
- } else {
- SweetAlert.swal({
- title: "当前服务类型不可新建",
- // text: myData.data,
- type: "warning"
- });
- }
- };
- // $scope.newincident = function(data) {
- // $state.go('app.incident.editor', {});
- // };
- // $scope.selectRowFunction = function(data) {
- // $state.go('app.incident.editor', { taskId: data.taskId, processInstanceId: data.processInstanceId });
- // };
- // $scope.followFunction = function(data) {
- // //console.log('data='+JSON.stringify(data));
- // $state.go('app.detail', { formKey: 'statusform', pdKey: 'incident', dataId: data.id, processInstanceId: data.processInstanceId });
- // };
- $scope.addNewFunction = function() {
- $state.go('app.incidentMobile.incidentRequestEditorMobile', {
- 'formKey': 'requestMobileEditor'
- // 'weChatFlag': 'requestMobile'
- });
- };
- //跳转到编辑列表
- $scope.editorFunction = function(data) {
- // $state.go('app.inspection.inspectListEditor', {
- // "taskId": data.taskId,
- // "processInstanceId": data.processInstanceId,
- // "pdKey": data.processKey,
- // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
- // // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
- // });
- $state.go('app.inspectionMobile.inspectionEditorMobile', {
- taskId: data.taskId,
- processInstanceId: data.processInstanceId
- });
- };
- //跳转到查看列表
- $scope.lookFunction = function(data) {
- $state.go('app.inspectionMobile.inspectionDetailMobile', {
- // "formKey": data.inspection.inspectionTypeDTO.formUiName,
- // "dataId": data.id,
- // "taskId": data.taskId,
- // "processInstanceId": data.processInstanceId,
- // "pdKey": data.processKey,
- // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
- // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
- "formKey": 'incident_back',
- "pdKey": 'incident',
- "dataId": data.id,
- "taskId": data.taskId,
- "processInstanceId": data.processInstanceId
- });
- };
- //页面刷新
- $scope.reload = function() {
- $scope.refreshListData('expand-right');
- }
- //前往第一页按钮
- $scope.paginationFristPage = function() {
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- filterData.currentPage = 1;
- sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- $scope.refreshListData('expand-right');
- }
- //前往最后一页按钮
- $scope.paginationLastPage = function() {
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- filterData.currentPage = filterData.endPage;
- sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- $scope.refreshListData('expand-right');
- }
- //加载某一页
- $scope.paginationLoadPage = function(page) {
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- filterData.currentPage = page;
- sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- $scope.refreshListData('expand-right');
- }
- //初始化分页栏
- var reloadPno = function() {
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- filterData.pages = calculateIndexes(filterData.currentPage, filterData.endPage, 4);
- $scope.paginationList = filterData;
- };
- //分页算法
- var calculateIndexes = function(current, length, displayLength) {
- var indexes = [];
- var start = Math.round(current - displayLength / 2);
- var end = Math.round(current + displayLength / 2);
- if (start <= 1) {
- start = 1;
- end = start + displayLength - 1;
- if (end >= length - 1) {
- end = length - 1;
- }
- }
- if (end >= length - 1) {
- end = length;
- start = end - displayLength + 1;
- if (start <= 1) {
- start = 1;
- }
- }
- for (var i = start; i <= end; i++) {
- indexes.push(i);
- }
- return indexes;
- };
- //数据加载
- $scope.ldloading = {};
- $scope.refreshListData = function(style) {
- //刷新按钮动画
- $scope.ldloading[style.replace('-', '_')] = true;
- //获取本地数据
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- //对接口参数进行重新组装
- var showData = {
- 'assignee': filterData.assignee,
- 'idx': filterData.currentPage ? filterData.currentPage - 1 : 0,
- 'searchType': filterData.searchType,
- 'status': filterData.status,
- 'sum': filterData.sum,
- };
- if (filterData.candidateGroups) {
- angular.extend(showData, { 'candidateGroups': filterData.candidateGroups });
- };
- $scope.myData = [];
- api_bpm_domain.weChatFetchServiceTasks(pdKey, showData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- filterData.count = myData.resultCount;
- if (angular.isArray(myData.data) && myData.data.length > 0) {
- $scope.myData = myData.data;
- $scope.listShow = true;
- filterData.endPage = Math.ceil(filterData.count / filterData.sum);
- // filterData.currentPage = filterData.pageIndex + 1;
- sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- reloadPno();
- angular.forEach($scope.myData, function(ObjIndex) {
- if (angular.isUndefined(ObjIndex.extendStatus)) {
- angular.extend(ObjIndex, { 'extendStatus': false })
- }
- });
- } else {
- // SweetAlert.swal({
- // title: "数据为空",
- // text: myData.data,
- // type: "warning"
- // });
- // if ($scope.paginationList || $scope.paginationList.count) {
- // $scope.paginationList.count = 0;
- // }
- $scope.listShow = false;
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- }
- $scope.openAside = function(position) {
- var asideOpen = $aside.open({
- templateUrl: 'assets/views/incident/incidentListMoblieDetail.html',
- placement: position,
- size: 'sm',
- backdrop: true,
- controller: function($scope, $modalInstance, api_user_data, api_solution, inspectListMobileCtrlTree) {
- var searchCriteria = {
- // 'searchType': '',
- // 'status': '',
- };
- // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- // searchCriteria.searchType = "";
- // searchCriteria.status = "";
- $scope.ok = function(e) {
- $modalInstance.close(searchCriteria);
- // e.stopPropagation();
- };
- $scope.cancel = function(e) {
- $modalInstance.dismiss();
- // e.stopPropagation();
- };
- $scope.statuses = [
- { status: 'all', label: '全部的事件', idName: 'a' },
- { status: 'todo', label: '待我处理的', idName: 'b' },
- { status: 'create', label: '我创建的', idName: 'c' },
- { status: 'done', label: '我处理过的', idName: 'd' },
- // { status: 's', label: '已驳回', idName: 'e' },
- // { status: '6', label: '已拒绝', idName: 'f' }
- ];
- //获取服务请求类型
- $scope.onChange = function(searchType) {
- // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- if (angular.isUndefined(searchType)) {
- searchCriteria.searchType = $scope.searchType;
- } else {
- searchCriteria.searchType = searchType;
- }
- // sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- }
- //通过树型控件获取服务请求分类
- $scope.my_tree_handler = function(branch) {
- // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- var filterData = {};
- searchCriteria.status = branch.id;
- if (branch.formUiEdit) {
- filterData.formUiEdit = branch.formUiEdit;
- };
- if (branch.formUiName) {
- filterData.formUiName = branch.formUiName;
- };
- if (branch.processKey) {
- filterData.processKey = branch.processKey;
- };
- if (branch.formUiStart) {
- filterData.formUiStart = branch.formUiStart;
- };
- searchCriteria.idx = 0;
- angular.extend(searchCriteria, filterData);
- // sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- };
- $scope.my_data = [];
- $scope.tree_data = [];
- $scope.my_tree = tree = {};
- $scope.try_async_load = function() {
- api_bpm_data.fetchDataList('inspectionType', { "idx": 0, "sum": 1000 }).then(function(response) {
- var responseData = inspectListMobileCtrlTree(response);
- $scope.my_data = responseData.my_data;
- $scope.tree_data = responseData.tree_data;
- });
- }
- $scope.try_async_load();
- }
- });
- asideOpen.result.then(function(searchCriteria) {
- if (searchCriteria.searchType || searchCriteria.status) {
- var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
- angular.extend(filterData, searchCriteria);
- sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
- $scope.refreshListData('expand-right');
- } else {
- SweetAlert.swal({
- title: "条件未选",
- text: "请选择服务请求条件",
- type: "warning"
- });
- }
- });
- };
- $scope.refreshListData('expand_right');
- // $scope.try_async_load();
- }]);
- app.factory('inspectListMobileCtrlTree', ['api_bpm_data', function(api_bpm_data) {
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {};
- var root = null;
- var parentNode = null;
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- datum.children = [];
- idToNodeMap[datum.id] = datum;
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- root = datum;
- treeMap[datum.id] = root;
- } else {
- parentNode = idToNodeMap[datum.parent];
- delete datum.parent;
- parentNode.children.push(datum);
- }
- }
- return root;
- };
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function(item) {
- list.push(item);
- });
- return list;
- };
- var forEachEelement = function forEachEelement(response) {
- var objects = [];
- angular.forEach(response.list, function(ObjIndex, index, destObj) {
- var object = {};
- object.id = ObjIndex.id;
- object.label = ObjIndex.type;
- if (ObjIndex.parent && ObjIndex.parent.id != 0) {
- object.parent = ObjIndex.parent.id;
- };
- if (ObjIndex.formUiEdit) {
- object.formUiEdit = ObjIndex.formUiEdit;
- };
- if (ObjIndex.formUiName) {
- object.formUiName = ObjIndex.formUiName;
- };
- if (ObjIndex.processKey) {
- object.processKey = ObjIndex.processKey;
- };
- if (ObjIndex.formUiStart) {
- object.formUiStart = ObjIndex.formUiStart;
- };
- objects.push(object);
- });
- var my_data = convertParentToChildList(objects);
- var tree_data = angular.copy(my_data);
- return {
- 'my_data': my_data,
- 'tree_data': tree_data
- }
- }
- return forEachEelement;
- }]);
|