configuration-category.component.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute } from "@angular/router";
  3. import { Subject } from 'rxjs';
  4. import { debounceTime } from 'rxjs/operators';
  5. import { MainService } from "../../../services/main.service";
  6. import { Validators, FormGroup, FormBuilder } from '@angular/forms';
  7. import { ToolService } from 'src/app/services/tool.service';
  8. import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
  9. @Component({
  10. selector: "app-configuration-category",
  11. templateUrl: "./configuration-category.component.html",
  12. styleUrls: ["./configuration-category.component.less"],
  13. })
  14. export class ConfigurationCategoryComponent implements OnInit {
  15. constructor(
  16. private route: ActivatedRoute,
  17. private mainService: MainService,
  18. private fb: FormBuilder,
  19. private tool: ToolService,
  20. ) {}
  21. @ViewChild("osComponentRef1", {
  22. read: OverlayScrollbarsComponent,
  23. static: false,
  24. })
  25. osComponentRef1: OverlayScrollbarsComponent;
  26. @ViewChild("osComponentRef2", {
  27. read: OverlayScrollbarsComponent,
  28. static: false,
  29. })
  30. osComponentRef2: OverlayScrollbarsComponent;
  31. @ViewChild("osComponentRef3", {
  32. read: OverlayScrollbarsComponent,
  33. static: false,
  34. })
  35. osComponentRef3: OverlayScrollbarsComponent;
  36. coopData: any = {}; //当前操作列
  37. currentHospital; //当前院区
  38. // 部门设置、全院设置
  39. hospitalConfig:any = 2;
  40. hospitalConfigList:any = [
  41. // { id: 1, name: '部门设置',},
  42. { id: 2, name: '全院设置',},
  43. ];
  44. changeInpSubject = new Subject(); //防抖
  45. debounceSubject = new Subject(); //防抖
  46. ngOnInit() {
  47. //防抖
  48. this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
  49. if(v[0] === 'user'){
  50. this.getUsers(v[1]);
  51. } else if(v[0] === 'group'){
  52. this.getGroups(v[1]);
  53. }
  54. });
  55. this.debounceSubject.pipe(debounceTime(500)).subscribe((v) => {
  56. if(v[0]){
  57. this.getCategoryList(v[0], v[1].id);
  58. }
  59. this.getCategoryConfigList(v[1].id);
  60. });
  61. this.currentHospital = this.tool.getCurrentHospital();
  62. // 故障现象
  63. setTimeout(() => {
  64. this.tableCategoryHeight = document.querySelector('#categoryTable').clientHeight - 8 - document.querySelector('#categoryTable .thead').clientHeight;
  65. }, 0)
  66. let { hospital, type } = this.tool.getHospitalOrDuty();
  67. if(type === 'duty'){
  68. // 是责任部门
  69. let flag = this.hospitalConfigList.some(v => v.id === 1);
  70. !flag && this.hospitalConfigList.unshift({ id: 1, name: '部门设置',});
  71. }
  72. this.getCategoryList(1);
  73. this.getHospitals(1);
  74. this.getHospitals(2);
  75. this.getPrioritys();
  76. this.getScores();
  77. }
  78. // 获取优先级
  79. priority_c_List: any = [];
  80. getPrioritys() {
  81. let postData = {
  82. priority: {},
  83. idx: 0,
  84. sum: 9999,
  85. };
  86. this.mainService
  87. .getFetchDataList("simple/data", "priority", postData)
  88. .subscribe((data) => {
  89. this.isLoading = false;
  90. this.priority_c_List = data.list || [];
  91. });
  92. }
  93. // 获取积分
  94. scoreList: any = [];
  95. getScores() {
  96. let postData = {
  97. dictionary: {
  98. key: "incident_category_score"
  99. },
  100. idx: 0,
  101. sum: 10,
  102. };
  103. this.mainService
  104. .getFetchDataList("simple/data", "dictionary", postData)
  105. .subscribe((data) => {
  106. this.isLoading = false;
  107. this.scoreList = data.list || [];
  108. });
  109. }
  110. // 边输边搜节流阀
  111. isLoading = false;
  112. changeInp(model, e) {
  113. this.isLoading = true;
  114. this.changeInpSubject.next([model, e]);
  115. }
  116. // 搜索
  117. // 获取用户
  118. userList: any = [];
  119. getUsers(keyword = '', isShowValue = false) {
  120. if((!this.validateConfigForm.value.groupId && this.validateConfigForm.value.userGroup === 1) || this.validateConfigForm.value.userGroup === 2){
  121. this.isLoading = false;
  122. this.userList = [];
  123. return;
  124. }
  125. let postData = {
  126. user: {
  127. hospital: { id: this.validateConfigForm.value.dutyId },
  128. name: keyword,
  129. simpleQuery: true,
  130. groupdata: { id: this.validateConfigForm.value.groupId },
  131. roleCodes: 'first-line support',
  132. engineer: 1,
  133. },
  134. idx: 0,
  135. sum: 10,
  136. };
  137. this.mainService
  138. .getFetchDataList("data", "user", postData)
  139. .subscribe((data) => {
  140. this.isLoading = false;
  141. let userList = data.list || [];
  142. if(isShowValue && this.coopData && this.coopData.userId){
  143. userList = userList.filter(v => v.id !== this.coopData.userId)
  144. userList.unshift(this.coopData.userDTO);
  145. }
  146. this.userList = userList;
  147. });
  148. }
  149. // 获取组
  150. groupList: any = []; //所有所属科室(搜索)
  151. getGroups(keyword = '', isShowValue = false) {
  152. if(!this.validateConfigForm.value.dutyId){
  153. this.isLoading = false;
  154. this.groupList = [];
  155. return;
  156. }
  157. let postData = {
  158. group2: {
  159. groupName: keyword,
  160. hospitals: this.validateConfigForm.value.dutyId,
  161. type: 3,
  162. },
  163. idx: 0,
  164. sum: 10,
  165. };
  166. this.mainService
  167. .getFetchDataList("data", "group2", postData)
  168. .subscribe((data) => {
  169. this.isLoading = false;
  170. let groupList = data.list || [];
  171. if(isShowValue && this.coopData && this.coopData.groupId){
  172. groupList = groupList.filter(v => v.id !== this.coopData.groupId)
  173. groupList.unshift(this.coopData.groupDTO);
  174. }
  175. this.groupList = groupList;
  176. });
  177. }
  178. // 点击故障现象
  179. activeCategory1:any = {};
  180. activeCategory2:any = {};
  181. activeCategory3:any = {};
  182. clickCategory(item, type:number){
  183. this.categoryConfigList = [];
  184. switch(type){
  185. case 1:
  186. this.categoryList2 = [];
  187. this.categoryList3 = [];
  188. this.activeCategory2 = {};
  189. this.activeCategory3 = {};
  190. break;
  191. case 2:
  192. this.categoryList3 = [];
  193. this.activeCategory3 = {};
  194. break;
  195. }
  196. this['activeCategory' + type] = item;
  197. console.log(this['activeCategory' + type])
  198. switch(type){
  199. case 1:
  200. this.categoryLoading2 = true;
  201. this.loading1 = true;
  202. this.debounceSubject.next([2, item]);
  203. break;
  204. case 2:
  205. this.categoryLoading3 = true;
  206. this.loading1 = true;
  207. this.debounceSubject.next([3, item]);
  208. break;
  209. case 3:
  210. this.loading1 = true;
  211. this.debounceSubject.next([0, item]);
  212. break;
  213. }
  214. }
  215. // 选择部门设置或全院设置
  216. changeHospitalConfig(e){
  217. console.log(e);
  218. this.getCategoryList(1);
  219. this.categoryList2 = [];
  220. this.categoryList3 = [];
  221. this.activeCategory1 = {};
  222. this.activeCategory2 = {};
  223. this.activeCategory3 = {};
  224. this.categoryConfigList = [];
  225. }
  226. // 获取当前选中的故障现象索引
  227. get currentCategoryIndex(){
  228. if(this.activeCategory3.id){
  229. return 3;
  230. }
  231. if(this.activeCategory2.id){
  232. return 2;
  233. }
  234. if(this.activeCategory1.id){
  235. return 1;
  236. }
  237. }
  238. // 获取当前选中的故障现象索引
  239. get currentCategory(){
  240. if(this.activeCategory3.id){
  241. return this.activeCategory3;
  242. }
  243. if(this.activeCategory2.id){
  244. return this.activeCategory2;
  245. }
  246. if(this.activeCategory1.id){
  247. return this.activeCategory1;
  248. }
  249. }
  250. // 获取当前选中的故障现象有没有子故障现象
  251. get currentChildrenCategoryList(){
  252. return this.currentCategoryIndex && this.currentCategoryIndex < 3 && this['categoryList' + (this.currentCategoryIndex + 1)].length;
  253. }
  254. categoryConfigList:any[] = [];
  255. getCategoryConfigList(parentId = 0) {
  256. this.loading1 = true;
  257. let postData = {
  258. idx: 0,
  259. sum: 9999,
  260. incidentCategoryConfig: {
  261. categoryId: parentId,
  262. dutyId: this.hospitalConfig === 1 ? this.currentHospital.id : undefined,
  263. },
  264. };
  265. this.mainService.getFetchDataList("simple/data", "incidentCategoryConfig", postData).subscribe(res => {
  266. this.loading1 = false;
  267. this.categoryConfigList = res.list || [];
  268. })
  269. }
  270. // 修改院区
  271. changeHospital(id){
  272. this.validateConfigForm.controls.dutyId.setValue(null);
  273. this.validateConfigForm.controls.userId.setValue(null);
  274. this.validateConfigForm.controls.groupId.setValue(null);
  275. // this.dutyList = [];
  276. this.userList = [];
  277. this.groupList = [];
  278. // this.getHospitals(2, id);
  279. }
  280. // 获取院区
  281. hospitalList: any = [];
  282. dutyList: any = [];
  283. getHospitals(type:number, parentId?) {
  284. if(type === 1){
  285. this.isLoading = false;
  286. this.hospitalList = this.tool.getHospitalList().filter(v => !v.parent);
  287. return;
  288. }
  289. // if(type === 2 && !parentId){
  290. // this.isLoading = false;
  291. // this.dutyList = [];
  292. // return;
  293. // }
  294. let postData = {
  295. hospital: {
  296. // parent: { id: parentId },
  297. type: { key: 'hospital_type', value: '6' },
  298. },
  299. idx: 0,
  300. sum: 9999,
  301. };
  302. this.mainService
  303. .getFetchDataList("data", "hospital", postData)
  304. .subscribe((data) => {
  305. this.isLoading = false;
  306. this.dutyList = data.list || [];
  307. });
  308. }
  309. // 修改责任部门
  310. changeDuty(id){
  311. this.validateConfigForm.controls.userId.setValue(null);
  312. this.validateConfigForm.controls.groupId.setValue(null);
  313. this.userList = [];
  314. this.groupList = [];
  315. this.getGroups();
  316. }
  317. // 一级故障现象
  318. loading1:boolean = false;
  319. tableCategoryHeight:number = 0;
  320. categoryList1: any[] = [];
  321. categoryList2: any[] = [];
  322. categoryList3: any[] = [];
  323. categoryLoading1:boolean = false;
  324. categoryLoading2:boolean = false;
  325. categoryLoading3:boolean = false;
  326. getCategoryList(type:number, parentId = 0) {
  327. setTimeout(() => {
  328. this['categoryLoading' + type] = true;
  329. }, 0)
  330. let postData = {
  331. category: {
  332. hierarchy: type === 1 ? 1 : undefined,
  333. dutyIds: this.hospitalConfig === 1 ? this.currentHospital.id.toString() : undefined,
  334. parent: type === 1 ? undefined : { id: parentId },
  335. },
  336. };
  337. this.mainService.incidentPost("listIncidentCategory", postData).subscribe(res => {
  338. this['categoryLoading' + type] = false;
  339. this['categoryList' + type] = res.data || [];
  340. })
  341. }
  342. // 新增故障现象弹框
  343. modelName = ""; //模态框名称
  344. add: boolean; //true:新增;false:编辑
  345. modalCategory: boolean = false; //新增/编辑模态框
  346. coopType: number = 0;
  347. addCategoryModal(type:number) {
  348. this.coopType = type;
  349. this.modelName = "新增";
  350. this.add = true; //新增
  351. this.modalCategory = true;
  352. this.initCategoryForm();
  353. }
  354. //关闭新增/编辑弹框
  355. hideCategoryModal() {
  356. this.modalCategory = false;
  357. }
  358. // 初始化新增form表单
  359. validateCategoryForm: FormGroup; //新增/编辑表单
  360. initCategoryForm() {
  361. this.validateCategoryForm = this.fb.group({
  362. name: [null, [Validators.required]],//名称
  363. });
  364. console.log(this.validateCategoryForm.controls)
  365. }
  366. // 编辑
  367. // editCategory(data) {
  368. // console.log(data);
  369. // this.modelName = "编辑";
  370. // this.add = false;
  371. // this.modalCategory = true;
  372. // this.initCategoryForm();
  373. // this.coopData = data;
  374. // this.validateCategoryForm.controls.name.setValue(data.name);
  375. // }
  376. // 新增/编辑表单提交
  377. btnLoading: boolean = false; //提交按钮loading状态
  378. submitCategoryForm(): void {
  379. for (const i in this.validateCategoryForm.controls) {
  380. this.validateCategoryForm.controls[i].markAsDirty();
  381. this.validateCategoryForm.controls[i].updateValueAndValidity();
  382. }
  383. if (this.validateCategoryForm.invalid) {
  384. return;
  385. }
  386. console.log(this.validateCategoryForm.value);
  387. this.btnLoading = true;
  388. // -----------------------------------
  389. let postData:any = {
  390. category: {
  391. hosId: this.currentHospital.id,
  392. parent: this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)],
  393. category: this.validateCategoryForm.value.name,
  394. hierarchy: this.coopType,
  395. dutyIds: this.hospitalConfig === 1 ? this.currentHospital.id.toString() : undefined,
  396. },
  397. };
  398. this.mainService
  399. .incidentPost("checkIncidentCategory", postData)
  400. .subscribe((result) => {
  401. let msg = "";
  402. if (this.add) {
  403. msg = "新增";
  404. } else {
  405. msg = "修改";
  406. }
  407. if (result.status == 200) {
  408. this.submitCategoryAddForm();
  409. } else if(result.status == 502) {
  410. this.btnLoading = false;
  411. this.showDelModal(null, result.msg, '', 'relevance');
  412. } else {
  413. this.btnLoading = false;
  414. this.showPromptModal(msg, false, result.msg);
  415. }
  416. });
  417. // -----------------------------------
  418. }
  419. delModal: boolean = false; //删除模态框
  420. tipsMsg1: string; //提示框信息
  421. tipsMsg2: string; //操作后信息
  422. confirmDelType: string; //确认的类型(启用/停用,删除)
  423. showDelModal(
  424. data,
  425. tipsMsg1: string,
  426. tipsMsg2: string,
  427. type: string,
  428. ) {
  429. this.confirmDelType = type;
  430. this.delModal = true;
  431. this.coopData = data;
  432. this.tipsMsg1 = tipsMsg1;
  433. this.tipsMsg2 = tipsMsg2;
  434. }
  435. // 隐藏删除框
  436. hideDelModal() {
  437. this.delModal = false;
  438. }
  439. // 确认删除
  440. confirmDel() {
  441. this.btnLoading = true;
  442. if (this.confirmDelType === "relevance") {
  443. //新增故障现象-关联
  444. this.btnLoading = false;
  445. this.delModal = false;
  446. this.submitCategoryAddForm();
  447. } else if (this.confirmDelType === "delConfig") {
  448. //删除-关联
  449. this.mainService
  450. .simplePost("rmvData", "incidentCategoryConfig", [this.coopData.id])
  451. .subscribe((data) => {
  452. this.btnLoading = false;
  453. this.delModal = false;
  454. if (data.status == 200) {
  455. this.showPromptModal(this.tipsMsg2, true, "");
  456. } else {
  457. this.showPromptModal(this.tipsMsg2, false, data.msg);
  458. }
  459. });
  460. } else if (this.confirmDelType === "copy") {
  461. //向下复制-关联
  462. let postData:any = {
  463. type: this.hospitalConfig === 1 ? 'duty': 'hospital',
  464. category: this.currentCategory,
  465. };
  466. postData.category.dutyIds = this.hospitalConfig === 1 ? this.currentHospital.id.toString() : undefined;
  467. this.mainService
  468. .incidentPost("copyIncidentCategoryConfig", postData)
  469. .subscribe((data) => {
  470. this.btnLoading = false;
  471. this.delModal = false;
  472. if (data.status == 200) {
  473. this.showPromptModal(this.tipsMsg2, true, "");
  474. } else {
  475. this.showPromptModal(this.tipsMsg2, false, data.msg);
  476. }
  477. });
  478. }
  479. }
  480. submitCategoryAddForm(): void {
  481. let postData:any = {};
  482. if (this.add) {
  483. //增加
  484. console.log(this['activeCategory' + this.coopType])
  485. postData = {
  486. category: {
  487. hosId: this.currentHospital.id,
  488. parent: this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)],
  489. category: this.validateCategoryForm.value.name,
  490. hierarchy: this.coopType,
  491. dutyIds: this.hospitalConfig === 1 ? this.currentHospital.id.toString() : undefined,
  492. },
  493. };
  494. } else {
  495. //编辑
  496. // postData = {
  497. // category: {
  498. // hosId: this.currentHospital.id,
  499. // parent: this.coopType === 1 ? undefined : { id: this.coopData.id },
  500. // category: this.validateCategoryForm.value.name,
  501. // hierarchy: this.coopType,
  502. // },
  503. // };
  504. }
  505. this.mainService
  506. .incidentPost("addIncidentCategory", postData)
  507. .subscribe((result) => {
  508. this.btnLoading = false;
  509. this.hideCategoryModal();
  510. let msg = "";
  511. if (this.add) {
  512. msg = "新增";
  513. } else {
  514. msg = "修改";
  515. }
  516. if (result.status == 200) {
  517. this.showPromptModal(msg, true, '');
  518. } else {
  519. this.showPromptModal(msg, false, result.msg);
  520. }
  521. });
  522. }
  523. // ------------------------------
  524. // 新增故障现象-关联弹框
  525. modalConfig: boolean = false; //新增/编辑模态框
  526. addConfigModal() {
  527. this.modelName = "新增";
  528. this.add = true; //新增
  529. this.modalConfig = true;
  530. this.initConfigForm();
  531. this.requiredConfigChange('userId', true);
  532. }
  533. //关闭新增/编辑弹框
  534. hideConfigModal() {
  535. this.modalConfig = false;
  536. }
  537. // 初始化新增form表单
  538. validateConfigForm: FormGroup; //新增/编辑表单
  539. initConfigForm() {
  540. this.validateConfigForm = this.fb.group({
  541. hosId: [null, [Validators.required]],//院区
  542. dutyId: [null, [Validators.required]],//责任部门
  543. priority: [null, [Validators.required]],//优先级
  544. score: [null, [Validators.required]],//积分
  545. userGroup: [1, [Validators.required]],//分配方式
  546. userId: [null],//维修人
  547. groupId: [null, [Validators.required]],//维修组
  548. });
  549. console.log(this.validateConfigForm.controls)
  550. }
  551. // 选择人|组
  552. changeUserGroup(id){
  553. this.validateConfigForm.controls.userId.setValue(null);
  554. this.validateConfigForm.controls.groupId.setValue(null);
  555. this.userList = [];
  556. if(id === 1){
  557. // 人
  558. this.requiredConfigChange('userId', true);
  559. }else if(id === 2){
  560. // 组
  561. this.requiredConfigChange('userId', false);
  562. }
  563. }
  564. // 编辑
  565. editConfig(data) {
  566. console.log(data);
  567. this.modelName = "编辑";
  568. this.add = false;
  569. this.modalConfig = true;
  570. this.initConfigForm();
  571. this.coopData = data;
  572. this.validateConfigForm.controls.hosId.setValue(data.hosId);
  573. this.validateConfigForm.controls.dutyId.setValue(data.dutyId);
  574. this.validateConfigForm.controls.priority.setValue(data.priority);
  575. this.validateConfigForm.controls.score.setValue(data.score ? data.score.id : null);
  576. this.validateConfigForm.controls.userGroup.setValue(data.userGroup);
  577. this.validateConfigForm.controls.userId.setValue(data.userId);
  578. this.validateConfigForm.controls.groupId.setValue(data.groupId);
  579. if(data.userGroup === 1){
  580. this.requiredConfigChange('userId', true);
  581. }else if(data.userGroup === 2){
  582. this.requiredConfigChange('userId', false);
  583. }
  584. // data.hosId && this.getHospitals(2, data.hosId);
  585. data.dutyId && this.getUsers('', true);
  586. data.dutyId && this.getGroups('', true);
  587. }
  588. // 修改组
  589. changeGroup(id){
  590. this.validateConfigForm.controls.userId.setValue(null);
  591. this.getUsers();
  592. }
  593. // 新增/编辑表单提交
  594. submitConfigForm(): void {
  595. for (const i in this.validateConfigForm.controls) {
  596. this.validateConfigForm.controls[i].markAsDirty();
  597. this.validateConfigForm.controls[i].updateValueAndValidity();
  598. }
  599. if (this.validateConfigForm.invalid) {
  600. return;
  601. }
  602. console.log(this.validateConfigForm.value);
  603. this.btnLoading = true;
  604. let postData:any = {};
  605. let categoryId = this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id;
  606. if (this.add) {
  607. //增加
  608. postData = {
  609. incidentCategoryConfig: {
  610. categoryId,
  611. priority: this.validateConfigForm.value.priority,
  612. score: { id: this.validateConfigForm.value.score },
  613. dutyId: this.validateConfigForm.value.dutyId,
  614. userGroup: this.validateConfigForm.value.userGroup,
  615. groupId: this.validateConfigForm.value.groupId || undefined,
  616. userId: this.validateConfigForm.value.userGroup === 1 ? this.validateConfigForm.value.userId : undefined,
  617. hosId: this.hospitalConfig === 1 ? this.currentHospital.id : this.validateConfigForm.value.hosId,
  618. }
  619. };
  620. } else {
  621. //编辑
  622. postData = {
  623. incidentCategoryConfig: {
  624. ...this.coopData,
  625. ...{
  626. categoryId,
  627. priority: this.validateConfigForm.value.priority,
  628. score: { id: this.validateConfigForm.value.score },
  629. userGroup: this.validateConfigForm.value.userGroup,
  630. groupId: this.validateConfigForm.value.groupId || undefined,
  631. userId: this.validateConfigForm.value.userGroup === 1 ? this.validateConfigForm.value.userId : undefined,
  632. }
  633. }
  634. };
  635. }
  636. console.log(postData);
  637. this.mainService
  638. .coopData("addData", "incidentCategoryConfig", postData)
  639. .subscribe((result) => {
  640. this.btnLoading = false;
  641. this.hideConfigModal();
  642. let msg = "";
  643. if (this.add) {
  644. msg = "新增";
  645. } else {
  646. msg = "修改";
  647. }
  648. if (result.status == 200) {
  649. this.showPromptModal(msg, true, '');
  650. } else {
  651. this.showPromptModal(msg, false, result.msg);
  652. }
  653. });
  654. }
  655. requiredConfigChange(name: string, required: boolean): void {
  656. if (!required) {
  657. this.validateConfigForm.get(name)!.clearValidators();
  658. this.validateConfigForm.get(name)!.markAsPristine();
  659. } else {
  660. this.validateConfigForm.get(name)!.setValidators(Validators.required);
  661. this.validateConfigForm.get(name)!.markAsDirty();
  662. }
  663. this.validateConfigForm.get(name)!.updateValueAndValidity();
  664. }
  665. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  666. promptContent: string; //操作提示框提示信息
  667. ifSuccess: boolean; //操作成功/失败
  668. promptInfo: string; //操作结果提示信息
  669. promptModalShow: boolean; //操作提示框是否展示
  670. showPromptModal(con, success, promptInfo?) {
  671. this.promptModalShow = false;
  672. this.promptContent = con;
  673. this.ifSuccess = success;
  674. this.promptInfo = promptInfo;
  675. setTimeout(() => {
  676. this.promptModalShow = true;
  677. }, 100);
  678. if(this.coopType !== 0){
  679. this.getCategoryList(this.coopType, this.coopType === 1 ? undefined : this['activeCategory' + (this.coopType - 1)].id);
  680. }else{
  681. this.getCategoryList(this.currentCategoryIndex, this.currentCategoryIndex === 1 ? undefined : this['activeCategory' + (this.currentCategoryIndex - 1)].id);
  682. }
  683. if(this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id){
  684. this.getCategoryConfigList(this.activeCategory3.id || this.activeCategory2.id || this.activeCategory1.id);
  685. }
  686. }
  687. }