recordCtrl.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  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: "23%",
  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: "20%",
  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: "13%",
  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.memoryfilterData;
  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.areas = [];
  235. $scope.places = [];
  236. $scope.networktypes = [];
  237. $scope.onChangeadd = function (searchData) {
  238. $scope.searchKey = searchData.account;
  239. var requesdata = angular.copy(searchData);
  240. if (requesdata.telephone) {
  241. delete requesdata.telephone;
  242. }
  243. angular.extend($scope.requester, requesdata);
  244. };
  245. $scope.refreshUseradd = function (searchKey) {
  246. //请求人搜索
  247. $scope.requester.account = searchKey;
  248. $scope.searchData = searchKey;
  249. serchdataadd(searchKey);
  250. };
  251. $scope.getMydata = function (x) {
  252. var reqestdatap = JSON.parse(x[0]);
  253. if ($scope.requester.telephone) {
  254. delete reqestdatap.telephone;
  255. }
  256. $scope.searchField = JSON.parse(x[0]).account;
  257. angular.extend($scope.requester, reqestdatap);
  258. };
  259. $scope.getMydataone = function (x) {
  260. $scope.searchField = x;
  261. $scope.requester.account = x;
  262. };
  263. serchdataadd();
  264. function serchdataadd(searchKey) {
  265. if (searchKey) {
  266. var filterData = {
  267. requester: {
  268. searchKey: searchKey,
  269. },
  270. idx: 0,
  271. sum: 10,
  272. };
  273. } else {
  274. var filterData = {
  275. idx: 0,
  276. sum: 10,
  277. };
  278. }
  279. api_user_data
  280. .fetchDataList("requester", filterData)
  281. .then(function (response) {
  282. var myData = response;
  283. $scope.myData = myData.list;
  284. });
  285. }
  286. api_user_data
  287. .fetchDataList("area", {
  288. idx: 0,
  289. sum: 1000,
  290. })
  291. .then(function (response) {
  292. if (response.status == 200) {
  293. $scope.areas = response.list;
  294. }
  295. });
  296. api_wechatfile
  297. .getDictionary(
  298. {
  299. key: "requester_type",
  300. type: "list",
  301. },
  302. {
  303. idx: 0,
  304. sum: 100,
  305. }
  306. )
  307. .then(function (response) {
  308. if (response) {
  309. $scope.networktypes = response;
  310. }
  311. });
  312. $scope.requesterAreaid = "";
  313. $scope.onChange = function (item) {
  314. $scope.requesterAreaid = item.id;
  315. api_user_data
  316. .fetchDataList("place", {
  317. place: {
  318. area: {
  319. id: item.id,
  320. },
  321. },
  322. idx: 0,
  323. sum: 1000,
  324. })
  325. .then(function (response) {
  326. if (response.status == 200) {
  327. $scope.places = response.list;
  328. // $scope.requester.place = {};
  329. }
  330. });
  331. };
  332. $scope.refresh = function (searchVal) {
  333. var faildata = {};
  334. if ($scope.requesterAreaid) {
  335. faildata = {
  336. idx: 0,
  337. sum: 1000,
  338. place: {
  339. areaId: $scope.requesterAreaid,
  340. place: searchVal,
  341. selectType: "pinyin_qs",
  342. },
  343. };
  344. } else {
  345. faildata = {
  346. idx: 0,
  347. sum: 1000,
  348. place: {
  349. place: searchVal,
  350. selectType: "pinyin_qs",
  351. },
  352. };
  353. }
  354. api_user_data
  355. .fetchDataList("place", faildata)
  356. .then(function (response) {
  357. $scope.places = response.list;
  358. // $scope.requester.place = {};
  359. });
  360. };
  361. $scope.requester = { telephone: recorddata.ano };
  362. $scope.ok = function () {
  363. $modalInstance.close($scope.requester);
  364. };
  365. $scope.cancel = function () {
  366. $modalInstance.dismiss("cancel");
  367. };
  368. },
  369. });
  370. modalInstance.result.then(function (selectedItem) {
  371. if (selectedItem) {
  372. if (selectedItem.telephone && !selectedItem.mphone) {
  373. selectedItem.telephone = angular.copy(selectedItem.mphone);
  374. delete selectedItem.mphone;
  375. }
  376. var data = {
  377. requester: selectedItem,
  378. };
  379. api_user_data
  380. .addData("requester", data)
  381. .then(function (response) {
  382. if (response.status == 200) {
  383. var data = {
  384. model: {
  385. requestershow: response.data,
  386. recordId: recorddata.id,
  387. incident: {
  388. requester: response.data,
  389. houseNumber: response.data.houseNumber,
  390. contactsInformation: response.data.mphone,
  391. source: { id: 1548 },
  392. },
  393. },
  394. };
  395. if (response.data.place) {
  396. data.model.incident.area = response.data.place.area;
  397. data.model.incident.place = response.data.place;
  398. }
  399. $state.go("app.incident.title", {
  400. model: JSON.stringify(data),
  401. });
  402. }
  403. });
  404. }
  405. });
  406. } else if (myData.list.length == 1) {
  407. var data = {
  408. model: {
  409. requestershow: myData.list[0],
  410. recordId: recorddata.id,
  411. incident: {
  412. requester: myData.list[0],
  413. houseNumber: myData.list[0].houseNumber,
  414. contactsInformation: myData.list[0].mphone,
  415. source: { id: 1548 },
  416. },
  417. },
  418. };
  419. if (myData.list[0].place) {
  420. data.model.incident.area = myData.list[0].place.area;
  421. data.model.incident.place = myData.list[0].place;
  422. }
  423. $state.go("app.incident.title", { model: JSON.stringify(data) });
  424. } else {
  425. var modalInstance = $modal.open({
  426. templateUrl: "assets/views/createincident.html",
  427. controller: function (
  428. $scope,
  429. datas,
  430. $modalInstance,
  431. api_user_data
  432. ) {
  433. $scope.title = "请确定报修人";
  434. $scope.requester = myData.list;
  435. $scope.choice = function (requester) {
  436. $modalInstance.dismiss("cancel");
  437. var data = {
  438. model: {
  439. requestershow: requester,
  440. recordId: recorddata.id,
  441. incident: {
  442. requester: requester,
  443. houseNumber: requester.houseNumber,
  444. contactsInformation: requester.mphone,
  445. source: { id: 1548 },
  446. },
  447. },
  448. };
  449. if (requester.place) {
  450. data.model.incident.area = requester.place.area;
  451. data.model.incident.place = requester.place;
  452. }
  453. $state.go("app.incident.title", {
  454. model: JSON.stringify(data),
  455. });
  456. };
  457. $scope.cancel = function () {
  458. $modalInstance.dismiss("cancel");
  459. };
  460. },
  461. resolve: {
  462. datas: function () {
  463. return recorddata;
  464. },
  465. },
  466. size: "lg",
  467. });
  468. }
  469. });
  470. // var formdata = {
  471. // 'model': {
  472. // 'incident': {
  473. // 'source': { 'id': 1 },
  474. // },
  475. // 'recordId': data.id
  476. // }
  477. // }
  478. // $state.go('app.incident.chart', { 'model': JSON.stringify(formdata) });
  479. };
  480. /*--------- Recordings --------- */
  481. // $scope.recordcall = function(data) {
  482. // $scope.oldRecord(data);
  483. // var modalInstance = $modal.open({
  484. // templateUrl: 'assets/views/incident/tpl/audio.html',
  485. // controller: function($rootScope, $scope, $modalInstance, $sce) {
  486. // $scope.data = {
  487. // "name": "视频",
  488. // "url": callIp + "/recording/recording?recordId=" + data.id
  489. // };
  490. // $rootScope.setbusy();
  491. // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  492. // $scope.cancel = function() {
  493. // $modalInstance.dismiss('cancel');
  494. // // $rootScope.setidle();
  495. // };
  496. // $modalInstance.close();
  497. // }
  498. // });
  499. // modalInstance.result.then(function(result) {
  500. // // $rootScope.setidle();
  501. // }, function(reason) {
  502. // $rootScope.setidle();
  503. // });
  504. // };
  505. //录音
  506. $scope.recordcall = function (data) {
  507. var modalInstance = $modal.open({
  508. backdrop: "static",
  509. templateUrl: "assets/views/incident/tpl/audio.html",
  510. controller: function (
  511. $rootScope,
  512. $scope,
  513. $modalInstance,
  514. $sce,
  515. $http,
  516. api_playservice
  517. ) {
  518. $scope.audioUrl = $sce.trustAsResourceUrl(callIp + data.recFileName);
  519. // $rootScope.setbusy();
  520. // $scope.datasurl = "";
  521. // $http({
  522. // url: callIp + "/recording/recording?recordId=" + data.id,
  523. // method: 'GET',
  524. // headers: {},
  525. // }).success(function(data, status, headers, config) {
  526. // $scope.data = {
  527. // "name": "视频",
  528. // "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
  529. // };
  530. // $scope.datasurl = data.rrpath;
  531. // }).error(function(data, status, headers, config) {});
  532. // $scope.download = function(contentId, filename) {
  533. // $http({
  534. // url: "http://" + $scope.datasurl,
  535. // method: 'GET',
  536. // headers: {
  537. // 'Content-type': 'application/octet-stream',
  538. // },
  539. // responseType: 'arraybuffer'
  540. // }).success(function(data, status, headers, config) {
  541. // var file = new Blob([data], {
  542. // type: 'application/octet-stream'
  543. // });
  544. // //trick to download store a file having its URL
  545. // var fileURL = URL.createObjectURL(file);
  546. // var a = document.createElement('a');
  547. // a.href = fileURL;
  548. // a.target = '_blank';
  549. // a.download = filename;
  550. // document.body.appendChild(a);
  551. // a.click();
  552. // }).error(function(data, status, headers, config) {
  553. // // console.log(data);
  554. // });
  555. // }
  556. $scope.cancel = function () {
  557. $modalInstance.dismiss("cancel");
  558. };
  559. $modalInstance.close();
  560. },
  561. });
  562. modalInstance.result.then(
  563. function (result) {
  564. // $rootScope.setidle();
  565. },
  566. function (reason) {
  567. $rootScope.setidle();
  568. }
  569. );
  570. };
  571. /*--------- call --------- */
  572. $scope.recordcallid = function (data) {
  573. // var telephone = '9' + data.ano;
  574. $rootScope.callout = 2;
  575. // if ($rootScope.takes) {
  576. // api_text.dialout($rootScope.takes, "@0", telephone).then(function(data) {
  577. // if (data.errno == 0) {
  578. // $rootScope.status = 6;
  579. // $scope.oldRecord(data);
  580. // }
  581. // })
  582. // } else {
  583. // SweetAlert.swal({
  584. // title: "呼叫失败",
  585. // text: "请先签入呼叫中心!",
  586. // type: "error",
  587. // confirmButtonColor: "#DD6B55"
  588. // });
  589. // }
  590. if (localStorage.getItem("fenjiNumber")) {
  591. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  592. // console.log(sessionStorage.getItem('phones'))
  593. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  594. // var isHuajihao = phones.length?phones.some(v=>v == data.ano):false;
  595. // console.log(isHuajihao)
  596. // if(isHuajihao){
  597. // tlwsa.tlaCallagc(data.ano);//呼叫坐席
  598. // }else{
  599. // tlwsa.tlaCallout(data.ano, caller, 0);//呼叫外线
  600. // }
  601. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  602. // tlwsa.tlaCallout(data.ano, caller, 0);
  603. $rootScope.toggle("off-sidebar");
  604. }else if(localStorage.getItem('hk_phone')){
  605. var gid = "@0"
  606. var telephone = '9' + teleno
  607. $rootScope.callout = 2;
  608. if ($rootScope.takes) {
  609. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  610. if (data.errno == 0) {
  611. $rootScope.status = 6;
  612. }
  613. })
  614. } else {
  615. SweetAlert.swal({
  616. title: "呼叫失败",
  617. text: "请先签入呼叫中心!",
  618. type: "error",
  619. confirmButtonColor: "#DD6B55"
  620. });
  621. }
  622. } else {
  623. SweetAlert.swal({
  624. title: "呼叫失败",
  625. text: "请先签入呼叫中心!",
  626. type: "error",
  627. confirmButtonColor: "#DD6B55",
  628. });
  629. }
  630. };
  631. /*--------- old record --------- */
  632. $scope.oldRecord = function (data) {
  633. api_bpm_data
  634. .updData("hjzxRecord", {
  635. id: data.id,
  636. field1: "1",
  637. isValid: data.isValid,
  638. isExcute: data.isExcute,
  639. })
  640. .then(function (data) {
  641. if (data.status) {
  642. $scope.refreshData("expand-right", defaultFilterData);
  643. }
  644. });
  645. };
  646. /*--------- record status translate --------- */
  647. $scope.record = function (data) {
  648. var keydata = 0;
  649. if (data.isValid == 1) {
  650. keydata = 0;
  651. } else {
  652. keydata = 1;
  653. }
  654. api_bpm_data
  655. .updData("hjzxRecord", {
  656. id: data.id,
  657. isValid: keydata,
  658. isExcute: 1,
  659. field1: "1",
  660. })
  661. .then(
  662. function (data) {
  663. if (data.status) {
  664. SweetAlert.swal(
  665. {
  666. title: "提交成功!",
  667. text: "有效状态转换成功!",
  668. type: "success",
  669. },
  670. function () {
  671. $scope.refreshData("expand-right", defaultFilterData);
  672. }
  673. );
  674. } else {
  675. SweetAlert.swal({
  676. title: "提交失败!",
  677. text: "有效状态转换失败,请重试!",
  678. type: "error",
  679. });
  680. }
  681. },
  682. function () {
  683. $scope.ldloading[style.replace("-", "_")] = false;
  684. }
  685. );
  686. };
  687. /*--------- double click --------- */
  688. // $scope.onDblClick = function(row) {
  689. // var modelfile = { model: { incident: row.entity } };
  690. // if (row.entity.state == "未受理") {
  691. // angular.extend(modelfile.model.incident, { status: 1 })
  692. // } else {
  693. // angular.extend(modelfile.model.incident, { status: 0 })
  694. // }
  695. // $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
  696. // };
  697. $scope.open = function ($event) {
  698. $event.preventDefault();
  699. $event.stopPropagation();
  700. $scope.opened = !$scope.opened;
  701. };
  702. $scope.endOpen = function ($event) {
  703. $event.preventDefault();
  704. $event.stopPropagation();
  705. $scope.startOpened = false;
  706. $scope.endOpened = !$scope.endOpened;
  707. };
  708. $scope.startOpen = function ($event) {
  709. $event.preventDefault();
  710. $event.stopPropagation();
  711. $scope.endOpened = false;
  712. $scope.startOpened = !$scope.startOpened;
  713. };
  714. /*--------- get zhe list data--------- */
  715. var defaultFilterData = {
  716. idx: 0,
  717. sum: mun,
  718. };
  719. $scope.filData = {
  720. idx: 0,
  721. sum: 10,
  722. hjzxRecord: {
  723. isExcute: 0,
  724. },
  725. };
  726. $scope.searchstate = "weishouli";
  727. $scope.toIncident = function (data) {
  728. $state.go("app.incident.detail", {
  729. formKey: "incident_back",
  730. pdKey: "incident",
  731. dataId: data.incidentDTO.id,
  732. taskId: data.incidentDTO.taskId,
  733. processInstanceId: data.incidentDTO.processInstanceId,
  734. isRecord: "ok",
  735. });
  736. };
  737. $scope.onChange = function (data) {
  738. var toData = "";
  739. if (data == "weishouli") {
  740. toData = 0;
  741. } else if (data == "yishouli") {
  742. toData = 1;
  743. } else if (data == "bushouli") {
  744. toData = 2;
  745. }
  746. $scope.filData.hjzxRecord.isExcute = toData;
  747. $scope.searchstate = data;
  748. $scope.refreshData("expand-right", $scope.filData);
  749. };
  750. // 搜索
  751. $scope.search = function () {
  752. if ($scope.filData.hjzxRecord.startTime) {
  753. $scope.filData.hjzxRecord.startTime = moment(
  754. $scope.filData.hjzxRecord.startTime
  755. ).format("YYYY-MM-DD HH:mm:ss");
  756. }
  757. if ($scope.filData.hjzxRecord.endTime) {
  758. $scope.filData.hjzxRecord.endTime = moment(
  759. $scope.filData.hjzxRecord.endTime
  760. ).format("YYYY-MM-DD HH:mm:ss");
  761. }
  762. $scope.refreshData("expand-right", $scope.filData);
  763. };
  764. // 清空
  765. $scope.cleanItem = function () {
  766. delete $scope.filData.hjzxRecord.startTime;
  767. delete $scope.filData.hjzxRecord.endTime;
  768. $scope.refreshData("expand-right", $scope.filData);
  769. };
  770. $scope.ldloading = {};
  771. $scope.refreshData = function (style, filterData) {
  772. $scope.ldloading[style.replace("-", "_")] = true;
  773. if (angular.isUndefined(filterData)) {
  774. filterData = defaultFilterData;
  775. }
  776. $scope.myData = [];
  777. $scope.gridOptions["sum"] = filterData.sum;
  778. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  779. function (data) {
  780. var myData = Restangular.stripRestangular(data);
  781. $scope.gridOptions["totalItems"] = myData.totalNum;
  782. $scope.myData = myData.list;
  783. for (var i = 0; i < $scope.myData.length; i++) {
  784. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  785. if (!$scope.myData[i]["id"]) {
  786. $scope.myData[i]["id"] = i;
  787. }
  788. }
  789. // console.log($scope.myData)
  790. $scope.ldloading[style.replace("-", "_")] = false;
  791. },
  792. function () {
  793. $scope.ldloading[style.replace("-", "_")] = false;
  794. }
  795. );
  796. };
  797. $scope.refreshData2 = function (style, filterData) {
  798. $scope.ldloading[style.replace("-", "_")] = true;
  799. if (angular.isUndefined(filterData)) {
  800. filterData = defaultFilterData;
  801. }
  802. // $scope.myData = [];
  803. $scope.gridOptions["sum"] = filterData.sum;
  804. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  805. function (data) {
  806. var myData = Restangular.stripRestangular(data);
  807. $scope.gridOptions["totalItems"] = myData.totalNum;
  808. $scope.myData = myData.list;
  809. for (var i = 0; i < $scope.myData.length; i++) {
  810. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  811. if (!$scope.myData[i]["id"]) {
  812. $scope.myData[i]["id"] = i;
  813. }
  814. }
  815. // console.log($scope.myData)
  816. $scope.ldloading[style.replace("-", "_")] = false;
  817. },
  818. function () {
  819. $scope.ldloading[style.replace("-", "_")] = false;
  820. }
  821. );
  822. };
  823. $scope.refreshData("expand-right", $scope.filData);
  824. $scope.timer = $interval(function () {
  825. $scope.refreshData2("expand-right", $scope.filData);
  826. }, $rootScope.refreshTime);
  827. $scope.$on("$destroy", function () {
  828. $interval.cancel($scope.timer);
  829. });
  830. },
  831. ]);
  832. /*--------- operation --------- */
  833. app.controller("Recordoperator", [
  834. "$rootScope",
  835. "$http",
  836. "$scope",
  837. "$modal",
  838. function ($rootScope, $http, $scope, $modal) {
  839. // $scope.handle = false;
  840. // $scope.isvalid = false;
  841. // $scope.novalid = false;
  842. // console.log($scope.item);
  843. // if (!$scope.item.isExcute && !$scope.item.isValid) {
  844. // $scope.handle = true;
  845. // } else { $scope.handle = false; }
  846. // if (!$scope.item.isExcute) {
  847. // if ($scope.item.isValid) {
  848. // $scope.isvalid = true;
  849. // $scope.novalid = false;
  850. // } else {
  851. // $scope.isvalid = false;
  852. // $scope.novalid = true;
  853. // }
  854. // } else {
  855. // $scope.isvalid = false;
  856. // }
  857. $scope.isHuibo = (function () {
  858. var phones = JSON.parse(sessionStorage.getItem("phones"));
  859. console.log(phones, $scope.item.ano);
  860. var isHuajihao = phones && phones.length
  861. ? phones.some((v) => v == $scope.item.ano)
  862. : false;
  863. return !isHuajihao;
  864. })();
  865. $scope.weishouli = false;
  866. $scope.yishouli = false;
  867. $scope.bushouli = false;
  868. var loginUser = $rootScope.user;
  869. $scope.chuli = false;
  870. for (var i = 0; i < loginUser.menu.length; i++) {
  871. if (loginUser.menu[i].link == "liuyanliebiao_chuli") {
  872. $scope.chuli = true;
  873. }
  874. }
  875. if ($scope.item.isExcute == 1) {
  876. $scope.yishouli = true;
  877. } else if ($scope.item.isExcute == 2) {
  878. $scope.bushouli = true;
  879. } else {
  880. $scope.weishouli = true;
  881. }
  882. $scope.edit = function () {
  883. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  884. // $scope.doEdit($scope.item.id);
  885. };
  886. $scope.record = function () {
  887. $scope.colobject.grid.appScope.record($scope.item);
  888. // $scope.doEdit($scope.item.id);
  889. };
  890. $scope.recordcall = function () {
  891. $scope.colobject.grid.appScope.recordcall($scope.item);
  892. // $scope.doEdit($scope.item.id);
  893. };
  894. $scope.recordcallid = function () {
  895. $scope.colobject.grid.appScope.recordcallid($scope.item);
  896. // $scope.doEdit($scope.item.id);
  897. };
  898. $scope.bushouli = function () {
  899. $scope.colobject.grid.appScope.bushouli($scope.item);
  900. };
  901. $scope.toIncident = function () {
  902. $scope.colobject.grid.appScope.toIncident($scope.item);
  903. };
  904. },
  905. ]);
  906. app.directive("recordoperator", function () {
  907. return {
  908. restrict: "E",
  909. scope: {
  910. item: "=",
  911. colobject: "=",
  912. },
  913. controller: "Recordoperator",
  914. template:
  915. '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  916. '<a ng-click="edit()" ng-show="weishouli&&chuli" class="bianjifont">新建事件</a>' +
  917. '<a ng-click="bushouli()" ng-show="weishouli&&chuli" class="bianjifont">不受理</a>' +
  918. // '<a ng-click="record()" ng-show="{{isvalid}}&&{{handle}}" class="luyinfont">有效</a>' +
  919. // '<a ng-click="record()" ng-show="{{novalid}}&&{{handle}}" class="luyinfont">无效</a>' +
  920. '<a ng-click="recordcall()" ng-show="(weishouli||yishouli)&&chuli" class="bianjifont">回放</a>' +
  921. '<a ng-click="recordcallid()" ng-show="(weishouli||yishouli)&&chuli&&isHuibo" class="bianjifont">回拨</a>' +
  922. '<a ng-click="toIncident()" ng-show="yishouli" class="bianjifont">查看事件</a>' +
  923. "</div>",
  924. };
  925. });