task-list.component.ts 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { FormBuilder, Validators, FormGroup, FormControl } from "@angular/forms";
  4. import { MainService } from "../../services/main.service";
  5. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  6. import { ToolService } from "../../services/tool.service";
  7. import { forkJoin, Subject } from "rxjs";
  8. import { debounceTime } from "rxjs/operators";
  9. import { NzMessageService } from "ng-zorro-antd";
  10. @Component({
  11. selector: "app-task-list",
  12. templateUrl: "./task-list.component.html",
  13. styleUrls: ["./task-list.component.less"],
  14. })
  15. export class TaskListComponent implements OnInit {
  16. @ViewChild("osComponentRef1", {
  17. read: OverlayScrollbarsComponent,
  18. static: false,
  19. })
  20. osComponentRef1: OverlayScrollbarsComponent;
  21. constructor(
  22. private message: NzMessageService,
  23. private fb: FormBuilder,
  24. private route: ActivatedRoute,
  25. private router: Router,
  26. private mainService: MainService,
  27. private tool: ToolService
  28. ) {}
  29. listOfData: any[] = []; //表格数据
  30. modal: boolean = false; //新增/编辑模态框
  31. add: boolean; //true:新增;false:编辑
  32. validateForm: FormGroup; //新增/编辑表单
  33. validateAllocationForm: FormGroup; //新增/编辑表单
  34. coopId: number; //表格中执行操作的id
  35. dept: any; //所属科室
  36. drugCode; //编号
  37. name; //名称
  38. userType: any; //用户类型
  39. hosId: any; //院区(搜索)
  40. userGroup; //所属组
  41. userGroup1; //所属组(搜索)
  42. userTypes: Array<any>; //所有用户类型
  43. alldepart: any = []; //所有所属科室
  44. alldepart1: any = []; //所有所属科室(搜索)
  45. hospitals1: any = []; //院区列表(搜索)
  46. drugTypeData: any = []; //药品类型
  47. allUserGroup: Array<any>; //所有用户组
  48. allUserGroup1: Array<any>; //用户组(搜索)
  49. allUserRole: Array<any>; //所有角色
  50. pageIndex: number = 1; //页码
  51. listLength: number = 10; //总条数
  52. pageSize: number = 10; //每页条数
  53. promptContent: string; //操作提示框提示信息
  54. ifSuccess: boolean; //操作成功/失败
  55. promptInfo: string; //操作结果提示信息
  56. promptModalShow: boolean; //操作提示框是否展示
  57. btnLoading: boolean = false; //提交按钮loading状态
  58. wxRequired = false; //新增或编辑用户的时候,微信号是否必填
  59. searchTaskSubject = new Subject(); //防抖
  60. searchParentDeptSubject = new Subject();
  61. specimenName:any = null;
  62. containPosition:any = null;
  63. placeList:any = [];
  64. systemList:any = [];
  65. apparatusList:any = [];
  66. specimenNameList:any = [];
  67. addressLoading:any = false;
  68. month:any = [];
  69. userId:any;
  70. ngOnInit() {
  71. for(let i=1; i<13; i++){
  72. this.month.push({
  73. name:i + '月'
  74. })
  75. }
  76. this.coopBtns = this.tool.initCoopBtns(this.route);
  77. this.hosId = this.tool.getCurrentHospital().id;
  78. this.userId = this.tool.getCurrentUserId();
  79. this.searchParentDeptSubject.pipe(debounceTime(500)).subscribe((e) => {
  80. this.isLoading = true;
  81. this.getAllUser(e[0])
  82. });
  83. this.searchTaskSubject.pipe(debounceTime(500)).subscribe((e) => {
  84. this.isLoading = true;
  85. this.getmonthlyData(e[0])
  86. });
  87. this.getList();
  88. this.getAllUser('');
  89. this.getStateDic();
  90. this.getPriorityData();
  91. this.getmonthlyData('');
  92. }
  93. // 选择月份
  94. selectIndex:any;
  95. itemData:any;
  96. itemClick(data, index){
  97. this.selectIndex = index;
  98. this.itemData = data;
  99. }
  100. // 初始化增删改按钮
  101. coopBtns: any = {};
  102. // 搜索
  103. search() {
  104. this.pageIndex = 1;
  105. this.getList();
  106. }
  107. // 重置
  108. reset() {
  109. this.pageIndex = 1;
  110. this.state = null;
  111. this.priority = null;
  112. this.monthTask = null;
  113. this.executor = null;
  114. this.getList();
  115. }
  116. // 表格数据
  117. loading1 = false;
  118. state:any;
  119. priority:any;
  120. monthTask:any;
  121. executor:any;
  122. getList() {
  123. let data = {
  124. idx: this.pageIndex - 1,
  125. sum: this.pageSize,
  126. monthTaskList: {
  127. priority: {
  128. id: '',
  129. },
  130. state: {
  131. id: '',
  132. },
  133. monthTask:this.monthTask || undefined,
  134. executor: this.userId,
  135. },
  136. };
  137. if(this.priority){
  138. data.monthTaskList.priority.id = this.priority
  139. }else{
  140. delete data.monthTaskList.priority
  141. }
  142. if(this.state){
  143. data.monthTaskList.state.id = this.state
  144. }else{
  145. delete data.monthTaskList.state
  146. }
  147. this.loading1 = true;
  148. this.mainService
  149. .getFetchDataList("data", "monthTaskList", data)
  150. .subscribe((data) => {
  151. this.loading1 = false;
  152. this.listOfData = data.list;
  153. this.listLength = data.totalNum;
  154. });
  155. }
  156. // 获取月度任务
  157. monthlyData:any=[];
  158. getmonthlyData(name){
  159. let data = {
  160. idx: 0,
  161. sum: 20,
  162. monthTask: {
  163. taskTitle: name || undefined,
  164. },
  165. };
  166. this.mainService
  167. .getFetchDataList("data", "monthTask", data)
  168. .subscribe((data) => {
  169. this.isLoading = false;
  170. this.monthlyData = data.list;
  171. });
  172. }
  173. // 获取责任人
  174. dutyUser:any= [];
  175. getAllUser(name) {
  176. let data:any = {
  177. user: {
  178. name,
  179. hosIds: this.hosId,
  180. },
  181. idx: 0,
  182. sum: 20,
  183. };
  184. this.mainService
  185. .getFetchDataList("data", "user", data)
  186. .subscribe((data) => {
  187. this.isLoading = false
  188. this.dutyUser = data.list
  189. });
  190. }
  191. // 搜索责任人
  192. isLoading = false;
  193. changeUser(e) {
  194. this.searchParentDeptSubject.next([e]);
  195. }
  196. // 搜索月度任务
  197. changeTask(e,type) {
  198. this.searchTaskSubject.next([e,type]);
  199. }
  200. // 获取优先级
  201. priorityData:any = [];
  202. getPriorityData(){
  203. let postData = {
  204. idx: 0,
  205. sum: 9999,
  206. priority: {},
  207. };
  208. this.isLoading = true;
  209. this.mainService
  210. .getFetchDataList("simple/data", "priority", postData)
  211. .subscribe((data) => {
  212. this.isLoading = false;
  213. if (data.status == 200) {
  214. this.priorityData = data.list;
  215. }
  216. });
  217. }
  218. // 获取状态
  219. stateList:any = [];
  220. getStateDic(){
  221. this.mainService.getDictionary("list", "month_task_list_state").subscribe((res) => {
  222. this.stateList = res
  223. });
  224. }
  225. // 开始任务
  226. startModal:boolean = false
  227. startTask(data){
  228. this.coopId = data.id;
  229. this.startModal = true
  230. }
  231. hideStartModal(){
  232. this.startModal = false
  233. }
  234. // 确认开始任务
  235. confirmStart() {
  236. let that = this;
  237. let query = {
  238. monthTaskList:{
  239. id: this.coopId,
  240. operationType: 'start'
  241. }
  242. }
  243. that.btnLoading = true;
  244. that.mainService
  245. .apiPublicData('updData', 'monthTaskList', query)
  246. .subscribe((data) => {
  247. that.btnLoading = false;
  248. that.hideStartModal();
  249. if (data["status"] == 200) {
  250. that.showPromptModal("操作", true, "");
  251. } else {
  252. that.showPromptModal("操作", false, data["msg"]);
  253. }
  254. });
  255. }
  256. // 任务记录
  257. allocationModal:boolean = false;
  258. record(data){
  259. this.coopId = data.id;
  260. this.initAllocationForm();
  261. this.allocationModal = true
  262. }
  263. hideAllocationModal() {
  264. this.allocationModal = false;
  265. this.initAllocationForm();
  266. }
  267. // 初始化新增form表单
  268. initAllocationForm() {
  269. this.validateAllocationForm = this.fb.group({
  270. taskConclusion: [null, [Validators.required]],
  271. manHour: [null, [Validators.required]],
  272. });
  273. }
  274. // 任务记录提交
  275. submitAllocationForm(): void {
  276. var that = this;
  277. for (const i in that.validateAllocationForm.controls) {
  278. that.validateAllocationForm.controls[i].markAsDirty();
  279. that.validateAllocationForm.controls[i].updateValueAndValidity();
  280. }
  281. if (that.validateAllocationForm.invalid) return;
  282. let data = {
  283. monthTaskList:{
  284. taskConclusion: this.validateAllocationForm.value.taskConclusion,
  285. manHour: this.validateAllocationForm.value.manHour,
  286. id:this.coopId,
  287. operationType: 'record'
  288. }
  289. };
  290. that.btnLoading = true;
  291. that.mainService
  292. .dataPost("updData", "monthTaskList", data)
  293. .subscribe((data) => {
  294. that.btnLoading = false;
  295. that.hideAllocationModal();
  296. if (data.status == 200) {
  297. that.showPromptModal("记录", true, "");
  298. } else {
  299. that.showPromptModal("记录", false, data.msg);
  300. }
  301. });
  302. }
  303. // 任务完成
  304. accomplishModal:boolean = false;
  305. taskConclusion:any;
  306. manHour:any;
  307. accomplish(data){
  308. this.coopId = data.id;
  309. this.taskConclusion = null;
  310. this.accomplishModal = true
  311. }
  312. // 任务完成提交
  313. submitAccomplishForm(){
  314. if(!this.taskConclusion){
  315. this.message.error('任务总结不能为空!')
  316. return
  317. }
  318. if(!this.manHour){
  319. this.message.error('总工时不能为空!')
  320. return
  321. }
  322. let data = {
  323. monthTaskList:{
  324. taskConclusion: this.taskConclusion,
  325. manHour: this.manHour,
  326. operationType: 'done',
  327. id:this.coopId
  328. }
  329. };
  330. this.btnLoading = true;
  331. this.mainService
  332. .dataPost("updData", "monthTaskList", data)
  333. .subscribe((data) => {
  334. this.btnLoading = false;
  335. this.hideAccomplishModal();
  336. if (data.status == 200) {
  337. this.showPromptModal("操作", true, "");
  338. } else {
  339. this.showPromptModal("操作", false, data.msg);
  340. }
  341. });
  342. }
  343. hideAccomplishModal(){
  344. this.accomplishModal = false
  345. }
  346. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  347. showPromptModal(con, success, promptInfo?) {
  348. this.promptModalShow = false;
  349. this.promptContent = con;
  350. this.ifSuccess = success;
  351. this.promptInfo = promptInfo;
  352. setTimeout(() => {
  353. this.promptModalShow = true;
  354. }, 100);
  355. this.getList();
  356. }
  357. }