operation-notice.component.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import { Component, OnInit } from '@angular/core';
  2. import { ToolService } from 'src/app/services/tool.service';
  3. import { MainService } from 'src/app/services/main.service';
  4. import { ActivatedRoute } from '@angular/router';
  5. import { KeyValue } from '@angular/common';
  6. @Component({
  7. selector: 'app-operation-notice',
  8. templateUrl: './operation-notice.component.html',
  9. styleUrls: ['./operation-notice.component.less']
  10. })
  11. export class OperationNoticeComponent implements OnInit {
  12. hosId; //当前院区
  13. allTaskType = []; //通知类型列表
  14. allTaskTypeShow; //通知类型列表选择标识
  15. taskTypeLoading = false; //通知类型加载中
  16. tabModalName = ""; //详情tab字段
  17. // 初始化增删改按钮
  18. coopBtns: any = {};
  19. variableNames = ['[$患者姓名$]', '[$主刀医生姓名$]', '[$麻醉医师姓名$]', '[$护士姓名$]', '[$助理医生姓名$]', '[$科室名称$]', '[$手术名称$]', '[$手术时间$]', '[$手术间名称$]'];
  20. tabs:any[] = [];
  21. tabsDefault:any[] = [
  22. {
  23. role: 'doctor',
  24. phoneFlag: false,
  25. phoneContent: '',
  26. wechatFlag: false,
  27. wechatContent: '',
  28. orders: 1,
  29. },
  30. {
  31. role: 'docAssistant',
  32. phoneFlag: false,
  33. phoneContent: '',
  34. wechatFlag: false,
  35. wechatContent: '',
  36. orders: 2,
  37. },
  38. {
  39. role: 'anesthetist',
  40. phoneFlag: false,
  41. phoneContent: '',
  42. wechatFlag: false,
  43. wechatContent: '',
  44. orders: 3,
  45. },
  46. {
  47. role: 'patient',
  48. phoneFlag: false,
  49. phoneContent: '',
  50. wechatFlag: false,
  51. wechatContent: '',
  52. orders: 4,
  53. },
  54. ];
  55. tabNames = {
  56. doctor: '主刀医生',
  57. docAssistant: '助理医生',
  58. anesthetist: '临床',
  59. patient: '手术患者',
  60. }
  61. constructor(
  62. private tool: ToolService,
  63. private mainService: MainService,
  64. private route: ActivatedRoute,
  65. ) { }
  66. ngOnInit() {
  67. this.hosId = this.tool.getCurrentHospital().id;
  68. this.coopBtns = this.tool.initCoopBtns(this.route);
  69. this.getAllTaskType(); //通知类型列表
  70. }
  71. originalOrder = (a: KeyValue<number,string>, b: KeyValue<number,string>): number => {
  72. return 0;
  73. }
  74. //通知类型列表
  75. getAllTaskType() {
  76. this.allTaskType = [{
  77. id: 1,
  78. taskName: '手术即将开始通知',
  79. code: 'surgery_begin',
  80. }];
  81. if (this.allTaskType.length) {
  82. this.itemChoice(this.allTaskType[0]);
  83. }
  84. }
  85. // 选中通知类型
  86. currentChoice;
  87. itemChoice(data){
  88. this.currentChoice = data;
  89. this.allTaskTypeShow = data.taskName;
  90. console.log(data);
  91. let postData = {
  92. idx: 0,
  93. sum: 9999,
  94. transportMessage: {
  95. hosId: this.hosId,
  96. code: data.code,
  97. },
  98. };
  99. this.taskTypeLoading = true;
  100. this.mainService
  101. .getFetchDataList("simple/data", "transportMessage", postData)
  102. .subscribe((result) => {
  103. this.taskTypeLoading = false;
  104. if (result.status == 200) {
  105. result.list = result.list || [];
  106. result.list.forEach(v => {
  107. v.phoneFlag = v.phoneFlag === 1;
  108. v.wechatFlag = v.wechatFlag === 1;
  109. })
  110. let tabs = result.list || [];
  111. if(tabs.length){
  112. this.tabs = tabs;
  113. }else{
  114. this.tabs = this.tabsDefault.map(v => ({...v, code: data.code, hosId: this.hosId}));
  115. }
  116. // 没有选中则默认第一项
  117. !this.tabModalName && this.tabModal(this.tabs[0].role);
  118. }
  119. });
  120. }
  121. //详情tab
  122. tabModal(name) {
  123. if (!this.allTaskType.length) {
  124. return;
  125. }
  126. this.tabModalName = name;
  127. }
  128. // 写入
  129. writeIn(tab, content, event, type){
  130. var element = event.target.parentElement.parentElement.previousElementSibling;
  131. if (element.selectionStart || element.selectionStart == '0') {
  132. var startPos = element.selectionStart;
  133. var endPos = element.selectionEnd;
  134. tab[type] = element.value.substring(0, startPos) + content + element.value.substring(endPos);
  135. element.focus();
  136. setTimeout(() => {
  137. element.setSelectionRange(startPos + content.length, startPos + content.length);
  138. },0)
  139. } else {
  140. var val = element.value + content;
  141. tab[type] = val;
  142. element.focus();
  143. }
  144. }
  145. // 展示信息提示框
  146. promptContent: string; //操作提示框提示信息
  147. ifSuccess: boolean; //操作成功/失败
  148. errorInfo: string; //操作失败原因提示信息
  149. promptModalShow: boolean; //操作提示框是否展示
  150. showPromptModal(con, success, errorInfo?) {
  151. this.promptModalShow = false;
  152. this.promptContent = con;
  153. this.ifSuccess = success;
  154. if (errorInfo !== undefined) {
  155. this.errorInfo = errorInfo;
  156. }
  157. setTimeout(() => {
  158. this.promptModalShow = true;
  159. }, 100);
  160. }
  161. //提交数据
  162. loading5 = false; //保存按钮loading
  163. submitForm() {
  164. this.loading5 = true;
  165. this.tabs.forEach(v => {
  166. v.phoneFlag = v.phoneFlag ? 1 : 0;
  167. v.wechatFlag = v.wechatFlag ? 1 : 0;
  168. })
  169. this.mainService
  170. .simplePost("addListData", "transportMessage", this.tabs)
  171. .subscribe((data) => {
  172. this.loading5 = false;
  173. if (data.status == 200) {
  174. this.showPromptModal("保存", true, "成功");
  175. this.itemChoice(this.currentChoice);
  176. } else {
  177. this.showPromptModal("保存", false, data.msg);
  178. }
  179. });
  180. }
  181. }