scoreConfigurationPerformanceCtrl.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. 'use strict';
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_schedule", "api_bpm_data", "api_wechatfile", "api_configure_data", "moment", function ($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_schedule, api_bpm_data, api_wechatfile, api_configure_data, moment) {
  6. $scope.langs = i18nService.getAllLangs();
  7. $scope.lang = 'zh-cn';
  8. i18nService.setCurrentLang($scope.lang);
  9. var loginUser = $rootScope.user;
  10. $scope.xinzeng = false;
  11. $scope.shanchu = false;
  12. $scope.bianji = false;
  13. $scope.zantingzhixing = false;
  14. for (var i = 0; i < loginUser.menu.length; i++) {
  15. if (loginUser.menu[i].link == "xunjianjihua_xinzeng") {
  16. $scope.xinzeng = true
  17. }
  18. if (loginUser.menu[i].link == "xunjianjihua_shanchu") {
  19. $scope.shanchu = true
  20. }
  21. if (loginUser.menu[i].link == "xunjianjihua_bianji") {
  22. $scope.bianji = true
  23. }
  24. if (loginUser.menu[i].link == "xunjianjihua_zantingzhixing") {
  25. $scope.zantingzhixing = true
  26. }
  27. }
  28. var defaultFilterData = {
  29. "idx": 0,
  30. "sum": 10
  31. };
  32. $scope.gridOptions = {};
  33. $scope.gridOptions.data = 'myData';
  34. $scope.gridOptions.enableColumnResizing = true;
  35. $scope.gridOptions.enableFiltering = false;
  36. $scope.gridOptions.enableGridMenu = true;
  37. $scope.gridOptions.enableRowSelection = true;
  38. $scope.gridOptions.showGridFooter = true;
  39. $scope.gridOptions.showColumnFooter = false;
  40. $scope.gridOptions.useExternalFiltering = false;
  41. $scope.gridOptions.useExternalPagination = true;
  42. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  43. $scope.gridOptions.paginationPageSize = 10;
  44. $scope.gridOptions.multiSelect = true;
  45. $scope.gridOptions.enableSelectionBatchEvent = true; //使用批量使用事件
  46. //行鼠标悬浮变色功能
  47. // $scope.gridOptions.rowTemplate = '<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ng-mouseover="grid.appScope.hoveredIndex = rowRenderIndex" ng-mouseleave="grid.appScope.hoveredIndex = null" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{\'ui-grid-row-header-cell\': col.isRowHeader, \'your-hover-class\': grid.appScope.hoveredIndex === rowRenderIndex}" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
  48. $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>";
  49. $scope.gridOptions.rowIdentity = function (row) {
  50. return row.id;
  51. };
  52. $scope.gridOptions.getRowIdentity = function (row) {
  53. return row.id;
  54. };
  55. $scope.transfer = function (status) {
  56. if (status === "执行中") {
  57. return "执行中"
  58. } else if (status === "暂停中") {
  59. return "暂停中"
  60. }
  61. }
  62. $scope.gridOptions.columnDefs = [{
  63. name: 'item',
  64. displayName: '序号',
  65. width: 50,
  66. enableFiltering: false
  67. },
  68. {
  69. name: 'one',
  70. displayName: '一级分类',
  71. width: '10%',
  72. enableFiltering: false
  73. },
  74. {
  75. name: 'two',
  76. displayName: '二级分类',
  77. width: '10%',
  78. enableFiltering: false
  79. },
  80. {
  81. name: 'three',
  82. displayName: '三级分类',
  83. width: '10%',
  84. enableFiltering: false
  85. },
  86. {
  87. name: 'four',
  88. displayName: '默认积分',
  89. width: '10%',
  90. enableFiltering: false
  91. },
  92. {
  93. name: 'five',
  94. displayName: '积分规则',
  95. width: '10%',
  96. enableFiltering: false
  97. },
  98. {
  99. minWidth: '300',
  100. name: '操作',
  101. enableFiltering: false,
  102. cellTemplate: '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
  103. '<a ng-click="grid.appScope.edit(row.entity)">编辑</a>' +
  104. '</div>'
  105. },
  106. ];
  107. // 批量修改积分
  108. $scope.edits = function (data) {
  109. console.log(data);
  110. var modalInstance = $modal.open({
  111. templateUrl: 'assets/views/scoreConfigurationPerformance-edit.html',
  112. size: "sm",
  113. controller: function ($scope, $modalInstance) {
  114. $scope.configs = {
  115. defaultScore:0,
  116. configs: []
  117. };
  118. // 增加配置
  119. $scope.addConfig = function(){
  120. $scope.configs.configs.push({startNum: 0, endNum: 0, score: 0});
  121. }
  122. // 移除配置
  123. $scope.removeConfig = function(index){
  124. $scope.configs.configs.splice(index, 1);
  125. }
  126. $scope.ok = function () {
  127. $modalInstance.close(data);
  128. };
  129. $scope.cancel = function () {
  130. $modalInstance.dismiss('cancel');
  131. };
  132. },
  133. })
  134. modalInstance.result.then(function (result) {
  135. console.log(result);
  136. if (result) {
  137. api_bpm_data.executeOnce({inspection:data}).then(function (response) {
  138. if(response.status == 200){
  139. SweetAlert.swal({
  140. title: "操作成功!",
  141. type: "success",
  142. });
  143. }else{
  144. SweetAlert.swal({
  145. title: "操作失败!",
  146. type: "error",
  147. });
  148. }
  149. })
  150. }
  151. });
  152. };
  153. //编辑
  154. $scope.edit = function (data) {
  155. console.log(data);
  156. var modalInstance = $modal.open({
  157. templateUrl: 'assets/views/scoreConfigurationPerformance-edit.html',
  158. size: "sm",
  159. controller: function ($scope, $modalInstance) {
  160. $scope.configs = {
  161. defaultScore:0,
  162. configs: []
  163. };
  164. // 增加配置
  165. $scope.addConfig = function(){
  166. $scope.configs.configs.push({startNum: 0, endNum: 0, score: 0});
  167. }
  168. // 移除配置
  169. $scope.removeConfig = function(index){
  170. $scope.configs.configs.splice(index, 1);
  171. }
  172. $scope.ok = function () {
  173. $modalInstance.close(data);
  174. };
  175. $scope.cancel = function () {
  176. $modalInstance.dismiss('cancel');
  177. };
  178. },
  179. })
  180. modalInstance.result.then(function (result) {
  181. console.log(result);
  182. if (result) {
  183. api_bpm_data.executeOnce({inspection:data}).then(function (response) {
  184. if(response.status == 200){
  185. SweetAlert.swal({
  186. title: "操作成功!",
  187. type: "success",
  188. });
  189. }else{
  190. SweetAlert.swal({
  191. title: "操作失败!",
  192. type: "error",
  193. });
  194. }
  195. })
  196. }
  197. });
  198. };
  199. $scope.selected = {
  200. items: []
  201. }
  202. $scope.gridOptions.onRegisterApi = function (gridApi) {
  203. //导入gridApi对象
  204. $scope.gridApi = gridApi;
  205. //勾选行事件
  206. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  207. if (data.isSelected) {
  208. $scope.selected.items.push(data.entity);
  209. } else {
  210. //objs:需要遍历的集合 data:遍历时当前的数据 index:遍历时当前索引
  211. //array:需要遍历的集合,每次遍历时都会把objs原样的传一次。
  212. //angular.forEach(objs, function(data,index,array)
  213. angular.forEach($scope.selected.items, function (ObjIndex, index, destObj) {
  214. // console.log(ObjIndex);
  215. // console.log(index);
  216. // console.log(destObj);
  217. if (ObjIndex.id == data.entity.id) {
  218. destObj.splice(index, 1)
  219. }
  220. })
  221. }
  222. });
  223. //批量全选
  224. gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows, event) {
  225. // if ($scope.selected.items.length != 0) {
  226. // $scope.selected.items = [];
  227. angular.forEach(rows, function (ObjIndex, index, destObj) {
  228. if (ObjIndex.isSelected) {
  229. $scope.selected.items.push(ObjIndex.entity);
  230. } else {
  231. $scope.selected.items = [];
  232. // $scope.selected.items.splice(index, 1);
  233. }
  234. });
  235. // } else {
  236. // }
  237. // $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  238. // if ($scope.selected.items.length == 0) {
  239. // $scope.selected.items = $scope.mySelectedRows;
  240. // } else if ($scope.mySelectedRows.length == 0) {
  241. // for (var i = 0; i < $scope.selected.items.length; i++) {
  242. // for (var j = 0; j < rows.length; j++) {
  243. // if ($scope.selected.items[i].id == rows[j].entity.id) {
  244. // $scope.selected.items.splice(i, 1);
  245. // }
  246. // }
  247. // }
  248. // } else {
  249. // angular.forEach($scope.mySelectedRows, function(item) {
  250. // $scope.selected.items.push(item);
  251. // });
  252. // }
  253. });
  254. };
  255. //重置按钮
  256. $scope.reload = function () {
  257. delete $scope.fileData.inspection.inspectionTypeDTO;
  258. delete $scope.fileData.inspection.executeUser;
  259. delete $scope.fileData.inspection.createUser;
  260. $scope.refreshData('expand-right', $scope.fileData);
  261. }
  262. //数据刷新
  263. $scope.refreshData = function (style, filterData) {
  264. $scope.ldloading[style.replace('-', '_')] = true;
  265. if (angular.isUndefined(filterData)) {
  266. filterData = defaultFilterData;
  267. }
  268. $scope.myData = [];
  269. api_bpm_data.fetchDataList('inspection', filterData).then(function (data) {
  270. var myData = Restangular.stripRestangular(data);
  271. $scope.gridOptions.totalItems = myData.totalNum;
  272. if (angular.isArray(myData.list)) {
  273. $scope.myData = myData.list;
  274. for (var i = 0; i < $scope.myData.length; i++) {
  275. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  276. if($scope.myData[i].onDoing + $scope.myData[i].onCompleted != 0){
  277. $scope.myData[i].onPercent = ($scope.myData[i].onCompleted*100/($scope.myData[i].onDoing + $scope.myData[i].onCompleted)).toFixed(1);
  278. }else if($scope.myData[i].onCompleted == 0){
  279. $scope.myData[i].onPercent = '0.0';
  280. }else{
  281. $scope.myData[i].onPercent = '0.0';
  282. }
  283. if($scope.myData[i].offDoing + $scope.myData[i].offCompleted != 0){
  284. $scope.myData[i].offPercent = ($scope.myData[i].offCompleted*100/($scope.myData[i].offDoing + $scope.myData[i].offCompleted)).toFixed(1);
  285. }else if($scope.myData[i].offCompleted == 0){
  286. $scope.myData[i].offPercent = '0.0';
  287. }else{
  288. $scope.myData[i].offPercent = '0.0';
  289. }
  290. }
  291. console.log($scope.myData)
  292. for (var i = 0; i < $scope.myData.length; i++) {
  293. if ($scope.myData[i].status == "执行中") {
  294. $scope.myData[i].style = "fa fa-play";
  295. } else if ($scope.myData[i].status == "暂停中") {
  296. $scope.myData[i].style = "fa fa-pause";
  297. };
  298. $scope.myData[i].runStatus = $scope.transfer($scope.myData[i].status);
  299. }
  300. } else {
  301. SweetAlert.swal({
  302. title: "数据为空",
  303. text: myData.data,
  304. type: "warning"
  305. });
  306. }
  307. $scope.ldloading[style.replace('-', '_')] = false;
  308. }, function () {
  309. $scope.ldloading[style.replace('-', '_')] = false;
  310. });
  311. };
  312. $scope.refreshData2 = function (style, filterData) {
  313. $scope.ldloading[style.replace('-', '_')] = true;
  314. if (angular.isUndefined(filterData)) {
  315. filterData = defaultFilterData;
  316. }
  317. api_bpm_data.fetchDataList('inspection', filterData).then(function (data) {
  318. var myData = Restangular.stripRestangular(data);
  319. $scope.gridOptions.totalItems = myData.totalNum;
  320. if (angular.isArray(myData.list)) {
  321. $scope.myData = myData.list;
  322. for (var i = 0; i < $scope.myData.length; i++) {
  323. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  324. if($scope.myData[i].doing + $scope.myData[i].completed != 0){
  325. $scope.myData[i].percent = ($scope.myData[i].completed*100/($scope.myData[i].doing + $scope.myData[i].completed)).toFixed(1);
  326. }else if($scope.myData[i].completed == 0){
  327. $scope.myData[i].percent = '0.0';
  328. }else{
  329. $scope.myData[i].percent = '0.0';
  330. }
  331. }
  332. console.log($scope.myData)
  333. for (var i = 0; i < $scope.myData.length; i++) {
  334. if ($scope.myData[i].status == "执行中") {
  335. $scope.myData[i].style = "fa fa-play";
  336. } else if ($scope.myData[i].status == "暂停中") {
  337. $scope.myData[i].style = "fa fa-pause";
  338. };
  339. $scope.myData[i].runStatus = $scope.transfer($scope.myData[i].status);
  340. }
  341. } else {
  342. SweetAlert.swal({
  343. title: "数据为空",
  344. text: myData.data,
  345. type: "warning"
  346. });
  347. }
  348. $scope.ldloading[style.replace('-', '_')] = false;
  349. }, function () {
  350. $scope.ldloading[style.replace('-', '_')] = false;
  351. });
  352. };
  353. $scope.ldloading = {};
  354. $scope.fileData = {
  355. "idx": 0,
  356. "sum": 10,
  357. "inspection": {}
  358. }
  359. $scope.searchinspe = function () {
  360. $scope.refreshData('expand-right', $scope.fileData);
  361. }
  362. // 获取一级分类
  363. $scope.getOneCates = function () {
  364. api_configure_data.fetchDataList("incidentcategory", {
  365. "idx": 0,
  366. "sum": 1000,
  367. "incidentcategory": {
  368. hierarchy: 1
  369. }
  370. }).then(function (res) {
  371. $scope.one_cates = res.list
  372. })
  373. }
  374. $scope.getOneCates()
  375. // 获取二级分类
  376. $scope.getTwoCates = function () {
  377. api_configure_data.fetchDataList("incidentcategory", {
  378. "idx": 0,
  379. "sum": 1000,
  380. "incidentcategory": {
  381. hierarchy: 1
  382. }
  383. }).then(function (res) {
  384. $scope.two_cates = res.list
  385. })
  386. }
  387. $scope.getTwoCates()
  388. $scope.refreshData('expand-right', $scope.fileData);
  389. $scope.timer = $interval(function () {
  390. $scope.refreshData2('expand-right', $scope.fileData);
  391. }, $rootScope.refreshTime);
  392. $scope.$on('$destroy', function () {
  393. $interval.cancel($scope.timer)
  394. })
  395. }]);
  396. app.factory('inspectListMobileCtrlTree', ['api_bpm_data', function (api_bpm_data) {
  397. function convertListToTree(data, treeMap) {
  398. var idToNodeMap = {};
  399. var root = null;
  400. var parentNode = null;
  401. for (var i = 0; i < data.length; i++) {
  402. var datum = data[i];
  403. datum.children = [];
  404. idToNodeMap[datum.id] = datum;
  405. if (typeof datum.parent === "undefined" || datum.parent == null) {
  406. root = datum;
  407. treeMap[datum.id] = root;
  408. } else {
  409. parentNode = idToNodeMap[datum.parent];
  410. delete datum.parent;
  411. parentNode.children.push(datum);
  412. }
  413. }
  414. return root;
  415. };
  416. function convertParentToChildList(data) {
  417. var treeMap = {};
  418. var list = [];
  419. convertListToTree(data, treeMap);
  420. angular.forEach(treeMap, function (item) {
  421. list.push(item);
  422. });
  423. return list;
  424. };
  425. var forEachEelement = function forEachEelement(response) {
  426. var objects = [];
  427. angular.forEach(response.list, function (ObjIndex, index, destObj) {
  428. var object = {};
  429. object.id = ObjIndex.id;
  430. object.label = ObjIndex.type;
  431. if (ObjIndex.parent && ObjIndex.parent.id != 0) {
  432. object.parent = ObjIndex.parent.id;
  433. };
  434. if (ObjIndex.formUiEdit) {
  435. object.formUiEdit = ObjIndex.formUiEdit;
  436. };
  437. if (ObjIndex.formUiName) {
  438. object.formUiName = ObjIndex.formUiName;
  439. };
  440. if (ObjIndex.processKey) {
  441. object.processKey = ObjIndex.processKey;
  442. };
  443. if (ObjIndex.formUiStart) {
  444. object.formUiStart = ObjIndex.formUiStart;
  445. };
  446. objects.push(object);
  447. });
  448. var my_data = convertParentToChildList(objects);
  449. var tree_data = angular.copy(my_data);
  450. return {
  451. 'my_data': my_data,
  452. 'tree_data': tree_data
  453. }
  454. }
  455. return forEachEelement;
  456. }]);