quick-combination.component.ts 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. import { Component, OnInit } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { FormBuilder, Validators, FormGroup } from "@angular/forms";
  4. import setSeconds from "date-fns/setSeconds";
  5. import setMinutes from "date-fns/setMinutes";
  6. import setHours from "date-fns/setHours";
  7. import { MainService } from "../../services/main.service";
  8. import { ToolService } from "../../services/tool.service";
  9. import { NzMessageService } from "ng-zorro-antd";
  10. @Component({
  11. selector: "app-quick-combination",
  12. templateUrl: "./quick-combination.component.html",
  13. styleUrls: ["./quick-combination.component.less"],
  14. })
  15. export class QuickCombinationComponent implements OnInit {
  16. constructor(
  17. private message: NzMessageService,
  18. private fb: FormBuilder,
  19. private mainService: MainService,
  20. private route: ActivatedRoute,
  21. private router: Router,
  22. private tool: ToolService
  23. ) {
  24. this.route.queryParams.subscribe((res) => {
  25. this.queryParamsId = res.id;
  26. this.queryParamsName = res.name;
  27. this.queryParamsType = res.type;
  28. if (this.queryParamsType == 2) {
  29. this.allWorkModel = [
  30. { id: 1, name: "自由抢单" },
  31. { id: 3, name: "科室绑定人员" },
  32. { id: 4, name: "科室绑定分组" },
  33. { id: 2, name: "绑定分组" },
  34. ];
  35. }
  36. });
  37. }
  38. searchCriteria = {
  39. //搜索条件
  40. name: "",
  41. workModel: null,
  42. };
  43. allWorkModel = [
  44. { id: 1, name: "自由抢单" },
  45. { id: 2, name: "指定分组" },
  46. { id: 3, name: "科室绑定人员" },
  47. { id: 4, name: "科室绑定分组" },
  48. ];
  49. quickCombinationModel;
  50. requireGroup = false;
  51. requireDept = false;
  52. requireDeptType = false;
  53. queryParamsId = ""; //方案id
  54. queryParamsName = ""; //方案名称
  55. queryParamsType: any = ""; //方案类型,1是综合排班,2是自选排班
  56. userInfo: any = JSON.parse(localStorage.getItem("user")) || {}; //登录用户信息
  57. listOfData: any[] = []; //表格数据
  58. pageIndex: number = 1; //表格当前页码
  59. pageSize: number = 10; //表格每页展示条数
  60. listLength: number = 10; //表格总数据量
  61. tableHeight: number; //表格动态高
  62. modal: boolean = false; //新增/编辑模态框
  63. personModal: boolean = false; //定时启用设置日期模态框
  64. groupsModal: boolean = false; //定时启用设置日期模态框
  65. add: boolean; //true:新增;false:编辑
  66. validateForm: FormGroup; //新增/编辑表单
  67. validateDateForm: FormGroup; //定时启动设置日期表单
  68. validatePersonForm: FormGroup; //
  69. validateGroupForm: FormGroup; //
  70. coopId: number; //当前操作列id
  71. timeDefaultValue = setHours(setMinutes(setSeconds(new Date(), 0), 0), 0);
  72. btnLoading: boolean = false; //提交按钮loading状态
  73. currentHospital; //当前院区
  74. promptContent: string; //操作提示框提示信息
  75. ifSuccess: boolean; //操作成功/失败
  76. promptInfo: string; //操作结果提示信息
  77. promptModalShow: boolean; //操作提示框是否展示
  78. showLoading = false; //操作是否显示loading
  79. classList = []; //班次列表
  80. maskFlag: any = false;
  81. // -----------------------
  82. ngOnInit() {
  83. this.currentHospital = this.tool.getCurrentHospital();
  84. this.initForm();
  85. this.getList(1);
  86. this.getDispatchMethods();
  87. this.getDispatchTypes();
  88. }
  89. // 重置
  90. reset() {
  91. this.searchCriteria = {
  92. //搜索条件
  93. name: "",
  94. workModel: null,
  95. };
  96. this.getList(1);
  97. }
  98. //查询班次列表,flag是下拉框展开状态
  99. cLoading = false;
  100. getClassList(flag?, fedit?) {
  101. if (!flag) {
  102. return;
  103. }
  104. if (fedit) {
  105. this.maskFlag = this.message.loading("正在加载中..", {
  106. nzDuration: 0,
  107. }).messageId;
  108. }
  109. let hosIds = this.currentHospital.id;
  110. let postData = {
  111. idx: 0,
  112. sum: 9999,
  113. scheduleClass: { hospital: { id: hosIds } },
  114. };
  115. this.cLoading = true;
  116. this.mainService
  117. .getFetchDataList("configuration", "scheduleClass", postData)
  118. .subscribe((data) => {
  119. this.cLoading = false;
  120. if (data.status == 200) {
  121. this.classList = data.list;
  122. if (fedit) {
  123. this.searchTaskList(true, true);
  124. }
  125. }
  126. });
  127. }
  128. //选中班次
  129. currentClassId; //当前班次
  130. selectClass(id) {
  131. this.validateForm.controls.quickCombinationType.setValue(null); //任务类型
  132. this.quickCombinationModel = "";
  133. this.deptList = [];
  134. this.groupList = [];
  135. this.validateForm.controls.quickCombinationDept.setValue(null); //科室
  136. this.validateForm.controls.quickCombinationGroup.setValue(null); //分组
  137. this.currentClassId = id;
  138. this.taskListFlag = true;
  139. }
  140. //搜索任务类型列表
  141. taskList = []; //当前班次下的任务类型列表
  142. tLoading = false;
  143. taskListFlag = true; //是否可以选择所有的工作模式
  144. getTaskList(flag?, keyWords?, fedit?) {
  145. console.log(
  146. this.validateForm.value.quickCombinationType,
  147. this.taskListFlag
  148. );
  149. // 关闭下拉框的时候阻止
  150. if (!flag) {
  151. return;
  152. }
  153. // 之前没有选择任务类型
  154. if (
  155. (this.validateForm.value.quickCombinationType === null ||
  156. this.validateForm.value.quickCombinationType.length === 0) &&
  157. this.taskListFlag &&
  158. (fedit ? this.info.classes.id : this.currentClassId)
  159. ) {
  160. let postData = {
  161. classesId: fedit ? this.info.classes.id : this.currentClassId,
  162. };
  163. if (keyWords) {
  164. postData["keyWords"] = keyWords;
  165. }
  166. this.tLoading = true;
  167. this.mainService
  168. .coopConfig("getTaskTypeByClasses", postData)
  169. .subscribe((data) => {
  170. this.tLoading = false;
  171. if (data.state == 200) {
  172. console.log(this.currentClassId);
  173. if (this.currentClassId) {
  174. this.taskList = data.data;
  175. } else {
  176. this.taskList = [];
  177. }
  178. if (fedit) {
  179. let arr = [];
  180. this.info.taskTypes.forEach((item) => {
  181. let flag = this.taskList.some((v) => v.id == item.id);
  182. if (!flag) {
  183. arr.push(item);
  184. }
  185. });
  186. this.taskList = [...arr, ...this.taskList];
  187. console.log(this.taskList);
  188. this.validateForm.controls.quickCombinationClass.setValue(
  189. this.info.classes.id + ""
  190. ); //班次
  191. this.validateForm.controls.quickCombinationType.setValue(
  192. this.info.taskTypesId
  193. ); //任务类型
  194. if(this.queryParamsType == 1){
  195. this.quickCombinationModel = this.info.ruleType + "";
  196. }else if(this.queryParamsType == 2){
  197. if(this.info.ruleType == 2){
  198. this.quickCombinationModel = '6';
  199. }else if(this.info.ruleType == 4){
  200. this.quickCombinationModel = '5';
  201. }else{
  202. this.quickCombinationModel = this.info.ruleType + "";
  203. }
  204. }
  205. this.taskListFlag = false;
  206. if (!this.copyFlag) {
  207. if (this.info.ruleType == 2) {
  208. this.getGroupList(true, "", true);
  209. } else if (this.info.ruleType == 3) {
  210. if(this.queryParamsType == 1){
  211. this.getDeptList(true, "", true);
  212. }else{
  213. this.getDeptTypeList(true, true);
  214. }
  215. } else if (this.info.ruleType == 4) {
  216. this.getDeptList(true, "", true);
  217. } else {
  218. this.message.remove(this.maskFlag);
  219. this.maskFlag = false;
  220. this.modal = true;
  221. }
  222. }
  223. }
  224. }
  225. this.message.remove(this.maskFlag);
  226. this.maskFlag = false;
  227. this.modal = true;
  228. });
  229. }
  230. }
  231. // 选择任务类型
  232. ids = [];
  233. selectTaskList(ids, keyWords?, fedit?) {
  234. console.log(fedit);
  235. if (ids === null) {
  236. return;
  237. }
  238. console.log(this.currentClassId);
  239. if (
  240. this.validateForm.value.quickCombinationType &&
  241. this.validateForm.value.quickCombinationType.length > 0
  242. ) {
  243. let postData = {
  244. classesId: fedit ? this.info.classes.id : this.currentClassId,
  245. taskTypeId: ids[0],
  246. workSchemeId: this.queryParamsId,
  247. };
  248. if (keyWords) {
  249. postData["keyWords"] = keyWords;
  250. }
  251. this.ids = ids;
  252. this.mainService
  253. .coopConfig("getTaskTypeByFirstType", postData)
  254. .subscribe((data) => {
  255. if (data.state == 200) {
  256. this.taskList = data.data;
  257. if (fedit) {
  258. let arr = [];
  259. this.info.taskTypes.forEach((item) => {
  260. let flag = this.taskList.some((v) => v.id == item.id);
  261. if (!flag) {
  262. arr.push(item);
  263. }
  264. });
  265. this.taskList = [...arr, ...this.taskList];
  266. this.validateForm.controls.quickCombinationClass.setValue(
  267. this.info.classes.id + ""
  268. ); //班次
  269. this.validateForm.controls.quickCombinationType.setValue(
  270. this.info.taskTypesId
  271. ); //任务类型
  272. this.quickCombinationModel = this.info.ruleType + "";
  273. this.taskListFlag = false;
  274. return;
  275. }
  276. if (data.data && data.data.length > 0) {
  277. let obj = data.data.find(
  278. (item) => item.ruleType != "0" && item.showFlag == 1
  279. );
  280. console.log(obj);
  281. if (obj) {
  282. if(this.queryParamsType == 1){
  283. this.quickCombinationModel = obj.ruleType + "";
  284. }else if(this.queryParamsType == 2){
  285. if(obj.ruleType == 2){
  286. this.quickCombinationModel = '6';
  287. }else if(obj.ruleType == 4){
  288. this.quickCombinationModel = '5';
  289. }else{
  290. this.quickCombinationModel = obj.ruleType + "";
  291. }
  292. }
  293. this.radioIt(1); //选择任务类型
  294. this.taskListFlag = false;
  295. } else {
  296. //都是置灰的或之前没设置过的
  297. this.taskListFlag = true;
  298. this.quickCombinationModel = "";
  299. }
  300. } else {
  301. //返回空
  302. this.taskListFlag = true;
  303. this.quickCombinationModel = "";
  304. }
  305. } else if (data.state == 201) {
  306. //201则是该班次该任务类型之前没有设置过,所以无法返回带置灰选项的列表
  307. this.taskListFlag = true;
  308. if (fedit) {
  309. this.getTaskList(true, "", true);
  310. } else {
  311. this.getTaskList(true);
  312. }
  313. this.quickCombinationModel = "";
  314. }
  315. });
  316. } else {
  317. this.taskListFlag = true;
  318. if (fedit) {
  319. this.getTaskList(true, "", true);
  320. } else {
  321. this.getTaskList(true);
  322. }
  323. this.quickCombinationModel = "";
  324. }
  325. }
  326. // 搜索任务类型列表
  327. searchTaskList(e, fedit?) {
  328. console.log(this.validateForm.value.quickCombinationType);
  329. if (
  330. this.validateForm.value.quickCombinationType &&
  331. this.validateForm.value.quickCombinationType.length === 0
  332. ) {
  333. if (fedit) {
  334. this.getTaskList(true, e, fedit);
  335. } else {
  336. this.getTaskList(true, e);
  337. }
  338. } else {
  339. if (fedit) {
  340. this.selectTaskList(this.ids, e, fedit);
  341. } else {
  342. this.selectTaskList(this.ids, e);
  343. }
  344. }
  345. }
  346. searchTaskList1(flag) {
  347. if (flag) {
  348. this.searchTaskList("");
  349. }
  350. }
  351. //对应ruleType与quickCombinationModel
  352. get quickCombinationModelComputed(){
  353. console.log(this.quickCombinationModel,'---------------------')
  354. if(this.quickCombinationModel == 5){//科室绑定分组
  355. return 4;
  356. }else if(this.quickCombinationModel == 6){//绑定分组
  357. return 2;
  358. }else{
  359. return this.quickCombinationModel;
  360. }
  361. }
  362. // 选中工作模式
  363. radioIt(flag?) {
  364. //undefined 打开复制弹窗,1 选择任务类型
  365. console.log(flag);
  366. if (!this.add) {
  367. // 回显储存的值
  368. console.log(this.info, this.quickCombinationModel);
  369. if (
  370. this.info.ruleType == this.quickCombinationModelComputed &&
  371. (this.quickCombinationModel == 2 || this.quickCombinationModel == 5 || this.quickCombinationModel == 6)
  372. ) {
  373. this.groupList = this.info.groups;
  374. if (!this.copyFlag) {
  375. if(this.quickCombinationModel == 6){
  376. this.validateForm.controls.quickCombinationGroup.setValue((this.info.groupsId?this.info.groupsId[0] + '':null));
  377. }else{
  378. this.validateForm.controls.quickCombinationGroup.setValue(
  379. this.info.groupsId
  380. );
  381. }
  382. } else {
  383. if (!flag) {
  384. this.validateForm.controls.quickCombinationGroup.setValue(null);
  385. } else {
  386. if(this.quickCombinationModel == 6){
  387. this.validateForm.controls.quickCombinationGroup.setValue((this.info.groupsId?this.info.groupsId[0] + '':null));
  388. }else{
  389. this.validateForm.controls.quickCombinationGroup.setValue(
  390. this.info.groupsId
  391. );
  392. }
  393. }
  394. }
  395. }
  396. if (
  397. (this.info.ruleType == 3 || this.info.ruleType == 4) &&
  398. (this.quickCombinationModel == 3 || this.quickCombinationModel == 4)
  399. ) {
  400. this.deptList = this.info.departmentDTOS;
  401. if (!this.copyFlag) {
  402. this.validateForm.controls.quickCombinationDept.setValue(
  403. this.info.departmentDTOSId
  404. );
  405. } else {
  406. if (!flag) {
  407. this.validateForm.controls.quickCombinationDept.setValue(null);
  408. } else {
  409. this.validateForm.controls.quickCombinationDept.setValue(
  410. this.info.departmentDTOSId
  411. );
  412. }
  413. }
  414. }
  415. }
  416. if (this.quickCombinationModel == 1) {
  417. this.requireGroup = false;
  418. this.requireDept = false;
  419. this.requireDeptType = false;
  420. } else if (this.quickCombinationModel == 2) {
  421. this.requireGroup = false;
  422. this.requireDept = false;
  423. this.requireDeptType = false;
  424. } else if (this.quickCombinationModel == 3) {
  425. if (this.queryParamsType == 1) {
  426. this.requireGroup = false;
  427. this.requireDept = true;
  428. this.requireDeptType = false;
  429. } else if (this.queryParamsType == 2) {
  430. this.requireGroup = false;
  431. this.requireDept = false;
  432. this.requireDeptType = true;
  433. }
  434. } else if (this.quickCombinationModel == 4) {
  435. this.requireGroup = false;
  436. this.requireDept = true;
  437. this.requireDeptType = false;
  438. }else if (this.quickCombinationModel == 5) {
  439. this.requireGroup = false;
  440. this.requireDept = false;
  441. this.requireDeptType = false;
  442. }else if (this.quickCombinationModel == 6) {
  443. this.requireGroup = false;
  444. this.requireDept = false;
  445. this.requireDeptType = false;
  446. }
  447. if (!this.requireGroup) {
  448. this.validateForm.get("quickCombinationGroup")!.clearValidators();
  449. this.validateForm.get("quickCombinationGroup")!.markAsPristine();
  450. } else {
  451. this.validateForm
  452. .get("quickCombinationGroup")!
  453. .setValidators(Validators.required);
  454. this.validateForm.get("quickCombinationGroup")!.markAsDirty();
  455. }
  456. this.validateForm.get("quickCombinationGroup")!.updateValueAndValidity();
  457. // ------
  458. if (!this.requireDept) {
  459. this.validateForm.get("quickCombinationDept")!.clearValidators();
  460. this.validateForm.get("quickCombinationDept")!.markAsPristine();
  461. } else {
  462. this.validateForm
  463. .get("quickCombinationDept")!
  464. .setValidators(Validators.required);
  465. this.validateForm.get("quickCombinationDept")!.markAsDirty();
  466. }
  467. this.validateForm.get("quickCombinationDept")!.updateValueAndValidity();
  468. // ------
  469. if (!this.requireDeptType) {
  470. this.validateForm.get("deptTypeIds")!.clearValidators();
  471. this.validateForm.get("deptTypeIds")!.markAsPristine();
  472. } else {
  473. this.validateForm
  474. .get("deptTypeIds")!
  475. .setValidators(Validators.required);
  476. this.validateForm.get("deptTypeIds")!.markAsDirty();
  477. }
  478. this.validateForm.get("deptTypeIds")!.updateValueAndValidity();
  479. // ------
  480. if (!(this.queryParamsType == 1 && this.quickCombinationModel == 1)) {
  481. this.validateForm.get("quickCombinationDispatchMethod")!.clearValidators();
  482. this.validateForm.get("quickCombinationDispatchMethod")!.markAsPristine();
  483. } else {
  484. this.validateForm.get("quickCombinationDispatchMethod")!.setValidators(Validators.required);
  485. this.validateForm.get("quickCombinationDispatchMethod")!.markAsDirty();
  486. }
  487. this.validateForm.get("quickCombinationDispatchMethod")!.updateValueAndValidity();
  488. if(this.add){
  489. this.validateForm.controls.quickCombinationDispatchMethod.setValue(null);
  490. }else{
  491. this.validateForm.controls.quickCombinationDispatchMethod.setValue(this.info.dispatchMethod ? this.info.dispatchMethod.value : null);
  492. }
  493. // ------
  494. if (!(this.queryParamsType == 1 && this.quickCombinationModel == 1 && this.validateForm.value.quickCombinationDispatchMethod == 2)) {
  495. this.validateForm.get("quickCombinationDispatchType")!.clearValidators();
  496. this.validateForm.get("quickCombinationDispatchType")!.markAsPristine();
  497. } else {
  498. this.validateForm.get("quickCombinationDispatchType")!.setValidators(Validators.required);
  499. this.validateForm.get("quickCombinationDispatchType")!.markAsDirty();
  500. }
  501. this.validateForm.get("quickCombinationDispatchType")!.updateValueAndValidity();
  502. if(this.add){
  503. this.validateForm.controls.quickCombinationDispatchType.setValue(null);
  504. }else{
  505. this.validateForm.controls.quickCombinationDispatchType.setValue(this.info.dispatchType ? this.info.dispatchType.value : null);
  506. }
  507. // ------
  508. if (!(this.queryParamsType == 1 && this.quickCombinationModel == 1 && this.validateForm.value.quickCombinationDispatchMethod == 2 && this.validateForm.value.quickCombinationDispatchType == 1)) {
  509. this.validateForm.get("quickCombinationDispatchWeight")!.clearValidators();
  510. this.validateForm.get("quickCombinationDispatchWeight")!.markAsPristine();
  511. } else {
  512. this.validateForm.get("quickCombinationDispatchWeight")!.setValidators(Validators.required);
  513. this.validateForm.get("quickCombinationDispatchWeight")!.markAsDirty();
  514. }
  515. this.validateForm.get("quickCombinationDispatchWeight")!.updateValueAndValidity();
  516. if(this.add){
  517. this.validateForm.controls.quickCombinationDispatchWeight.setValue(null);
  518. }else{
  519. this.validateForm.controls.quickCombinationDispatchWeight.setValue(this.info.maxWeight);
  520. }
  521. }
  522. //获取派单方式
  523. dispatchMethods:any[] = [];
  524. getDispatchMethods() {
  525. this.mainService.getDictionary("list", "dispatchMethod").subscribe((data) => {
  526. this.dispatchMethods = data;
  527. });
  528. }
  529. //获取派单类型
  530. dispatchTypes:any[] = [];
  531. getDispatchTypes() {
  532. this.mainService.getDictionary("list", "dispatchType").subscribe((data) => {
  533. this.dispatchTypes = data;
  534. });
  535. }
  536. // 选择派单方式
  537. radioDispatchMethod(){
  538. if (!(this.queryParamsType == 1 && this.quickCombinationModel == 1 && this.validateForm.value.quickCombinationDispatchMethod == 2)) {
  539. this.validateForm.get("quickCombinationDispatchType")!.clearValidators();
  540. this.validateForm.get("quickCombinationDispatchType")!.markAsPristine();
  541. } else {
  542. this.validateForm.get("quickCombinationDispatchType")!.setValidators(Validators.required);
  543. this.validateForm.get("quickCombinationDispatchType")!.markAsDirty();
  544. }
  545. this.validateForm.get("quickCombinationDispatchType")!.updateValueAndValidity();
  546. this.validateForm.controls.quickCombinationDispatchType.setValue(null);
  547. }
  548. // 选择自动派单类型
  549. radioDispatchType(){
  550. if (!(this.queryParamsType == 1 && this.quickCombinationModel == 1 && this.validateForm.value.quickCombinationDispatchMethod == 2 && this.validateForm.value.quickCombinationDispatchType == 1)) {
  551. this.validateForm.get("quickCombinationDispatchWeight")!.clearValidators();
  552. this.validateForm.get("quickCombinationDispatchWeight")!.markAsPristine();
  553. } else {
  554. this.validateForm.get("quickCombinationDispatchWeight")!.setValidators(Validators.required);
  555. this.validateForm.get("quickCombinationDispatchWeight")!.markAsDirty();
  556. }
  557. this.validateForm.get("quickCombinationDispatchWeight")!.updateValueAndValidity();
  558. this.validateForm.controls.quickCombinationDispatchWeight.setValue(null);
  559. }
  560. //获取科室类型列表
  561. deptTypeList:any[] = [];
  562. getDeptTypeList(flag?, fedit?) {
  563. if (!flag) {
  564. return;
  565. }
  566. this.dLoading = true;
  567. this.mainService
  568. .getDictionary("list", "dept_type")
  569. .subscribe((data) => {
  570. this.dLoading = false;
  571. this.deptTypeList = data;
  572. if (fedit) {
  573. switch (this.info.ruleType) {
  574. case 1:
  575. break;
  576. case 2:
  577. break;
  578. case 3:
  579. if(this.queryParamsType == 2){
  580. console.log(this.info);
  581. let deptTypeList = this.info.deptTypeList || [];
  582. this.validateForm.controls.deptTypeIds.setValue(deptTypeList.map(v => v.id.toString()));
  583. }
  584. break;
  585. case 4:
  586. break;
  587. }
  588. }
  589. });
  590. }
  591. deptList = []; //科室列表
  592. dLoading = false;
  593. dNum = 0;
  594. //获取科室列表
  595. getDeptList(flag?, search = "", fedit?) {
  596. if (!flag) {
  597. return;
  598. }
  599. let hosIds = this.currentHospital.id;
  600. let postData = {
  601. idx: 0,
  602. sum: 20,
  603. department: { cascadeHosId: hosIds, dept: search },
  604. };
  605. this.dLoading = true;
  606. this.dNum++;
  607. this.mainService
  608. .getFetchDataList("data", "department", postData)
  609. .subscribe((data) => {
  610. this.dNum--;
  611. if (this.dNum === 0) {
  612. this.dLoading = false;
  613. }
  614. if (data.status == 200) {
  615. this.deptList = data.list;
  616. if (fedit) {
  617. switch (this.info.ruleType) {
  618. case 1:
  619. this.validateForm.controls.quickCombinationDept.setValue(null);
  620. break;
  621. case 2:
  622. this.validateForm.controls.quickCombinationDept.setValue(null);
  623. break;
  624. case 3:
  625. let arr = [];
  626. let arrr = [];
  627. this.info.departmentDTOS.forEach((item) => {
  628. arr.push(item.id + "");
  629. });
  630. this.info.departmentDTOS.forEach((item) => {
  631. let flag = this.deptList.some((v) => v.id == item.id);
  632. if (!flag) {
  633. arrr.push(item);
  634. }
  635. });
  636. this.deptList = [...arrr, ...this.deptList];
  637. this.validateForm.controls.quickCombinationDept.setValue(arr);
  638. break;
  639. case 4:
  640. if(this.queryParamsType == 1){
  641. let arr1 = [];
  642. let arr11 = [];
  643. this.info.departmentDTOS.forEach((item) => {
  644. arr1.push(item.id + "");
  645. });
  646. this.info.departmentDTOS.forEach((item) => {
  647. let flag = this.deptList.some((v) => v.id == item.id);
  648. if (!flag) {
  649. arr11.push(item);
  650. }
  651. });
  652. this.deptList = [...arr11, ...this.deptList];
  653. this.validateForm.controls.quickCombinationDept.setValue(arr1);
  654. }else if(this.queryParamsType == 2){
  655. this.validateForm.controls.quickCombinationDept.setValue(null);
  656. }
  657. break;
  658. }
  659. }
  660. }
  661. this.message.remove(this.maskFlag);
  662. this.maskFlag = false;
  663. this.modal = true;
  664. });
  665. }
  666. // 搜索科室列表
  667. searchDeptList(e) {
  668. this.getDeptList(true, e);
  669. }
  670. // 选择科室
  671. selectDeptList(ids) {
  672. console.log(ids);
  673. if (!this.add) {
  674. console.log(this.info.departmentDTOSId);
  675. this.info.departmentDTOSId = ids;
  676. }
  677. }
  678. groupList = []; //分组列表
  679. gLoading = false;
  680. gNum = 0;
  681. //获取分组列表
  682. getGroupList(flag?, search = "", fedit?) {
  683. if (!flag) {
  684. return;
  685. }
  686. let hosIds = this.currentHospital.id;
  687. let postData:any = {
  688. idx: 0,
  689. sum: 20,
  690. group2: {
  691. groupName: search,
  692. scheduleClass: {
  693. id: fedit ? this.info.classes.id : this.currentClassId,
  694. },
  695. hospitals: hosIds,
  696. },
  697. };
  698. console.log(this.queryParamsType,this.quickCombinationModel);
  699. if(this.queryParamsType == 2 && (this.quickCombinationModel == 5 || this.quickCombinationModel == 6)){
  700. postData.group2.type = 2;
  701. }else{
  702. postData.group2.type = 1;
  703. }
  704. this.gLoading = true;
  705. this.gNum++;
  706. this.mainService
  707. .getFetchDataList("data", "group2", postData)
  708. .subscribe((data) => {
  709. this.gNum--;
  710. if (this.gNum === 0) {
  711. this.gLoading = false;
  712. }
  713. if (data.status == 200) {
  714. this.groupList = data.list;
  715. console.log(fedit, this.info);
  716. if (fedit) {
  717. switch (this.info.ruleType) {
  718. case 1:
  719. this.validateForm.controls.quickCombinationGroup.setValue(null);
  720. break;
  721. case 2:
  722. let arr = [];
  723. let arrr = [];
  724. this.info.groups.forEach((item) => {
  725. let flag = this.groupList.some((v) => v.id == item.id);
  726. arr.push(item.id + "");
  727. console.log(flag);
  728. if (!flag) {
  729. arrr.push(item);
  730. }
  731. });
  732. this.groupList = [...arrr, ...this.groupList];
  733. console.log(this.groupList, arrr, arr);
  734. if(this.queryParamsType == 1){
  735. this.validateForm.controls.quickCombinationGroup.setValue(arr);
  736. }else if(this.queryParamsType == 2){
  737. this.validateForm.controls.quickCombinationGroup.setValue(arr[0] + '');
  738. }
  739. break;
  740. case 3:
  741. this.validateForm.controls.quickCombinationGroup.setValue(null);
  742. break;
  743. case 4:
  744. if(this.queryParamsType == 1){
  745. this.validateForm.controls.quickCombinationGroup.setValue(null);
  746. }else if(this.queryParamsType == 2){
  747. let arr = [];
  748. let arrr = [];
  749. this.info.groups.forEach((item) => {
  750. let flag = this.groupList.some((v) => v.id == item.id);
  751. arr.push(item.id + "");
  752. console.log(flag);
  753. if (!flag) {
  754. arrr.push(item);
  755. }
  756. });
  757. this.groupList = [...arrr, ...this.groupList];
  758. console.log(this.groupList, arrr, arr);
  759. this.validateForm.controls.quickCombinationGroup.setValue(arr);
  760. }
  761. break;
  762. }
  763. }
  764. }
  765. this.message.remove(this.maskFlag);
  766. this.maskFlag = false;
  767. this.modal = true;
  768. });
  769. }
  770. // 搜索分组列表
  771. searchGroupList(e) {
  772. this.getGroupList(true, e);
  773. }
  774. // 选择分组
  775. selectGroupList(ids) {
  776. if (!this.add) {
  777. this.info.groupsId = ids !== null ? ids : [];
  778. }
  779. }
  780. // 切换
  781. goToOther() {
  782. this.router.navigateByUrl(
  783. `/main/jobAssignment?id=${this.queryParamsId}&name=${this.queryParamsName}`
  784. );
  785. }
  786. personList = []; //分配人员列表
  787. pLoading = false;
  788. pNum = 0;
  789. //获取分配人员列表
  790. getPersonList(flag?, search = "", edit?, info?) {
  791. if (!flag) {
  792. return;
  793. }
  794. let postData = {
  795. idx: 0,
  796. sum: 20,
  797. user: {
  798. simpleQuery:true,
  799. usertype: { id: 106 },
  800. name: search,
  801. hospital: {
  802. id: this.currentHospital.id,
  803. },
  804. },
  805. };
  806. this.pLoading = true;
  807. this.pNum++;
  808. if (edit) {
  809. this.maskFlag = this.message.loading("正在加载中..", {
  810. nzDuration: 0,
  811. }).messageId;
  812. }
  813. this.mainService
  814. .getFetchDataList("data", "user", postData)
  815. .subscribe((data) => {
  816. this.pNum--;
  817. if (this.pNum === 0) {
  818. this.pLoading = false;
  819. if (edit) {
  820. this.message.remove(this.maskFlag);
  821. this.maskFlag = false;
  822. this.personModal = true;
  823. }
  824. }
  825. if (data.status == 200) {
  826. this.personList = data.list;
  827. if (edit) {
  828. let arr = [];
  829. let arrIds = [];
  830. info.users.forEach((item) => {
  831. let flag = this.personList.some((v) => v.id == item.id);
  832. if (!flag) {
  833. arr.push(item);
  834. }
  835. arrIds.push(item.id + "");
  836. });
  837. this.personList = [...arr, ...this.personList];
  838. this.validatePersonForm.controls.quickCombinationPerson.setValue(
  839. arrIds[0]
  840. ); //人员
  841. }
  842. }
  843. });
  844. }
  845. // 搜索分配人员列表
  846. searchPersonList(e) {
  847. this.getPersonList(true, e);
  848. }
  849. groupsList = []; //分组列表
  850. gpLoading = false;
  851. gpNum = 0;
  852. //获取分配分组列表
  853. getGroupsList(flag?, search = "", edit?, info?) {
  854. if (!flag) {
  855. return;
  856. }
  857. let hosIds = this.currentHospital.id;
  858. let postData = {
  859. idx: 0,
  860. sum: 20,
  861. group2: {
  862. groupName: search,
  863. scheduleClass: {
  864. id: this.gpClassId,
  865. },
  866. hospitals: hosIds,
  867. type:1
  868. },
  869. };
  870. this.gpLoading = true;
  871. if (edit) {
  872. this.maskFlag = this.message.loading("正在加载中..", {
  873. nzDuration: 0,
  874. }).messageId;
  875. }
  876. this.gpNum++;
  877. this.mainService
  878. .getFetchDataList("data", "group2", postData)
  879. .subscribe((data) => {
  880. this.gpNum--;
  881. if (this.gpNum === 0) {
  882. this.gpLoading = false;
  883. if (edit) {
  884. this.message.remove(this.maskFlag);
  885. this.maskFlag = false;
  886. this.groupsModal = true;
  887. }
  888. }
  889. if (data.status == 200) {
  890. this.groupsList = data.list;
  891. if (edit) {
  892. console.log(info);
  893. let arr = [];
  894. let arrIds = [];
  895. info.groups.forEach((item) => {
  896. let flag = this.groupsList.some((v) => v.id == item.id);
  897. if (!flag) {
  898. arr.push(item);
  899. }
  900. arrIds.push(item.id + "");
  901. });
  902. this.groupsList = [...arr, ...this.groupsList];
  903. this.validateGroupForm.controls.quickCombinationGroups.setValue(
  904. arrIds
  905. ); //分组
  906. }
  907. }
  908. });
  909. }
  910. // 搜索分配人员列表
  911. searchGroupsList(e) {
  912. this.getGroupsList(true, e);
  913. }
  914. // 表格数据
  915. loading1 = false;
  916. getList(type) {
  917. if (type == 1) {
  918. this.pageIndex = 1;
  919. }
  920. let data = {
  921. workAllocationQuickConfig: {
  922. workSchemeId: this.queryParamsId,
  923. hosId: this.currentHospital.id,
  924. },
  925. idx: this.pageIndex - 1,
  926. sum: this.pageSize,
  927. };
  928. if (this.searchCriteria.name) {
  929. data["workAllocationQuickConfig"]["configName"] =
  930. this.searchCriteria.name;
  931. }
  932. if (this.searchCriteria.workModel) {
  933. data["workAllocationQuickConfig"]["ruleType"] =
  934. this.searchCriteria.workModel;
  935. }
  936. this.loading1 = true;
  937. this.mainService
  938. .getFetchDataList("configuration", "workAllocationQuickConfig", data)
  939. .subscribe((data) => {
  940. this.loading1 = false;
  941. if (data.status == 200) {
  942. let arr = ["自由抢单", "指定分组", "科室绑定人员", "科室绑定分组"];
  943. let _arr = ["自由抢单", "绑定分组", "科室绑定人员", "科室绑定分组"];
  944. this.listOfData = data.list;
  945. data.list.forEach((item) => {
  946. let arr1 = [];
  947. let arr2 = [];
  948. let arr3 = [];
  949. let arr4 = [];
  950. let arr5 = [];
  951. let arr6 = [];
  952. let arr7 = [];
  953. if(this.queryParamsType == 1){
  954. item.ruleTypeName = arr[item.ruleType - 1];
  955. }else if(this.queryParamsType == 2){
  956. item.ruleTypeName = _arr[item.ruleType - 1];
  957. }
  958. item.taskTypes.forEach((v) => {
  959. arr1.push(v.taskName);
  960. arr2.push(v.id + "");
  961. });
  962. if (item.users) {
  963. item.users.forEach((v) => {
  964. arr3.push(v.name);
  965. arr6.push(v.id);
  966. });
  967. } else if (item.groups) {
  968. item.groups.forEach((v) => {
  969. arr3.push(v.groupName);
  970. arr4.push(v.id + "");
  971. });
  972. } else {
  973. arr3 = ["-"];
  974. }
  975. if (item.departmentDTOS) {
  976. item.departmentDTOS.forEach((v) => {
  977. arr5.push(v.id + "");
  978. arr7.push(v.dept);
  979. });
  980. } else {
  981. arr7 = ["-"];
  982. }
  983. item.taskTypesName = arr1;
  984. item.taskTypesId = arr2;
  985. item.allName = arr3;
  986. item.groupsId = arr4;
  987. item.departmentDTOSId = arr5;
  988. item.usersId = arr6;
  989. item.departmentDTOSName = arr7;
  990. });
  991. this.listLength = data.totalNum;
  992. }
  993. });
  994. }
  995. // 新增/编辑弹框
  996. addModal() {
  997. this.add = true; //新增
  998. this.modal = true;
  999. this.initForm();
  1000. }
  1001. //关闭新增/编辑弹框
  1002. hideAddModal() {
  1003. this.modal = false;
  1004. this.copyFlag = false;
  1005. this.initForm();
  1006. }
  1007. // 新增/编辑弹框
  1008. ruleTypeCoopId;
  1009. addPersonModal(e, data) {
  1010. e.stopPropagation();
  1011. this.coopId = data.id;
  1012. this.ruleTypeCoopId = data.ruleType;
  1013. this.initPersonForm();
  1014. this.getPersonList(true, "", "edit", data);
  1015. }
  1016. //关闭
  1017. hidePersonModal() {
  1018. this.personModal = false;
  1019. this.initPersonForm();
  1020. }
  1021. // 分配分组弹框
  1022. gpClassId;
  1023. addGroupsModal(e, data) {
  1024. e.stopPropagation();
  1025. console.log(data);
  1026. this.gpClassId = data.classes.id;
  1027. this.coopId = data.id;
  1028. this.ruleTypeCoopId = data.ruleType;
  1029. this.initGroupsForm();
  1030. this.getGroupsList(true, "", "edit", data);
  1031. }
  1032. //关闭
  1033. hideGroupsModal() {
  1034. this.groupsModal = false;
  1035. this.initGroupsForm();
  1036. }
  1037. // 初始化新增form表单
  1038. initForm() {
  1039. this.taskList = [];
  1040. this.currentClassId = "";
  1041. this.quickCombinationModel = "";
  1042. this.taskListFlag = true;
  1043. this.validateForm = this.fb.group({
  1044. quickCombinationName: [null, [Validators.required]],
  1045. quickCombinationClass: [null, [Validators.required]],
  1046. quickCombinationType: [null, [Validators.required]],
  1047. quickCombinationModel: [null, [Validators.required]],
  1048. quickCombinationDept: this.requireGroup ? [null, [Validators.required]] : [null],
  1049. quickCombinationGroup: this.requireDept ? [null, [Validators.required]] : [null],
  1050. deptTypeIds: this.requireDeptType ? [null, [Validators.required]] : [null],
  1051. quickCombinationDispatchMethod: [null],
  1052. quickCombinationDispatchType: [null],
  1053. quickCombinationDispatchWeight: [null],
  1054. });
  1055. }
  1056. // 初始化新增form表单
  1057. initPersonForm() {
  1058. this.validatePersonForm = this.fb.group({
  1059. quickCombinationPerson: [null, [Validators.required]],
  1060. });
  1061. }
  1062. // 初始化新增form表单
  1063. initGroupsForm() {
  1064. this.validateGroupForm = this.fb.group({
  1065. quickCombinationGroups: [null, [Validators.required]],
  1066. });
  1067. }
  1068. //生效
  1069. takeEffect() {
  1070. let postData = { workSchemeId: this.queryParamsId };
  1071. this.tLoading = true;
  1072. this.showPromptModal("生效", false, "", true);
  1073. this.mainService
  1074. .coopConfig(
  1075. this.queryParamsType == 1 ? "takeEffect" : "optionalTakeEffect",
  1076. postData
  1077. )
  1078. .subscribe((data) => {
  1079. if (data.state == 200) {
  1080. this.ifSuccess = true;
  1081. this.promptInfo = "";
  1082. this.showLoading = false;
  1083. } else if (data.state == 201 || data.state == 203) {
  1084. this.promptInfo = data.msg;
  1085. this.showLoading = false;
  1086. } else {
  1087. this.promptInfo = "";
  1088. this.showLoading = false;
  1089. }
  1090. });
  1091. }
  1092. // 新增/编辑表单提交
  1093. submitForm(): void {
  1094. for (const i in this.validateForm.controls) {
  1095. this.validateForm.controls[i].markAsDirty();
  1096. this.validateForm.controls[i].updateValueAndValidity();
  1097. }
  1098. console.log(this.validateForm);
  1099. this.btnLoading = true;
  1100. if (this.validateForm.invalid) {
  1101. this.btnLoading = false;
  1102. return;
  1103. }
  1104. let data = {};
  1105. let taskTypesIds = this.validateForm.value.quickCombinationType.map(
  1106. (item) => {
  1107. return {
  1108. id: item,
  1109. };
  1110. }
  1111. );
  1112. data = {
  1113. workAllocationQuickConfig: {
  1114. hosId: this.currentHospital.id,
  1115. configName: this.validateForm.value.quickCombinationName,
  1116. classes: {
  1117. id: this.validateForm.value.quickCombinationClass,
  1118. },
  1119. taskTypes: taskTypesIds,
  1120. ruleType: this.quickCombinationModelComputed,
  1121. workSchemeId: this.queryParamsId,
  1122. dispatchMethod: this.dispatchMethods.find(v => v.value == this.validateForm.value.quickCombinationDispatchMethod),
  1123. dispatchType: this.validateForm.value.quickCombinationDispatchMethod == 2 ? (this.dispatchTypes.find(v => v.value == this.validateForm.value.quickCombinationDispatchType)) : undefined,
  1124. maxWeight: (this.validateForm.value.quickCombinationDispatchMethod == 2 && this.validateForm.value.quickCombinationDispatchType == 1) ? this.validateForm.value.quickCombinationDispatchWeight : undefined,
  1125. },
  1126. };
  1127. console.log(this.validateForm.value.deptTypeIds);
  1128. //添加科室类型字段
  1129. if (this.validateForm.value.deptTypeIds && this.quickCombinationModel == 3 && this.queryParamsType == 2) {
  1130. data["workAllocationQuickConfig"]["deptTypeIds"] = this.validateForm.value.deptTypeIds.toString();
  1131. }
  1132. //添加科室字段,绑定人字段
  1133. if (
  1134. this.validateForm.value.quickCombinationDept &&
  1135. this.quickCombinationModel == 3 &&
  1136. this.queryParamsType == 1
  1137. ) {
  1138. let departmentDTOS = this.validateForm.value.quickCombinationDept.map(
  1139. (item) => {
  1140. return {
  1141. id: item,
  1142. };
  1143. }
  1144. );
  1145. let usersId = [];
  1146. if (!this.add) {
  1147. usersId = this.info.usersId.map((item) => {
  1148. return {
  1149. id: item,
  1150. };
  1151. });
  1152. }
  1153. data["workAllocationQuickConfig"]["departmentDTOS"] = departmentDTOS;
  1154. if (!this.add) {
  1155. if (this.info.ruleType != this.quickCombinationModel || this.copyFlag) {
  1156. data["workAllocationQuickConfig"]["users"] = null;
  1157. } else {
  1158. data["workAllocationQuickConfig"]["users"] = usersId;
  1159. }
  1160. }
  1161. }
  1162. //添加科室字段,绑定组字段
  1163. if (
  1164. this.validateForm.value.quickCombinationDept &&
  1165. this.quickCombinationModel == 4
  1166. ) {
  1167. let departmentDTOS = this.validateForm.value.quickCombinationDept.map(
  1168. (item) => {
  1169. return {
  1170. id: item,
  1171. };
  1172. }
  1173. );
  1174. let groupsId = [];
  1175. if (!this.add) {
  1176. groupsId = this.info.groupsId.map((item) => {
  1177. return {
  1178. id: item,
  1179. };
  1180. });
  1181. }
  1182. data["workAllocationQuickConfig"]["departmentDTOS"] = departmentDTOS;
  1183. if (!this.add) {
  1184. if (this.info.ruleType != this.quickCombinationModel || this.copyFlag) {
  1185. data["workAllocationQuickConfig"]["groups"] = null;
  1186. } else {
  1187. data["workAllocationQuickConfig"]["groups"] = groupsId;
  1188. }
  1189. }
  1190. }
  1191. //指定分组,添加分组字段
  1192. console.log(this.validateForm.value.quickCombinationGroup);
  1193. if (
  1194. this.validateForm.value.quickCombinationGroup &&
  1195. (this.quickCombinationModel == 2 || this.quickCombinationModel == 5 || this.quickCombinationModel == 6)
  1196. ) {
  1197. if(this.quickCombinationModel == 5){
  1198. let groups = this.validateForm.value.quickCombinationGroup.map((item) => {
  1199. return {
  1200. id: item,
  1201. };
  1202. });
  1203. if (groups.length > 0) {
  1204. if (this.copyFlag) {
  1205. data["workAllocationQuickConfig"]["groups"] = null;
  1206. } else {
  1207. data["workAllocationQuickConfig"]["groups"] = groups;
  1208. }
  1209. } else {
  1210. data["workAllocationQuickConfig"]["groups"] = null;
  1211. }
  1212. }else if(this.quickCombinationModel == 6){
  1213. if(this.validateForm.value.quickCombinationGroup){
  1214. let groups = [{id:this.validateForm.value.quickCombinationGroup}];
  1215. if (this.copyFlag) {
  1216. data["workAllocationQuickConfig"]["groups"] = null;
  1217. } else {
  1218. data["workAllocationQuickConfig"]["groups"] = groups;
  1219. }
  1220. }else{
  1221. data["workAllocationQuickConfig"]["groups"] = null;
  1222. }
  1223. }
  1224. }
  1225. if (!this.add && !this.copyFlag) {
  1226. //编辑
  1227. data["workAllocationQuickConfig"]["id"] = this.info.id;
  1228. }
  1229. this.mainService
  1230. .coopTypeConfig(
  1231. this.add || (!this.add && this.copyFlag) ? "addData" : "updData",
  1232. "workAllocationQuickConfig",
  1233. data
  1234. )
  1235. .subscribe((result) => {
  1236. this.btnLoading = false;
  1237. if (result.status == 200) {
  1238. console.log(this.copyFlag);
  1239. if (this.add) {
  1240. this.showPromptModal("新增", true, "");
  1241. this.listLength++;
  1242. } else if (this.copyFlag) {
  1243. this.showPromptModal("复制", true, "");
  1244. this.listLength++;
  1245. } else if (!this.copyFlag) {
  1246. //编辑
  1247. this.showPromptModal("编辑", true, "");
  1248. }
  1249. } else {
  1250. let msg = "";
  1251. if (this.add) {
  1252. msg = "新增";
  1253. } else if (!this.copyFlag) {
  1254. msg = "修改";
  1255. } else if (this.copyFlag) {
  1256. msg = "复制";
  1257. }
  1258. this.showPromptModal(msg, false, result.msg);
  1259. }
  1260. this.hideAddModal();
  1261. this.initForm();
  1262. });
  1263. }
  1264. // 分配人员提交
  1265. submitPersonForm(): void {
  1266. this.btnLoading = true;
  1267. for (const i in this.validatePersonForm.controls) {
  1268. this.validatePersonForm.controls[i].markAsDirty();
  1269. this.validatePersonForm.controls[i].updateValueAndValidity();
  1270. }
  1271. if (this.validatePersonForm.invalid) {
  1272. this.btnLoading = false;
  1273. return;
  1274. }
  1275. let usersIds = [];
  1276. if (this.validatePersonForm.value.quickCombinationPerson) {
  1277. // usersIds = this.validatePersonForm.value.quickCombinationPerson.map(
  1278. // (item) => {
  1279. // return { id: item };
  1280. // }
  1281. // );
  1282. usersIds.push({ id: this.validatePersonForm.value.quickCombinationPerson });
  1283. }
  1284. let data = {
  1285. workAllocationQuickConfig: {
  1286. hosId: this.currentHospital.id,
  1287. id: this.coopId,
  1288. users: usersIds,
  1289. ruleType: this.ruleTypeCoopId,
  1290. },
  1291. };
  1292. this.mainService
  1293. .coopTypeConfig("updData", "workAllocationQuickConfig", data)
  1294. .subscribe((data) => {
  1295. this.btnLoading = false;
  1296. this.hidePersonModal();
  1297. this.initPersonForm();
  1298. if (data.status == 200) {
  1299. this.showPromptModal("分配人员", true, "");
  1300. } else {
  1301. this.showPromptModal("分配人员", false, data.msg);
  1302. }
  1303. });
  1304. }
  1305. // 分配分组提交
  1306. submitGroupsForm(): void {
  1307. this.btnLoading = true;
  1308. for (const i in this.validateGroupForm.controls) {
  1309. this.validateGroupForm.controls[i].markAsDirty();
  1310. this.validateGroupForm.controls[i].updateValueAndValidity();
  1311. }
  1312. if (this.validateGroupForm.invalid) {
  1313. this.btnLoading = false;
  1314. return;
  1315. }
  1316. let groupIds = [];
  1317. if (this.validateGroupForm.value.quickCombinationGroups) {
  1318. groupIds = this.validateGroupForm.value.quickCombinationGroups.map(
  1319. (item) => {
  1320. return { id: item };
  1321. }
  1322. );
  1323. }
  1324. let data = {
  1325. workAllocationQuickConfig: {
  1326. hosId: this.currentHospital.id,
  1327. id: this.coopId,
  1328. groups: groupIds,
  1329. ruleType: this.ruleTypeCoopId,
  1330. },
  1331. };
  1332. this.mainService
  1333. .coopTypeConfig("updData", "workAllocationQuickConfig", data)
  1334. .subscribe((data) => {
  1335. this.btnLoading = false;
  1336. this.hideGroupsModal();
  1337. this.initGroupsForm();
  1338. if (data.status == 200) {
  1339. this.showPromptModal("分配分组", true, "");
  1340. } else {
  1341. this.showPromptModal("分配分组", false, data.msg);
  1342. }
  1343. });
  1344. }
  1345. // 复制
  1346. copyFlag = false;
  1347. copy(e, data) {
  1348. e.stopPropagation();
  1349. console.log(data);
  1350. this.add = false;
  1351. this.copyFlag = true;
  1352. this.coopId = data.id;
  1353. this.info = data;
  1354. this.ids = data.taskTypesId;
  1355. this.currentClassId = data.classes.id;
  1356. this.getClassList(true, true);
  1357. }
  1358. // 编辑
  1359. info; //编辑时候保存的信息
  1360. edit(e, data) {
  1361. e.stopPropagation();
  1362. console.log(data);
  1363. this.add = false;
  1364. this.coopId = data.id;
  1365. this.info = data;
  1366. this.validateForm.controls.quickCombinationName.setValue(data.configName); //快捷组合名称
  1367. this.ids = data.taskTypesId;
  1368. this.currentClassId = data.classes.id;
  1369. this.getClassList(true, true);
  1370. }
  1371. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  1372. // promptModalUrl = '';
  1373. showPromptModal(con, success, promptInfo?, loading?) {
  1374. this.promptModalShow = false;
  1375. this.promptContent = con;
  1376. this.ifSuccess = success;
  1377. this.promptInfo = promptInfo;
  1378. if (loading !== undefined) {
  1379. this.showLoading = loading;
  1380. } else {
  1381. this.showLoading = false;
  1382. this.getList(0);
  1383. }
  1384. // this.promptModalUrl = url;
  1385. setTimeout(() => {
  1386. this.promptModalShow = true;
  1387. }, 100);
  1388. }
  1389. // 选中表格中快捷建单
  1390. isAllDisplayDataChecked = false; //当前页是否全选
  1391. mapOfCheckedId = {};
  1392. checkedDepIds = []; //已选中快捷建单id
  1393. refreshStatus(): void {
  1394. this.isAllDisplayDataChecked = this.listOfData.every(
  1395. (item) => this.mapOfCheckedId[item.id]
  1396. );
  1397. let arr = [];
  1398. for (var k in this.mapOfCheckedId) {
  1399. if (this.mapOfCheckedId[k]) {
  1400. arr.push(Number(k));
  1401. }
  1402. }
  1403. this.checkedDepIds = arr;
  1404. console.log(this.checkedDepIds, this.isAllDisplayDataChecked);
  1405. }
  1406. // 整行选中或不选中
  1407. selectedListData(id) {
  1408. this.mapOfCheckedId[id] = !this.mapOfCheckedId[id];
  1409. this.refreshStatus();
  1410. }
  1411. // 全选
  1412. checkAll(value: boolean): void {
  1413. this.listOfData.forEach((item) => (this.mapOfCheckedId[item.id] = value));
  1414. this.refreshStatus();
  1415. }
  1416. // 删除轮巡计划
  1417. delModal: boolean = false; //删除模态框
  1418. tipsMsg1: string; //提示框信息
  1419. tipsMsg2: string; //操作后信息
  1420. confirmDelType: string; //确认的类型(启用/停用,删除)
  1421. confirmDelIsSwitch: boolean; //启用/停用
  1422. showDelModal(
  1423. e,
  1424. id: any,
  1425. tipsMsg1: string,
  1426. tipsMsg2: string,
  1427. type: string,
  1428. isSwitch?: boolean
  1429. ) {
  1430. e.stopPropagation();
  1431. this.confirmDelIsSwitch = isSwitch;
  1432. this.confirmDelType = type;
  1433. this.delModal = true;
  1434. this.coopId = id;
  1435. this.tipsMsg1 = tipsMsg1;
  1436. this.tipsMsg2 = tipsMsg2;
  1437. }
  1438. // 隐藏删除框
  1439. hideDelModal() {
  1440. this.delModal = false;
  1441. }
  1442. // 确认删除
  1443. confirmDel() {
  1444. this.btnLoading = true;
  1445. if (this.confirmDelType === "del") {
  1446. //删除
  1447. let arrData = [];
  1448. if (Array.isArray(this.coopId)) {
  1449. arrData = this.coopId;
  1450. } else {
  1451. arrData = [this.coopId];
  1452. }
  1453. this.mainService
  1454. .coopTypeConfig("rmvData", "workAllocationQuickConfig", arrData)
  1455. .subscribe((data) => {
  1456. this.btnLoading = false;
  1457. this.delModal = false;
  1458. if (data.status == 200) {
  1459. if (
  1460. this.listOfData.length == 1 &&
  1461. this.pageIndex == Math.ceil(this.listLength / this.pageSize)
  1462. ) {
  1463. this.listLength--;
  1464. if (this.listLength === 0) {
  1465. this.pageIndex = 1;
  1466. } else {
  1467. this.pageIndex = Math.ceil(this.listLength / this.pageSize);
  1468. }
  1469. }
  1470. this.showPromptModal(this.tipsMsg2, true, "");
  1471. this.isAllDisplayDataChecked = false;
  1472. this.checkedDepIds = [];
  1473. this.mapOfCheckedId = {};
  1474. } else {
  1475. this.showPromptModal(this.tipsMsg2, false, data.msg);
  1476. }
  1477. });
  1478. }
  1479. }
  1480. // ----------返回拦截------------
  1481. tipModal = false;
  1482. // tipMsg1 = '是否确定离开该界面,如果未点击生效,数据可能会遗失?';
  1483. // 隐藏模态框
  1484. hideTipModal() {
  1485. this.tipModal = false;
  1486. }
  1487. // 返回
  1488. goToWorkAssignment() {
  1489. this.tipModal = true;
  1490. }
  1491. // 模态框确认
  1492. confirmTip() {
  1493. this.tipModal = false;
  1494. this.router.navigateByUrl(`/main/workAssignment`);
  1495. }
  1496. }