chartCtrl.js 44 KB

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