recordCtrl.js 34 KB

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