advice-management.component.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import { ActivatedRoute, Router } from "@angular/router";
  2. import { Component, OnInit } from "@angular/core";
  3. import { MainService } from "../../services/main.service";
  4. import { ToolService } from "../../services/tool.service";
  5. import { Subject } from "rxjs";
  6. import { debounceTime } from "rxjs/operators";
  7. @Component({
  8. selector: "app-advice-management",
  9. templateUrl: "./advice-management.component.html",
  10. styleUrls: ["./advice-management.component.less"],
  11. })
  12. export class AdviceManagementComponent implements OnInit {
  13. constructor(
  14. private route: ActivatedRoute,
  15. private router: Router,
  16. private mainService: MainService,
  17. private tool: ToolService
  18. ) {}
  19. changeInpSubject = new Subject();
  20. ngOnInit() {
  21. this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
  22. this.getDeparts(v);
  23. });
  24. this.coopBtns = this.tool.initCoopBtns(this.route);
  25. this.getAllHos();
  26. this.getReplyTypes();
  27. }
  28. listOfData: any[] = []; //表格数据
  29. modal: boolean = false; //回复模态框
  30. coopId: number; //表格中执行操作的id
  31. department: any; //所属科室
  32. num; //工号
  33. name; //姓名
  34. replyType: any; //选择状态
  35. alldepart: any = []; //所有所属科室
  36. replyTypes: any; //所有状态
  37. pageIndex: number = 1; //页码
  38. listLength: number = 10; //总条数
  39. pageSize: number = 10; //每页条数
  40. promptContent: string; //操作提示框提示信息
  41. ifSuccess: boolean; //操作成功/失败
  42. promptInfo: string; //操作结果提示信息
  43. promptModalShow: boolean; //操作提示框是否展示
  44. btnLoading: boolean = false; //提交按钮loading状态
  45. // 初始化增删改按钮
  46. coopBtns: any = {};
  47. // 获取院区
  48. hospital: string; //选中院区
  49. getAllHos() {
  50. this.hospital = this.tool.getCurrentHospital().id + "";
  51. this.changeHos();
  52. this.getList();
  53. }
  54. // 修改院区获取对应科室
  55. changeHos() {
  56. this.department = null;
  57. this.getDeparts();
  58. }
  59. // 搜索
  60. search() {
  61. this.pageIndex = 1;
  62. this.getList();
  63. }
  64. // 重置
  65. reset() {
  66. this.pageIndex = 1;
  67. this.replyType = null;
  68. this.department = null;
  69. this.getList();
  70. }
  71. // 表格数据
  72. loading1 = false;
  73. getList() {
  74. var that = this;
  75. let data = {
  76. idx: that.pageIndex - 1,
  77. sum: that.pageSize,
  78. advice: {
  79. replaceFlag: that.replyType || "",
  80. hosId: that.hospital,
  81. creatDepartment: {
  82. id: that.department || "",
  83. },
  84. },
  85. };
  86. if (!data.advice.replaceFlag) {
  87. delete data.advice.replaceFlag;
  88. }
  89. if (!data.advice.creatDepartment || !data.advice.creatDepartment.id) {
  90. delete data.advice.creatDepartment;
  91. }
  92. this.loading1 = true;
  93. that.mainService
  94. .getFetchDataList("adviceCollection", "advice", data)
  95. .subscribe((data) => {
  96. this.loading1 = false;
  97. that.listOfData = data.list;
  98. that.listLength = data.totalNum;
  99. });
  100. }
  101. // 获取所有科室
  102. timerNum = 0; //边输入边搜索的定时器
  103. getDeparts(dept?) {
  104. var that = this;
  105. let data = {
  106. department: {
  107. hospital: { id: that.hospital },
  108. dept: dept || "",
  109. },
  110. idx: 0,
  111. sum: 20,
  112. };
  113. this.timerNum++;
  114. that.mainService
  115. .getFetchDataList("data", "department", data)
  116. .subscribe((data) => {
  117. console.log(data);
  118. that.alldepart = data.list;
  119. this.timerNum--;
  120. if (this.timerNum === 0) {
  121. that.isLoading = false;
  122. }
  123. });
  124. }
  125. // 获取所属组
  126. getReplyTypes() {
  127. var that = this;
  128. that.replyTypes = [
  129. {
  130. value: 0,
  131. label: "未回复",
  132. },
  133. {
  134. value: 1,
  135. label: "已回复",
  136. },
  137. ];
  138. }
  139. // 新增弹框
  140. replyCon: any; //意见内容
  141. reply(data) {
  142. this.modal = true;
  143. this.replyCon = data;
  144. }
  145. hideModal() {
  146. this.modal = false;
  147. }
  148. // 回复
  149. adviceSubContent: string; //回复内容
  150. submitForm() {
  151. console.log(this.adviceSubContent);
  152. let that = this;
  153. if (!that.adviceSubContent) return;
  154. that.btnLoading = true;
  155. let postData = {
  156. advice: {
  157. id: that.replyCon.id,
  158. replyUser: { id: that.replyCon.createUser.id },
  159. replyContent: that.adviceSubContent,
  160. },
  161. };
  162. that.mainService
  163. .postCustom("adviceCollection", "updData/advice", postData)
  164. .subscribe((data) => {
  165. that.btnLoading = false;
  166. that.adviceSubContent = "";
  167. if (data.status == 200) {
  168. that.showPromptModal("回复", true, "");
  169. that.getList();
  170. that.hideModal();
  171. } else {
  172. that.showPromptModal("回复", false, data.msg);
  173. }
  174. });
  175. }
  176. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  177. showPromptModal(con, success, promptInfo?) {
  178. this.promptModalShow = false;
  179. this.promptContent = con;
  180. this.ifSuccess = success;
  181. this.promptInfo = promptInfo;
  182. setTimeout(() => {
  183. this.promptModalShow = true;
  184. }, 100);
  185. this.getList();
  186. }
  187. // 查看
  188. detail(id) {
  189. this.router.navigateByUrl("/main/adviceManagement/adviceDetail/" + id);
  190. }
  191. // 边输边搜节流阀
  192. isLoading = false;
  193. changeInp(e) {
  194. this.isLoading = true;
  195. this.changeInpSubject.next(e);
  196. }
  197. // 截取意见内容(ie内核截取)
  198. spliceContent(con) {
  199. if (con.length >= 41 && navigator.userAgent.indexOf("Trident") > -1) {
  200. return con.slice(0, 20) + "...";
  201. } else {
  202. return con;
  203. }
  204. }
  205. }