bind-extension-number.component.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import { Component, OnInit, Output, Input } from '@angular/core';
  2. import { EventEmitter } from '@angular/core';
  3. import { MainService } from 'src/app/services/main.service';
  4. import { ToolService } from 'src/app/services/tool.service';
  5. import { NzMessageService } from 'ng-zorro-antd';
  6. import { WebsocketIncomingService } from 'src/app/services/websocket-incoming.service';
  7. import { Router } from "@angular/router";
  8. @Component({
  9. selector: 'app-bind-extension-number',
  10. templateUrl: './bind-extension-number.component.html',
  11. styleUrls: ['./bind-extension-number.component.less']
  12. })
  13. export class BindExtensionNumberComponent implements OnInit {
  14. @Input() websocketLoading:boolean = false;
  15. @Input() hsmsData:any = {
  16. checkedHos: undefined,
  17. scopeGroups: [],
  18. orderScopeRadio: undefined,
  19. }
  20. @Input() itsmData:any = {
  21. checkedHos: undefined,
  22. scopeGroups: [],
  23. orderScopeRadio: undefined,
  24. }
  25. @Output() confirmModal = new EventEmitter();
  26. @Output() cancelModal = new EventEmitter();
  27. @Input() coopBtns:any;
  28. constructor(
  29. private mainService: MainService,
  30. private tool: ToolService,
  31. private message: NzMessageService,
  32. private icomingService: WebsocketIncomingService,
  33. public router: Router
  34. ) { }
  35. user = JSON.parse(localStorage.getItem("user")); //用户信息
  36. isLoading:boolean = false;
  37. formData1:any = {};
  38. formData2:any = {};
  39. hospitalList:any[] = [];
  40. // 工单范选项卡
  41. scopeTabs:any[] = [];
  42. activeScopeTab:any;
  43. menuList:any;
  44. ngOnInit() {
  45. // console.log('itsmData', this.itsmData);
  46. // console.log('hsmsData', this.hsmsData);
  47. let menuItem = JSON.parse(localStorage.getItem("menuItem"))
  48. this.menuList = menuItem.find(i=>i.link=='bangdingfenji')
  49. // console.log(111, this.menuList);
  50. this.init()
  51. this.getHospitalList();
  52. this.getHjzxCornetList();
  53. this.getCallCenterConfig();
  54. }
  55. init(){
  56. if(this.menuList && this.menuList.childrens){
  57. for(let i of this.menuList.childrens){
  58. if(i.link=='extension'){
  59. this.scopeTabs.push({ name: '分机绑定', value: 1, checked: false })
  60. }
  61. if(i.link=='callCenter'){
  62. this.scopeTabs.push({ name: '呼叫中心', value: 2, checked: false })
  63. }
  64. }
  65. }
  66. if(this.scopeTabs.length>0){
  67. this.activeScopeTab = this.scopeTabs[0]
  68. }
  69. if(this.scopeTabs.length == 1){
  70. this.scopeTabs[0].checked = true
  71. }
  72. }
  73. // 获取院区列表
  74. getHospitalList() {
  75. // 工单范围
  76. // 运维不限制部门,则取权限下的所有院区和部门
  77. // 运维限制部门,则取运维选中的部门和配送选中的院区
  78. if(this.itsmData.mdv2Switch){
  79. // 开通运维
  80. if(this.itsmData.allDuty === 1){
  81. // 不限制部门
  82. let hospitals = this.user.infoPermission.hospitals || [];
  83. let dutyList = this.user.infoPermission.dutyList || [];
  84. this.hospitalList = hospitals.concat(dutyList);
  85. }else{
  86. // 限制部门
  87. if(this.hsmsData.hsmsSwitch){
  88. // 开通配送
  89. this.hospitalList = this.itsmData.checkedHos.concat(this.hsmsData.checkedHosDTO);
  90. }else{
  91. // 未开通配送
  92. this.hospitalList = this.itsmData.checkedHos;
  93. }
  94. }
  95. }else{
  96. // 未开通运维
  97. if(this.hsmsData.hsmsSwitch){
  98. // 开通配送
  99. this.hospitalList = [this.hsmsData.checkedHosDTO];
  100. }else{
  101. // 未开通配送
  102. this.hospitalList = [];
  103. }
  104. }
  105. }
  106. //获取呼叫中心分机号码
  107. hjzxCornetList:any[] = [];
  108. getHjzxCornetList() {
  109. this.isLoading = true;
  110. this.mainService.getDictionary('list', 'hjzx_cornet').subscribe((data) => {
  111. this.isLoading = false;
  112. this.hjzxCornetList = data || [];
  113. });
  114. }
  115. // 获取呼叫中心服务连接地址
  116. callCenterConfigObj:any = {};
  117. getCallCenterConfig() {
  118. let data = {
  119. idx: 0,
  120. sum: 9999,
  121. callCenterConfig: {},
  122. };
  123. this.mainService
  124. .getFetchDataList("simple/data", "callCenterConfig", data)
  125. .subscribe((data) => {
  126. if (data.status == 200) {
  127. let list = data.list || [];
  128. this.callCenterConfigObj = list.length ? list[0] : {};
  129. }else{
  130. this.message.error(data.msg || "请求数据失败");
  131. }
  132. });
  133. }
  134. // 修改院区
  135. changeHospital(hosId){
  136. this.phoneNumList = [];
  137. this.getPhoneNumList(hosId);
  138. }
  139. // 修改选项卡-是否启动
  140. changeFlag(flag, item){
  141. this.activeScopeTab = item;
  142. if(flag){
  143. this.scopeTabs.forEach(v => {
  144. if(v.value != item.value){
  145. v.checked = false;
  146. }
  147. })
  148. }
  149. }
  150. //获取所有分机号码列表
  151. phoneNumList:any[] = [];
  152. getPhoneNumList(hosId) {
  153. this.isLoading = true;
  154. let postData = {
  155. idx: 0,
  156. sum: 100,
  157. hospitalConfig: { hosId },
  158. };
  159. this.mainService
  160. .getFetchDataList("simple/data", "hospitalConfig", postData)
  161. .subscribe((result) => {
  162. this.isLoading = false;
  163. this.phoneNumList = result.list.filter((item) => item.key.includes("phone_num_port") && item.value);
  164. console.log('this.phoneNumList:', this.phoneNumList)
  165. });
  166. }
  167. // 保存工单范围设置
  168. saveOrderScope() {
  169. let startObj = this.scopeTabs.find((item) => item.checked);
  170. if(startObj){
  171. if(startObj.value == 1){
  172. // 录音盒
  173. if(!this.formData1.number){
  174. this.message.warning('请选择【分机绑定】分机号码')
  175. return;
  176. }
  177. this.icomingService.setSign('box');
  178. this.confirmModal.emit(this.formData1.number);
  179. }else if(startObj.value == 2){
  180. // 呼叫中心
  181. if(!this.formData2.number){
  182. this.message.warning('请选择【呼叫中心】分机号码')
  183. return;
  184. }
  185. if(!this.callCenterConfigObj.socketUrl.trim()){
  186. this.message.warning('呼叫中心服务连接地址未配置,请前往配置中心->三方配置中配置')
  187. return;
  188. }
  189. this.icomingService.setSign('callCenter');
  190. this.icomingService.setSocketUrl(this.callCenterConfigObj.socketUrl);
  191. this.confirmModal.emit(this.formData2.number);
  192. }
  193. }else{
  194. this.message.warning('请启动分机号码或呼叫中心')
  195. }
  196. }
  197. // 关闭弹窗
  198. cancelInit() {
  199. this.cancelModal.emit();
  200. }
  201. }