chartCtrl.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. 'use strict';
  2. app.controller('chartCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data", "api_text", "api_user_data", "api_wechatfile", "api_search_ks", function ($scope, i18nService, $rootScope, $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data, api_text, api_user_data, api_wechatfile, api_search_ks) {
  3. $scope.langs = i18nService.getAllLangs();
  4. $scope.lang = 'zh-cn';
  5. i18nService.setCurrentLang($scope.lang);
  6. // $(window).resize(function() {
  7. // // console.log("1111")
  8. // });
  9. var loginUser = $rootScope.user;
  10. //保存报修主体
  11. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  12. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  14. // ----------------分割线 start-----------------
  15. // 报修科室下拉
  16. $scope.ks_pageNum = 0; //科室下拉列表分页
  17. $scope.ks_len = 0; //科室所有数据列表数量
  18. $scope.ks_arr = [];//科室所有数据
  19. $scope.ksFlag = false;//默认下拉框列表隐藏
  20. $scope.ksModel = '';//科室输入内容
  21. //点击文本框
  22. $scope.ksClickHandle = function () {
  23. $scope.ks_arr = [];
  24. $scope.ks_pageNum = 0;
  25. $scope.getDepartmentList($scope.ks_pageNum);
  26. angular.element('#bx_ks_ul').scrollTop(0);
  27. }
  28. //修改文字,实时监听
  29. $scope.ksChangeHandle = _.debounce(function () {
  30. $scope.ks_arr = [];
  31. $scope.ks_pageNum = 0;
  32. $scope.getDepartmentList($scope.ks_pageNum);
  33. angular.element('#bx_ks_ul').scrollTop(0);
  34. }, 500)
  35. //滚动加载
  36. $scope.ksScrollHandle = function () {
  37. var itemLen = $scope.ks_arr.length;
  38. $scope.ks_pageNum++;
  39. if ($scope.ks_len != itemLen) {
  40. $scope.ks_len = itemLen;
  41. $scope.getDepartmentList($scope.ks_pageNum);
  42. }
  43. }
  44. //获取科室列表seimin
  45. $scope.getDepartmentList = function (idx) {
  46. api_search_ks.getKsList({ "idx": idx, "sum": 50, "department": { "dept": $scope.ksModel } })
  47. .then(res => {
  48. if (res.status == 200) {
  49. //添加分页数据,汇总
  50. $scope.ks_arr = $scope.ks_arr.concat(res.list);
  51. $scope.ksFlag = true;//显示
  52. }
  53. })
  54. .catch(err => {
  55. console.log(err);
  56. })
  57. }
  58. //下拉框列表选中
  59. $scope.ksItemClick = function (obj) {
  60. $scope.ksModel = obj.dept;//文本框赋值
  61. $scope.ksFlag = false;//隐藏
  62. }
  63. //点击空白处隐藏
  64. angular.element(document).on('click', function (e) {
  65. if (e.target !== angular.element('#bx_ks').get(0)) {
  66. $scope.ksFlag = false;//隐藏
  67. //模拟placeholder
  68. // if ($('#bx_ks').val() == '') {
  69. // $('#bx_ks').val('请选择报修科室');
  70. // }
  71. }
  72. })
  73. // -----------------分割线 end----------------
  74. // var voiceurl=$rootScope.audioiIp;
  75. // delete $rootScope.user.authority;
  76. var pdKey = $state.current.pdKey;
  77. $scope.gridOptions = {};
  78. $scope.gridOptions.data = 'myData';
  79. $scope.gridOptions.enableColumnResizing = true;
  80. $scope.gridOptions.enableFiltering = false;
  81. $scope.gridOptions.enableGridMenu = true;
  82. $scope.gridOptions.enableRowSelection = true;
  83. $scope.gridOptions.showGridFooter = true;
  84. $scope.gridOptions.showColumnFooter = false;
  85. $scope.gridOptions.fastWatch = true;
  86. // $scope.gridOptions.useExternalFiltering=true;
  87. $scope.gridOptions.useExternalPagination = true;
  88. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  89. $scope.gridOptions.paginationPageSize = 10;
  90. $scope.gridOptions.multiSelect = true;
  91. var mun = $scope.gridOptions.paginationPageSize;
  92. $scope.gridOptions.rowTemplate = "<div ng-click=\"lookFunction(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>";
  93. $scope.gridOptions.rowIdentity = function (row) {
  94. return row.id;
  95. };
  96. $scope.gridOptions.getRowIdentity = function (row) {
  97. return row.id;
  98. };
  99. //处理图标与文字
  100. $scope.transfertip = function (item) {
  101. var tip = "";
  102. if (item.operationLog) {
  103. tip = item.operationLog.userName;
  104. }
  105. return tip;
  106. }
  107. $scope.transferColor = function (item) {
  108. var color = "";
  109. if (item.operationLog) {
  110. if (item.operationLog.opValue == 1) {
  111. color = "dash dash-lock redfont";
  112. } else {
  113. color = "dash dash-unlock greenfont";
  114. }
  115. } else {
  116. color = "dash dash-unlock greenfont";
  117. }
  118. return color;
  119. }
  120. //表格列表显示
  121. if ($scope.repairMain.valueconfig == 1) {//报修主体为报修人
  122. $scope.gridOptions.columnDefs = [
  123. {
  124. name: 'id',
  125. displayName: '',
  126. width: 35,
  127. cellTemplate: '<div>' +
  128. '<div class="ui-grid-cell-contents" tooltip={{grid.appScope.transfertip(row.entity)}} tooltip-placement="right"><i style="font-size: 18px !important;" class="{{grid.appScope.transferColor(row.entity)}}"></i></div></div>' +
  129. '</div>'
  130. },
  131. {
  132. name: 'item',
  133. displayName: '序号',
  134. width: 50,
  135. cellTemplate: '<div>' +
  136. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  137. '</div>'
  138. }, {
  139. name: 'bxcode',
  140. displayName: '报修单号',
  141. width: 150,
  142. cellTemplate: '<div>' +
  143. '<div class="ui-grid-cell-contents">{{row.entity.bxcode}}</div>' +
  144. '</div>'
  145. }, {
  146. name: 'incidentDescription',
  147. displayName: '事件描述',
  148. width: 150,
  149. cellTemplate: '<div>' +
  150. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.incidentDescription}}</div>' +
  151. '</div>'
  152. },
  153. // {
  154. // name: 'incidentDescription1',
  155. // displayName: '报修科室',
  156. // width: '12%',
  157. // cellTemplate: '<div>' +
  158. // '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.incidentDescription1}}</div>' +
  159. // '</div>'
  160. // },
  161. {
  162. name: 'address',
  163. displayName: '故障地点',
  164. width: 150,
  165. cellTemplate: '<div>' +
  166. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.place.place||""}} {{row.entity.address}}</div>' +
  167. '</div>'
  168. }, {
  169. name: 'contacts',
  170. displayName: '联系人',
  171. width: 150,
  172. cellTemplate: '<div>' +
  173. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.contacts}}</div>' +
  174. '</div>'
  175. }, {
  176. name: 'requester.account',
  177. displayName: '学工号',
  178. width: 150,
  179. cellTemplate: '<div>' +
  180. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.requester.account}}</div>' +
  181. '</div>'
  182. }, {
  183. name: 'contactsInformation',
  184. displayName: '联系电话',
  185. width: 150,
  186. cellTemplate: '<div>' +
  187. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.contactsInformation}}</div>' +
  188. '</div>'
  189. }, {
  190. name: 'incident.acceptUser.name',
  191. displayName: '受理人',
  192. width: 150,
  193. cellTemplate: '<div>' +
  194. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" ng-if="row.entity.incident&&row.entity.incident.acceptUser">{{row.entity.incident.acceptUser.name||""}}</div>' +
  195. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" ng-if="row.entity.rejectUser">{{row.entity.rejectUser.name||""}}</div>' +
  196. '</div>'
  197. },
  198. // {
  199. // name: 'requester.name',
  200. // displayName: '报修人',
  201. // width: '10%',
  202. // cellTemplate: '<div>' +
  203. // '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.requester.name}}</div>' +
  204. // '</div>'
  205. // },
  206. {
  207. name: 'serviceState.name',
  208. displayName: '状态',
  209. width: 150,
  210. cellTemplate: '<div>' +
  211. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.serviceState.name}}</div>' +
  212. '</div>'
  213. }, {
  214. name: 'createTime',
  215. displayName: '报修时间',
  216. width: 150,
  217. cellTemplate: '<div>' +
  218. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.createTime)}}</div>' +
  219. '</div>'
  220. // },
  221. // {
  222. // name: '生成事件',
  223. // width: 80,
  224. // cellTemplate: '<div class="links cl-effect-1">' +
  225. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="新建事件" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
  226. // '</div>'
  227. },
  228. {
  229. name: '操作',
  230. width: 200,
  231. cellTemplate: '<wechatoperator item="row.entity" colobject="col">',
  232. enableFiltering: false
  233. }
  234. ];
  235. // 是否展示资产
  236. if ($scope.wxIncidentWithCmdb == 1) {
  237. let index = $scope.gridOptions.columnDefs.findIndex(v => v.name == 'address');
  238. $scope.gridOptions.columnDefs.splice(index, 0, {
  239. name: 'assetId',
  240. displayName: '资产',
  241. width: 150
  242. })
  243. }
  244. } else if ($scope.repairMain.valueconfig == 2) {//报修主体为科室
  245. $scope.gridOptions.columnDefs = [{
  246. name: 'item',
  247. displayName: '序号',
  248. width: 50,
  249. cellTemplate: '<div>' +
  250. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  251. '</div>'
  252. }, {
  253. name: 'bxcode',
  254. displayName: '报修单号',
  255. width: 150,
  256. cellTemplate: '<div>' +
  257. '<div class="ui-grid-cell-contents">{{row.entity.bxcode}}</div>' +
  258. '</div>'
  259. }, {
  260. name: 'incidentDescription',
  261. displayName: '事件描述',
  262. width: 150,
  263. cellTemplate: '<div>' +
  264. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.incidentDescription}}</div>' +
  265. '</div>'
  266. },
  267. // {
  268. // name: 'incidentDescription1',
  269. // displayName: '报修科室',
  270. // width: '12%',
  271. // cellTemplate: '<div>' +
  272. // '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.incidentDescription1}}</div>' +
  273. // '</div>'
  274. // },
  275. {
  276. name: 'address',
  277. displayName: '故障地点',
  278. width: 150,
  279. cellTemplate: '<div>' +
  280. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.place.place||""}} {{row.entity.address}}</div>' +
  281. '</div>'
  282. }, {
  283. name: 'departmentDTO.dept',
  284. displayName: '报修科室',
  285. width: 150,
  286. cellTemplate: '<div>' +
  287. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.departmentDTO.dept}}</div>' +
  288. '</div>'
  289. }, {
  290. name: 'contacts',
  291. displayName: '联系人',
  292. width: 150,
  293. cellTemplate: '<div>' +
  294. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.contacts}}</div>' +
  295. '</div>'
  296. }, {
  297. name: 'contactsInformation',
  298. displayName: '联系电话',
  299. width: 150,
  300. cellTemplate: '<div>' +
  301. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.contactsInformation}}</div>' +
  302. '</div>'
  303. },
  304. // {
  305. // name: 'requester.name',
  306. // displayName: '报修人',
  307. // width: '10%',
  308. // cellTemplate: '<div>' +
  309. // '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.requester.name}}</div>' +
  310. // '</div>'
  311. // },
  312. {
  313. name: 'serviceState.name',
  314. displayName: '状态',
  315. width: 150,
  316. cellTemplate: '<div>' +
  317. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.serviceState.name}}</div>' +
  318. '</div>'
  319. }, {
  320. name: 'createTime',
  321. displayName: '报修时间',
  322. width: 150,
  323. cellTemplate: '<div>' +
  324. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.createTime)}}</div>' +
  325. '</div>'
  326. // },
  327. // {
  328. // name: '生成事件',
  329. // width: 80,
  330. // cellTemplate: '<div class="links cl-effect-1">' +
  331. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="新建事件" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
  332. // '</div>'
  333. },
  334. {
  335. name: '操作',
  336. width: 200,
  337. cellTemplate: '<wechatoperator item="row.entity" colobject="col">',
  338. enableFiltering: false
  339. }
  340. ];
  341. }
  342. $scope.value = 10;
  343. $scope.decrement = function () {
  344. $scope.value = $scope.value - 1;
  345. };
  346. $scope.searchkeys = {};
  347. //点击切换
  348. $scope.onChange = function (searchType) {
  349. $scope.searchstate = searchType;
  350. // defaultFilterData = $scope.memoryfilterData;
  351. if (searchType) {
  352. $scope.fileData.wxincident.serviceState = { "id": searchType };
  353. } else {
  354. delete $scope.fileData.wxincident.serviceState
  355. }
  356. // sessionStorage.searchchart.state = searchType;
  357. $scope.refreshData('expand-right', $scope.fileData);
  358. }
  359. $scope.record = function () {
  360. api_text.record($rootScope.takes).then(function (data) {
  361. if (data.errno == 0) {
  362. $scope.busy = false;
  363. }
  364. })
  365. };
  366. $scope.transferTime = function (time) {
  367. return moment(time).format('YYYY-MM-DD HH:mm');
  368. }
  369. $scope.parameters = null;
  370. $scope.open = function ($event) {
  371. $event.preventDefault();
  372. $event.stopPropagation();
  373. $scope.opened = !$scope.opened;
  374. };
  375. $scope.endOpen = function ($event) {
  376. $event.preventDefault();
  377. $event.stopPropagation();
  378. $scope.startOpened = false;
  379. $scope.endOpened = !$scope.endOpened;
  380. };
  381. $scope.startOpen = function ($event) {
  382. $event.preventDefault();
  383. $event.stopPropagation();
  384. $scope.endOpened = false;
  385. $scope.startOpened = !$scope.startOpened;
  386. };
  387. var getUser = function (fieldatas) {
  388. api_user_data.fetchDataList('requester', fieldatas).then(function (data) {
  389. $scope.requester = data.list;
  390. });
  391. }
  392. $scope.onChangehandling = function (key) {
  393. var filuser = {
  394. "idx": 0,
  395. "sum": 10,
  396. "requester": {
  397. "name": key
  398. }
  399. }
  400. getUser(filuser);
  401. }
  402. getUser({
  403. "idx": 0,
  404. "sum": 10
  405. });
  406. //搜索
  407. $scope.chiceIncident = function (item) {
  408. // var fildata = {};
  409. // if (sessionStorage.searchincident) {
  410. // fildata = JSON.parse(sessionStorage.getItem("searchchart"));
  411. // $scope.gridOptions.paginationCurrentPage = 1;
  412. // fildata.idx = 0;
  413. // } else {
  414. // fildata = defaultFilterData;
  415. // }
  416. // if (!fildata.incident) {
  417. // fildata['wxincident'] = {};
  418. // }
  419. // if (item.createTime) {
  420. // item.createTime = moment(item.createTime).format('YYYY-MM-DD HH:mm:ss');
  421. // }
  422. // if (item.createTimeEnd) {
  423. // item.createTimeEnd = moment(new Date(item.createTimeEnd).getTime() + 86399999).format('YYYY-MM-DD HH:mm:ss');
  424. // }
  425. // angular.extend(fildata.wxincident, item)
  426. // sessionStorage['searchchart'] = angular.copy(JSON.stringify(fildata));
  427. // $scope.memoryfilterData = fildata;
  428. if ($scope.fileData.wxincident.createTime) {
  429. $scope.fileData.wxincident.createTime = moment($scope.fileData.wxincident.createTime).format('YYYY-MM-DD HH:mm:ss');
  430. }
  431. if ($scope.fileData.wxincident.createTimeEnd) {
  432. $scope.fileData.wxincident.createTimeEnd = moment($scope.fileData.wxincident.createTimeEnd).format('YYYY-MM-DD HH:mm:ss');
  433. }
  434. $scope.refreshData('expand-right', $scope.fileData);
  435. }
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  439. var filtersData = $scope.memoryfilterData;
  440. filtersData.idx = newPage - 1;
  441. filtersData.sum = pageSize;
  442. $scope.fileData.idx = newPage - 1;
  443. $scope.fileData.sum = pageSize;
  444. $scope.refreshData('expand-right', $scope.fileData);
  445. // if (JSON.parse(sessionStorage.getItem("searchchart")).idx != filtersData.idx) {
  446. // $scope.refreshData('expand-right', filtersData);
  447. // }
  448. // $scope.refreshData('expand-right', filtersData);
  449. });
  450. $scope.selected = {
  451. items: []
  452. }
  453. };
  454. $scope.memoryfilterData = defaultFilterData = {
  455. // "assignee":$rootScope.user.id,
  456. // "candidateGroups":$rootScope.user.group[0].id,
  457. "idx": 0,
  458. "wxincident": {
  459. "serviceState": { "id": 1650 }
  460. },
  461. "sum": mun
  462. };
  463. //收集搜索数据
  464. $scope.fileData = {
  465. "idx": 0,
  466. "wxincident": {
  467. "serviceState": { "id": 1650 }
  468. },
  469. "sum": 10
  470. }
  471. $scope.selectRowFunction = function (data) {
  472. var formdata = {
  473. 'model': {
  474. 'incident': {
  475. 'requester': data.requester,
  476. 'area': data.place.area,
  477. 'place': data.place,
  478. 'houseNumber': data.address,
  479. 'contacts': data.contacts,
  480. 'contactsInformation': data.contactsInformation,
  481. // 'category': data.wxIncidentClassifyDTO.category,
  482. 'description': data.incidentDescription,
  483. 'source': {
  484. 'id': 1549
  485. },
  486. 'sourceType': data.sourceType,
  487. 'fileUrl': data.fileUrl
  488. },
  489. 'requestershow': data.requester,
  490. 'flow': data.id
  491. }
  492. }
  493. // if (data.requester.requesterTypeDTO && data.requester.requesterTypeDTO.id == 2) {
  494. // angular.extend(formdata.model.incident, { 'priority': { 'id': 2 } });
  495. // }
  496. $state.go('app.incident.chart', {
  497. 'model': JSON.stringify(formdata)
  498. });
  499. };
  500. $scope.lookFunction = function (data) {
  501. // // var data = row.entity;
  502. // var formdata = {
  503. // 'model': {
  504. // 'incident': {
  505. // 'requester': data.requester,
  506. // 'area': data.place.area.area,
  507. // 'place': data.place.place,
  508. // 'houseNumber': data.address,
  509. // 'contacts': data.contacts,
  510. // 'contactsInformation': data.contactsInformation,
  511. // // 'category': data.wxIncidentClassifyDTO.category,
  512. // 'incidentState':data.incidentState,
  513. // 'description': data.incidentDescription,
  514. // 'source': {
  515. // 'id': 1549
  516. // },
  517. // 'sourceType': data.sourceType,
  518. // 'fileUrl': data.fileUrl
  519. // },
  520. // 'requestershow': data.requester,
  521. // 'flow': data.id
  522. // }
  523. // }
  524. // var modelfile = {
  525. // model: {
  526. // incident: data
  527. // }
  528. // };
  529. // if (data.incidentState.name == "未受理") {
  530. // angular.extend(modelfile.model, {
  531. // 'gourl': 'app.incident.chart',
  532. // 'state_model': formdata
  533. // })
  534. // angular.extend(modelfile.model.incident, {
  535. // status: 1
  536. // })
  537. // } else {
  538. // angular.extend(modelfile.model.incident, {
  539. // status: 0
  540. // })
  541. // }
  542. // $state.go('app.desk.form_editor', {
  543. // formKey: 'desk_detail',
  544. // service: 'api_user_data',
  545. // model: JSON.stringify(modelfile)
  546. // });
  547. $state.go('app.desk.detail', {
  548. model: JSON.stringify(data)
  549. });
  550. };
  551. $scope.toHandleFunction = function (data) {
  552. // var data = row.entity;
  553. console.log(data)
  554. var formdata = {
  555. 'model': {
  556. 'incident': {
  557. 'requester': data.requester,
  558. // 'area': data.place.area.area,
  559. // 'place': data.place.place,
  560. 'houseNumber': data.address,
  561. 'contacts': data.contacts,
  562. 'contactsInformation': data.contactsInformation,
  563. // 'category': data.wxIncidentClassifyDTO.category,
  564. 'incidentState': data.incidentState,
  565. 'description': data.incidentDescription,
  566. 'source': {
  567. 'id': 1549
  568. },
  569. 'sourceType': data.sourceType,
  570. 'fileUrl': data.fileUrl
  571. },
  572. 'requestershow': data.requester,
  573. 'flow': data.id,
  574. 'retractReason': data.retractReason
  575. }
  576. }
  577. var modelfile = {
  578. model: {
  579. incident: data
  580. }
  581. };
  582. // if (data.incidentState.name == "未受理") {
  583. angular.extend(modelfile.model, {
  584. 'gourl': 'app.incident.chart',
  585. 'state_model': formdata
  586. })
  587. angular.extend(modelfile.model.incident, {
  588. status: 1
  589. })
  590. // } else {
  591. // angular.extend(modelfile.model.incident, {
  592. // status: 0
  593. // })
  594. // }
  595. $state.go('app.desk.form_editor', {
  596. formKey: 'desk_detail',
  597. service: 'api_user_data',
  598. model: JSON.stringify(modelfile)
  599. });
  600. };
  601. $scope.seeIncidentFunction = function (data) {
  602. // console.log(data);
  603. $state.go('app.incident.detail', {
  604. formKey: 'incident_back',
  605. pdKey: 'incident',
  606. dataId: data.incident.id,
  607. taskId: data.incident.taskId,
  608. processInstanceId: data.incident.processInstanceId,
  609. isChart: "ok"
  610. });
  611. }
  612. //重置
  613. $scope.cleanItem = function () {
  614. delete $scope.fileData.wxincident.contacts;
  615. delete $scope.fileData.wxincident.contactsInformation;
  616. delete $scope.fileData.wxincident.createTime;
  617. delete $scope.fileData.wxincident.createTimeEnd;
  618. delete $scope.fileData.wxincident.departmentDTO;
  619. $scope.ksModel = '';
  620. $scope.refreshData('expand-right', $scope.fileData);
  621. }
  622. // $scope.followFunction = function(data){
  623. // //console.log('data='+JSON.stringify(data));
  624. // $state.go('app.detail', { formKey:'statusform', pdKey:'incident', dataId: data.id,processInstanceId: data.processInstanceId});
  625. // };
  626. // $scope.onDblClick = function (row) {
  627. // var data = row.entity;
  628. // var formdata = {
  629. // 'model': {
  630. // 'incident': {
  631. // 'requester': data.requester,
  632. // 'area': data.area,
  633. // 'place': data.place,
  634. // 'houseNumber': data.address,
  635. // 'contacts': data.contacts,
  636. // 'contactsInformation': data.contactsInformation,
  637. // // 'category': data.wxIncidentClassifyDTO.category,
  638. // 'description': data.incidentDescription,
  639. // 'source': {
  640. // 'id': 4
  641. // },
  642. // 'sourceType': data.sourceType,
  643. // 'fileUrl': data.fileUrl
  644. // },
  645. // 'requestershow': data.requester,
  646. // 'flow': data.id
  647. // }
  648. // }
  649. // var modelfile = {
  650. // model: {
  651. // incident: row.entity
  652. // }
  653. // };
  654. // if (row.entity.state == "未受理") {
  655. // angular.extend(modelfile.model, {
  656. // 'gourl': 'app.incident.chart',
  657. // 'state_model': formdata
  658. // })
  659. // angular.extend(modelfile.model.incident, {
  660. // status: 1
  661. // })
  662. // } else {
  663. // angular.extend(modelfile.model.incident, {
  664. // status: 0
  665. // })
  666. // }
  667. // $state.go('app.desk.form_editor', {
  668. // formKey: 'desk_detail',
  669. // service: 'api_user_data',
  670. // model: JSON.stringify(modelfile)
  671. // });
  672. // };
  673. var defaultFilterData = {
  674. // "assignee":$rootScope.user.id,
  675. // "candidateGroups":$rootScope.user.group[0].id,
  676. "idx": 0,
  677. "wxincident": {
  678. "serviceState": { "id": 1650 }
  679. },
  680. "sum": mun
  681. };
  682. $scope.ldloading = {};
  683. $scope.refreshData = function (style, filterData) {
  684. $scope.ldloading[style.replace('-', '_')] = true;
  685. // if (angular.isUndefined(filterData)) {
  686. // filterData = defaultFilterData;
  687. // }
  688. if (angular.isUndefined(filterData)) {
  689. // if (sessionStorage.searchchart) {
  690. // filterData = JSON.parse(sessionStorage.getItem("searchchart"));
  691. // $scope.searchkeys = filterData.wxincident;
  692. // // $scope.searchstate = filterData.state;
  693. // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  694. // $scope.searchstate = filterData.wxincident.searchType;
  695. // } else {
  696. filterData = defaultFilterData;
  697. // }
  698. }
  699. $scope.myData = [];
  700. $scope.gridOptions['sum'] = filterData.sum;
  701. sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData));
  702. //科室列表选中数据,请求参数判断
  703. if ($scope.repairMain.valueconfig == 2 && $scope.ksModel != '') {//报修科室且不是空字符
  704. $scope.fileData.wxincident.departmentDTO = {
  705. dept: $scope.ksModel
  706. }
  707. }
  708. //搜索接口
  709. api_bpm_data.fetchDataList("wxincident", filterData).then(function (data) {
  710. // console.log(filterData)
  711. var myData = Restangular.stripRestangular(data);
  712. for (var i = 0; i < myData.list.length; i++) {
  713. myData.list[i].createTime = moment(myData.list[i].createTime).format('YYYY-MM-DD HH:mm:ss')
  714. }
  715. $scope.gridOptions['totalItems'] = myData.totalNum;
  716. $scope.myData = myData.list;
  717. for (var i = 0; i < $scope.myData.length; i++) {
  718. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  719. }
  720. // console.log($scope.myData)
  721. $scope.ldloading[style.replace('-', '_')] = false;
  722. }, function () {
  723. $scope.ldloading[style.replace('-', '_')] = false;
  724. });
  725. };
  726. $scope.refreshData2 = function (style, filterData) {
  727. $scope.ldloading[style.replace('-', '_')] = true;
  728. // if (angular.isUndefined(filterData)) {
  729. // filterData = defaultFilterData;
  730. // }
  731. if (angular.isUndefined(filterData)) {
  732. // if (sessionStorage.searchchart) {
  733. // filterData = JSON.parse(sessionStorage.getItem("searchchart"));
  734. // $scope.searchkeys = filterData.wxincident;
  735. // // $scope.searchstate = filterData.state;
  736. // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  737. // $scope.searchstate = filterData.wxincident.searchType;
  738. // } else {
  739. filterData = defaultFilterData;
  740. // }
  741. }
  742. // $scope.myData = [];
  743. $scope.gridOptions['sum'] = filterData.sum;
  744. sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData));
  745. api_bpm_data.fetchDataList("wxincident", filterData).then(function (data) {
  746. console.log(222)
  747. var myData = Restangular.stripRestangular(data);
  748. for (var i = 0; i < myData.list.length; i++) {
  749. myData.list[i].createTime = moment(myData.list[i].createTime).format('YYYY-MM-DD HH:mm:ss')
  750. }
  751. $scope.gridOptions['totalItems'] = myData.totalNum;
  752. $scope.myData = myData.list;
  753. for (var i = 0; i < $scope.myData.length; i++) {
  754. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  755. }
  756. // console.log($scope.myData)
  757. $scope.ldloading[style.replace('-', '_')] = false;
  758. }, function () {
  759. $scope.ldloading[style.replace('-', '_')] = false;
  760. });
  761. };
  762. $scope.timer = $interval(function () {
  763. $scope.refreshData2('expand-right', $scope.fileData);
  764. }, $rootScope.refreshTime);
  765. console.log($state.params);
  766. if ($state.params.tab) {
  767. if ($state.params.tab == '-1') {
  768. $scope.searchstate = '';
  769. $scope.fileData.wxincident = {};
  770. } else {
  771. $scope.searchstate = $state.params.tab;
  772. $scope.fileData.wxincident.serviceState.id = $scope.searchstate;
  773. }
  774. } else {
  775. //默认未受理
  776. $scope.searchstate = 1650;
  777. if (sessionStorage.getItem('jry_data')) {
  778. $scope.searchstate = sessionStorage.getItem('jry_data');
  779. $scope.fileData.wxincident.serviceState.id = sessionStorage.getItem('jry_data');
  780. }
  781. }
  782. $scope.$on('$destroy', function () {
  783. sessionStorage.setItem('jry_data', $scope.searchstate);
  784. $interval.cancel($scope.timer)
  785. });
  786. $scope.refreshData('expand-right', $scope.fileData);
  787. }]);
  788. app.controller('Wechatoperator', ['$rootScope', '$http', '$scope', '$modal', 'api_user_data', function ($rootScope, $http, $scope, $modal, api_user_data) {
  789. $scope.handle = false;
  790. $scope.see = false;
  791. $scope.toHandle = false;
  792. var loginUser = $rootScope.user;
  793. // 是否是服务台经理
  794. $scope.isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0;
  795. // 是否显示解除锁定
  796. $scope.isUnLock = false;
  797. console.log($scope.item)
  798. if ($scope.item.operationLog) {
  799. $scope.isUnLock = ($scope.item.operationLog.userId == loginUser.id) && ($scope.item.operationLog.opValue == 1);
  800. } else {
  801. $scope.isUnLock = false;
  802. }
  803. // 是否显示处理--锁定相关的操作
  804. $scope.isChuli = false;
  805. if ($scope.isFuwutaijingli) {
  806. //如果有服务台经理角色
  807. $scope.isChuli = true;
  808. } else {
  809. //如果没有服务台经理角色
  810. if ($scope.item.operationLog) {
  811. if ($scope.item.operationLog.opValue == 1) {
  812. //如果锁定
  813. $scope.isChuli = $scope.item.operationLog.userId == loginUser.id;
  814. } else {
  815. //如果没锁定
  816. $scope.isChuli = true;
  817. }
  818. } else {
  819. $scope.isChuli = true;
  820. }
  821. }
  822. $scope.chuli = false;
  823. for (var i = 0; i < loginUser.menu.length; i++) {
  824. if (loginUser.menu[i].link == "weixinbaozhang_chuli") {
  825. $scope.chuli = true
  826. }
  827. }
  828. if ($scope.item.serviceState.name == "已受理") {
  829. $scope.toHandle = true;
  830. } else {
  831. $scope.toHandle = false;
  832. }
  833. if ($scope.item.serviceState.name == "未受理") {
  834. $scope.handle = true;
  835. } else {
  836. $scope.handle = false;
  837. }
  838. if ($scope.item.serviceState.name == "已受理" || $scope.item.serviceState.name == "不受理" || $scope.item.serviceState.name == "未受理") {
  839. $scope.see = true;
  840. } else {
  841. $scope.see = false;
  842. }
  843. $scope.edit = function () {
  844. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  845. // $scope.doEdit($scope.item.id);
  846. }
  847. //查看,查看详情
  848. $scope.look = function () {
  849. $scope.colobject.grid.appScope.lookFunction($scope.item);
  850. // $scope.doEdit($scope.item.id);
  851. }
  852. //处理
  853. $scope.handleFn = function () {
  854. console.log($scope.item)
  855. // $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  856. //是否包含服务台经理角色
  857. var isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0;
  858. if (!isFuwutaijingli) {
  859. if ($scope.item.operationLog) {
  860. //有锁定操作记录的
  861. var p1 = {
  862. idx: 0,
  863. sum: 1000,
  864. operationLog: {
  865. id: $scope.item.operationLog.id,
  866. extra1: $scope.item.id,
  867. opType: 'wxincidentLock'
  868. }
  869. };
  870. api_user_data.fetchDataList('operationLog', p1).then(function (result) {
  871. if (result.status == 200) {
  872. var opValue = result.list[0].opValue;//查询锁定状态
  873. var userName = result.list[0].userName;//查询锁定人
  874. var userId = result.list[0].userId;//查询锁定人ID
  875. if (opValue == 1&&userId!=loginUser.id) {
  876. //如果锁定了,并不是锁定人操作
  877. $modal.open({
  878. templateUrl: 'assets/views/delete.html',
  879. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  880. $scope.title = '提示';
  881. $scope.connect = '该报修已被【' + userName + '】锁定!';
  882. $scope.yesFlag = true;
  883. //选择“取消”或“确定”
  884. $scope.cancel = function () {
  885. $modalInstance.dismiss('cancel');
  886. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  887. };
  888. },
  889. size: 'sm',
  890. resolve: {
  891. scope: function () {
  892. return $scope;
  893. }
  894. }
  895. });
  896. } else if(opValue == 1&&userId==loginUser.id){
  897. //如果锁定了,并是锁定人操作
  898. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  899. }else{
  900. //如果没有锁定
  901. $scope.operateUnLock($scope.item.operationLog.id)
  902. }
  903. }
  904. })
  905. } else {
  906. //没有锁定记录的
  907. $scope.operateUnLock();
  908. }
  909. } else {
  910. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  911. }
  912. // $scope.doEdit($scope.item.id);
  913. }
  914. //是否锁定,id是日志ID,有是修改,没有是新增
  915. $scope.operateUnLock = function (id) {
  916. $modal.open({
  917. templateUrl: 'assets/views/delete.html',
  918. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  919. $scope.title = '提示';
  920. $scope.connect = '是否锁定?锁定后其他人(服务台经理除外)无法操作此报修!';
  921. $scope.noFlag = true;
  922. //选择“是”
  923. $scope.yes = function () {
  924. if (scope.item) {
  925. var postData = {
  926. operationLog: {
  927. extra1: scope.item.id,
  928. userId: loginUser.id,
  929. userName: loginUser.name,
  930. opType: 'wxincidentLock',
  931. opValue: '1'
  932. }
  933. };
  934. if(id){
  935. postData.operationLog.id = id;
  936. }
  937. api_user_data.addData('operationLog', postData).then(function (response) {
  938. if (response.data) {
  939. $modalInstance.dismiss('cancel');
  940. SweetAlert.swal({
  941. title: "锁定成功!",
  942. type: "success",
  943. confirmButtonColor: "#007AFF"
  944. }, function () {
  945. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  946. });
  947. } else {
  948. SweetAlert.swal({
  949. title: "操作异常!",
  950. text: "系统异常,请稍后重试,或者联系管理员!",
  951. type: "error"
  952. });
  953. }
  954. })
  955. }
  956. };
  957. //选择“取消”
  958. $scope.cancel = function () {
  959. $modalInstance.dismiss('cancel');
  960. };
  961. //选择“否”
  962. $scope.no = function () {
  963. $modalInstance.dismiss('cancel');
  964. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  965. };
  966. },
  967. size: 'sm',
  968. resolve: {
  969. scope: function () {
  970. return $scope;
  971. }
  972. }
  973. });
  974. }
  975. //解锁
  976. $scope.unLock = function(){
  977. $modal.open({
  978. templateUrl: 'assets/views/delete.html',
  979. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  980. $scope.title = '提示';
  981. $scope.connect = '是否解锁?';
  982. $scope.noFlag = true;
  983. //选择“是”
  984. $scope.yes = function () {
  985. if (scope.item) {
  986. var postData = {
  987. operationLog: {
  988. id:scope.item.operationLog.id,
  989. extra1: scope.item.id,
  990. userId: loginUser.id,
  991. userName: loginUser.name,
  992. opType: 'wxincidentLock',
  993. opValue: '0'
  994. }
  995. };
  996. api_user_data.addData('operationLog', postData).then(function (response) {
  997. if (response.data) {
  998. $modalInstance.dismiss('cancel');
  999. SweetAlert.swal({
  1000. title: "解锁成功!",
  1001. type: "success",
  1002. confirmButtonColor: "#007AFF"
  1003. }, function () {
  1004. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  1005. });
  1006. } else {
  1007. SweetAlert.swal({
  1008. title: "操作异常!",
  1009. text: "系统异常,请稍后重试,或者联系管理员!",
  1010. type: "error"
  1011. });
  1012. }
  1013. })
  1014. }
  1015. };
  1016. //选择“取消”
  1017. $scope.cancel = function () {
  1018. $modalInstance.dismiss('cancel');
  1019. };
  1020. //选择“否”
  1021. $scope.no = function () {
  1022. $modalInstance.dismiss('cancel');
  1023. };
  1024. },
  1025. size: 'sm',
  1026. resolve: {
  1027. scope: function () {
  1028. return $scope;
  1029. }
  1030. }
  1031. });
  1032. }
  1033. //查看事件
  1034. $scope.seeIncident = function () {
  1035. $scope.colobject.grid.appScope.seeIncidentFunction($scope.item);
  1036. // $scope.doEdit($scope.item.id);
  1037. }
  1038. }]);
  1039. app.directive('wechatoperator', function () {
  1040. return {
  1041. restrict: 'E',
  1042. scope: {
  1043. item: '=',
  1044. colobject: '='
  1045. },
  1046. controller: 'Wechatoperator',
  1047. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  1048. // '<a ng-click="edit()" ng-show="{{handle}}" tooltip="生成事件" tooltip-placement="left">生成事件</a>' +
  1049. // '<a ng-click="edit()" class="bianjifont">生成事件</a>' +
  1050. '<a ng-click="handleFn()" ng-show="{{(handle&&chuli)&&isChuli}}" class="bianjifont">处理</a>' +
  1051. '<a ng-click="unLock()" ng-show="{{isUnLock}}" class="bianjifont">解除锁定</a>' +
  1052. '<a ng-click="look()" ng-show="{{see}}" class="bianjifont">查看</a>' +
  1053. // '<a ng-click="look()" ng-show="{{toHandle}}" class="bianjifont">查看详情</a>' +
  1054. '<a ng-click="seeIncident()" ng-show="{{toHandle}}" class="bianjifont">查看事件</a>' +
  1055. // '<a ng-click="look()" ng-show="{{handle}}" tooltip="查看" tooltip-placement="right"><i class="ti-eye"></i></a>' +
  1056. '</div>'
  1057. };
  1058. });
  1059. // app.factory('myFactory', function() {
  1060. // //定义factory返回对象
  1061. // var myServices = {};
  1062. // //定义参数对象
  1063. // var myObject = {};
  1064. // var _set = function(data) {
  1065. // myObject = data;
  1066. // };
  1067. // })