configuration-message.component.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. import { Component, OnInit, Input } from "@angular/core";
  2. import { ActivatedRoute } from "@angular/router";
  3. import { MainService } from "../../../services/main.service";
  4. import { ToolService } from 'src/app/services/tool.service';
  5. import { NzMessageService } from 'ng-zorro-antd';
  6. @Component({
  7. selector: "app-configuration-message",
  8. templateUrl: "./configuration-message.component.html",
  9. styleUrls: ["./configuration-message.component.less"],
  10. })
  11. export class ConfigurationMessageComponent implements OnInit {
  12. @Input() wechatConfigTypeValue: string;
  13. constructor(
  14. private route: ActivatedRoute,
  15. private mainService: MainService,
  16. private tool: ToolService,
  17. private message: NzMessageService,
  18. ) {}
  19. coopData: any = {}; //当前操作列
  20. currentHospital; //当前院区
  21. ngOnInit() {
  22. this.currentHospital = this.tool.getCurrentHospital();
  23. setTimeout(() => {
  24. this.tableHeight = document.querySelector('#wechatTable').clientHeight - 8 - document.querySelector('#wechatTable .thead').clientHeight;
  25. }, 0)
  26. this.getWechatConfigTypeList();
  27. this.getList();
  28. }
  29. // 新增弹框
  30. modelName = ""; //模态框名称
  31. modalMessage: boolean = false; //新增/编辑模态框
  32. add: boolean; //true:新增;false:编辑
  33. //关闭新增/编辑弹框
  34. hideMessageModal() {
  35. this.modalMessage = false;
  36. }
  37. // 选项卡
  38. //tabName: 名称,processTitle:标题, processContent: 内容, checkboxFlag: checkbox是否选中,,disable:遮罩是否显示
  39. tabs = []
  40. //变量参数
  41. varArr = [];
  42. // 写入
  43. writeIn(tab, content, event, type){
  44. console.log(event);
  45. var element = event.target.parentElement.parentElement.parentElement.previousElementSibling.children[1];
  46. if (element.selectionStart || element.selectionStart == '0') {
  47. var startPos = element.selectionStart;
  48. var endPos = element.selectionEnd;
  49. tab[type] = element.value.substring(0, startPos) + content + element.value.substring(endPos);
  50. element.focus();
  51. setTimeout(() => {
  52. element.setSelectionRange(startPos + content.length, startPos + content.length);
  53. },0)
  54. } else {
  55. var val = element.value + content;
  56. tab[type] = val;
  57. element.focus();
  58. }
  59. }
  60. // 编辑
  61. currentIndex = 0;
  62. editData:any = {};
  63. edit(data) {
  64. console.log(data);
  65. this.modelName = "编辑";
  66. this.add = false;
  67. this.modalMessage = true;
  68. this.coopData = data;
  69. this.editData = {
  70. id: data.id,//id
  71. noticeCode: data.noticeCode,
  72. noticeRule: data.noticeRule === undefined ? 'no' : data.noticeRule,//通知规则,数字
  73. noticeNode: data.noticeNode,//流程节点
  74. processName: data.processName,//报修流程或者事件流程
  75. noticeState: data.noticeState,//状态
  76. noticeDetails: data.noticeDetails,//被通知人
  77. noticeProcess: data.noticeProcess,//1为报修流程、2为事件流程
  78. messageStationContent: data.messageStationContent,//站内消息通知内容
  79. shortMessageContent: data.shortMessageContent,//短信通知内容
  80. wechatMessageContent: data.wechatMessageContent,//微信通知内容
  81. messageStationFlag: data.messageStationFlag == 1 ? true : false,//站内消息是否开启
  82. shortMessageFlag: data.shortMessageFlag == 1 ? true : false,//短信是否开启
  83. wechatMessageFlag: data.wechatMessageFlag == 1 ? true : false,//微信是否开启
  84. messageStationTitle: data.messageStationTitle,//站内消息标题
  85. wechatMessageTitle: data.wechatMessageTitle,//微信标题
  86. flag: data.flag == 1 ? true : false,//总开关是否开启,0为关闭,1为开启
  87. wechatConfigTypeId: data.wechatConfigType ? data.wechatConfigType.id : null,//微信配置类型
  88. };
  89. if(this.wechatConfigTypeValue === 'hsms'){
  90. // 转运
  91. this.tabs = [
  92. {
  93. tabName: "站内消息",
  94. processTitle: this.editData.messageStationTitle,
  95. processContent: this.editData.messageStationContent,
  96. checkboxFlag: this.editData.messageStationFlag,
  97. disable: !this.editData.messageStationFlag,
  98. hidden: true,
  99. },
  100. {
  101. tabName: "短信",
  102. processTitle: '',
  103. processContent: this.editData.shortMessageContent,
  104. checkboxFlag: this.editData.shortMessageFlag,
  105. disable: !this.editData.shortMessageFlag,
  106. hidden: false,
  107. },
  108. {
  109. tabName: "微信",
  110. processTitle: this.editData.wechatMessageTitle,
  111. processContent: this.editData.wechatMessageContent,
  112. checkboxFlag: this.editData.wechatMessageFlag,
  113. disable: !this.editData.wechatMessageFlag,
  114. hidden: false,
  115. }
  116. ];
  117. this.varArr = [
  118. "[$患者信息$]",
  119. "[$建单人$]",
  120. ];
  121. if(data.noticeCode === 'pil_sign_user'){
  122. // 驻点人员
  123. this.varArr = [
  124. "[$患者信息$]",
  125. "[$建单人$]",
  126. ];
  127. }else if(data.noticeCode === 'remove_workorder'){
  128. // 支助人员
  129. this.varArr = [
  130. "[$工单单号$]",
  131. "[$申请科室$]",
  132. "[$起点科室$]",
  133. "[$终点科室$]",
  134. "[$发起时间$]",
  135. "[$执行人$]",
  136. "[$状态$]",
  137. "[$任务类型$]",
  138. "[$总积分$]",
  139. "[$执行时长$]",
  140. "[$患者信息$]",
  141. "[$删除原因$]",
  142. ];
  143. }else if(data.noticeCode === 'pil_sign_user2'){
  144. // 陪检签到通知驻点人员
  145. this.varArr = [
  146. "[$患者信息$]",
  147. "[$签到人$]",
  148. "[$签到科室$]",
  149. "[$签到时间$]",
  150. ];
  151. }else if(data.noticeCode === 'inspect_trans_receiver' || data.noticeCode ==='inspect_trans_transUser'){
  152. this.varArr = [
  153. "[$患者信息$]",
  154. "[$患者联系电话$]",
  155. "[$工单单号$]",
  156. "[$转派人$]",
  157. "[$接收人$]",
  158. "[$任务类型$]",
  159. "[$发起时间$]",
  160. "[$申请科室$]",
  161. "[$起点科室$]",
  162. "[$终点科室$]",
  163. ];
  164. }else if(data.noticeCode === 'work_order_remind' || data.noticeCode ==='work_order_remind_freedom' || data.noticeCode === 'work_order_dispatch_reminder'){
  165. this.varArr = [
  166. "[$任务类型$]",
  167. "[$工单单号$]",
  168. "[$申请科室$]",
  169. "[$起点科室$]",
  170. "[$终点科室$]",
  171. "[$发起时间$]",
  172. "[$是否紧急$]"
  173. ];
  174. }
  175. this.currentIndex = 1;
  176. }else if(this.wechatConfigTypeValue === 'mdv2_handle'){
  177. // 运维
  178. this.tabs = [
  179. {
  180. tabName: "站内消息",
  181. processTitle: this.editData.messageStationTitle,
  182. processContent: this.editData.messageStationContent,
  183. checkboxFlag: this.editData.messageStationFlag,
  184. disable: !this.editData.messageStationFlag,
  185. hidden: false,
  186. },
  187. {
  188. tabName: "短信",
  189. processTitle: '',
  190. processContent: this.editData.shortMessageContent,
  191. checkboxFlag: this.editData.shortMessageFlag,
  192. disable: !this.editData.shortMessageFlag,
  193. hidden: false,
  194. },
  195. {
  196. tabName: "微信",
  197. processTitle: this.editData.wechatMessageTitle,
  198. processContent: this.editData.wechatMessageContent,
  199. checkboxFlag: this.editData.wechatMessageFlag,
  200. disable: !this.editData.wechatMessageFlag,
  201. hidden: false,
  202. }
  203. ];
  204. this.varArr = [
  205. "[$报修单号$]",
  206. "[$报修科室$]",
  207. "[$报修时间$]",
  208. "[$报修人$]",
  209. "[$详细地址$]",
  210. "[$不受理时间$]",
  211. "[$不受理原因$]",
  212. "[$故障描述$]",
  213. "[$服务台人员$]",
  214. "[$受理时间$]",
  215. "[$事件单号$]",
  216. "[$地点$]",
  217. "[$区域$]",
  218. "[$学工号$]",
  219. "[$联系人电话$]",
  220. "[$受理人$]",
  221. "[$受理人电话$]",
  222. "[$处理人$]",
  223. "[$处理人电话$]",
  224. "[$指派人$]",
  225. "[$转派人$]",
  226. "[$延期原因$]",
  227. "[$进入系统$]",
  228. "[$回访满意度$]",
  229. "[$回访备注$]",
  230. "[$回访处理结果$]",
  231. "[$评价满意度$]",
  232. "[$评价内容$]",
  233. ];
  234. this.currentIndex = 0;
  235. }
  236. }
  237. //tab页面切换
  238. selectTab(index) {
  239. this.currentIndex = index;
  240. };
  241. //checkbox选中或者取消
  242. selectThis(e, index) {
  243. this.selectTab(index);
  244. //遮罩切换
  245. this.tabs[index].disable = !this.tabs[index].checkboxFlag;
  246. //所有checkbox有一个选中,总开关开启
  247. this.editData.flag = this.tabs.some(function (v) {
  248. return v.checkboxFlag;
  249. });
  250. };
  251. // 新增/编辑表单提交
  252. btnLoading: boolean = false; //提交按钮loading状态
  253. submitMessageForm(): void {
  254. // 微信-微信配置类型
  255. if(this.tabs[2].checkboxFlag && !this.editData.wechatConfigTypeId) {
  256. this.showPromptModal('保存', false, "请选择微信配置类型");
  257. return;
  258. }
  259. var filterArr = this.tabs.filter(item => {
  260. return item.checkboxFlag;
  261. });
  262. for (var i = 0; i < filterArr.length; i++) {
  263. if (filterArr[i].processContent == '') {
  264. this.showPromptModal('保存', false, "通知内容【" + filterArr[i].tabName + "】不能为空!");
  265. return;
  266. } else {
  267. var nowArr = [...new Set([...(filterArr[i].processContent.match(/\[\$[^\$\[\]]*?\$\]/g) || []), ...this.varArr])];
  268. if (nowArr.length !== this.varArr.length) {
  269. this.showPromptModal('保存', false, "【" + filterArr[i].tabName + "】请填写有效的变量名称!");
  270. return;
  271. }
  272. }
  273. }
  274. this.btnLoading = true;
  275. let postData:any = {};
  276. //请求参数处理(是否有输入数字控件)
  277. if (this.editData.noticeRule !== 'no') {
  278. postData = {
  279. // "messageManager": {
  280. "id": this.editData.id,
  281. "noticeRule": this.editData.noticeRule,
  282. "messageStationFlag": this.tabs[0].checkboxFlag ? 1 : 0,
  283. "messageStationTitle": this.tabs[0].processTitle,
  284. "messageStationContent": this.tabs[0].processContent,
  285. "shortMessageFlag": this.tabs[1].checkboxFlag ? 1 : 0,
  286. "shortMessageContent": this.tabs[1].processContent,
  287. "wechatMessageFlag": this.tabs[2].checkboxFlag ? 1 : 0,
  288. "wechatMessageTitle": this.tabs[2].processTitle,
  289. "wechatMessageContent": this.tabs[2].processContent,
  290. "flag": this.editData.flag ? 1 : 0,
  291. "wechatConfigType": this.editData.wechatConfigTypeId ? { id: this.editData.wechatConfigTypeId } : undefined,
  292. // }
  293. };
  294. } else {
  295. postData = {
  296. // "messageManager": {
  297. "id": this.editData.id,
  298. "messageStationFlag": this.tabs[0].checkboxFlag ? 1 : 0,
  299. "messageStationTitle": this.tabs[0].processTitle,
  300. "messageStationContent": this.tabs[0].processContent,
  301. "shortMessageFlag": this.tabs[1].checkboxFlag ? 1 : 0,
  302. "shortMessageContent": this.tabs[1].processContent,
  303. "wechatMessageFlag": this.tabs[2].checkboxFlag ? 1 : 0,
  304. "wechatMessageTitle": this.tabs[2].processTitle,
  305. "wechatMessageContent": this.tabs[2].processContent,
  306. "flag": this.editData.flag ? 1 : 0,
  307. "wechatConfigType": this.editData.wechatConfigTypeId ? { id: this.editData.wechatConfigTypeId } : undefined,
  308. // }
  309. };
  310. }
  311. // 关闭模态窗口并传递一个结果
  312. postData = Object.assign({}, this.coopData, postData);
  313. this.mainService
  314. .simplePost("updData", "messageManager", postData)
  315. .subscribe((result) => {
  316. this.btnLoading = false;
  317. this.hideMessageModal();
  318. let msg = "";
  319. if (this.add) {
  320. msg = "新增";
  321. } else {
  322. msg = "修改";
  323. }
  324. if (result.status == 200) {
  325. this.showPromptModal(msg, true, '');
  326. } else {
  327. this.showPromptModal(msg, false, result.msg);
  328. }
  329. });
  330. }
  331. //获取微信配置类型
  332. wechatConfigTypeList:any[] = [];
  333. getWechatConfigTypeList() {
  334. this.mainService
  335. .getDictionary('list', 'wechat_config_type')
  336. .subscribe((data) => {
  337. this.wechatConfigTypeList = data || [];
  338. });
  339. }
  340. // 获取列表
  341. loading1:boolean = false;
  342. messageList: any[] = []; //表格数据
  343. tableHeight:number = 0;
  344. getList() {
  345. let data = {
  346. idx: 0,
  347. sum: 9999,
  348. messageManager: {
  349. "noticeProcess": 1,
  350. "wechatConfigType": {
  351. value: this.wechatConfigTypeValue,
  352. },
  353. },
  354. };
  355. this.loading1 = true;
  356. this.mainService
  357. .getFetchDataList("simple/data", "messageManager", data)
  358. .subscribe((data) => {
  359. this.loading1 = false;
  360. if (data.status == 200) {
  361. // let arr = [
  362. // {
  363. // noticeNode: '复诊时间',
  364. // noticeDetails: '患者',
  365. // shortMessageFlag: '1',
  366. // flag: '1'
  367. // },
  368. // {
  369. // noticeNode: '用药提醒',
  370. // noticeDetails: '患者',
  371. // shortMessageFlag: '1',
  372. // flag: '1'
  373. // },
  374. // {
  375. // noticeNode: '注意事项',
  376. // noticeDetails: '患者',
  377. // shortMessageFlag: '1',
  378. // flag: '1'
  379. // }
  380. // ]
  381. // for(let i of arr){
  382. // data.list.unshift(i)
  383. // }
  384. this.messageList = data.list || [];
  385. }else{
  386. this.message.error(data.msg || "请求数据失败");
  387. }
  388. });
  389. }
  390. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  391. promptContent: string; //操作提示框提示信息
  392. ifSuccess: boolean; //操作成功/失败
  393. promptInfo: string; //操作结果提示信息
  394. promptModalShow: boolean; //操作提示框是否展示
  395. showPromptModal(con, success, promptInfo?) {
  396. this.promptModalShow = false;
  397. this.promptContent = con;
  398. this.ifSuccess = success;
  399. this.promptInfo = promptInfo;
  400. setTimeout(() => {
  401. this.promptModalShow = true;
  402. }, 100);
  403. this.getList();
  404. }
  405. }