inspectListCtrl.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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. }
  371. }
  372. }else{
  373. postData = {
  374. "idx": 0,
  375. "sum": 100,
  376. user: {
  377. roledata: { rolecode: "inspectman" },
  378. selectType: "1",
  379. selectDetails:1
  380. }
  381. }
  382. }
  383. api_user_data.fetchDataList('user', postData).then(function (data) {
  384. $scope.user = data.list;
  385. })
  386. }
  387. $scope.assignUser = null;
  388. $scope.user = [];
  389. $scope.group = [];
  390. $scope.getUsers();
  391. api_user_data.fetchDataList('group', {
  392. "idx": 0,
  393. "sum": 100,
  394. group: {'selectType':'nouser'}
  395. }).then(function (data) {
  396. $scope.group = data.list;
  397. })
  398. $scope.onChangeRotateUser = function(item){
  399. $scope.assignUser = item.id;
  400. }
  401. $scope.onChangeRotateGroup = function(item){
  402. $scope.assignGroup = item.id;
  403. $scope.getUsers(item.id)
  404. }
  405. $scope.ok = function () {
  406. if (!$scope.assignUser){
  407. Alert.swal({
  408. title: "操作失败",
  409. text: "请选择转派对象信息!",
  410. type: "error"
  411. });
  412. return;
  413. }
  414. api_bpm.assign({ids:sendList.join(),userId:$scope.assignUser}).then(function (response) {
  415. console.log(response)
  416. if (response.status == 200) {
  417. Alert.swal({
  418. title: "操作成功!",
  419. confirmButtonColor: "#007AFF",
  420. type: "success"
  421. });
  422. $modalInstance.close('success');
  423. _$scope.gridApi.selection.clearSelectedRows();
  424. } else {
  425. Alert.swal({
  426. title: "操作失败",
  427. text: "操作失败, 请稍后再试!",
  428. type: "error"
  429. });
  430. }
  431. });
  432. }
  433. $scope.cancel = function () {
  434. $modalInstance.dismiss('cancel');
  435. }
  436. },
  437. size: 'sm',
  438. resolve: {
  439. api_bpm: function () {
  440. return api_bpm;
  441. },
  442. modelData: function () {
  443. return _$scope.selected.items;
  444. },
  445. currentUserId: function () {
  446. return loginUser.id;
  447. },
  448. Alert: function () {
  449. return SweetAlert;
  450. },
  451. api_user_data: function () {
  452. return api_user_data;
  453. }
  454. }
  455. });
  456. modalInstance.result.then(function (selectedItem) {
  457. if (selectedItem == 'success') {
  458. defaultFilterData.assignee = loginUser.id;
  459. $scope.refreshData('expand-right', defaultFilterData);
  460. }
  461. });
  462. return;
  463. // --------------------------------------------------------
  464. }
  465. $scope.selected = {
  466. items: [],
  467. };
  468. $scope.editted = {
  469. items: [],
  470. };
  471. $scope.jry_idx = 0;
  472. $scope.jry_sum = 10;
  473. //分页控制
  474. $scope.gridOptions.onRegisterApi = function (gridApi) {
  475. $scope.gridApi = gridApi;
  476. gridApi.pagination.on.paginationChanged(
  477. $scope,
  478. function (newPage, pageSize) {
  479. console.log("ok");
  480. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  481. filterData.idx = newPage - 1;
  482. filterData.sum = pageSize;
  483. $scope.jry_idx = newPage - 1;
  484. $scope.jry_sum = pageSize;
  485. $scope.model.idx = newPage - 1;
  486. $scope.model.sum = pageSize;
  487. $scope.refreshData("expand-right", $scope.model);
  488. }
  489. );
  490. // 单选
  491. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  492. console.log(scope)
  493. if (scope.isSelected) {
  494. scope.grid.appScope.selected.items.push(scope.entity)
  495. } else {
  496. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  497. if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
  498. scope.grid.appScope.selected.items.splice(i, 1);
  499. break;
  500. }
  501. }
  502. }
  503. console.log(scope.grid.appScope.selected.items)
  504. });
  505. // 全选/全不选
  506. gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
  507. console.log(rows)
  508. var selectitem = [];
  509. selectitem = angular.copy($scope.selected.items);
  510. for (var j = 0; j < rows.length; j++) {
  511. if (rows[j].isSelected == true) {
  512. selectitem.push(rows[j].entity);
  513. } else {
  514. delete selectitem[j];
  515. }
  516. }
  517. $scope.selected.items = [];
  518. for (var i = 0; i < selectitem.length; i++) {
  519. if (selectitem[i]) {
  520. $scope.selected.items.push(selectitem[i]);
  521. }
  522. }
  523. console.log($scope.selected.items)
  524. });
  525. };
  526. // var data = JSON.parse(sessionStorage.inspectListParameter);
  527. // sessionStorage.inspectListParameter = JSON.stringify(data);
  528. $scope.ldloading = {};
  529. $scope.statusData = {};
  530. $scope.tData = { title: "", batchNo: "" };
  531. //搜索事件
  532. $scope.searchinspectlist = function (item) {
  533. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  534. // console.log(filterData);
  535. // if (item.type) {
  536. // filterData.inspection = { 'inspectionTypeDTO': { 'id':item.type.id}};
  537. // }
  538. // if (item.title) {
  539. // filterData.inspection = { 'title': item.title};
  540. // }
  541. $scope.model.idx = $scope.jry_idx;
  542. $scope.model.sum = $scope.jry_sum;
  543. if ($scope.model.inspectionProcessActual.inspectionType) {
  544. $scope.model.inspectionProcessActual.inspectionTypeId =
  545. $scope.model.inspectionProcessActual.inspectionType.id;
  546. delete $scope.model.inspectionProcessActual.inspectionType;
  547. }
  548. if ($scope.statusData.state) {
  549. $scope.model.inspectionProcessActual.state =
  550. $scope.statusData.state.state;
  551. }
  552. if ($scope.tData.title) {
  553. if ($scope.model.inspectionProcessActual.inspection) {
  554. $scope.model.inspectionProcessActual.inspection.title =
  555. $scope.tData.title.title;
  556. } else {
  557. $scope.model.inspectionProcessActual.inspection = {
  558. title: $scope.tData.title.title,
  559. };
  560. }
  561. }
  562. if ($scope.tData.batchNo) {
  563. $scope.model.inspectionProcessActual.batchNo = $scope.tData.batchNo.batchNo;
  564. }
  565. // filterData.status = item;
  566. sessionStorage.inspectListParameter = JSON.stringify(filterData);
  567. $scope.refreshData("expand-right", $scope.model);
  568. };
  569. $scope.clean = function () {
  570. $scope.tData = { title: "", batchNo: "" };
  571. delete $scope.model.inspectionProcessActual.batchNo;
  572. delete $scope.model.inspectionProcessActual.inspection.title;
  573. delete $scope.model.inspectionProcessActual.inspectionType;
  574. delete $scope.model.inspectionProcessActual.inspectionTypeId;
  575. delete $scope.model.inspectionProcessActual.inspection.executeUser;
  576. delete $scope.model.inspectionProcessActual.inspection.createUser;
  577. delete $scope.model.inspectionProcessActual.state;
  578. $scope.statusData = {};
  579. $scope.try_async_load();
  580. $scope.refreshData("expand-right", $scope.model);
  581. };
  582. //树形控件点击事件
  583. $scope.my_tree_handler = function (branch) {
  584. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  585. filterData.status = branch.id;
  586. // if (filterData.inspectionProcessActual) {
  587. // filterData.inspectionProcessActual.inspectionTypeId = branch.id;
  588. // } else {
  589. // filterData = angular.extend(filterData, {
  590. // "inspectionProcessActual": {
  591. // "inspectionTypeId": branch.id
  592. // }
  593. // })
  594. // }
  595. sessionStorage.inspectListParameter = JSON.stringify(filterData);
  596. $scope.refreshData("expand-right", filterData);
  597. };
  598. //搜索栏点击事件
  599. $scope.searchstate = "todo";
  600. $scope.onChange = function (searchType) {
  601. console.log($scope.gridApi)
  602. $scope.gridApi.selection.clearSelectedRows();
  603. $scope.searchstate = searchType;
  604. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  605. filterData.searchType = searchType;
  606. $scope.model.searchType = searchType;
  607. sessionStorage.inspectListParameter = JSON.stringify(filterData);
  608. $scope.refreshData("expand-right", $scope.model);
  609. };
  610. $scope.reload = function () {
  611. var filterData = JSON.parse(sessionStorage.inspectListParameter);
  612. $scope.refreshData("expand-right", filterData);
  613. };
  614. $scope.refreshData = function (style, filterData) {
  615. $scope.ldloading[style.replace("-", "_")] = true;
  616. if (angular.isUndefined(filterData)) {
  617. filterData = defaultFilterData;
  618. }
  619. if(filterData.searchType === 'todo'){
  620. // 待处理添加筛选条件
  621. console.log(filterData,'2022年5月30日')
  622. filterData.candidateGroups = $rootScope.user.group.map(function(v){return v.id}).toString()
  623. }else{
  624. delete filterData.candidateGroups;
  625. }
  626. $scope.myData = [];
  627. $scope.memoryfilterData = filterData;
  628. api_bpm_data.fetchInspectServiceTasks(filterData.status, filterData).then(
  629. function (data) {
  630. var myData = Restangular.stripRestangular(data);
  631. $scope.gridOptions.totalItems = myData.resultCount;
  632. if (angular.isArray(myData.data)) {
  633. $scope.myData = myData.data;
  634. for (var i = 0; i < $scope.myData.length; i++) {
  635. //添加序号
  636. $scope.myData[i]["itemId"] =
  637. i + 1 + filterData.idx * filterData.sum;
  638. }
  639. $scope.ldloading[style.replace("-", "_")] = false;
  640. } else {
  641. $scope.ldloading[style.replace("-", "_")] = false;
  642. SweetAlert.swal({
  643. title: "数据为空",
  644. text: myData.data,
  645. type: "warning",
  646. });
  647. }
  648. },
  649. function () {
  650. $scope.ldloading[style.replace("-", "_")] = false;
  651. }
  652. );
  653. };
  654. $scope.refreshData2 = function (style, filterData) {
  655. $scope.ldloading[style.replace("-", "_")] = true;
  656. if (angular.isUndefined(filterData)) {
  657. filterData = defaultFilterData;
  658. }
  659. if(filterData.searchType === 'todo'){
  660. // 待处理添加筛选条件
  661. console.log(filterData,'2022年5月30日')
  662. filterData.candidateGroups = $rootScope.user.group.map(function(v){return v.id}).toString()
  663. }else{
  664. delete filterData.candidateGroups;
  665. }
  666. // $scope.myData = [];
  667. $scope.memoryfilterData = filterData;
  668. api_bpm_data.fetchInspectServiceTasks(filterData.status, filterData).then(
  669. function (data) {
  670. var myData = Restangular.stripRestangular(data);
  671. $scope.gridOptions.totalItems = myData.resultCount;
  672. if (angular.isArray(myData.data)) {
  673. $scope.myData = myData.data;
  674. for (var i = 0; i < $scope.myData.length; i++) {
  675. //添加序号
  676. $scope.myData[i]["itemId"] =
  677. i + 1 + filterData.idx * filterData.sum;
  678. }
  679. $scope.ldloading[style.replace("-", "_")] = false;
  680. } else {
  681. $scope.ldloading[style.replace("-", "_")] = false;
  682. SweetAlert.swal({
  683. title: "数据为空",
  684. text: myData.data,
  685. type: "warning",
  686. });
  687. }
  688. },
  689. function () {
  690. $scope.ldloading[style.replace("-", "_")] = false;
  691. }
  692. );
  693. };
  694. $scope.inspecttype = {};
  695. // 获取处理人
  696. $scope.getExecuteUser = function () {
  697. api_configure_data
  698. .fetchDataList("user", {
  699. idx: 0,
  700. sum: 1000,
  701. user: {
  702. roledata: {
  703. rolecode: "inspectman",
  704. },
  705. simple: true,
  706. },
  707. })
  708. .then(function (res) {
  709. $scope.executeUserData = res.list;
  710. });
  711. };
  712. $scope.getExecuteUser();
  713. $scope.statusData = [
  714. {
  715. name: "执行中",
  716. state: 0,
  717. },
  718. {
  719. name: "已完成",
  720. state: 1,
  721. },
  722. ];
  723. $scope.titleData = []; //计划主题列表
  724. $scope.batchNoData = []; //批次号列表
  725. // 获取计划主题列表
  726. $scope.getTitleData = function () {
  727. var postData = {
  728. assignee: $rootScope.user.id,
  729. idx: 0,
  730. sum: 9999,
  731. searchType: "all",
  732. inspectionProcessActual: {},
  733. };
  734. api_bpm_data
  735. .fetchDataList("inspection", postData)
  736. .then(function (result) {
  737. if (result.status == 200) {
  738. $scope.titleData = result.list;
  739. }
  740. });
  741. };
  742. $scope.getTitleData();
  743. //修改计划主题
  744. $scope.changeTitle = function(){
  745. $scope.tData.batchNo = "";
  746. $scope.batchNoData = $scope.tData.title.batchNos.map(v=>({id:v,batchNo:v}));
  747. }
  748. // 获取创建人
  749. $scope.getCreateUser = function () {
  750. api_configure_data
  751. .fetchDataList("user", {
  752. idx: 0,
  753. sum: 1000,
  754. user: {
  755. simple: true,
  756. },
  757. })
  758. .then(function (res) {
  759. $scope.createUserData = res.list;
  760. });
  761. };
  762. $scope.getCreateUser();
  763. $scope.open = function ($event) {
  764. $event.preventDefault();
  765. $event.stopPropagation();
  766. $scope.opened = !$scope.opened;
  767. };
  768. $scope.endOpen = function ($event) {
  769. $event.preventDefault();
  770. $event.stopPropagation();
  771. $scope.startOpened = false;
  772. $scope.endOpened = !$scope.endOpened;
  773. };
  774. $scope.startOpen = function ($event) {
  775. $event.preventDefault();
  776. $event.stopPropagation();
  777. $scope.endOpened = false;
  778. $scope.startOpened = !$scope.startOpened;
  779. };
  780. //树形控件加载
  781. $scope.my_tree = {};
  782. $scope.try_async_load = function () {
  783. $scope.my_data = [];
  784. $scope.doing_async = true;
  785. api_bpm_data
  786. .fetchDataList("inspectionType", {
  787. idx: 0,
  788. sum: 1000,
  789. })
  790. .then(function (response) {
  791. if (response.status == 200) {
  792. var data = response.list;
  793. var objects = [];
  794. for (var i = 0; i < data.length; i++) {
  795. var object = {};
  796. object.id = data[i].id;
  797. if (data[i].parent && data[i].parent.id != 0) {
  798. object.parent = data[i].parent.id;
  799. }
  800. object.label = data[i].type;
  801. objects.push(object);
  802. }
  803. $scope.my_data = convertParentToChildList(objects);
  804. $scope.tree_data = angular.copy($scope.my_data);
  805. if ($scope.my_data.length > 0) {
  806. $scope.doing_async = false;
  807. }
  808. // return $scope.my_tree.expand_all()
  809. } else {
  810. SweetAlert.swal({
  811. title: "系统错误!",
  812. text: "请刷新重试!",
  813. type: "error",
  814. });
  815. }
  816. });
  817. };
  818. function convertListToTree(data, treeMap) {
  819. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  820. var root = null; //Initially set our loop to null
  821. var parentNode = null;
  822. //loop over data
  823. for (var i = 0; i < data.length; i++) {
  824. var datum = data[i];
  825. //each node will have children, so let's give it a "children" poperty
  826. datum.children = [];
  827. //add an entry for this node to the map so that any future children can
  828. //lookup the parent
  829. idToNodeMap[datum.id] = datum;
  830. //Does this node have a parent?
  831. if (typeof datum.parent === "undefined" || datum.parent == null) {
  832. //Doesn't look like it, so this node is the root of the tree
  833. root = datum;
  834. treeMap[datum.id] = root;
  835. } else {
  836. //This node has a parent, so let's look it up using the id
  837. parentNode = idToNodeMap[datum.parent];
  838. //We don't need this property, so let's delete it.
  839. delete datum.parent;
  840. //Let's add the current node as a child of the parent node.
  841. parentNode.children.push(datum);
  842. }
  843. }
  844. return root;
  845. }
  846. function convertParentToChildList(data) {
  847. var treeMap = {};
  848. var list = [];
  849. convertListToTree(data, treeMap);
  850. angular.forEach(treeMap, function (item) {
  851. list.push(item);
  852. });
  853. return list;
  854. }
  855. $scope.refreshData("expand-right", defaultFilterData);
  856. $scope.try_async_load();
  857. $scope.timer = $interval(function () {
  858. $scope.refreshData2("expand-right", $scope.model);
  859. }, $rootScope.refreshTime);
  860. $scope.$on("$destroy", function () {
  861. $interval.cancel($scope.timer);
  862. });
  863. },
  864. ]);