recordCtrl.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  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. $scope.selectedItemTodo($scope.requester)
  428. };
  429. $scope.selectedItemTodo = function(selectedItem){
  430. if (selectedItem) {
  431. if (selectedItem.telephone && !selectedItem.mphone) {
  432. selectedItem.telephone = angular.copy(selectedItem.mphone);
  433. delete selectedItem.mphone;
  434. }
  435. var data = {
  436. requester: selectedItem,
  437. };
  438. api_user_data
  439. .addData("requester", data)
  440. .then(function (response) {
  441. if (response.status == 200) {
  442. $modalInstance.dismiss("ok");
  443. var data = {
  444. model: {
  445. requestershow: response.data,
  446. recordId: recorddata.id,
  447. incident: {
  448. requester: response.data,
  449. houseNumber: response.data.houseNumber,
  450. contactsInformation: response.data.mphone,
  451. source: { id: 1548 },
  452. },
  453. },
  454. };
  455. if (response.data.branch) {
  456. data.model.incident.branch = response.data.branch;
  457. }
  458. if (response.data.place) {
  459. data.model.incident.area = response.data.place.area;
  460. data.model.incident.place = response.data.place;
  461. }
  462. $state.go("app.incident.title", {
  463. model: JSON.stringify(data),
  464. });
  465. }else{
  466. modalInstance.SweetAlert.swal({
  467. title: "系统错误",
  468. text: "账号重复!",
  469. type: "error",
  470. });
  471. }
  472. });
  473. }
  474. }
  475. $scope.cancel = function () {
  476. $modalInstance.dismiss("cancel");
  477. };
  478. },
  479. });
  480. // modalInstance.result.then(function (selectedItem) {
  481. // if (selectedItem) {
  482. // if (selectedItem.telephone && !selectedItem.mphone) {
  483. // selectedItem.telephone = angular.copy(selectedItem.mphone);
  484. // delete selectedItem.mphone;
  485. // }
  486. // var data = {
  487. // requester: selectedItem,
  488. // };
  489. // api_user_data
  490. // .addData("requester", data)
  491. // .then(function (response) {
  492. // if (response.status == 200) {
  493. // var data = {
  494. // model: {
  495. // requestershow: response.data,
  496. // recordId: recorddata.id,
  497. // incident: {
  498. // requester: response.data,
  499. // houseNumber: response.data.houseNumber,
  500. // contactsInformation: response.data.mphone,
  501. // source: { id: 1548 },
  502. // },
  503. // },
  504. // };
  505. // if (response.data.branch) {
  506. // data.model.incident.branch = response.data.branch;
  507. // }
  508. // if (response.data.place) {
  509. // data.model.incident.area = response.data.place.area;
  510. // data.model.incident.place = response.data.place;
  511. // }
  512. // $state.go("app.incident.title", {
  513. // model: JSON.stringify(data),
  514. // });
  515. // }else{
  516. // modalInstance.SweetAlert.swal({
  517. // title: "系统错误",
  518. // text: "账号重复!",
  519. // type: "error",
  520. // });
  521. // }
  522. // });
  523. // }
  524. // });
  525. } else if (myData.list.length == 1) {
  526. var data = {
  527. model: {
  528. requestershow: myData.list[0],
  529. recordId: recorddata.id,
  530. incident: {
  531. requester: myData.list[0],
  532. houseNumber: myData.list[0].houseNumber,
  533. contactsInformation: myData.list[0].mphone,
  534. source: { id: 1548 },
  535. },
  536. },
  537. };
  538. if (myData.list[0].branch) {
  539. data.model.incident.branch = myData.list[0].branch;
  540. }
  541. if (myData.list[0].place) {
  542. data.model.incident.area = myData.list[0].place.area;
  543. data.model.incident.place = myData.list[0].place;
  544. }
  545. $state.go("app.incident.title", { model: JSON.stringify(data) });
  546. } else {
  547. var modalInstance = $modal.open({
  548. templateUrl: "assets/views/createincident.html",
  549. controller: function (
  550. $scope,
  551. datas,
  552. $modalInstance,
  553. api_user_data
  554. ) {
  555. $scope.title = "请确定报修人";
  556. $scope.requester = myData.list;
  557. $scope.choice = function (requester) {
  558. $modalInstance.dismiss("cancel");
  559. var data = {
  560. model: {
  561. requestershow: requester,
  562. recordId: recorddata.id,
  563. incident: {
  564. requester: requester,
  565. houseNumber: requester.houseNumber,
  566. contactsInformation: requester.mphone,
  567. source: { id: 1548 },
  568. },
  569. },
  570. };
  571. if (requester.branch) {
  572. data.model.incident.branch = requester.branch;
  573. }
  574. if (requester.place) {
  575. data.model.incident.area = requester.place.area;
  576. data.model.incident.place = requester.place;
  577. }
  578. $state.go("app.incident.title", {
  579. model: JSON.stringify(data),
  580. });
  581. };
  582. $scope.cancel = function () {
  583. $modalInstance.dismiss("cancel");
  584. };
  585. },
  586. resolve: {
  587. datas: function () {
  588. return recorddata;
  589. },
  590. },
  591. size: "lg",
  592. });
  593. }
  594. });
  595. // var formdata = {
  596. // 'model': {
  597. // 'incident': {
  598. // 'source': { 'id': 1 },
  599. // },
  600. // 'recordId': data.id
  601. // }
  602. // }
  603. // $state.go('app.incident.chart', { 'model': JSON.stringify(formdata) });
  604. };
  605. /*--------- Recordings --------- */
  606. // $scope.recordcall = function(data) {
  607. // $scope.oldRecord(data);
  608. // var modalInstance = $modal.open({
  609. // templateUrl: 'assets/views/incident/tpl/audio.html',
  610. // controller: function($rootScope, $scope, $modalInstance, $sce) {
  611. // $scope.data = {
  612. // "name": "视频",
  613. // "url": callIp + "/recording/recording?recordId=" + data.id
  614. // };
  615. // $rootScope.setbusy();
  616. // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  617. // $scope.cancel = function() {
  618. // $modalInstance.dismiss('cancel');
  619. // // $rootScope.setidle();
  620. // };
  621. // $modalInstance.close();
  622. // }
  623. // });
  624. // modalInstance.result.then(function(result) {
  625. // // $rootScope.setidle();
  626. // }, function(reason) {
  627. // $rootScope.setidle();
  628. // });
  629. // };
  630. //录音
  631. $scope.recordcall = function (data) {
  632. var modalInstance = $modal.open({
  633. backdrop: "static",
  634. templateUrl: "assets/views/incident/tpl/audio.html",
  635. controller: function (
  636. $rootScope,
  637. $scope,
  638. $modalInstance,
  639. $sce,
  640. $http,
  641. api_playservice
  642. ) {
  643. $scope.audioUrl = $sce.trustAsResourceUrl(callIp + data.recFileName);
  644. $rootScope.setbusy();
  645. // $scope.datasurl = "";
  646. // $http({
  647. // url: callIp + "/recording/recording?recordId=" + data.id,
  648. // method: 'GET',
  649. // headers: {},
  650. // }).success(function(data, status, headers, config) {
  651. // $scope.data = {
  652. // "name": "视频",
  653. // "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
  654. // };
  655. // $scope.datasurl = data.rrpath;
  656. // }).error(function(data, status, headers, config) {});
  657. // $scope.download = function(contentId, filename) {
  658. // $http({
  659. // url: "http://" + $scope.datasurl,
  660. // method: 'GET',
  661. // headers: {
  662. // 'Content-type': 'application/octet-stream',
  663. // },
  664. // responseType: 'arraybuffer'
  665. // }).success(function(data, status, headers, config) {
  666. // var file = new Blob([data], {
  667. // type: 'application/octet-stream'
  668. // });
  669. // //trick to download store a file having its URL
  670. // var fileURL = URL.createObjectURL(file);
  671. // var a = document.createElement('a');
  672. // a.href = fileURL;
  673. // a.target = '_blank';
  674. // a.download = filename;
  675. // document.body.appendChild(a);
  676. // a.click();
  677. // }).error(function(data, status, headers, config) {
  678. // // console.log(data);
  679. // });
  680. // }
  681. $scope.cancel = function () {
  682. $modalInstance.dismiss("cancel");
  683. };
  684. $modalInstance.close();
  685. },
  686. });
  687. modalInstance.result.then(
  688. function (result) {
  689. // $rootScope.setidle();
  690. },
  691. function (reason) {
  692. $rootScope.setidle();
  693. }
  694. );
  695. };
  696. /*--------- call --------- */
  697. $scope.recordcallid = function (data) {
  698. // var telephone = '9' + data.ano;
  699. // $rootScope.callout = 2;
  700. // if ($rootScope.takes) {
  701. // api_text.dialout($rootScope.takes, "@0", telephone).then(function(data) {
  702. // if (data.errno == 0) {
  703. // $rootScope.status = 6;
  704. // $scope.oldRecord(data);
  705. // }
  706. // })
  707. // } else {
  708. // SweetAlert.swal({
  709. // title: "呼叫失败",
  710. // text: "请先签入呼叫中心!",
  711. // type: "error",
  712. // confirmButtonColor: "#DD6B55"
  713. // });
  714. // }
  715. if (localStorage.getItem("fenjiNumber")) {
  716. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  717. // console.log(sessionStorage.getItem('phones'))
  718. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  719. // var isHuajihao = phones.length?phones.some(v=>v == data.ano):false;
  720. // console.log(isHuajihao)
  721. // if(isHuajihao){
  722. // tlwsa.tlaCallagc(data.ano);//呼叫坐席
  723. // }else{
  724. // tlwsa.tlaCallout(data.ano, caller, 0);//呼叫外线
  725. // }
  726. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  727. // tlwsa.tlaCallout(data.ano, caller, 0);
  728. $rootScope.toggle("off-sidebar");
  729. }else if(localStorage.getItem('hk_phone')){
  730. var gid = "@0"
  731. var telephone = '9' + data.ano
  732. if ($rootScope.takes) {
  733. $rootScope.isMask = true;
  734. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  735. $rootScope.isMask = false;
  736. if (data.errno == 0) {
  737. $rootScope.preStatus = $rootScope.callStatus;
  738. $rootScope.callStatus = 4;
  739. $rootScope.callout = 2;
  740. }else{
  741. new Notification("呼叫失败1!", {
  742. icon: './bower_components/HTML5-Desktop-Notifications/alert.ico',
  743. });
  744. }
  745. }, function(err){
  746. $rootScope.isMask = false;
  747. console.error('err', err);
  748. new Notification("呼叫失败2!", {
  749. icon: './bower_components/HTML5-Desktop-Notifications/alert.ico',
  750. });
  751. })
  752. } else {
  753. SweetAlert.swal({
  754. title: "呼叫失败",
  755. text: "请先签入呼叫中心!",
  756. type: "error",
  757. confirmButtonColor: "#DD6B55"
  758. });
  759. }
  760. } else {
  761. SweetAlert.swal({
  762. title: "呼叫失败",
  763. text: "请先签入呼叫中心!",
  764. type: "error",
  765. confirmButtonColor: "#DD6B55",
  766. });
  767. }
  768. };
  769. /*--------- old record --------- */
  770. $scope.oldRecord = function (data) {
  771. api_bpm_data
  772. .updData("hjzxRecord", {
  773. id: data.id,
  774. field1: "1",
  775. isValid: data.isValid,
  776. isExcute: (data.isExcute === 0 || data.isExcute) ? data.isExcute : undefined
  777. })
  778. .then(function (data) {
  779. if (data.status) {
  780. $scope.refreshData("expand-right", defaultFilterData);
  781. }
  782. });
  783. };
  784. /*--------- record status translate --------- */
  785. $scope.record = function (data) {
  786. var keydata = 0;
  787. if (data.isValid == 1) {
  788. keydata = 0;
  789. } else {
  790. keydata = 1;
  791. }
  792. api_bpm_data
  793. .updData("hjzxRecord", {
  794. id: data.id,
  795. isValid: keydata,
  796. isExcute: 1,
  797. field1: "1",
  798. })
  799. .then(
  800. function (data) {
  801. if (data.status) {
  802. SweetAlert.swal(
  803. {
  804. title: "提交成功!",
  805. text: "有效状态转换成功!",
  806. type: "success",
  807. },
  808. function () {
  809. $scope.refreshData("expand-right", defaultFilterData);
  810. }
  811. );
  812. } else {
  813. SweetAlert.swal({
  814. title: "提交失败!",
  815. text: "有效状态转换失败,请重试!",
  816. type: "error",
  817. });
  818. }
  819. },
  820. function () {
  821. $scope.ldloading[style.replace("-", "_")] = false;
  822. }
  823. );
  824. };
  825. /*--------- double click --------- */
  826. // $scope.onDblClick = function(row) {
  827. // var modelfile = { model: { incident: row.entity } };
  828. // if (row.entity.state == "未受理") {
  829. // angular.extend(modelfile.model.incident, { status: 1 })
  830. // } else {
  831. // angular.extend(modelfile.model.incident, { status: 0 })
  832. // }
  833. // $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
  834. // };
  835. $scope.open = function ($event) {
  836. $event.preventDefault();
  837. $event.stopPropagation();
  838. $scope.opened = !$scope.opened;
  839. };
  840. $scope.endOpen = function ($event) {
  841. $event.preventDefault();
  842. $event.stopPropagation();
  843. $scope.startOpened = false;
  844. $scope.endOpened = !$scope.endOpened;
  845. };
  846. $scope.startOpen = function ($event) {
  847. $event.preventDefault();
  848. $event.stopPropagation();
  849. $scope.endOpened = false;
  850. $scope.startOpened = !$scope.startOpened;
  851. };
  852. /*--------- get zhe list data--------- */
  853. var defaultFilterData = {
  854. idx: 0,
  855. sum: mun,
  856. };
  857. $scope.filData = {
  858. idx: 0,
  859. sum: 10,
  860. hjzxRecord: {
  861. isExcute: 0,
  862. },
  863. };
  864. $scope.searchstate = "weishouli";
  865. $scope.toIncident = function (data) {
  866. $state.go("app.incident.detail", {
  867. formKey: "incident_back",
  868. pdKey: "incident",
  869. dataId: data.incidentDTO.id,
  870. taskId: data.incidentDTO.taskId,
  871. processInstanceId: data.incidentDTO.processInstanceId,
  872. isRecord: "ok",
  873. });
  874. };
  875. $scope.onChange = function (data) {
  876. var toData = "";
  877. if (data == "weishouli") {
  878. toData = 0;
  879. } else if (data == "yishouli") {
  880. toData = 1;
  881. } else if (data == "bushouli") {
  882. toData = 2;
  883. }
  884. $scope.filData.idx = 0;
  885. $scope.filData.hjzxRecord.isExcute = (toData === 0 || toData) ? toData : undefined;
  886. if($scope.searchstate == data){
  887. $scope.refreshData("expand-right", $scope.filData);
  888. }else{
  889. $scope.gridOptions.paginationCurrentPage = 0;
  890. }
  891. $scope.searchstate = data;
  892. };
  893. // 搜索
  894. $scope.search = function () {
  895. if ($scope.filData.hjzxRecord.startTime) {
  896. $scope.filData.hjzxRecord.startTime = moment(
  897. $scope.filData.hjzxRecord.startTime
  898. ).format("YYYY-MM-DD HH:mm:ss");
  899. }
  900. if ($scope.filData.hjzxRecord.endTime) {
  901. $scope.filData.hjzxRecord.endTime = moment(
  902. $scope.filData.hjzxRecord.endTime
  903. ).format("YYYY-MM-DD HH:mm:ss");
  904. }
  905. $scope.refreshData("expand-right", $scope.filData);
  906. };
  907. // 清空
  908. $scope.cleanItem = function () {
  909. delete $scope.filData.hjzxRecord.startTime;
  910. delete $scope.filData.hjzxRecord.endTime;
  911. delete $scope.filData.hjzxRecord.ano;
  912. $scope.refreshData("expand-right", $scope.filData);
  913. };
  914. $scope.ldloading = {};
  915. $scope.refreshData = function (style, filterData) {
  916. $scope.ldloading[style.replace("-", "_")] = true;
  917. if (angular.isUndefined(filterData)) {
  918. filterData = defaultFilterData;
  919. }
  920. $scope.myData = [];
  921. $scope.gridOptions["sum"] = filterData.sum;
  922. var toData = '';
  923. if ($scope.searchstate == "weishouli") {
  924. toData = 0;
  925. } else if ($scope.searchstate == "yishouli") {
  926. toData = 1;
  927. } else if ($scope.searchstate == "bushouli") {
  928. toData = 2;
  929. }
  930. filterData.hjzxRecord.isExcute = (toData === 0 || toData) ? toData : undefined;
  931. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  932. function (data) {
  933. var myData = Restangular.stripRestangular(data);
  934. $scope.gridOptions["totalItems"] = myData.totalNum;
  935. $scope.myData = myData.list;
  936. for (var i = 0; i < $scope.myData.length; i++) {
  937. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  938. if (!$scope.myData[i]["id"]) {
  939. $scope.myData[i]["id"] = i;
  940. }
  941. }
  942. // console.log($scope.myData)
  943. $scope.ldloading[style.replace("-", "_")] = false;
  944. },
  945. function () {
  946. $scope.ldloading[style.replace("-", "_")] = false;
  947. }
  948. );
  949. };
  950. $scope.refreshData2 = function (style, filterData) {
  951. $scope.ldloading[style.replace("-", "_")] = true;
  952. if (angular.isUndefined(filterData)) {
  953. filterData = defaultFilterData;
  954. }
  955. // $scope.myData = [];
  956. $scope.gridOptions["sum"] = filterData.sum;
  957. $scope.gridOptions.paginationCurrentPage = filterData.idx + 1;
  958. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  959. function (data) {
  960. var myData = Restangular.stripRestangular(data);
  961. $scope.gridOptions["totalItems"] = myData.totalNum;
  962. $scope.myData = myData.list;
  963. for (var i = 0; i < $scope.myData.length; i++) {
  964. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  965. if (!$scope.myData[i]["id"]) {
  966. $scope.myData[i]["id"] = i;
  967. }
  968. }
  969. // console.log($scope.myData)
  970. $scope.ldloading[style.replace("-", "_")] = false;
  971. },
  972. function () {
  973. $scope.ldloading[style.replace("-", "_")] = false;
  974. }
  975. );
  976. };
  977. $scope.refreshData("expand-right", $scope.filData);
  978. // $scope.timer = $interval(function () {
  979. // $scope.refreshData2("expand-right", $scope.filData);
  980. // }, $rootScope.refreshTime);
  981. $scope.$on("$destroy", function () {
  982. $interval.cancel($scope.timer);
  983. });
  984. },
  985. ]);
  986. /*--------- operation --------- */
  987. app.controller("Recordoperator", [
  988. "$rootScope",
  989. "$http",
  990. "$scope",
  991. "$modal",
  992. function ($rootScope, $http, $scope, $modal) {
  993. // $scope.handle = false;
  994. // $scope.isvalid = false;
  995. // $scope.novalid = false;
  996. // console.log($scope.item);
  997. // if (!$scope.item.isExcute && !$scope.item.isValid) {
  998. // $scope.handle = true;
  999. // } else { $scope.handle = false; }
  1000. // if (!$scope.item.isExcute) {
  1001. // if ($scope.item.isValid) {
  1002. // $scope.isvalid = true;
  1003. // $scope.novalid = false;
  1004. // } else {
  1005. // $scope.isvalid = false;
  1006. // $scope.novalid = true;
  1007. // }
  1008. // } else {
  1009. // $scope.isvalid = false;
  1010. // }
  1011. $scope.isHuibo = (function () {
  1012. var phones = JSON.parse(sessionStorage.getItem("phones"));
  1013. console.log(phones, $scope.item.ano);
  1014. var isHuajihao = phones && phones.length
  1015. ? phones.some((v) => v == $scope.item.ano)
  1016. : false;
  1017. return !isHuajihao;
  1018. })();
  1019. $scope.weishouli = false;
  1020. $scope.yishouli = false;
  1021. $scope.bushouli = false;
  1022. var loginUser = $rootScope.user;
  1023. $scope.chuli = false;
  1024. for (var i = 0; i < loginUser.menu.length; i++) {
  1025. if (loginUser.menu[i].link == "liuyanliebiao_chuli") {
  1026. $scope.chuli = true;
  1027. }
  1028. }
  1029. if ($scope.item.isExcute == 1) {
  1030. $scope.yishouli = true;
  1031. } else if ($scope.item.isExcute == 2) {
  1032. $scope.bushouli = true;
  1033. } else {
  1034. $scope.weishouli = true;
  1035. }
  1036. $scope.edit = function () {
  1037. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  1038. // $scope.doEdit($scope.item.id);
  1039. };
  1040. $scope.record = function () {
  1041. $scope.colobject.grid.appScope.record($scope.item);
  1042. // $scope.doEdit($scope.item.id);
  1043. };
  1044. $scope.recordcall = function () {
  1045. $scope.colobject.grid.appScope.recordcall($scope.item);
  1046. // $scope.doEdit($scope.item.id);
  1047. };
  1048. $scope.recordcallid = function () {
  1049. $scope.colobject.grid.appScope.recordcallid($scope.item);
  1050. // $scope.doEdit($scope.item.id);
  1051. };
  1052. $scope.bushouli = function () {
  1053. $scope.colobject.grid.appScope.bushouli($scope.item);
  1054. };
  1055. $scope.toIncident = function () {
  1056. $scope.colobject.grid.appScope.toIncident($scope.item);
  1057. };
  1058. },
  1059. ]);
  1060. app.directive("recordoperator", function () {
  1061. return {
  1062. restrict: "E",
  1063. scope: {
  1064. item: "=",
  1065. colobject: "=",
  1066. },
  1067. controller: "Recordoperator",
  1068. template:
  1069. '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  1070. '<a ng-click="edit()" ng-show="weishouli&&chuli" class="bianjifont">新建事件</a>' +
  1071. '<a ng-click="bushouli()" ng-show="weishouli&&chuli" class="bianjifont">不受理</a>' +
  1072. // '<a ng-click="record()" ng-show="{{isvalid}}&&{{handle}}" class="luyinfont">有效</a>' +
  1073. // '<a ng-click="record()" ng-show="{{novalid}}&&{{handle}}" class="luyinfont">无效</a>' +
  1074. '<a ng-click="recordcall()" ng-show="(weishouli||yishouli)&&chuli" class="bianjifont">回放</a>' +
  1075. '<a ng-click="recordcallid()" ng-show="(weishouli||yishouli)&&chuli&&isHuibo" class="bianjifont">回拨</a>' +
  1076. '<a ng-click="toIncident()" ng-show="yishouli" class="bianjifont">查看事件</a>' +
  1077. "</div>",
  1078. };
  1079. });