recordCtrl.js 35 KB

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