inspectListCtrl.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. "use strict";
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller("inspectListCtrl", [
  6. "$rootScope",
  7. "$scope",
  8. "$state",
  9. "$timeout",
  10. "$interval",
  11. "$modal",
  12. "SweetAlert",
  13. "i18nService",
  14. "uiGridConstants",
  15. "uiGridGroupingConstants",
  16. "Restangular",
  17. "api_bpm_schedule",
  18. "api_bpm_data",
  19. "api_configure_data",
  20. "api_bpm",
  21. "api_user_data",
  22. function (
  23. $rootScope,
  24. $scope,
  25. $state,
  26. $timeout,
  27. $interval,
  28. $modal,
  29. SweetAlert,
  30. i18nService,
  31. uiGridConstants,
  32. uiGridGroupingConstants,
  33. Restangular,
  34. api_bpm_schedule,
  35. api_bpm_data,
  36. api_configure_data,
  37. api_bpm,
  38. api_user_data
  39. ) {
  40. $scope.langs = i18nService.getAllLangs();
  41. $scope.lang = "zh-cn";
  42. i18nService.setCurrentLang($scope.lang);
  43. var loginUser = $rootScope.user;
  44. $scope.chuli = false;
  45. $scope.assign = false;
  46. for (var i = 0; i < loginUser.menu.length; i++) {
  47. if (loginUser.menu[i].link == "xunjianliebiao_chuli") {
  48. $scope.chuli = true;
  49. }
  50. if (loginUser.menu[i].link == "xunjianliebiao_assign") {
  51. $scope.assign = true;
  52. }
  53. }
  54. var defaultFilterData = {
  55. assignee: loginUser.id,
  56. // "assignee": "1",
  57. idx: 0,
  58. sum: 10,
  59. status: "",
  60. searchType: "todo",
  61. };
  62. var inspectListParameter = {
  63. assignee: loginUser.id,
  64. // "assignee": "1",
  65. idx: 0,
  66. sum: 10,
  67. status: "",
  68. };
  69. // $scope.memoryfilterData = {
  70. // "idx": 0,
  71. // "sum": 10
  72. // }
  73. //本地存储
  74. sessionStorage.inspectListParameter = JSON.stringify(inspectListParameter);
  75. //ui-grid设置
  76. $scope.gridOptions = {};
  77. $scope.gridOptions.data = "myData";
  78. $scope.gridOptions.enableColumnResizing = true;
  79. $scope.gridOptions.enableFiltering = true;
  80. $scope.gridOptions.enableGridMenu = true;
  81. $scope.gridOptions.enableRowSelection = true;
  82. $scope.gridOptions.showGridFooter = true;
  83. $scope.gridOptions.showColumnFooter = false;
  84. $scope.gridOptions.fastWatch = true;
  85. $scope.gridOptions.useExternalFiltering = true;
  86. $scope.gridOptions.useExternalPagination = true;
  87. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  88. $scope.gridOptions.paginationPageSize = 10;
  89. $scope.gridOptions.multiSelect = true;
  90. // $scope.gridOptions.rowTemplate = '<div style="background: red"><a>123</a></div';
  91. // $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>";
  92. $scope.gridOptions.rowIdentity = function (row) {
  93. return row.id;
  94. };
  95. $scope.gridOptions.getRowIdentity = function (row) {
  96. return row.id;
  97. };
  98. //执行中的巡检才能批量派单
  99. $scope.gridOptions.isRowSelectable = function (row,i) {
  100. // console.log(row,row.uid,document);
  101. if (row.entity.state == 0) {
  102. return true;
  103. } else {
  104. return false;
  105. }
  106. };
  107. $scope.transferColor = function (item) {
  108. var color = "icon iconfont icon-zhengchang greenfont";
  109. if (item && item.colourInfo) {
  110. if (item.colourInfo.id == 1) {
  111. color = "icon iconfont icon-yiyuqi redfont";
  112. } else if (item.colourInfo.id == 2) {
  113. color = "iconfont icon-yuqixinxiu yellofont";
  114. }
  115. } else {
  116. // color = "white";
  117. }
  118. return color;
  119. };
  120. $scope.transfertip = function (item) {
  121. var tip = "正常";
  122. if (item && item.colourInfo) {
  123. if (item.colourInfo.id == 1) {
  124. tip = "逾期";
  125. } else if (item.colourInfo.id == 2) {
  126. tip = "即将逾期";
  127. }
  128. } else {
  129. // color = "white";
  130. }
  131. return tip;
  132. };
  133. $scope.gridOptions.columnDefs = [
  134. {
  135. name: "id",
  136. displayName: "",
  137. width: 40,
  138. enableFiltering: false,
  139. cellTemplate:
  140. "<div>" +
  141. '<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>',
  142. },
  143. {
  144. name: "inspection.title",
  145. displayName: "计划主题",
  146. width: "12%",
  147. minWidth: 120,
  148. enableFiltering: false,
  149. },
  150. {
  151. name: "sign",
  152. displayName: "单号",
  153. width: "12%",
  154. minWidth: 120,
  155. enableFiltering: false,
  156. },
  157. {
  158. name: "online",
  159. displayName: "巡检分类",
  160. width: "23%",
  161. minWidth: 200,
  162. enableFiltering: false,
  163. cellTemplate:
  164. "<div>" +
  165. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  166. "</div>",
  167. },
  168. // {
  169. // name: "inspection.createUser.name",
  170. // displayName: "创建人",
  171. // width: "8%",
  172. // minWidth: 80,
  173. // enableFiltering: false,
  174. // },
  175. {
  176. name: "stateName",
  177. displayName: "状态",
  178. width: "8%",
  179. minWidth: 80,
  180. enableFiltering: false,
  181. },
  182. {
  183. name: "processUser.name",
  184. displayName: "处理人/组",
  185. width: "8%",
  186. minWidth: 80,
  187. enableFiltering: false,
  188. cellTemplate: '<div>' +
  189. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  190. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  191. '</div>'
  192. },
  193. {
  194. name: "startDate",
  195. displayName: "开始时间",
  196. width: "15%",
  197. minWidth: 160,
  198. enableFiltering: false,
  199. cellTemplate:
  200. "<div>" +
  201. '<div class="ui-grid-cell-contents">{{row.entity.startDate?grid.appScope.transferTime(row.entity.startDate):""}}</div>' +
  202. "</div>",
  203. },
  204. {
  205. name: "endTime",
  206. displayName: "结束时间",
  207. width: "15%",
  208. width: 160,
  209. enableFiltering: false,
  210. cellTemplate:
  211. "<div>" +
  212. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  213. "</div>",
  214. },
  215. {
  216. name: "操作",
  217. minWidth: "150",
  218. enableFiltering: false,
  219. cellTemplate:
  220. '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
  221. '<a ng-click="grid.appScope.lookFunction(row.entity)" tooltip="查看" tooltip-placement="right" class="bianjifont">查看</a>' +
  222. '<a ng-show="{{grid.appScope.showChuli(row.entity)&&grid.appScope.chuli}}" ng-click="grid.appScope.selectRowFunction(row.entity)" class="bianjifont">处理</a>' +
  223. // '<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>' +
  224. "</div>",
  225. },
  226. ];
  227. // $scope.addData = function() {
  228. // $state.go('app.inspection.inspectList.editor', {
  229. // formKey: 'inspectionform',
  230. // service: 'api_bpm_data'
  231. // });
  232. // }
  233. $scope.transferTime = function (time) {
  234. return moment(time).format("YYYY-MM-DD HH:mm");
  235. };
  236. $scope.showChuli = function (data) {
  237. if(data.inspection.dictionary.value == 1){
  238. // 按巡检人员
  239. if (data.processUser.id == loginUser.id && data.stateName == "执行中") {
  240. return true;
  241. } else {
  242. return false;
  243. }
  244. }else if(data.inspection.dictionary.value == 3){
  245. // 按工作组
  246. var hasGroup = loginUser.group.some(v=>v.id == data.group.id);
  247. if (hasGroup && data.stateName == "执行中") {
  248. return true;
  249. } else {
  250. return false;
  251. }
  252. }else if(data.inspection.dictionary.value == 4){
  253. // 系统默认
  254. if(data.online){
  255. // 线上人
  256. if (data.processUser.id == loginUser.id && data.stateName == "执行中") {
  257. return true;
  258. } else {
  259. return false;
  260. }
  261. }else{
  262. // 线下组
  263. var hasGroup = loginUser.group.some(v=>v.id == data.group.id);
  264. if (hasGroup && data.stateName == "执行中") {
  265. return true;
  266. } else {
  267. return false;
  268. }
  269. }
  270. }
  271. };
  272. $scope.selectRowFunction = function (data) {
  273. var filedata = {
  274. model: {
  275. inspectionProcessActual: data,
  276. },
  277. };
  278. $state.go("app.inspection.inspectListEditor", {
  279. taskId: data.taskId,
  280. dataId: data.id,
  281. processInstanceId: data.processInstanceId,
  282. pdKey: data.processKey,
  283. formUiEdit: data.inspectionType.formUiEdit,
  284. // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  285. model: JSON.stringify(filedata),
  286. });
  287. };
  288. $scope.lookFunction = function (data) {
  289. var filedata = {
  290. model: {
  291. inspectionProcessActual: data,
  292. },
  293. // model:data
  294. };
  295. $state.go("app.inspection.inspectListdetail", {
  296. formKey: data.inspectionType.formUiName,
  297. dataId: data.id,
  298. taskId: data.taskId,
  299. processInstanceId: data.processInstanceId,
  300. pdKey: data.processKey,
  301. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  302. formUiName: data.inspectionType.formUiName,
  303. model: JSON.stringify(filedata),
  304. });
  305. };
  306. $scope.model = {
  307. assignee: JSON.parse(sessionStorage.inspectListParameter).assignee,
  308. idx: 0,
  309. sum: 10,
  310. searchType: "todo",
  311. inspectionProcessActual: {
  312. inspection: {},
  313. },
  314. };
  315. // $scope.removeData = function() {
  316. // // var rmvList = [$scope.selected.items.id]
  317. // var rmvList = [];
  318. // angular.forEach($scope.selected.items, function(item) {
  319. // rmvList.push(item.id);
  320. // });
  321. // if (rmvList.length > 0) {
  322. // api_bpm_data.rmvData('inspection', rmvList).then(function(response) {
  323. // if (response.status == 200) {
  324. // SweetAlert.swal({
  325. // title: "删除成功!",
  326. // type: "success",
  327. // confirmButtonColor: "#007AFF"
  328. // }, function() {
  329. // $scope.myData = _.reject($scope.myData, function(o) { return _.includes(rmvList, o.id); });
  330. // $scope.selected = {
  331. // items: []
  332. // };
  333. // });
  334. // } else {
  335. // SweetAlert.swal({
  336. // title: "操作异常!",
  337. // text: "系统异常,请稍后重试,或者联系管理员!",
  338. // type: "error"
  339. // });
  340. // }
  341. // })
  342. // }
  343. // }
  344. //批量派单
  345. $scope.toAssign = function() {
  346. var _$scope = $scope;
  347. console.log($scope.selected.items);
  348. var sendList = [];
  349. angular.forEach($scope.selected.items, function(item) {
  350. sendList.push(item.id);
  351. });
  352. // --------------------------------------------------------
  353. var modalInstance = $modal.open({
  354. templateUrl: 'assets/views/incident/tpl/toAssign.tpl.html',
  355. controller: function ($scope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data) {
  356. console.log(_$scope.selected.items,loginUser);
  357. //获取组下面的用户
  358. $scope.getUsers = function(groupId){
  359. $scope.user = [];
  360. var postData = {};
  361. if(groupId){
  362. postData = {
  363. "idx": 0,
  364. "sum": 100,
  365. user: {
  366. groupdata:{id:groupId},
  367. roledata: { rolecode: "inspectman" },
  368. selectType: "1",
  369. selectDetails:1,
  370. engineer: 1,
  371. }
  372. }
  373. }else{
  374. postData = {
  375. "idx": 0,
  376. "sum": 100,
  377. user: {
  378. roledata: { rolecode: "inspectman" },
  379. selectType: "1",
  380. selectDetails:1,
  381. engineer: 1,
  382. }
  383. }
  384. }
  385. api_user_data.fetchDataList('user', postData).then(function (data) {
  386. $scope.user = data.list;
  387. })
  388. }
  389. $scope.assignUser = null;
  390. $scope.user = [];
  391. $scope.group = [];
  392. $scope.getUsers();
  393. api_user_data.fetchDataList('group', {
  394. "idx": 0,
  395. "sum": 100,
  396. group: {'selectType':'nouser'}
  397. }).then(function (data) {
  398. $scope.group = data.list;
  399. })
  400. $scope.onChangeRotateUser = function(item){
  401. $scope.assignUser = item.id;
  402. }
  403. $scope.onChangeRotateGroup = function(item){
  404. $scope.assignGroup = item.id;
  405. $scope.getUsers(item.id)
  406. }
  407. $scope.ok = function () {
  408. if (!$scope.assignUser){
  409. Alert.swal({
  410. title: "操作失败",
  411. text: "请选择转派对象信息!",
  412. type: "error"
  413. });
  414. return;
  415. }
  416. api_bpm.assign({ids:sendList.join(),userId:$scope.assignUser}).then(function (response) {
  417. console.log(response)
  418. if (response.status == 200) {
  419. Alert.swal({
  420. title: "操作成功!",
  421. confirmButtonColor: "#007AFF",
  422. type: "success"
  423. });
  424. $modalInstance.close('success');
  425. _$scope.gridApi.selection.clearSelectedRows();
  426. } else {
  427. Alert.swal({
  428. title: "操作失败",
  429. text: "操作失败, 请稍后再试!",
  430. type: "error"
  431. });
  432. }
  433. });
  434. }
  435. $scope.cancel = function () {
  436. $modalInstance.dismiss('cancel');
  437. }
  438. },
  439. size: 'sm',
  440. resolve: {
  441. api_bpm: function () {
  442. return api_bpm;
  443. },
  444. modelData: function () {
  445. return _$scope.selected.items;
  446. },
  447. currentUserId: function () {
  448. return loginUser.id;
  449. },
  450. Alert: function () {
  451. return SweetAlert;
  452. },
  453. api_user_data: function () {
  454. return api_user_data;
  455. }
  456. }
  457. });
  458. modalInstance.result.then(function (selectedItem) {
  459. if (selectedItem == 'success') {
  460. defaultFilterData.assignee = loginUser.id;
  461. $scope.refreshData('expand-right', defaultFilterData);
  462. }
  463. });
  464. return;
  465. // --------------------------------------------------------
  466. }
  467. $scope.selected = {
  468. items: [],
  469. };
  470. $scope.editted = {
  471. items: [],
  472. };
  473. $scope.jry_idx = 0;
  474. $scope.jry_sum = 10;
  475. //分页控制
  476. $scope.gridOptions.onRegisterApi = function (gridApi) {
  477. $scope.gridApi = gridApi;
  478. gridApi.pagination.on.paginationChanged(
  479. $scope,
  480. function (newPage, pageSize) {
  481. console.log("ok");
  482. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  483. filterData.idx = newPage - 1;
  484. filterData.sum = pageSize;
  485. $scope.jry_idx = newPage - 1;
  486. $scope.jry_sum = pageSize;
  487. $scope.model.idx = newPage - 1;
  488. $scope.model.sum = pageSize;
  489. $scope.refreshData("expand-right", $scope.model);
  490. }
  491. );
  492. // 单选
  493. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  494. console.log(scope)
  495. if (scope.isSelected) {
  496. scope.grid.appScope.selected.items.push(scope.entity)
  497. } else {
  498. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  499. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  500. scope.grid.appScope.selected.items.splice(i, 1);
  501. break;
  502. }
  503. }
  504. }
  505. console.log(scope.grid.appScope.selected.items)
  506. });
  507. // 全选/全不选
  508. gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
  509. console.log(rows)
  510. var selectitem = [];
  511. selectitem = angular.copy($scope.selected.items);
  512. for (var j = 0; j < rows.length; j++) {
  513. if (rows[j].isSelected == true) {
  514. selectitem.push(rows[j].entity);
  515. } else {
  516. delete selectitem[j];
  517. }
  518. }
  519. $scope.selected.items = [];
  520. for (var i = 0; i < selectitem.length; i++) {
  521. if (selectitem[i]) {
  522. $scope.selected.items.push(selectitem[i]);
  523. }
  524. }
  525. console.log($scope.selected.items)
  526. });
  527. };
  528. // var data = JSON.parse(sessionStorage.inspectListParameter);
  529. // sessionStorage.inspectListParameter = JSON.stringify(data);
  530. $scope.ldloading = {};
  531. $scope.statusData = {};
  532. $scope.tData = { title: "", batchNo: "" };
  533. //搜索事件
  534. $scope.searchinspectlist = function (item) {
  535. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  536. // console.log(filterData);
  537. // if (item.type) {
  538. // filterData.inspection = { 'inspectionTypeDTO': { 'id':item.type.id}};
  539. // }
  540. // if (item.title) {
  541. // filterData.inspection = { 'title': item.title};
  542. // }
  543. $scope.model.idx = $scope.jry_idx;
  544. $scope.model.sum = $scope.jry_sum;
  545. if ($scope.model.inspectionProcessActual.inspectionType) {
  546. $scope.model.inspectionProcessActual.inspectionTypeId =
  547. $scope.model.inspectionProcessActual.inspectionType.id;
  548. delete $scope.model.inspectionProcessActual.inspectionType;
  549. }
  550. if ($scope.statusData.state) {
  551. $scope.model.inspectionProcessActual.state =
  552. $scope.statusData.state.state;
  553. }
  554. if ($scope.tData.title) {
  555. if ($scope.model.inspectionProcessActual.inspection) {
  556. $scope.model.inspectionProcessActual.inspection.title =
  557. $scope.tData.title.title;
  558. } else {
  559. $scope.model.inspectionProcessActual.inspection = {
  560. title: $scope.tData.title.title,
  561. };
  562. }
  563. }
  564. if ($scope.tData.batchNo) {
  565. $scope.model.inspectionProcessActual.batchNo = $scope.tData.batchNo.batchNo;
  566. }
  567. // filterData.status = item;
  568. sessionStorage.inspectListParameter = JSON.stringify(filterData);
  569. $scope.refreshData("expand-right", $scope.model);
  570. };
  571. $scope.clean = function () {
  572. $scope.tData = { title: "", batchNo: "" };
  573. delete $scope.model.inspectionProcessActual.batchNo;
  574. delete $scope.model.inspectionProcessActual.inspection.title;
  575. delete $scope.model.inspectionProcessActual.inspectionType;
  576. delete $scope.model.inspectionProcessActual.inspectionTypeId;
  577. delete $scope.model.inspectionProcessActual.inspection.executeUser;
  578. delete $scope.model.inspectionProcessActual.inspection.createUser;
  579. delete $scope.model.inspectionProcessActual.state;
  580. $scope.statusData = {};
  581. $scope.try_async_load();
  582. $scope.refreshData("expand-right", $scope.model);
  583. };
  584. //树形控件点击事件
  585. $scope.my_tree_handler = function (branch) {
  586. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  587. filterData.status = branch.id;
  588. // if (filterData.inspectionProcessActual) {
  589. // filterData.inspectionProcessActual.inspectionTypeId = branch.id;
  590. // } else {
  591. // filterData = angular.extend(filterData, {
  592. // "inspectionProcessActual": {
  593. // "inspectionTypeId": branch.id
  594. // }
  595. // })
  596. // }
  597. sessionStorage.inspectListParameter = JSON.stringify(filterData);
  598. $scope.refreshData("expand-right", filterData);
  599. };
  600. //搜索栏点击事件
  601. $scope.searchstate = "todo";
  602. $scope.onChange = function (searchType) {
  603. console.log($scope.gridApi)
  604. $scope.gridApi.selection.clearSelectedRows();
  605. $scope.searchstate = searchType;
  606. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  607. filterData.searchType = searchType;
  608. $scope.model.searchType = searchType;
  609. sessionStorage.inspectListParameter = JSON.stringify(filterData);
  610. $scope.refreshData("expand-right", $scope.model);
  611. };
  612. $scope.reload = function () {
  613. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  614. $scope.refreshData("expand-right", filterData);
  615. };
  616. $scope.refreshData = function (style, filterData) {
  617. $scope.ldloading[style.replace("-", "_")] = true;
  618. if (angular.isUndefined(filterData)) {
  619. filterData = defaultFilterData;
  620. }
  621. if(filterData.searchType === 'todo'){
  622. // 待处理添加筛选条件
  623. console.log(filterData,'2022年5月30日')
  624. filterData.candidateGroups = $rootScope.user.group.map(function(v){return v.id}).toString()
  625. }else{
  626. delete filterData.candidateGroups;
  627. }
  628. $scope.myData = [];
  629. $scope.memoryfilterData = filterData;
  630. api_bpm_data.fetchInspectServiceTasks(filterData.status, filterData).then(
  631. function (data) {
  632. var myData = Restangular.stripRestangular(data);
  633. $scope.gridOptions.totalItems = myData.resultCount;
  634. if (angular.isArray(myData.data)) {
  635. $scope.myData = myData.data;
  636. for (var i = 0; i < $scope.myData.length; i++) {
  637. //添加序号
  638. $scope.myData[i]["itemId"] =
  639. i + 1 + filterData.idx * filterData.sum;
  640. }
  641. $scope.ldloading[style.replace("-", "_")] = false;
  642. } else {
  643. $scope.ldloading[style.replace("-", "_")] = false;
  644. SweetAlert.swal({
  645. title: "数据为空",
  646. text: myData.data,
  647. type: "warning",
  648. });
  649. }
  650. },
  651. function () {
  652. $scope.ldloading[style.replace("-", "_")] = false;
  653. }
  654. );
  655. };
  656. $scope.refreshData2 = function (style, filterData) {
  657. $scope.ldloading[style.replace("-", "_")] = true;
  658. if (angular.isUndefined(filterData)) {
  659. filterData = defaultFilterData;
  660. }
  661. if(filterData.searchType === 'todo'){
  662. // 待处理添加筛选条件
  663. console.log(filterData,'2022年5月30日')
  664. filterData.candidateGroups = $rootScope.user.group.map(function(v){return v.id}).toString()
  665. }else{
  666. delete filterData.candidateGroups;
  667. }
  668. // $scope.myData = [];
  669. $scope.memoryfilterData = filterData;
  670. api_bpm_data.fetchInspectServiceTasks(filterData.status, filterData).then(
  671. function (data) {
  672. var myData = Restangular.stripRestangular(data);
  673. $scope.gridOptions.totalItems = myData.resultCount;
  674. if (angular.isArray(myData.data)) {
  675. $scope.myData = myData.data;
  676. for (var i = 0; i < $scope.myData.length; i++) {
  677. //添加序号
  678. $scope.myData[i]["itemId"] =
  679. i + 1 + filterData.idx * filterData.sum;
  680. }
  681. $scope.ldloading[style.replace("-", "_")] = false;
  682. } else {
  683. $scope.ldloading[style.replace("-", "_")] = false;
  684. SweetAlert.swal({
  685. title: "数据为空",
  686. text: myData.data,
  687. type: "warning",
  688. });
  689. }
  690. },
  691. function () {
  692. $scope.ldloading[style.replace("-", "_")] = false;
  693. }
  694. );
  695. };
  696. $scope.inspecttype = {};
  697. // 获取处理人
  698. $scope.getExecuteUser = function () {
  699. api_configure_data
  700. .fetchDataList("user", {
  701. idx: 0,
  702. sum: 1000,
  703. user: {
  704. roledata: {
  705. rolecode: "inspectman",
  706. },
  707. simple: true,
  708. engineer: 1,
  709. },
  710. })
  711. .then(function (res) {
  712. $scope.executeUserData = res.list;
  713. });
  714. };
  715. $scope.getExecuteUser();
  716. $scope.statusData = [
  717. {
  718. name: "执行中",
  719. state: 0,
  720. },
  721. {
  722. name: "已完成",
  723. state: 1,
  724. },
  725. ];
  726. $scope.titleData = []; //计划主题列表
  727. $scope.batchNoData = []; //批次号列表
  728. // 获取计划主题列表
  729. $scope.getTitleData = function () {
  730. var postData = {
  731. assignee: $rootScope.user.id,
  732. idx: 0,
  733. sum: 9999,
  734. searchType: "all",
  735. inspectionProcessActual: {},
  736. };
  737. api_bpm_data
  738. .fetchDataList("inspection", postData)
  739. .then(function (result) {
  740. if (result.status == 200) {
  741. $scope.titleData = result.list;
  742. }
  743. });
  744. };
  745. $scope.getTitleData();
  746. //修改计划主题
  747. $scope.changeTitle = function(){
  748. $scope.tData.batchNo = "";
  749. $scope.batchNoData = $scope.tData.title.batchNos.map(v=>({id:v,batchNo:v}));
  750. }
  751. // 获取创建人
  752. $scope.getCreateUser = function () {
  753. api_configure_data
  754. .fetchDataList("user", {
  755. idx: 0,
  756. sum: 1000,
  757. user: {
  758. simple: true,
  759. engineer: 1,
  760. },
  761. })
  762. .then(function (res) {
  763. $scope.createUserData = res.list;
  764. });
  765. };
  766. $scope.getCreateUser();
  767. $scope.open = function ($event) {
  768. $event.preventDefault();
  769. $event.stopPropagation();
  770. $scope.opened = !$scope.opened;
  771. };
  772. $scope.endOpen = function ($event) {
  773. $event.preventDefault();
  774. $event.stopPropagation();
  775. $scope.startOpened = false;
  776. $scope.endOpened = !$scope.endOpened;
  777. };
  778. $scope.startOpen = function ($event) {
  779. $event.preventDefault();
  780. $event.stopPropagation();
  781. $scope.endOpened = false;
  782. $scope.startOpened = !$scope.startOpened;
  783. };
  784. //树形控件加载
  785. $scope.my_tree = {};
  786. $scope.try_async_load = function () {
  787. $scope.my_data = [];
  788. $scope.doing_async = true;
  789. api_bpm_data
  790. .fetchDataList("inspectionType", {
  791. idx: 0,
  792. sum: 1000,
  793. })
  794. .then(function (response) {
  795. if (response.status == 200) {
  796. var data = response.list;
  797. var objects = [];
  798. for (var i = 0; i < data.length; i++) {
  799. var object = {};
  800. object.id = data[i].id;
  801. if (data[i].parent && data[i].parent.id != 0) {
  802. object.parent = data[i].parent.id;
  803. }
  804. object.label = data[i].type;
  805. objects.push(object);
  806. }
  807. $scope.my_data = convertParentToChildList(objects);
  808. $scope.tree_data = angular.copy($scope.my_data);
  809. if ($scope.my_data.length > 0) {
  810. $scope.doing_async = false;
  811. }
  812. // return $scope.my_tree.expand_all()
  813. } else {
  814. SweetAlert.swal({
  815. title: "系统错误!",
  816. text: "请刷新重试!",
  817. type: "error",
  818. });
  819. }
  820. });
  821. };
  822. function convertListToTree(data, treeMap) {
  823. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  824. var root = null; //Initially set our loop to null
  825. var parentNode = null;
  826. //loop over data
  827. for (var i = 0; i < data.length; i++) {
  828. var datum = data[i];
  829. //each node will have children, so let's give it a "children" poperty
  830. datum.children = [];
  831. //add an entry for this node to the map so that any future children can
  832. //lookup the parent
  833. idToNodeMap[datum.id] = datum;
  834. //Does this node have a parent?
  835. if (typeof datum.parent === "undefined" || datum.parent == null) {
  836. //Doesn't look like it, so this node is the root of the tree
  837. root = datum;
  838. treeMap[datum.id] = root;
  839. } else {
  840. //This node has a parent, so let's look it up using the id
  841. parentNode = idToNodeMap[datum.parent];
  842. //We don't need this property, so let's delete it.
  843. delete datum.parent;
  844. //Let's add the current node as a child of the parent node.
  845. parentNode.children.push(datum);
  846. }
  847. }
  848. return root;
  849. }
  850. function convertParentToChildList(data) {
  851. var treeMap = {};
  852. var list = [];
  853. convertListToTree(data, treeMap);
  854. angular.forEach(treeMap, function (item) {
  855. list.push(item);
  856. });
  857. return list;
  858. }
  859. $scope.refreshData("expand-right", defaultFilterData);
  860. $scope.try_async_load();
  861. $scope.timer = $interval(function () {
  862. $scope.refreshData2("expand-right", $scope.model);
  863. }, $rootScope.refreshTime);
  864. $scope.$on("$destroy", function () {
  865. $interval.cancel($scope.timer);
  866. });
  867. },
  868. ]);