chartCtrl.js 44 KB

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