recordCtrl.js 32 KB

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