123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- "use strict";
- /**
- * controller for User Profile Example
- */
- app.controller("inspectListCtrl", [
- "$rootScope",
- "$scope",
- "$state",
- "$timeout",
- "$interval",
- "$modal",
- "SweetAlert",
- "i18nService",
- "uiGridConstants",
- "uiGridGroupingConstants",
- "Restangular",
- "api_bpm_schedule",
- "api_bpm_data",
- "api_configure_data",
- "api_bpm",
- "api_user_data",
- function (
- $rootScope,
- $scope,
- $state,
- $timeout,
- $interval,
- $modal,
- SweetAlert,
- i18nService,
- uiGridConstants,
- uiGridGroupingConstants,
- Restangular,
- api_bpm_schedule,
- api_bpm_data,
- api_configure_data,
- api_bpm,
- api_user_data
- ) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = "zh-cn";
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- $scope.chuli = false;
- $scope.assign = false;
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "xunjianliebiao_chuli") {
- $scope.chuli = true;
- }
- if (loginUser.menu[i].link == "xunjianliebiao_assign") {
- $scope.assign = true;
- }
- }
- var defaultFilterData = {
- assignee: loginUser.id,
- // "assignee": "1",
- idx: 0,
- sum: 10,
- status: "",
- searchType: "todo",
- };
- var inspectListParameter = {
- assignee: loginUser.id,
- // "assignee": "1",
- idx: 0,
- sum: 10,
- status: "",
- };
- // $scope.memoryfilterData = {
- // "idx": 0,
- // "sum": 10
- // }
- //本地存储
- sessionStorage.inspectListParameter = JSON.stringify(inspectListParameter);
- //ui-grid设置
- $scope.gridOptions = {};
- $scope.gridOptions.data = "myData";
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- // $scope.gridOptions.rowTemplate = '<div style="background: red"><a>123</a></div';
- // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- //执行中的巡检才能批量派单
- $scope.gridOptions.isRowSelectable = function (row,i) {
- // console.log(row,row.uid,document);
- if (row.entity.state == 0) {
- return true;
- } else {
- return false;
- }
- };
- $scope.transferColor = function (item) {
- var color = "icon iconfont icon-zhengchang greenfont";
- if (item && item.colourInfo) {
- if (item.colourInfo.id == 1) {
- color = "icon iconfont icon-yiyuqi redfont";
- } else if (item.colourInfo.id == 2) {
- color = "iconfont icon-yuqixinxiu yellofont";
- }
- } else {
- // color = "white";
- }
- return color;
- };
- $scope.transfertip = function (item) {
- var tip = "正常";
- if (item && item.colourInfo) {
- if (item.colourInfo.id == 1) {
- tip = "逾期";
- } else if (item.colourInfo.id == 2) {
- tip = "即将逾期";
- }
- } else {
- // color = "white";
- }
- return tip;
- };
- $scope.gridOptions.columnDefs = [
- {
- name: "id",
- displayName: "",
- width: 40,
- enableFiltering: false,
- cellTemplate:
- "<div>" +
- '<div class="ui-grid-cell-contents" tooltip={{grid.appScope.transfertip(row.entity.ruleColour)}} tooltip-placement="right"><i style="font-size: 18px !important;" class="{{grid.appScope.transferColor(row.entity.ruleColour)}}"></i></div></div>',
- },
- {
- name: "inspection.title",
- displayName: "计划主题",
- width: "12%",
- minWidth: 120,
- enableFiltering: false,
- },
- {
- name: "sign",
- displayName: "单号",
- width: "12%",
- minWidth: 120,
- enableFiltering: false,
- },
- {
- name: "online",
- displayName: "巡检分类",
- width: "23%",
- minWidth: 200,
- enableFiltering: false,
- cellTemplate:
- "<div>" +
- '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
- "</div>",
- },
- // {
- // name: "inspection.createUser.name",
- // displayName: "创建人",
- // width: "8%",
- // minWidth: 80,
- // enableFiltering: false,
- // },
- {
- name: "stateName",
- displayName: "状态",
- width: "8%",
- minWidth: 80,
- enableFiltering: false,
- },
- {
- name: "processUser.name",
- displayName: "处理人/组",
- width: "8%",
- minWidth: 80,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
- '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
- '</div>'
- },
- {
- name: "startDate",
- displayName: "开始时间",
- width: "15%",
- minWidth: 160,
- enableFiltering: false,
- cellTemplate:
- "<div>" +
- '<div class="ui-grid-cell-contents">{{row.entity.startDate?grid.appScope.transferTime(row.entity.startDate):""}}</div>' +
- "</div>",
- },
- {
- name: "endTime",
- displayName: "结束时间",
- width: "15%",
- width: 160,
- enableFiltering: false,
- cellTemplate:
- "<div>" +
- '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
- "</div>",
- },
- {
- name: "操作",
- minWidth: "150",
- enableFiltering: false,
- cellTemplate:
- '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
- '<a ng-click="grid.appScope.lookFunction(row.entity)" tooltip="查看" tooltip-placement="right" class="bianjifont">查看</a>' +
- '<a ng-show="{{grid.appScope.showChuli(row.entity)&&grid.appScope.chuli}}" ng-click="grid.appScope.selectRowFunction(row.entity)" class="bianjifont">处理</a>' +
- // '<a ng-show="{{!row.entity.state==1}}" ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"/></a>' +
- "</div>",
- },
- ];
- // $scope.addData = function() {
- // $state.go('app.inspection.inspectList.editor', {
- // formKey: 'inspectionform',
- // service: 'api_bpm_data'
- // });
- // }
- $scope.transferTime = function (time) {
- return moment(time).format("YYYY-MM-DD HH:mm");
- };
- $scope.showChuli = function (data) {
- if(data.inspection.dictionary.value == 1){
- // 按巡检人员
- if (data.processUser.id == loginUser.id && data.stateName == "执行中") {
- return true;
- } else {
- return false;
- }
- }else if(data.inspection.dictionary.value == 3){
- // 按工作组
- var hasGroup = loginUser.group.some(v=>v.id == data.group.id);
- if (hasGroup && data.stateName == "执行中") {
- return true;
- } else {
- return false;
- }
- }else if(data.inspection.dictionary.value == 4){
- // 系统默认
- if(data.online){
- // 线上人
- if (data.processUser.id == loginUser.id && data.stateName == "执行中") {
- return true;
- } else {
- return false;
- }
- }else{
- // 线下组
- var hasGroup = loginUser.group.some(v=>v.id == data.group.id);
- if (hasGroup && data.stateName == "执行中") {
- return true;
- } else {
- return false;
- }
- }
- }
- };
- $scope.selectRowFunction = function (data) {
- var filedata = {
- model: {
- inspectionProcessActual: data,
- },
- };
- $state.go("app.inspection.inspectListEditor", {
- taskId: data.taskId,
- dataId: data.id,
- processInstanceId: data.processInstanceId,
- pdKey: data.processKey,
- formUiEdit: data.inspectionType.formUiEdit,
- // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
- model: JSON.stringify(filedata),
- });
- };
- $scope.lookFunction = function (data) {
- var filedata = {
- model: {
- inspectionProcessActual: data,
- },
- // model:data
- };
- $state.go("app.inspection.inspectListdetail", {
- formKey: data.inspectionType.formUiName,
- dataId: data.id,
- taskId: data.taskId,
- processInstanceId: data.processInstanceId,
- pdKey: data.processKey,
- // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
- formUiName: data.inspectionType.formUiName,
- model: JSON.stringify(filedata),
- });
- };
- $scope.model = {
- assignee: JSON.parse(sessionStorage.inspectListParameter).assignee,
- idx: 0,
- sum: 10,
- searchType: "todo",
- inspectionProcessActual: {
- inspection: {},
- },
- };
- // $scope.removeData = function() {
- // // var rmvList = [$scope.selected.items.id]
- // var rmvList = [];
- // angular.forEach($scope.selected.items, function(item) {
- // rmvList.push(item.id);
- // });
- // if (rmvList.length > 0) {
- // api_bpm_data.rmvData('inspection', rmvList).then(function(response) {
- // if (response.status == 200) {
- // SweetAlert.swal({
- // title: "删除成功!",
- // type: "success",
- // confirmButtonColor: "#007AFF"
- // }, function() {
- // $scope.myData = _.reject($scope.myData, function(o) { return _.includes(rmvList, o.id); });
- // $scope.selected = {
- // items: []
- // };
- // });
- // } else {
- // SweetAlert.swal({
- // title: "操作异常!",
- // text: "系统异常,请稍后重试,或者联系管理员!",
- // type: "error"
- // });
- // }
- // })
- // }
- // }
- //批量派单
- $scope.toAssign = function() {
- var _$scope = $scope;
- console.log($scope.selected.items);
- var sendList = [];
- angular.forEach($scope.selected.items, function(item) {
- sendList.push(item.id);
- });
- // --------------------------------------------------------
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/toAssign.tpl.html',
- controller: function ($scope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data) {
- console.log(_$scope.selected.items,loginUser);
- //获取组下面的用户
- $scope.getUsers = function(groupId){
- $scope.user = [];
- var postData = {};
- if(groupId){
- postData = {
- "idx": 0,
- "sum": 100,
- user: {
- groupdata:{id:groupId},
- roledata: { rolecode: "inspectman" },
- selectType: "1",
- selectDetails:1,
- engineer: 1,
- }
- }
- }else{
- postData = {
- "idx": 0,
- "sum": 100,
- user: {
- roledata: { rolecode: "inspectman" },
- selectType: "1",
- selectDetails:1,
- engineer: 1,
- }
- }
- }
- api_user_data.fetchDataList('user', postData).then(function (data) {
- $scope.user = data.list;
- })
- }
- $scope.assignUser = null;
- $scope.user = [];
- $scope.group = [];
- $scope.getUsers();
- api_user_data.fetchDataList('group', {
- "idx": 0,
- "sum": 100,
- group: {'selectType':'nouser'}
- }).then(function (data) {
- $scope.group = data.list;
- })
- $scope.onChangeRotateUser = function(item){
- $scope.assignUser = item.id;
- }
- $scope.onChangeRotateGroup = function(item){
- $scope.assignGroup = item.id;
- $scope.getUsers(item.id)
- }
- $scope.ok = function () {
- if (!$scope.assignUser){
- Alert.swal({
- title: "操作失败",
- text: "请选择转派对象信息!",
- type: "error"
- });
- return;
- }
- api_bpm.assign({ids:sendList.join(),userId:$scope.assignUser}).then(function (response) {
- console.log(response)
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- _$scope.gridApi.selection.clearSelectedRows();
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return _$scope.selected.items;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- defaultFilterData.assignee = loginUser.id;
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- return;
- // --------------------------------------------------------
- }
- $scope.selected = {
- items: [],
- };
- $scope.editted = {
- items: [],
- };
- $scope.jry_idx = 0;
- $scope.jry_sum = 10;
- //分页控制
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged(
- $scope,
- function (newPage, pageSize) {
- console.log("ok");
- var filterData = JSON.parse(sessionStorage.inspectListParameter);
- filterData.idx = newPage - 1;
- filterData.sum = pageSize;
- $scope.jry_idx = newPage - 1;
- $scope.jry_sum = pageSize;
- $scope.model.idx = newPage - 1;
- $scope.model.sum = pageSize;
- $scope.refreshData("expand-right", $scope.model);
- }
- );
- // 单选
- gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
- console.log(scope)
- if (scope.isSelected) {
- scope.grid.appScope.selected.items.push(scope.entity)
- } else {
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
- scope.grid.appScope.selected.items.splice(i, 1);
- break;
- }
- }
- }
- console.log(scope.grid.appScope.selected.items)
- });
- // 全选/全不选
- gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
- console.log(rows)
- var selectitem = [];
- selectitem = angular.copy($scope.selected.items);
- for (var j = 0; j < rows.length; j++) {
- if (rows[j].isSelected == true) {
- selectitem.push(rows[j].entity);
- } else {
- delete selectitem[j];
- }
- }
- $scope.selected.items = [];
- for (var i = 0; i < selectitem.length; i++) {
- if (selectitem[i]) {
- $scope.selected.items.push(selectitem[i]);
- }
- }
- console.log($scope.selected.items)
- });
- };
- // var data = JSON.parse(sessionStorage.inspectListParameter);
- // sessionStorage.inspectListParameter = JSON.stringify(data);
- $scope.ldloading = {};
- $scope.statusData = {};
- $scope.tData = { title: "", batchNo: "" };
- //搜索事件
- $scope.searchinspectlist = function (item) {
- var filterData = JSON.parse(sessionStorage.inspectListParameter);
- // console.log(filterData);
- // if (item.type) {
- // filterData.inspection = { 'inspectionTypeDTO': { 'id':item.type.id}};
- // }
- // if (item.title) {
- // filterData.inspection = { 'title': item.title};
- // }
- $scope.model.idx = $scope.jry_idx;
- $scope.model.sum = $scope.jry_sum;
- if ($scope.model.inspectionProcessActual.inspectionType) {
- $scope.model.inspectionProcessActual.inspectionTypeId =
- $scope.model.inspectionProcessActual.inspectionType.id;
- delete $scope.model.inspectionProcessActual.inspectionType;
- }
- if ($scope.statusData.state) {
- $scope.model.inspectionProcessActual.state =
- $scope.statusData.state.state;
- }
- if ($scope.tData.title) {
- if ($scope.model.inspectionProcessActual.inspection) {
- $scope.model.inspectionProcessActual.inspection.title =
- $scope.tData.title.title;
- } else {
- $scope.model.inspectionProcessActual.inspection = {
- title: $scope.tData.title.title,
- };
- }
- }
- if ($scope.tData.batchNo) {
- $scope.model.inspectionProcessActual.batchNo = $scope.tData.batchNo.batchNo;
- }
- // filterData.status = item;
- sessionStorage.inspectListParameter = JSON.stringify(filterData);
- $scope.refreshData("expand-right", $scope.model);
- };
- $scope.clean = function () {
- $scope.tData = { title: "", batchNo: "" };
- delete $scope.model.inspectionProcessActual.batchNo;
- delete $scope.model.inspectionProcessActual.inspection.title;
- delete $scope.model.inspectionProcessActual.inspectionType;
- delete $scope.model.inspectionProcessActual.inspectionTypeId;
- delete $scope.model.inspectionProcessActual.inspection.executeUser;
- delete $scope.model.inspectionProcessActual.inspection.createUser;
- delete $scope.model.inspectionProcessActual.state;
- $scope.statusData = {};
- $scope.try_async_load();
- $scope.refreshData("expand-right", $scope.model);
- };
- //树形控件点击事件
- $scope.my_tree_handler = function (branch) {
- var filterData = JSON.parse(sessionStorage.inspectListParameter);
- filterData.status = branch.id;
- // if (filterData.inspectionProcessActual) {
- // filterData.inspectionProcessActual.inspectionTypeId = branch.id;
- // } else {
- // filterData = angular.extend(filterData, {
- // "inspectionProcessActual": {
- // "inspectionTypeId": branch.id
- // }
- // })
- // }
- sessionStorage.inspectListParameter = JSON.stringify(filterData);
- $scope.refreshData("expand-right", filterData);
- };
- //搜索栏点击事件
- $scope.searchstate = "todo";
- $scope.onChange = function (searchType) {
- console.log($scope.gridApi)
- $scope.gridApi.selection.clearSelectedRows();
- $scope.searchstate = searchType;
- var filterData = JSON.parse(sessionStorage.inspectListParameter);
- filterData.searchType = searchType;
- $scope.model.searchType = searchType;
- sessionStorage.inspectListParameter = JSON.stringify(filterData);
- $scope.refreshData("expand-right", $scope.model);
- };
- $scope.reload = function () {
- var filterData = JSON.parse(sessionStorage.inspectListParameter);
- $scope.refreshData("expand-right", filterData);
- };
- $scope.refreshData = function (style, filterData) {
- $scope.ldloading[style.replace("-", "_")] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- if(filterData.searchType === 'todo'){
- // 待处理添加筛选条件
- console.log(filterData,'2022年5月30日')
- filterData.candidateGroups = $rootScope.user.group.map(function(v){return v.id}).toString()
- }else{
- delete filterData.candidateGroups;
- }
- $scope.myData = [];
- $scope.memoryfilterData = filterData;
- api_bpm_data.fetchInspectServiceTasks(filterData.status, filterData).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.resultCount;
- if (angular.isArray(myData.data)) {
- $scope.myData = myData.data;
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]["itemId"] =
- i + 1 + filterData.idx * filterData.sum;
- }
- $scope.ldloading[style.replace("-", "_")] = false;
- } else {
- $scope.ldloading[style.replace("-", "_")] = false;
- SweetAlert.swal({
- title: "数据为空",
- text: myData.data,
- type: "warning",
- });
- }
- },
- function () {
- $scope.ldloading[style.replace("-", "_")] = false;
- }
- );
- };
- $scope.refreshData2 = function (style, filterData) {
- $scope.ldloading[style.replace("-", "_")] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- if(filterData.searchType === 'todo'){
- // 待处理添加筛选条件
- console.log(filterData,'2022年5月30日')
- filterData.candidateGroups = $rootScope.user.group.map(function(v){return v.id}).toString()
- }else{
- delete filterData.candidateGroups;
- }
- // $scope.myData = [];
- $scope.memoryfilterData = filterData;
- api_bpm_data.fetchInspectServiceTasks(filterData.status, filterData).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.resultCount;
- if (angular.isArray(myData.data)) {
- $scope.myData = myData.data;
- for (var i = 0; i < $scope.myData.length; i++) {
- //添加序号
- $scope.myData[i]["itemId"] =
- i + 1 + filterData.idx * filterData.sum;
- }
- $scope.ldloading[style.replace("-", "_")] = false;
- } else {
- $scope.ldloading[style.replace("-", "_")] = false;
- SweetAlert.swal({
- title: "数据为空",
- text: myData.data,
- type: "warning",
- });
- }
- },
- function () {
- $scope.ldloading[style.replace("-", "_")] = false;
- }
- );
- };
- $scope.inspecttype = {};
- // 获取处理人
- $scope.getExecuteUser = function () {
- api_configure_data
- .fetchDataList("user", {
- idx: 0,
- sum: 1000,
- user: {
- roledata: {
- rolecode: "inspectman",
- },
- simple: true,
- engineer: 1,
- },
- })
- .then(function (res) {
- $scope.executeUserData = res.list;
- });
- };
- $scope.getExecuteUser();
- $scope.statusData = [
- {
- name: "执行中",
- state: 0,
- },
- {
- name: "已完成",
- state: 1,
- },
- ];
- $scope.titleData = []; //计划主题列表
- $scope.batchNoData = []; //批次号列表
- // 获取计划主题列表
- $scope.getTitleData = function () {
- var postData = {
- assignee: $rootScope.user.id,
- idx: 0,
- sum: 9999,
- searchType: "all",
- inspectionProcessActual: {},
- };
- api_bpm_data
- .fetchDataList("inspection", postData)
- .then(function (result) {
- if (result.status == 200) {
- $scope.titleData = result.list;
- }
- });
- };
- $scope.getTitleData();
- //修改计划主题
- $scope.changeTitle = function(){
- $scope.tData.batchNo = "";
- $scope.batchNoData = $scope.tData.title.batchNos.map(v=>({id:v,batchNo:v}));
- }
- // 获取创建人
- $scope.getCreateUser = function () {
- api_configure_data
- .fetchDataList("user", {
- idx: 0,
- sum: 1000,
- user: {
- simple: true,
- engineer: 1,
- },
- })
- .then(function (res) {
- $scope.createUserData = res.list;
- });
- };
- $scope.getCreateUser();
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- //树形控件加载
- $scope.my_tree = {};
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.doing_async = true;
- api_bpm_data
- .fetchDataList("inspectionType", {
- idx: 0,
- sum: 1000,
- })
- .then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (data[i].parent && data[i].parent.id != 0) {
- object.parent = data[i].parent.id;
- }
- object.label = data[i].type;
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- // return $scope.my_tree.expand_all()
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error",
- });
- }
- });
- };
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- 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;
- }
- $scope.refreshData("expand-right", defaultFilterData);
- $scope.try_async_load();
- $scope.timer = $interval(function () {
- $scope.refreshData2("expand-right", $scope.model);
- }, $rootScope.refreshTime);
- $scope.$on("$destroy", function () {
- $interval.cancel($scope.timer);
- });
- },
- ]);
|