recordCtrl.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. "use strict";
  2. app.controller("recordCtrl", [
  3. "$scope",
  4. "i18nService",
  5. "$rootScope",
  6. "$state",
  7. "$timeout",
  8. "$interval",
  9. "$modal",
  10. "SweetAlert",
  11. "uiGridConstants",
  12. "uiGridGroupingConstants",
  13. "Restangular",
  14. "api_bpm_data",
  15. "api_text",
  16. "api_user_data",
  17. function (
  18. $scope,
  19. i18nService,
  20. $rootScope,
  21. $state,
  22. $timeout,
  23. $interval,
  24. $modal,
  25. SweetAlert,
  26. uiGridConstants,
  27. uiGridGroupingConstants,
  28. Restangular,
  29. api_bpm_data,
  30. api_text,
  31. api_user_data
  32. ) {
  33. $scope.langs = i18nService.getAllLangs();
  34. $scope.lang = "zh-cn";
  35. i18nService.setCurrentLang($scope.lang);
  36. // $(window).resize(function() {
  37. // // console.log("1111")
  38. // });
  39. var loginUser = $rootScope.user;
  40. // var voiceurl=$rootScope.audioiIp;
  41. // delete $rootScope.user.authority;
  42. var pdKey = $state.current.pdKey;
  43. $scope.gridOptions = {};
  44. $scope.gridOptions.data = "myData";
  45. $scope.gridOptions.enableColumnResizing = true;
  46. $scope.gridOptions.enableFiltering = false;
  47. $scope.gridOptions.enableGridMenu = true;
  48. $scope.gridOptions.enableRowSelection = true;
  49. $scope.gridOptions.showGridFooter = true;
  50. $scope.gridOptions.showColumnFooter = false;
  51. $scope.gridOptions.fastWatch = true;
  52. // $scope.gridOptions.useExternalFiltering=true;
  53. $scope.gridOptions.useExternalPagination = true;
  54. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  55. $scope.gridOptions.paginationPageSize = 10;
  56. $scope.gridOptions.multiSelect = true;
  57. var mun = $scope.gridOptions.paginationPageSize;
  58. // $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>";
  59. $scope.gridOptions.rowIdentity = function (row) {
  60. return row.id;
  61. };
  62. $scope.gridOptions.getRowIdentity = function (row) {
  63. return row.id;
  64. };
  65. $scope.transferstate = function (item) {
  66. // var handstate = "未受理";
  67. if (item.isExcute == 1) {
  68. return "已受理";
  69. } else if (item.isExcute == 2) {
  70. return "不受理";
  71. } else {
  72. return "未受理";
  73. }
  74. };
  75. $scope.bushouli = function (item) {
  76. // console.log(item)
  77. SweetAlert.swal(
  78. {
  79. title: "确认不受理?",
  80. text: "确认不受理后,将无法转换为事件工单!",
  81. type: "warning",
  82. showCancelButton: true,
  83. confirmButtonColor: "#DD6B55",
  84. confirmButtonText: "确定",
  85. cancelButtonText: "取消",
  86. closeOnConfirm: false,
  87. closeOnCancel: false,
  88. },
  89. function (isConfirm) {
  90. if (isConfirm) {
  91. item.isExcute = 2;
  92. delete item.item;
  93. api_bpm_data
  94. .updData("hjzxRecord", { hjzxRecord: item })
  95. .then(function (res) {
  96. if (res.status == 200) {
  97. SweetAlert.swal(
  98. {
  99. title: "操作成功!",
  100. type: "success",
  101. confirmButtonColor: "#007AFF",
  102. },
  103. function () {
  104. $scope.refreshData("expand-right", $scope.filData);
  105. }
  106. );
  107. } else {
  108. SweetAlert.swal({
  109. title: "系统错误",
  110. text: "系统错误,请稍后重试!",
  111. type: "error",
  112. confirmButtonColor: "#DD6B55",
  113. });
  114. }
  115. });
  116. } else {
  117. SweetAlert.swal("操作取消", "数据安全", "error");
  118. }
  119. }
  120. );
  121. };
  122. $scope.transfersucc = function (item) {
  123. var handstate = "有效";
  124. if (item.isValid) {
  125. //未处理
  126. handstate = "无效";
  127. }
  128. return handstate;
  129. };
  130. $scope.transferTime = function (time) {
  131. return moment(time).format("YYYY-MM-DD HH:mm");
  132. };
  133. $scope.gridOptions.columnDefs = [
  134. {
  135. name: "item",
  136. displayName: "序号",
  137. width: 50,
  138. cellTemplate:
  139. "<div>" +
  140. '<div class="ui-grid-cell-contents"}">{{row.entity.item}}</div>' +
  141. "</div>",
  142. },
  143. {
  144. name: "recTime",
  145. displayName: "留言时间",
  146. width: '140',
  147. cellTemplate:
  148. "<div>" +
  149. '<div class="ui-grid-cell-contents"}">{{grid.appScope.transferTime(row.entity.recTime)}}</div>' +
  150. "</div>",
  151. },
  152. {
  153. name: "ano",
  154. displayName: "来电号码",
  155. width: '120',
  156. cellTemplate:
  157. "<div>" +
  158. '<div class="ui-grid-cell-contents"}">{{row.entity.ano}}</div>' +
  159. "</div>",
  160. },
  161. // {
  162. // name: 'isValid',
  163. // displayName: '有效状态',
  164. // width: '10%',
  165. // cellTemplate: '<div>' +
  166. // '<div class="ui-grid-cell-contents"}">{{grid.appScope.transfersucc(row.entity)}}</div>' +
  167. // '</div>'
  168. // },
  169. {
  170. name: "isExcute",
  171. displayName: "处理状态",
  172. width: "70",
  173. cellTemplate:
  174. "<div>" +
  175. '<div class="ui-grid-cell-contents"}">{{grid.appScope.transferstate(row.entity)}}</div>',
  176. },
  177. {
  178. name: "操作",
  179. cellTemplate: '<recordoperator item="row.entity" colobject="col">',
  180. },
  181. ];
  182. $scope.value = 10;
  183. $scope.decrement = function () {
  184. $scope.value = $scope.value - 1;
  185. };
  186. $scope.gridOptions.onRegisterApi = function (gridApi) {
  187. $scope.gridApi = gridApi;
  188. gridApi.pagination.on.paginationChanged(
  189. $scope,
  190. function (newPage, pageSize) {
  191. var filtersData = $scope.filData;
  192. filtersData.idx = newPage - 1;
  193. filtersData.sum = pageSize;
  194. $scope.refreshData("expand-right", filtersData);
  195. }
  196. );
  197. $scope.selected = {
  198. items: [],
  199. };
  200. };
  201. $scope.memoryfilterData = defaultFilterData = {
  202. idx: 0,
  203. sum: mun,
  204. };
  205. /*--------- new incident --------- */
  206. $scope.selectRowFunction = function (recorddata) {
  207. var filterData = {
  208. idx: 0,
  209. sum: 10,
  210. requester: {
  211. mphone: recorddata.ano,
  212. telephone: recorddata.ano,
  213. selectType: 1,
  214. },
  215. };
  216. api_user_data
  217. .fetchDataList("requester", filterData)
  218. .then(function (data) {
  219. var myData = Restangular.stripRestangular(data);
  220. // $rootScope.phone="";
  221. // $rootScope.setbusy();
  222. if (myData.list.length == 0) {
  223. var modalInstance = $modal.open({
  224. templateUrl:
  225. "assets/views/customform/tpl/modal-add-callrequester.html",
  226. controller: function (
  227. $scope,
  228. $modalInstance,
  229. api_user_data,
  230. api_wechatfile
  231. ) {
  232. $scope.title = "新增报修人";
  233. $scope.requester = {};
  234. $scope.branchs = [];
  235. $scope.areas = [];
  236. $scope.places = [];
  237. $scope.networktypes = [];
  238. $scope.onChangeadd = function (searchData) {
  239. $scope.searchKey = searchData.account;
  240. var requesdata = angular.copy(searchData);
  241. if (requesdata.telephone) {
  242. delete requesdata.telephone;
  243. }
  244. angular.extend($scope.requester, requesdata);
  245. };
  246. $scope.refreshUseradd = function (searchKey) {
  247. //请求人搜索
  248. $scope.requester.account = searchKey;
  249. $scope.searchData = searchKey;
  250. serchdataadd(searchKey);
  251. };
  252. $scope.getMydata = function (x) {
  253. var reqestdatap = JSON.parse(x[0]);
  254. if ($scope.requester.telephone) {
  255. delete reqestdatap.telephone;
  256. }
  257. $scope.searchField = JSON.parse(x[0]).account;
  258. angular.extend($scope.requester, reqestdatap);
  259. // $scope.searchField = JSON.parse(x[0]).account;
  260. // $scope.requester = JSON.parse(x[0]);
  261. console.log($scope.requester);
  262. $scope.refreshArea('');
  263. $scope.refresh('');
  264. };
  265. $scope.getMydataone = function (x) {
  266. $scope.searchField = x;
  267. $scope.requester.account = x;
  268. };
  269. serchdataadd();
  270. function serchdataadd(searchKey) {
  271. if (searchKey) {
  272. var filterData = {
  273. requester: {
  274. searchKey: searchKey,
  275. },
  276. idx: 0,
  277. sum: 10,
  278. };
  279. } else {
  280. var filterData = {
  281. idx: 0,
  282. sum: 10,
  283. };
  284. }
  285. api_user_data
  286. .fetchDataList("requester", filterData)
  287. .then(function (response) {
  288. var myData = response;
  289. $scope.myData = myData.list;
  290. });
  291. }
  292. api_user_data
  293. .fetchDataList("branch", {
  294. idx: 0,
  295. sum: 1000,
  296. })
  297. .then(function (response) {
  298. if (response.status == 200) {
  299. $scope.branchs = response.list;
  300. }
  301. });
  302. api_wechatfile
  303. .getDictionary(
  304. {
  305. key: "requester_type",
  306. type: "list",
  307. },
  308. {
  309. idx: 0,
  310. sum: 100,
  311. }
  312. )
  313. .then(function (response) {
  314. if (response) {
  315. $scope.networktypes = response;
  316. }
  317. });
  318. $scope.onChangeBranch = function (item) {
  319. delete $scope.requester.place;
  320. console.log($scope.requester, 'changeArea');
  321. api_user_data
  322. .fetchDataList("area", {
  323. area: {
  324. branch: item.id,
  325. },
  326. idx: 0,
  327. sum: 1000,
  328. })
  329. .then(function (response) {
  330. if (response.status == 200) {
  331. $scope.areas = response.list;
  332. }
  333. });
  334. };
  335. $scope.onChange = function (item) {
  336. $scope.requester.place = {area: $scope.requester.place.area};
  337. console.log($scope.requester, 'changeArea');
  338. api_user_data
  339. .fetchDataList("place", {
  340. place: {
  341. area: {
  342. id: item.id,
  343. },
  344. },
  345. idx: 0,
  346. sum: 1000,
  347. })
  348. .then(function (response) {
  349. if (response.status == 200) {
  350. $scope.places = response.list;
  351. // $scope.requester.place = {};
  352. }
  353. });
  354. };
  355. // 修改地点
  356. $scope.requesterPlaceid = "";
  357. $scope.onChangePlace = function (item) {
  358. $scope.requesterPlaceid = item.id;
  359. console.log($scope.requester, 'changePlace');
  360. api_user_data
  361. .fetchDataList("room", {
  362. room: {
  363. place: {
  364. id: item.id,
  365. },
  366. },
  367. idx: 0,
  368. sum: 1000,
  369. })
  370. .then(function (response) {
  371. if (response.status == 200) {
  372. $scope.rooms = response.list;
  373. }
  374. });
  375. };
  376. $scope.refreshArea = function (searchVal) {
  377. console.log($scope.requester, 'area');
  378. var faildata = {};
  379. if ($scope.requester.branch) {
  380. faildata = {
  381. idx: 0,
  382. sum: 1000,
  383. area: {
  384. branch: $scope.requester.branch.id,
  385. area: searchVal,
  386. selectType: "pinyin_qs",
  387. },
  388. };
  389. } else {
  390. return;
  391. }
  392. api_user_data
  393. .fetchDataList("area", faildata)
  394. .then(function (response) {
  395. $scope.areas = response.list;
  396. delete $scope.requester.areaDTO;
  397. });
  398. };
  399. $scope.refresh = function (searchVal) {
  400. console.log($scope.requester, 'place');
  401. var faildata = {};
  402. if ($scope.requester.place && $scope.requester.place.area) {
  403. faildata = {
  404. idx: 0,
  405. sum: 1000,
  406. place: {
  407. areaId: $scope.requester.place.area.id,
  408. place: searchVal,
  409. selectType: "pinyin_qs",
  410. },
  411. };
  412. } else {
  413. return;
  414. }
  415. api_user_data
  416. .fetchDataList("place", faildata)
  417. .then(function (response) {
  418. $scope.places = response.list;
  419. delete $scope.requester.placeDTO;
  420. });
  421. };
  422. $scope.requester = { telephone: recorddata.ano };
  423. $scope.ok = function () {
  424. $modalInstance.close($scope.requester);
  425. };
  426. $scope.cancel = function () {
  427. $modalInstance.dismiss("cancel");
  428. };
  429. },
  430. });
  431. modalInstance.result.then(function (selectedItem) {
  432. if (selectedItem) {
  433. if (selectedItem.telephone && !selectedItem.mphone) {
  434. selectedItem.telephone = angular.copy(selectedItem.mphone);
  435. delete selectedItem.mphone;
  436. }
  437. var data = {
  438. requester: selectedItem,
  439. };
  440. api_user_data
  441. .addData("requester", data)
  442. .then(function (response) {
  443. if (response.status == 200) {
  444. var data = {
  445. model: {
  446. requestershow: response.data,
  447. recordId: recorddata.id,
  448. incident: {
  449. requester: response.data,
  450. houseNumber: response.data.houseNumber,
  451. contactsInformation: response.data.mphone,
  452. source: { id: 1548 },
  453. },
  454. },
  455. };
  456. if (response.data.branch) {
  457. data.model.incident.branch = response.data.branch;
  458. }
  459. if (response.data.place) {
  460. data.model.incident.area = response.data.place.area;
  461. data.model.incident.place = response.data.place;
  462. }
  463. $state.go("app.incident.title", {
  464. model: JSON.stringify(data),
  465. });
  466. }
  467. });
  468. }
  469. });
  470. } else if (myData.list.length == 1) {
  471. var data = {
  472. model: {
  473. requestershow: myData.list[0],
  474. recordId: recorddata.id,
  475. incident: {
  476. requester: myData.list[0],
  477. houseNumber: myData.list[0].houseNumber,
  478. contactsInformation: myData.list[0].mphone,
  479. source: { id: 1548 },
  480. },
  481. },
  482. };
  483. if (myData.list[0].branch) {
  484. data.model.incident.branch = myData.list[0].branch;
  485. }
  486. if (myData.list[0].place) {
  487. data.model.incident.area = myData.list[0].place.area;
  488. data.model.incident.place = myData.list[0].place;
  489. }
  490. $state.go("app.incident.title", { model: JSON.stringify(data) });
  491. } else {
  492. var modalInstance = $modal.open({
  493. templateUrl: "assets/views/createincident.html",
  494. controller: function (
  495. $scope,
  496. datas,
  497. $modalInstance,
  498. api_user_data
  499. ) {
  500. $scope.title = "请确定报修人";
  501. $scope.requester = myData.list;
  502. $scope.choice = function (requester) {
  503. $modalInstance.dismiss("cancel");
  504. var data = {
  505. model: {
  506. requestershow: requester,
  507. recordId: recorddata.id,
  508. incident: {
  509. requester: requester,
  510. houseNumber: requester.houseNumber,
  511. contactsInformation: requester.mphone,
  512. source: { id: 1548 },
  513. },
  514. },
  515. };
  516. if (requester.branch) {
  517. data.model.incident.branch = requester.branch;
  518. }
  519. if (requester.place) {
  520. data.model.incident.area = requester.place.area;
  521. data.model.incident.place = requester.place;
  522. }
  523. $state.go("app.incident.title", {
  524. model: JSON.stringify(data),
  525. });
  526. };
  527. $scope.cancel = function () {
  528. $modalInstance.dismiss("cancel");
  529. };
  530. },
  531. resolve: {
  532. datas: function () {
  533. return recorddata;
  534. },
  535. },
  536. size: "lg",
  537. });
  538. }
  539. });
  540. // var formdata = {
  541. // 'model': {
  542. // 'incident': {
  543. // 'source': { 'id': 1 },
  544. // },
  545. // 'recordId': data.id
  546. // }
  547. // }
  548. // $state.go('app.incident.chart', { 'model': JSON.stringify(formdata) });
  549. };
  550. /*--------- Recordings --------- */
  551. // $scope.recordcall = function(data) {
  552. // $scope.oldRecord(data);
  553. // var modalInstance = $modal.open({
  554. // templateUrl: 'assets/views/incident/tpl/audio.html',
  555. // controller: function($rootScope, $scope, $modalInstance, $sce) {
  556. // $scope.data = {
  557. // "name": "视频",
  558. // "url": callIp + "/recording/recording?recordId=" + data.id
  559. // };
  560. // $rootScope.setbusy();
  561. // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  562. // $scope.cancel = function() {
  563. // $modalInstance.dismiss('cancel');
  564. // // $rootScope.setidle();
  565. // };
  566. // $modalInstance.close();
  567. // }
  568. // });
  569. // modalInstance.result.then(function(result) {
  570. // // $rootScope.setidle();
  571. // }, function(reason) {
  572. // $rootScope.setidle();
  573. // });
  574. // };
  575. //录音
  576. $scope.recordcall = function (data) {
  577. var modalInstance = $modal.open({
  578. backdrop: "static",
  579. templateUrl: "assets/views/incident/tpl/audio.html",
  580. controller: function (
  581. $rootScope,
  582. $scope,
  583. $modalInstance,
  584. $sce,
  585. $http,
  586. api_playservice
  587. ) {
  588. $scope.audioUrl = $sce.trustAsResourceUrl(callIp + data.recFileName);
  589. $rootScope.setbusy();
  590. // $scope.datasurl = "";
  591. // $http({
  592. // url: callIp + "/recording/recording?recordId=" + data.id,
  593. // method: 'GET',
  594. // headers: {},
  595. // }).success(function(data, status, headers, config) {
  596. // $scope.data = {
  597. // "name": "视频",
  598. // "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
  599. // };
  600. // $scope.datasurl = data.rrpath;
  601. // }).error(function(data, status, headers, config) {});
  602. // $scope.download = function(contentId, filename) {
  603. // $http({
  604. // url: "http://" + $scope.datasurl,
  605. // method: 'GET',
  606. // headers: {
  607. // 'Content-type': 'application/octet-stream',
  608. // },
  609. // responseType: 'arraybuffer'
  610. // }).success(function(data, status, headers, config) {
  611. // var file = new Blob([data], {
  612. // type: 'application/octet-stream'
  613. // });
  614. // //trick to download store a file having its URL
  615. // var fileURL = URL.createObjectURL(file);
  616. // var a = document.createElement('a');
  617. // a.href = fileURL;
  618. // a.target = '_blank';
  619. // a.download = filename;
  620. // document.body.appendChild(a);
  621. // a.click();
  622. // }).error(function(data, status, headers, config) {
  623. // // console.log(data);
  624. // });
  625. // }
  626. $scope.cancel = function () {
  627. $modalInstance.dismiss("cancel");
  628. };
  629. $modalInstance.close();
  630. },
  631. });
  632. modalInstance.result.then(
  633. function (result) {
  634. // $rootScope.setidle();
  635. },
  636. function (reason) {
  637. $rootScope.setidle();
  638. }
  639. );
  640. };
  641. /*--------- call --------- */
  642. $scope.recordcallid = function (data) {
  643. // var telephone = '9' + data.ano;
  644. $rootScope.callout = 2;
  645. // if ($rootScope.takes) {
  646. // api_text.dialout($rootScope.takes, "@0", telephone).then(function(data) {
  647. // if (data.errno == 0) {
  648. // $rootScope.status = 6;
  649. // $scope.oldRecord(data);
  650. // }
  651. // })
  652. // } else {
  653. // SweetAlert.swal({
  654. // title: "呼叫失败",
  655. // text: "请先签入呼叫中心!",
  656. // type: "error",
  657. // confirmButtonColor: "#DD6B55"
  658. // });
  659. // }
  660. if (localStorage.getItem("fenjiNumber")) {
  661. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  662. // console.log(sessionStorage.getItem('phones'))
  663. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  664. // var isHuajihao = phones.length?phones.some(v=>v == data.ano):false;
  665. // console.log(isHuajihao)
  666. // if(isHuajihao){
  667. // tlwsa.tlaCallagc(data.ano);//呼叫坐席
  668. // }else{
  669. // tlwsa.tlaCallout(data.ano, caller, 0);//呼叫外线
  670. // }
  671. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  672. // tlwsa.tlaCallout(data.ano, caller, 0);
  673. $rootScope.toggle("off-sidebar");
  674. }else if(localStorage.getItem('hk_phone')){
  675. var gid = "@0"
  676. var telephone = '9' + teleno
  677. $rootScope.callout = 2;
  678. if ($rootScope.takes) {
  679. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  680. if (data.errno == 0) {
  681. $rootScope.status = 6;
  682. }
  683. })
  684. } else {
  685. SweetAlert.swal({
  686. title: "呼叫失败",
  687. text: "请先签入呼叫中心!",
  688. type: "error",
  689. confirmButtonColor: "#DD6B55"
  690. });
  691. }
  692. } else {
  693. SweetAlert.swal({
  694. title: "呼叫失败",
  695. text: "请先签入呼叫中心!",
  696. type: "error",
  697. confirmButtonColor: "#DD6B55",
  698. });
  699. }
  700. };
  701. /*--------- old record --------- */
  702. $scope.oldRecord = function (data) {
  703. api_bpm_data
  704. .updData("hjzxRecord", {
  705. id: data.id,
  706. field1: "1",
  707. isValid: data.isValid,
  708. isExcute: (data.isExcute === 0 || data.isExcute) ? data.isExcute : undefined
  709. })
  710. .then(function (data) {
  711. if (data.status) {
  712. $scope.refreshData("expand-right", defaultFilterData);
  713. }
  714. });
  715. };
  716. /*--------- record status translate --------- */
  717. $scope.record = function (data) {
  718. var keydata = 0;
  719. if (data.isValid == 1) {
  720. keydata = 0;
  721. } else {
  722. keydata = 1;
  723. }
  724. api_bpm_data
  725. .updData("hjzxRecord", {
  726. id: data.id,
  727. isValid: keydata,
  728. isExcute: 1,
  729. field1: "1",
  730. })
  731. .then(
  732. function (data) {
  733. if (data.status) {
  734. SweetAlert.swal(
  735. {
  736. title: "提交成功!",
  737. text: "有效状态转换成功!",
  738. type: "success",
  739. },
  740. function () {
  741. $scope.refreshData("expand-right", defaultFilterData);
  742. }
  743. );
  744. } else {
  745. SweetAlert.swal({
  746. title: "提交失败!",
  747. text: "有效状态转换失败,请重试!",
  748. type: "error",
  749. });
  750. }
  751. },
  752. function () {
  753. $scope.ldloading[style.replace("-", "_")] = false;
  754. }
  755. );
  756. };
  757. /*--------- double click --------- */
  758. // $scope.onDblClick = function(row) {
  759. // var modelfile = { model: { incident: row.entity } };
  760. // if (row.entity.state == "未受理") {
  761. // angular.extend(modelfile.model.incident, { status: 1 })
  762. // } else {
  763. // angular.extend(modelfile.model.incident, { status: 0 })
  764. // }
  765. // $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
  766. // };
  767. $scope.open = function ($event) {
  768. $event.preventDefault();
  769. $event.stopPropagation();
  770. $scope.opened = !$scope.opened;
  771. };
  772. $scope.endOpen = function ($event) {
  773. $event.preventDefault();
  774. $event.stopPropagation();
  775. $scope.startOpened = false;
  776. $scope.endOpened = !$scope.endOpened;
  777. };
  778. $scope.startOpen = function ($event) {
  779. $event.preventDefault();
  780. $event.stopPropagation();
  781. $scope.endOpened = false;
  782. $scope.startOpened = !$scope.startOpened;
  783. };
  784. /*--------- get zhe list data--------- */
  785. var defaultFilterData = {
  786. idx: 0,
  787. sum: mun,
  788. };
  789. $scope.filData = {
  790. idx: 0,
  791. sum: 10,
  792. hjzxRecord: {
  793. isExcute: 0,
  794. },
  795. };
  796. $scope.searchstate = "weishouli";
  797. $scope.toIncident = function (data) {
  798. $state.go("app.incident.detail", {
  799. formKey: "incident_back",
  800. pdKey: "incident",
  801. dataId: data.incidentDTO.id,
  802. taskId: data.incidentDTO.taskId,
  803. processInstanceId: data.incidentDTO.processInstanceId,
  804. isRecord: "ok",
  805. });
  806. };
  807. $scope.onChange = function (data) {
  808. var toData = "";
  809. if (data == "weishouli") {
  810. toData = 0;
  811. } else if (data == "yishouli") {
  812. toData = 1;
  813. } else if (data == "bushouli") {
  814. toData = 2;
  815. }
  816. $scope.filData.idx = 0;
  817. $scope.filData.hjzxRecord.isExcute = (toData === 0 || toData) ? toData : undefined;
  818. if($scope.searchstate == data){
  819. $scope.refreshData("expand-right", $scope.filData);
  820. }else{
  821. $scope.gridOptions.paginationCurrentPage = 0;
  822. }
  823. $scope.searchstate = data;
  824. };
  825. // 搜索
  826. $scope.search = function () {
  827. if ($scope.filData.hjzxRecord.startTime) {
  828. $scope.filData.hjzxRecord.startTime = moment(
  829. $scope.filData.hjzxRecord.startTime
  830. ).format("YYYY-MM-DD HH:mm:ss");
  831. }
  832. if ($scope.filData.hjzxRecord.endTime) {
  833. $scope.filData.hjzxRecord.endTime = moment(
  834. $scope.filData.hjzxRecord.endTime
  835. ).format("YYYY-MM-DD HH:mm:ss");
  836. }
  837. $scope.refreshData("expand-right", $scope.filData);
  838. };
  839. // 清空
  840. $scope.cleanItem = function () {
  841. delete $scope.filData.hjzxRecord.startTime;
  842. delete $scope.filData.hjzxRecord.endTime;
  843. delete $scope.filData.hjzxRecord.ano;
  844. $scope.refreshData("expand-right", $scope.filData);
  845. };
  846. $scope.ldloading = {};
  847. $scope.refreshData = function (style, filterData) {
  848. $scope.ldloading[style.replace("-", "_")] = true;
  849. if (angular.isUndefined(filterData)) {
  850. filterData = defaultFilterData;
  851. }
  852. $scope.myData = [];
  853. $scope.gridOptions["sum"] = filterData.sum;
  854. var toData = '';
  855. if ($scope.searchstate == "weishouli") {
  856. toData = 0;
  857. } else if ($scope.searchstate == "yishouli") {
  858. toData = 1;
  859. } else if ($scope.searchstate == "bushouli") {
  860. toData = 2;
  861. }
  862. filterData.hjzxRecord.isExcute = (toData === 0 || toData) ? toData : undefined;
  863. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  864. function (data) {
  865. var myData = Restangular.stripRestangular(data);
  866. $scope.gridOptions["totalItems"] = myData.totalNum;
  867. $scope.myData = myData.list;
  868. for (var i = 0; i < $scope.myData.length; i++) {
  869. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  870. if (!$scope.myData[i]["id"]) {
  871. $scope.myData[i]["id"] = i;
  872. }
  873. }
  874. // console.log($scope.myData)
  875. $scope.ldloading[style.replace("-", "_")] = false;
  876. },
  877. function () {
  878. $scope.ldloading[style.replace("-", "_")] = false;
  879. }
  880. );
  881. };
  882. $scope.refreshData2 = function (style, filterData) {
  883. $scope.ldloading[style.replace("-", "_")] = true;
  884. if (angular.isUndefined(filterData)) {
  885. filterData = defaultFilterData;
  886. }
  887. // $scope.myData = [];
  888. $scope.gridOptions["sum"] = filterData.sum;
  889. $scope.gridOptions.paginationCurrentPage = filterData.idx + 1;
  890. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  891. function (data) {
  892. var myData = Restangular.stripRestangular(data);
  893. $scope.gridOptions["totalItems"] = myData.totalNum;
  894. $scope.myData = myData.list;
  895. for (var i = 0; i < $scope.myData.length; i++) {
  896. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  897. if (!$scope.myData[i]["id"]) {
  898. $scope.myData[i]["id"] = i;
  899. }
  900. }
  901. // console.log($scope.myData)
  902. $scope.ldloading[style.replace("-", "_")] = false;
  903. },
  904. function () {
  905. $scope.ldloading[style.replace("-", "_")] = false;
  906. }
  907. );
  908. };
  909. $scope.refreshData("expand-right", $scope.filData);
  910. // $scope.timer = $interval(function () {
  911. // $scope.refreshData2("expand-right", $scope.filData);
  912. // }, $rootScope.refreshTime);
  913. $scope.$on("$destroy", function () {
  914. $interval.cancel($scope.timer);
  915. });
  916. },
  917. ]);
  918. /*--------- operation --------- */
  919. app.controller("Recordoperator", [
  920. "$rootScope",
  921. "$http",
  922. "$scope",
  923. "$modal",
  924. function ($rootScope, $http, $scope, $modal) {
  925. // $scope.handle = false;
  926. // $scope.isvalid = false;
  927. // $scope.novalid = false;
  928. // console.log($scope.item);
  929. // if (!$scope.item.isExcute && !$scope.item.isValid) {
  930. // $scope.handle = true;
  931. // } else { $scope.handle = false; }
  932. // if (!$scope.item.isExcute) {
  933. // if ($scope.item.isValid) {
  934. // $scope.isvalid = true;
  935. // $scope.novalid = false;
  936. // } else {
  937. // $scope.isvalid = false;
  938. // $scope.novalid = true;
  939. // }
  940. // } else {
  941. // $scope.isvalid = false;
  942. // }
  943. $scope.isHuibo = (function () {
  944. var phones = JSON.parse(sessionStorage.getItem("phones"));
  945. console.log(phones, $scope.item.ano);
  946. var isHuajihao = phones && phones.length
  947. ? phones.some((v) => v == $scope.item.ano)
  948. : false;
  949. return !isHuajihao;
  950. })();
  951. $scope.weishouli = false;
  952. $scope.yishouli = false;
  953. $scope.bushouli = false;
  954. var loginUser = $rootScope.user;
  955. $scope.chuli = false;
  956. for (var i = 0; i < loginUser.menu.length; i++) {
  957. if (loginUser.menu[i].link == "liuyanliebiao_chuli") {
  958. $scope.chuli = true;
  959. }
  960. }
  961. if ($scope.item.isExcute == 1) {
  962. $scope.yishouli = true;
  963. } else if ($scope.item.isExcute == 2) {
  964. $scope.bushouli = true;
  965. } else {
  966. $scope.weishouli = true;
  967. }
  968. $scope.edit = function () {
  969. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  970. // $scope.doEdit($scope.item.id);
  971. };
  972. $scope.record = function () {
  973. $scope.colobject.grid.appScope.record($scope.item);
  974. // $scope.doEdit($scope.item.id);
  975. };
  976. $scope.recordcall = function () {
  977. $scope.colobject.grid.appScope.recordcall($scope.item);
  978. // $scope.doEdit($scope.item.id);
  979. };
  980. $scope.recordcallid = function () {
  981. $scope.colobject.grid.appScope.recordcallid($scope.item);
  982. // $scope.doEdit($scope.item.id);
  983. };
  984. $scope.bushouli = function () {
  985. $scope.colobject.grid.appScope.bushouli($scope.item);
  986. };
  987. $scope.toIncident = function () {
  988. $scope.colobject.grid.appScope.toIncident($scope.item);
  989. };
  990. },
  991. ]);
  992. app.directive("recordoperator", function () {
  993. return {
  994. restrict: "E",
  995. scope: {
  996. item: "=",
  997. colobject: "=",
  998. },
  999. controller: "Recordoperator",
  1000. template:
  1001. '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  1002. '<a ng-click="edit()" ng-show="weishouli&&chuli" class="bianjifont">新建事件</a>' +
  1003. '<a ng-click="bushouli()" ng-show="weishouli&&chuli" class="bianjifont">不受理</a>' +
  1004. // '<a ng-click="record()" ng-show="{{isvalid}}&&{{handle}}" class="luyinfont">有效</a>' +
  1005. // '<a ng-click="record()" ng-show="{{novalid}}&&{{handle}}" class="luyinfont">无效</a>' +
  1006. '<a ng-click="recordcall()" ng-show="(weishouli||yishouli)&&chuli" class="bianjifont">回放</a>' +
  1007. '<a ng-click="recordcallid()" ng-show="(weishouli||yishouli)&&chuli&&isHuibo" class="bianjifont">回拨</a>' +
  1008. '<a ng-click="toIncident()" ng-show="yishouli" class="bianjifont">查看事件</a>' +
  1009. "</div>",
  1010. };
  1011. });