chartCtrl.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  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: 300,
  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: 300,
  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. if ($scope.fileData.wxincident.createTime) {
  422. $scope.fileData.wxincident.createTime = moment($scope.fileData.wxincident.createTime).format('YYYY-MM-DD HH:mm:ss');
  423. }
  424. if ($scope.fileData.wxincident.createTimeEnd) {
  425. $scope.fileData.wxincident.createTimeEnd = moment($scope.fileData.wxincident.createTimeEnd).format('YYYY-MM-DD HH:mm:ss');
  426. }
  427. $scope.refreshData('expand-right', $scope.fileData);
  428. }
  429. $scope.gridOptions.onRegisterApi = function (gridApi) {
  430. $scope.gridApi = gridApi;
  431. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  432. var filtersData = $scope.memoryfilterData;
  433. filtersData.idx = newPage - 1;
  434. filtersData.sum = pageSize;
  435. $scope.fileData.idx = newPage - 1;
  436. $scope.fileData.sum = pageSize;
  437. $scope.refreshData('expand-right', $scope.fileData);
  438. // if (JSON.parse(sessionStorage.getItem("searchchart")).idx != filtersData.idx) {
  439. // $scope.refreshData('expand-right', filtersData);
  440. // }
  441. // $scope.refreshData('expand-right', filtersData);
  442. });
  443. $scope.selected = {
  444. items: []
  445. }
  446. };
  447. $scope.memoryfilterData = defaultFilterData = {
  448. // "assignee":$rootScope.user.id,
  449. // "candidateGroups":$rootScope.user.group[0].id,
  450. "idx": 0,
  451. "wxincident": {
  452. "serviceState": { "id": 1650 }
  453. },
  454. "sum": mun
  455. };
  456. //收集搜索数据
  457. $scope.fileData = {
  458. "idx": 0,
  459. "wxincident": {
  460. "serviceState": { "id": 1650 }
  461. },
  462. "sum": 10
  463. }
  464. $scope.selectRowFunction = function (data) {
  465. var formdata = {
  466. 'model': {
  467. 'incident': {
  468. 'requester': data.requester,
  469. 'area': data.place.area,
  470. 'place': data.place,
  471. 'houseNumber': data.address,
  472. 'contacts': data.contacts,
  473. 'contactsInformation': data.contactsInformation,
  474. // 'category': data.wxIncidentClassifyDTO.category,
  475. 'description': data.incidentDescription,
  476. 'source': {
  477. 'id': 1549
  478. },
  479. 'sourceType': data.sourceType,
  480. 'fileUrl': data.fileUrl
  481. },
  482. 'requestershow': data.requester,
  483. 'flow': data.id
  484. }
  485. }
  486. // if (data.requester.requesterTypeDTO && data.requester.requesterTypeDTO.id == 2) {
  487. // angular.extend(formdata.model.incident, { 'priority': { 'id': 2 } });
  488. // }
  489. $state.go('app.incident.chart', {
  490. 'model': JSON.stringify(formdata)
  491. });
  492. };
  493. $scope.lookFunction = function (data) {
  494. // // var data = row.entity;
  495. // var formdata = {
  496. // 'model': {
  497. // 'incident': {
  498. // 'requester': data.requester,
  499. // 'area': data.place.area.area,
  500. // 'place': data.place.place,
  501. // 'houseNumber': data.address,
  502. // 'contacts': data.contacts,
  503. // 'contactsInformation': data.contactsInformation,
  504. // // 'category': data.wxIncidentClassifyDTO.category,
  505. // 'incidentState':data.incidentState,
  506. // 'description': data.incidentDescription,
  507. // 'source': {
  508. // 'id': 1549
  509. // },
  510. // 'sourceType': data.sourceType,
  511. // 'fileUrl': data.fileUrl
  512. // },
  513. // 'requestershow': data.requester,
  514. // 'flow': data.id
  515. // }
  516. // }
  517. // var modelfile = {
  518. // model: {
  519. // incident: data
  520. // }
  521. // };
  522. // if (data.incidentState.name == "未受理") {
  523. // angular.extend(modelfile.model, {
  524. // 'gourl': 'app.incident.chart',
  525. // 'state_model': formdata
  526. // })
  527. // angular.extend(modelfile.model.incident, {
  528. // status: 1
  529. // })
  530. // } else {
  531. // angular.extend(modelfile.model.incident, {
  532. // status: 0
  533. // })
  534. // }
  535. // $state.go('app.desk.form_editor', {
  536. // formKey: 'desk_detail',
  537. // service: 'api_user_data',
  538. // model: JSON.stringify(modelfile)
  539. // });
  540. $state.go('app.desk.detail', {
  541. model: JSON.stringify(data)
  542. });
  543. };
  544. $scope.toHandleFunction = function (data) {
  545. // var data = row.entity;
  546. console.log(data)
  547. var formdata = {
  548. 'model': {
  549. 'incident': {
  550. 'requester': data.requester,
  551. // 'area': data.place.area.area,
  552. // 'place': data.place.place,
  553. 'houseNumber': data.address,
  554. 'contacts': data.contacts,
  555. 'contactsInformation': data.contactsInformation,
  556. // 'category': data.wxIncidentClassifyDTO.category,
  557. 'incidentState': data.incidentState,
  558. 'description': data.incidentDescription,
  559. 'source': {
  560. 'id': 1549
  561. },
  562. 'sourceType': data.sourceType,
  563. 'fileUrl': data.fileUrl
  564. },
  565. 'requestershow': data.requester,
  566. 'flow': data.id,
  567. 'retractReason': data.retractReason
  568. }
  569. }
  570. var modelfile = {
  571. model: {
  572. incident: data
  573. }
  574. };
  575. // if (data.incidentState.name == "未受理") {
  576. angular.extend(modelfile.model, {
  577. 'gourl': 'app.incident.chart',
  578. 'state_model': formdata
  579. })
  580. angular.extend(modelfile.model.incident, {
  581. status: 1
  582. })
  583. // } else {
  584. // angular.extend(modelfile.model.incident, {
  585. // status: 0
  586. // })
  587. // }
  588. $state.go('app.desk.form_editor', {
  589. formKey: 'desk_detail',
  590. service: 'api_user_data',
  591. model: JSON.stringify(modelfile)
  592. });
  593. };
  594. $scope.seeIncidentFunction = function (data) {
  595. // console.log(data);
  596. $state.go('app.incident.detail', {
  597. formKey: 'incident_back',
  598. pdKey: 'incident',
  599. dataId: data.incident.id,
  600. taskId: data.incident.taskId,
  601. processInstanceId: data.incident.processInstanceId,
  602. isChart: "ok"
  603. });
  604. }
  605. //重置
  606. $scope.cleanItem = function () {
  607. delete $scope.fileData.wxincident.contacts;
  608. delete $scope.fileData.wxincident.contactsInformation;
  609. delete $scope.fileData.wxincident.createTime;
  610. delete $scope.fileData.wxincident.createTimeEnd;
  611. delete $scope.fileData.wxincident.departmentDTO;
  612. delete $scope.fileData.wxincident.sourceType;
  613. $scope.seiminObj = null;
  614. $scope.ksModel = '';
  615. $scope.refreshData('expand-right', $scope.fileData);
  616. }
  617. // $scope.followFunction = function(data){
  618. // //console.log('data='+JSON.stringify(data));
  619. // $state.go('app.detail', { formKey:'statusform', pdKey:'incident', dataId: data.id,processInstanceId: data.processInstanceId});
  620. // };
  621. // $scope.onDblClick = function (row) {
  622. // var data = row.entity;
  623. // var formdata = {
  624. // 'model': {
  625. // 'incident': {
  626. // 'requester': data.requester,
  627. // 'area': data.area,
  628. // 'place': data.place,
  629. // 'houseNumber': data.address,
  630. // 'contacts': data.contacts,
  631. // 'contactsInformation': data.contactsInformation,
  632. // // 'category': data.wxIncidentClassifyDTO.category,
  633. // 'description': data.incidentDescription,
  634. // 'source': {
  635. // 'id': 4
  636. // },
  637. // 'sourceType': data.sourceType,
  638. // 'fileUrl': data.fileUrl
  639. // },
  640. // 'requestershow': data.requester,
  641. // 'flow': data.id
  642. // }
  643. // }
  644. // var modelfile = {
  645. // model: {
  646. // incident: row.entity
  647. // }
  648. // };
  649. // if (row.entity.state == "未受理") {
  650. // angular.extend(modelfile.model, {
  651. // 'gourl': 'app.incident.chart',
  652. // 'state_model': formdata
  653. // })
  654. // angular.extend(modelfile.model.incident, {
  655. // status: 1
  656. // })
  657. // } else {
  658. // angular.extend(modelfile.model.incident, {
  659. // status: 0
  660. // })
  661. // }
  662. // $state.go('app.desk.form_editor', {
  663. // formKey: 'desk_detail',
  664. // service: 'api_user_data',
  665. // model: JSON.stringify(modelfile)
  666. // });
  667. // };
  668. var defaultFilterData = {
  669. // "assignee":$rootScope.user.id,
  670. // "candidateGroups":$rootScope.user.group[0].id,
  671. "idx": 0,
  672. "wxincident": {
  673. "serviceState": { "id": 1650 }
  674. },
  675. "sum": mun
  676. };
  677. $scope.ldloading = {};
  678. $scope.refreshData = function (style, filterData) {
  679. $scope.ldloading[style.replace('-', '_')] = true;
  680. // if (angular.isUndefined(filterData)) {
  681. // filterData = defaultFilterData;
  682. // }
  683. if (angular.isUndefined(filterData)) {
  684. // if (sessionStorage.searchchart) {
  685. // filterData = JSON.parse(sessionStorage.getItem("searchchart"));
  686. // $scope.searchkeys = filterData.wxincident;
  687. // // $scope.searchstate = filterData.state;
  688. // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  689. // $scope.searchstate = filterData.wxincident.searchType;
  690. // } else {
  691. filterData = defaultFilterData;
  692. // }
  693. }
  694. $scope.myData = [];
  695. $scope.gridOptions['sum'] = filterData.sum;
  696. //科室列表选中数据,请求参数判断
  697. if ($scope.repairMain.valueconfig == 2 && $scope.ksModel != '') {//报修科室且不是空字符
  698. $scope.fileData.wxincident.departmentDTO = {
  699. dept: $scope.ksModel
  700. }
  701. }
  702. // 根据权限查询
  703. if($rootScope.user.duty){
  704. // 当前的所属责任科室
  705. filterData.wxincident.duty = $rootScope.user.duty;
  706. }else if($rootScope.user.branch){
  707. // 当前的所属院区
  708. filterData.wxincident.branch = $rootScope.user.branch.id;
  709. }
  710. sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData));
  711. //搜索接口
  712. api_bpm_data.fetchDataList("wxincident", filterData).then(function (data) {
  713. // console.log(filterData)
  714. var myData = Restangular.stripRestangular(data);
  715. for (var i = 0; i < myData.list.length; i++) {
  716. myData.list[i].createTime = moment(myData.list[i].createTime).format('YYYY-MM-DD HH:mm:ss')
  717. }
  718. $scope.gridOptions['totalItems'] = myData.totalNum;
  719. $scope.myData = myData.list;
  720. for (var i = 0; i < $scope.myData.length; i++) {
  721. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  722. }
  723. // console.log($scope.myData)
  724. $scope.ldloading[style.replace('-', '_')] = false;
  725. }, function () {
  726. $scope.ldloading[style.replace('-', '_')] = false;
  727. });
  728. };
  729. $scope.refreshData2 = function (style, filterData) {
  730. $scope.ldloading[style.replace('-', '_')] = true;
  731. // if (angular.isUndefined(filterData)) {
  732. // filterData = defaultFilterData;
  733. // }
  734. if (angular.isUndefined(filterData)) {
  735. // if (sessionStorage.searchchart) {
  736. // filterData = JSON.parse(sessionStorage.getItem("searchchart"));
  737. // $scope.searchkeys = filterData.wxincident;
  738. // // $scope.searchstate = filterData.state;
  739. // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  740. // $scope.searchstate = filterData.wxincident.searchType;
  741. // } else {
  742. filterData = defaultFilterData;
  743. // }
  744. }
  745. // $scope.myData = [];
  746. $scope.gridOptions['sum'] = filterData.sum;
  747. // 根据权限查询
  748. if($rootScope.user.duty){
  749. // 当前的所属责任科室
  750. filterData.wxincident.duty = $rootScope.user.duty;
  751. }else if($rootScope.user.branch){
  752. // 当前的所属院区
  753. filterData.wxincident.branch = $rootScope.user.branch.id;
  754. }
  755. sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData));
  756. api_bpm_data.fetchDataList("wxincident", filterData).then(function (data) {
  757. console.log(222)
  758. var myData = Restangular.stripRestangular(data);
  759. for (var i = 0; i < myData.list.length; i++) {
  760. myData.list[i].createTime = moment(myData.list[i].createTime).format('YYYY-MM-DD HH:mm:ss')
  761. }
  762. $scope.gridOptions['totalItems'] = myData.totalNum;
  763. $scope.myData = myData.list;
  764. for (var i = 0; i < $scope.myData.length; i++) {
  765. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  766. }
  767. // console.log($scope.myData)
  768. $scope.ldloading[style.replace('-', '_')] = false;
  769. }, function () {
  770. $scope.ldloading[style.replace('-', '_')] = false;
  771. });
  772. };
  773. $scope.timer = $interval(function () {
  774. $scope.refreshData2('expand-right', $scope.fileData);
  775. }, $rootScope.refreshTime);
  776. console.log($state.params);
  777. if ($state.params.tab) {
  778. if ($state.params.tab == '-1') {
  779. $scope.searchstate = '';
  780. $scope.fileData.wxincident = {};
  781. } else {
  782. $scope.searchstate = $state.params.tab;
  783. $scope.fileData.wxincident.serviceState.id = $scope.searchstate;
  784. }
  785. } else {
  786. //默认未受理
  787. $scope.searchstate = 1650;
  788. if (sessionStorage.getItem('jry_data')) {
  789. $scope.searchstate = sessionStorage.getItem('jry_data');
  790. $scope.fileData.wxincident.serviceState.id = sessionStorage.getItem('jry_data');
  791. }
  792. }
  793. $scope.$on('$destroy', function () {
  794. sessionStorage.setItem('jry_data', $scope.searchstate);
  795. $interval.cancel($scope.timer)
  796. });
  797. $scope.refreshData('expand-right', $scope.fileData);
  798. }]);
  799. app.controller('Wechatoperator', ['$rootScope', '$http', '$scope', '$modal', 'api_user_data', function ($rootScope, $http, $scope, $modal, api_user_data) {
  800. $scope.handle = false;
  801. $scope.see = false;
  802. $scope.toHandle = false;
  803. var loginUser = $rootScope.user;
  804. // 是否是服务台经理
  805. $scope.isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0;
  806. // 是否显示解除锁定
  807. $scope.isUnLock = false;
  808. console.log($scope.item)
  809. if ($scope.item.operationLog) {
  810. $scope.isUnLock = ($scope.item.operationLog.userId == loginUser.id) && ($scope.item.operationLog.opValue == 1);
  811. } else {
  812. $scope.isUnLock = false;
  813. }
  814. // 是否显示处理--锁定相关的操作
  815. $scope.isChuli = false;
  816. if ($scope.isFuwutaijingli) {
  817. //如果有服务台经理角色
  818. $scope.isChuli = true;
  819. } else {
  820. //如果没有服务台经理角色
  821. if ($scope.item.operationLog) {
  822. if ($scope.item.operationLog.opValue == 1) {
  823. //如果锁定
  824. $scope.isChuli = $scope.item.operationLog.userId == loginUser.id;
  825. } else {
  826. //如果没锁定
  827. $scope.isChuli = true;
  828. }
  829. } else {
  830. $scope.isChuli = true;
  831. }
  832. }
  833. $scope.chuli = false;
  834. for (var i = 0; i < loginUser.menu.length; i++) {
  835. if (loginUser.menu[i].link == "weixinbaozhang_chuli") {
  836. $scope.chuli = true
  837. }
  838. }
  839. if ($scope.item.serviceState.name == "已受理") {
  840. $scope.toHandle = true;
  841. } else {
  842. $scope.toHandle = false;
  843. }
  844. if ($scope.item.serviceState.name == "未受理") {
  845. $scope.handle = true;
  846. } else {
  847. $scope.handle = false;
  848. }
  849. if ($scope.item.serviceState.name == "已受理" || $scope.item.serviceState.name == "不受理" || $scope.item.serviceState.name == "未受理") {
  850. $scope.see = true;
  851. } else {
  852. $scope.see = false;
  853. }
  854. $scope.edit = function () {
  855. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  856. // $scope.doEdit($scope.item.id);
  857. }
  858. //查看,查看详情
  859. $scope.look = function () {
  860. $scope.colobject.grid.appScope.lookFunction($scope.item);
  861. // $scope.doEdit($scope.item.id);
  862. }
  863. //处理
  864. $scope.handleFn = function () {
  865. console.log($scope.item)
  866. // $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  867. //是否包含服务台经理角色
  868. var isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0;
  869. if (!isFuwutaijingli) {
  870. if ($scope.item.operationLog) {
  871. //有锁定操作记录的
  872. var p1 = {
  873. idx: 0,
  874. sum: 1000,
  875. operationLog: {
  876. id: $scope.item.operationLog.id,
  877. extra1: $scope.item.id,
  878. opType: 'wxincidentLock'
  879. }
  880. };
  881. api_user_data.fetchDataList('operationLog', p1).then(function (result) {
  882. if (result.status == 200) {
  883. var opValue = result.list[0].opValue;//查询锁定状态
  884. var userName = result.list[0].userName;//查询锁定人
  885. var userId = result.list[0].userId;//查询锁定人ID
  886. if (opValue == 1&&userId!=loginUser.id) {
  887. //如果锁定了,并不是锁定人操作
  888. $modal.open({
  889. templateUrl: 'assets/views/delete.html',
  890. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  891. $scope.title = '提示';
  892. $scope.connect = '该报修已被【' + userName + '】锁定!';
  893. $scope.yesFlag = true;
  894. //选择“取消”或“确定”
  895. $scope.cancel = function () {
  896. $modalInstance.dismiss('cancel');
  897. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  898. };
  899. },
  900. size: 'sm',
  901. resolve: {
  902. scope: function () {
  903. return $scope;
  904. }
  905. }
  906. });
  907. } else if(opValue == 1&&userId==loginUser.id){
  908. //如果锁定了,并是锁定人操作
  909. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  910. }else{
  911. //如果没有锁定
  912. $scope.operateUnLock($scope.item.operationLog.id)
  913. }
  914. }
  915. })
  916. } else {
  917. //没有锁定记录的
  918. $scope.operateUnLock();
  919. }
  920. } else {
  921. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  922. }
  923. // $scope.doEdit($scope.item.id);
  924. }
  925. //是否锁定,id是日志ID,有是修改,没有是新增
  926. $scope.operateUnLock = function (id) {
  927. $modal.open({
  928. templateUrl: 'assets/views/delete.html',
  929. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  930. $scope.title = '提示';
  931. $scope.connect = '是否锁定?锁定后其他人(服务台经理除外)无法操作此报修!';
  932. $scope.noFlag = true;
  933. //选择“是”
  934. $scope.yes = function () {
  935. if (scope.item) {
  936. var postData = {
  937. operationLog: {
  938. extra1: scope.item.id,
  939. userId: loginUser.id,
  940. userName: loginUser.name,
  941. opType: 'wxincidentLock',
  942. opValue: '1'
  943. }
  944. };
  945. if(id){
  946. postData.operationLog.id = id;
  947. }
  948. api_user_data.addData('operationLog', postData).then(function (response) {
  949. if (response.data) {
  950. $modalInstance.dismiss('cancel');
  951. SweetAlert.swal({
  952. title: "锁定成功!",
  953. type: "success",
  954. confirmButtonColor: "#007AFF"
  955. }, function () {
  956. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  957. });
  958. } else {
  959. SweetAlert.swal({
  960. title: "操作异常!",
  961. text: "系统异常,请稍后重试,或者联系管理员!",
  962. type: "error"
  963. });
  964. }
  965. })
  966. }
  967. };
  968. //选择“取消”
  969. $scope.cancel = function () {
  970. $modalInstance.dismiss('cancel');
  971. };
  972. //选择“否”
  973. $scope.no = function () {
  974. $modalInstance.dismiss('cancel');
  975. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  976. };
  977. },
  978. size: 'sm',
  979. resolve: {
  980. scope: function () {
  981. return $scope;
  982. }
  983. }
  984. });
  985. }
  986. //解锁
  987. $scope.unLock = function(){
  988. $modal.open({
  989. templateUrl: 'assets/views/delete.html',
  990. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  991. $scope.title = '提示';
  992. $scope.connect = '是否解锁?';
  993. $scope.noFlag = true;
  994. //选择“是”
  995. $scope.yes = function () {
  996. if (scope.item) {
  997. var postData = {
  998. operationLog: {
  999. id:scope.item.operationLog.id,
  1000. extra1: scope.item.id,
  1001. userId: loginUser.id,
  1002. userName: loginUser.name,
  1003. opType: 'wxincidentLock',
  1004. opValue: '0'
  1005. }
  1006. };
  1007. api_user_data.addData('operationLog', postData).then(function (response) {
  1008. if (response.data) {
  1009. $modalInstance.dismiss('cancel');
  1010. SweetAlert.swal({
  1011. title: "解锁成功!",
  1012. type: "success",
  1013. confirmButtonColor: "#007AFF"
  1014. }, function () {
  1015. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  1016. });
  1017. } else {
  1018. SweetAlert.swal({
  1019. title: "操作异常!",
  1020. text: "系统异常,请稍后重试,或者联系管理员!",
  1021. type: "error"
  1022. });
  1023. }
  1024. })
  1025. }
  1026. };
  1027. //选择“取消”
  1028. $scope.cancel = function () {
  1029. $modalInstance.dismiss('cancel');
  1030. };
  1031. //选择“否”
  1032. $scope.no = function () {
  1033. $modalInstance.dismiss('cancel');
  1034. };
  1035. },
  1036. size: 'sm',
  1037. resolve: {
  1038. scope: function () {
  1039. return $scope;
  1040. }
  1041. }
  1042. });
  1043. }
  1044. //查看事件
  1045. $scope.seeIncident = function () {
  1046. $scope.colobject.grid.appScope.seeIncidentFunction($scope.item);
  1047. // $scope.doEdit($scope.item.id);
  1048. }
  1049. }]);
  1050. app.directive('wechatoperator', function () {
  1051. return {
  1052. restrict: 'E',
  1053. scope: {
  1054. item: '=',
  1055. colobject: '='
  1056. },
  1057. controller: 'Wechatoperator',
  1058. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  1059. // '<a ng-click="edit()" ng-show="{{handle}}" tooltip="生成事件" tooltip-placement="left">生成事件</a>' +
  1060. // '<a ng-click="edit()" class="bianjifont">生成事件</a>' +
  1061. '<a ng-click="handleFn()" ng-show="{{(handle&&chuli)&&isChuli}}" class="bianjifont">处理</a>' +
  1062. '<a ng-click="unLock()" ng-show="{{isUnLock}}" class="bianjifont">解除锁定</a>' +
  1063. '<a ng-click="look()" ng-show="{{see}}" class="bianjifont">查看</a>' +
  1064. // '<a ng-click="look()" ng-show="{{toHandle}}" class="bianjifont">查看详情</a>' +
  1065. '<a ng-click="seeIncident()" ng-show="{{toHandle}}" class="bianjifont">查看事件</a>' +
  1066. // '<a ng-click="look()" ng-show="{{handle}}" tooltip="查看" tooltip-placement="right"><i class="ti-eye"></i></a>' +
  1067. '</div>'
  1068. };
  1069. });
  1070. // app.factory('myFactory', function() {
  1071. // //定义factory返回对象
  1072. // var myServices = {};
  1073. // //定义参数对象
  1074. // var myObject = {};
  1075. // var _set = function(data) {
  1076. // myObject = data;
  1077. // };
  1078. // })