chartCtrl.js 45 KB

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