recordCtrl.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  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. $rootScope.callout = 2;
  733. if ($rootScope.takes) {
  734. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  735. if (data.errno == 0) {
  736. $rootScope.status = 6;
  737. }
  738. })
  739. } else {
  740. SweetAlert.swal({
  741. title: "呼叫失败",
  742. text: "请先签入呼叫中心!",
  743. type: "error",
  744. confirmButtonColor: "#DD6B55"
  745. });
  746. }
  747. } else {
  748. SweetAlert.swal({
  749. title: "呼叫失败",
  750. text: "请先签入呼叫中心!",
  751. type: "error",
  752. confirmButtonColor: "#DD6B55",
  753. });
  754. }
  755. };
  756. /*--------- old record --------- */
  757. $scope.oldRecord = function (data) {
  758. api_bpm_data
  759. .updData("hjzxRecord", {
  760. id: data.id,
  761. field1: "1",
  762. isValid: data.isValid,
  763. isExcute: (data.isExcute === 0 || data.isExcute) ? data.isExcute : undefined
  764. })
  765. .then(function (data) {
  766. if (data.status) {
  767. $scope.refreshData("expand-right", defaultFilterData);
  768. }
  769. });
  770. };
  771. /*--------- record status translate --------- */
  772. $scope.record = function (data) {
  773. var keydata = 0;
  774. if (data.isValid == 1) {
  775. keydata = 0;
  776. } else {
  777. keydata = 1;
  778. }
  779. api_bpm_data
  780. .updData("hjzxRecord", {
  781. id: data.id,
  782. isValid: keydata,
  783. isExcute: 1,
  784. field1: "1",
  785. })
  786. .then(
  787. function (data) {
  788. if (data.status) {
  789. SweetAlert.swal(
  790. {
  791. title: "提交成功!",
  792. text: "有效状态转换成功!",
  793. type: "success",
  794. },
  795. function () {
  796. $scope.refreshData("expand-right", defaultFilterData);
  797. }
  798. );
  799. } else {
  800. SweetAlert.swal({
  801. title: "提交失败!",
  802. text: "有效状态转换失败,请重试!",
  803. type: "error",
  804. });
  805. }
  806. },
  807. function () {
  808. $scope.ldloading[style.replace("-", "_")] = false;
  809. }
  810. );
  811. };
  812. /*--------- double click --------- */
  813. // $scope.onDblClick = function(row) {
  814. // var modelfile = { model: { incident: row.entity } };
  815. // if (row.entity.state == "未受理") {
  816. // angular.extend(modelfile.model.incident, { status: 1 })
  817. // } else {
  818. // angular.extend(modelfile.model.incident, { status: 0 })
  819. // }
  820. // $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
  821. // };
  822. $scope.open = function ($event) {
  823. $event.preventDefault();
  824. $event.stopPropagation();
  825. $scope.opened = !$scope.opened;
  826. };
  827. $scope.endOpen = function ($event) {
  828. $event.preventDefault();
  829. $event.stopPropagation();
  830. $scope.startOpened = false;
  831. $scope.endOpened = !$scope.endOpened;
  832. };
  833. $scope.startOpen = function ($event) {
  834. $event.preventDefault();
  835. $event.stopPropagation();
  836. $scope.endOpened = false;
  837. $scope.startOpened = !$scope.startOpened;
  838. };
  839. /*--------- get zhe list data--------- */
  840. var defaultFilterData = {
  841. idx: 0,
  842. sum: mun,
  843. };
  844. $scope.filData = {
  845. idx: 0,
  846. sum: 10,
  847. hjzxRecord: {
  848. isExcute: 0,
  849. },
  850. };
  851. $scope.searchstate = "weishouli";
  852. $scope.toIncident = function (data) {
  853. $state.go("app.incident.detail", {
  854. formKey: "incident_back",
  855. pdKey: "incident",
  856. dataId: data.incidentDTO.id,
  857. taskId: data.incidentDTO.taskId,
  858. processInstanceId: data.incidentDTO.processInstanceId,
  859. isRecord: "ok",
  860. });
  861. };
  862. $scope.onChange = function (data) {
  863. var toData = "";
  864. if (data == "weishouli") {
  865. toData = 0;
  866. } else if (data == "yishouli") {
  867. toData = 1;
  868. } else if (data == "bushouli") {
  869. toData = 2;
  870. }
  871. $scope.filData.idx = 0;
  872. $scope.filData.hjzxRecord.isExcute = (toData === 0 || toData) ? toData : undefined;
  873. if($scope.searchstate == data){
  874. $scope.refreshData("expand-right", $scope.filData);
  875. }else{
  876. $scope.gridOptions.paginationCurrentPage = 0;
  877. }
  878. $scope.searchstate = data;
  879. };
  880. // 搜索
  881. $scope.search = function () {
  882. if ($scope.filData.hjzxRecord.startTime) {
  883. $scope.filData.hjzxRecord.startTime = moment(
  884. $scope.filData.hjzxRecord.startTime
  885. ).format("YYYY-MM-DD HH:mm:ss");
  886. }
  887. if ($scope.filData.hjzxRecord.endTime) {
  888. $scope.filData.hjzxRecord.endTime = moment(
  889. $scope.filData.hjzxRecord.endTime
  890. ).format("YYYY-MM-DD HH:mm:ss");
  891. }
  892. $scope.refreshData("expand-right", $scope.filData);
  893. };
  894. // 清空
  895. $scope.cleanItem = function () {
  896. delete $scope.filData.hjzxRecord.startTime;
  897. delete $scope.filData.hjzxRecord.endTime;
  898. delete $scope.filData.hjzxRecord.ano;
  899. $scope.refreshData("expand-right", $scope.filData);
  900. };
  901. $scope.ldloading = {};
  902. $scope.refreshData = function (style, filterData) {
  903. $scope.ldloading[style.replace("-", "_")] = true;
  904. if (angular.isUndefined(filterData)) {
  905. filterData = defaultFilterData;
  906. }
  907. $scope.myData = [];
  908. $scope.gridOptions["sum"] = filterData.sum;
  909. var toData = '';
  910. if ($scope.searchstate == "weishouli") {
  911. toData = 0;
  912. } else if ($scope.searchstate == "yishouli") {
  913. toData = 1;
  914. } else if ($scope.searchstate == "bushouli") {
  915. toData = 2;
  916. }
  917. filterData.hjzxRecord.isExcute = (toData === 0 || toData) ? toData : undefined;
  918. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  919. function (data) {
  920. var myData = Restangular.stripRestangular(data);
  921. $scope.gridOptions["totalItems"] = myData.totalNum;
  922. $scope.myData = myData.list;
  923. for (var i = 0; i < $scope.myData.length; i++) {
  924. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  925. if (!$scope.myData[i]["id"]) {
  926. $scope.myData[i]["id"] = i;
  927. }
  928. }
  929. // console.log($scope.myData)
  930. $scope.ldloading[style.replace("-", "_")] = false;
  931. },
  932. function () {
  933. $scope.ldloading[style.replace("-", "_")] = false;
  934. }
  935. );
  936. };
  937. $scope.refreshData2 = function (style, filterData) {
  938. $scope.ldloading[style.replace("-", "_")] = true;
  939. if (angular.isUndefined(filterData)) {
  940. filterData = defaultFilterData;
  941. }
  942. // $scope.myData = [];
  943. $scope.gridOptions["sum"] = filterData.sum;
  944. $scope.gridOptions.paginationCurrentPage = filterData.idx + 1;
  945. api_bpm_data.fetchDataList("hjzxRecord", filterData).then(
  946. function (data) {
  947. var myData = Restangular.stripRestangular(data);
  948. $scope.gridOptions["totalItems"] = myData.totalNum;
  949. $scope.myData = myData.list;
  950. for (var i = 0; i < $scope.myData.length; i++) {
  951. $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
  952. if (!$scope.myData[i]["id"]) {
  953. $scope.myData[i]["id"] = i;
  954. }
  955. }
  956. // console.log($scope.myData)
  957. $scope.ldloading[style.replace("-", "_")] = false;
  958. },
  959. function () {
  960. $scope.ldloading[style.replace("-", "_")] = false;
  961. }
  962. );
  963. };
  964. $scope.refreshData("expand-right", $scope.filData);
  965. // $scope.timer = $interval(function () {
  966. // $scope.refreshData2("expand-right", $scope.filData);
  967. // }, $rootScope.refreshTime);
  968. $scope.$on("$destroy", function () {
  969. $interval.cancel($scope.timer);
  970. });
  971. },
  972. ]);
  973. /*--------- operation --------- */
  974. app.controller("Recordoperator", [
  975. "$rootScope",
  976. "$http",
  977. "$scope",
  978. "$modal",
  979. function ($rootScope, $http, $scope, $modal) {
  980. // $scope.handle = false;
  981. // $scope.isvalid = false;
  982. // $scope.novalid = false;
  983. // console.log($scope.item);
  984. // if (!$scope.item.isExcute && !$scope.item.isValid) {
  985. // $scope.handle = true;
  986. // } else { $scope.handle = false; }
  987. // if (!$scope.item.isExcute) {
  988. // if ($scope.item.isValid) {
  989. // $scope.isvalid = true;
  990. // $scope.novalid = false;
  991. // } else {
  992. // $scope.isvalid = false;
  993. // $scope.novalid = true;
  994. // }
  995. // } else {
  996. // $scope.isvalid = false;
  997. // }
  998. $scope.isHuibo = (function () {
  999. var phones = JSON.parse(sessionStorage.getItem("phones"));
  1000. console.log(phones, $scope.item.ano);
  1001. var isHuajihao = phones && phones.length
  1002. ? phones.some((v) => v == $scope.item.ano)
  1003. : false;
  1004. return !isHuajihao;
  1005. })();
  1006. $scope.weishouli = false;
  1007. $scope.yishouli = false;
  1008. $scope.bushouli = false;
  1009. var loginUser = $rootScope.user;
  1010. $scope.chuli = false;
  1011. for (var i = 0; i < loginUser.menu.length; i++) {
  1012. if (loginUser.menu[i].link == "liuyanliebiao_chuli") {
  1013. $scope.chuli = true;
  1014. }
  1015. }
  1016. if ($scope.item.isExcute == 1) {
  1017. $scope.yishouli = true;
  1018. } else if ($scope.item.isExcute == 2) {
  1019. $scope.bushouli = true;
  1020. } else {
  1021. $scope.weishouli = true;
  1022. }
  1023. $scope.edit = function () {
  1024. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  1025. // $scope.doEdit($scope.item.id);
  1026. };
  1027. $scope.record = function () {
  1028. $scope.colobject.grid.appScope.record($scope.item);
  1029. // $scope.doEdit($scope.item.id);
  1030. };
  1031. $scope.recordcall = function () {
  1032. $scope.colobject.grid.appScope.recordcall($scope.item);
  1033. // $scope.doEdit($scope.item.id);
  1034. };
  1035. $scope.recordcallid = function () {
  1036. $scope.colobject.grid.appScope.recordcallid($scope.item);
  1037. // $scope.doEdit($scope.item.id);
  1038. };
  1039. $scope.bushouli = function () {
  1040. $scope.colobject.grid.appScope.bushouli($scope.item);
  1041. };
  1042. $scope.toIncident = function () {
  1043. $scope.colobject.grid.appScope.toIncident($scope.item);
  1044. };
  1045. },
  1046. ]);
  1047. app.directive("recordoperator", function () {
  1048. return {
  1049. restrict: "E",
  1050. scope: {
  1051. item: "=",
  1052. colobject: "=",
  1053. },
  1054. controller: "Recordoperator",
  1055. template:
  1056. '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  1057. '<a ng-click="edit()" ng-show="weishouli&&chuli" class="bianjifont">新建事件</a>' +
  1058. '<a ng-click="bushouli()" ng-show="weishouli&&chuli" class="bianjifont">不受理</a>' +
  1059. // '<a ng-click="record()" ng-show="{{isvalid}}&&{{handle}}" class="luyinfont">有效</a>' +
  1060. // '<a ng-click="record()" ng-show="{{novalid}}&&{{handle}}" class="luyinfont">无效</a>' +
  1061. '<a ng-click="recordcall()" ng-show="(weishouli||yishouli)&&chuli" class="bianjifont">回放</a>' +
  1062. '<a ng-click="recordcallid()" ng-show="(weishouli||yishouli)&&chuli&&isHuibo" class="bianjifont">回拨</a>' +
  1063. '<a ng-click="toIncident()" ng-show="yishouli" class="bianjifont">查看事件</a>' +
  1064. "</div>",
  1065. };
  1066. });