milestone-category.component.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { Component, OnInit, ViewChild, HostListener } from '@angular/core';
  2. import { _HttpClient, ModalHelper } from '@delon/theme';
  3. import { STColumn, STComponent } from '@delon/abc';
  4. import { SFSchema } from '@delon/form';
  5. import { NzNotificationService } from 'ng-zorro-antd';
  6. import { DictService } from 'app/services/dict.service';
  7. import { I18NService } from '@core';
  8. import { DictItem } from 'app/entity/dict-item';
  9. import { messageShared } from '@shared/utils/message';
  10. import { BasedataMilestoneCategoryEditComponent } from './edit/edit.component';
  11. import { PlatformLocation } from '@angular/common';
  12. @Component({
  13. selector: 'app-basedata-milestone-category',
  14. templateUrl: './milestone-category.component.html',
  15. })
  16. export class BasedataMilestoneCategoryComponent implements OnInit {
  17. constructor(
  18. private notification: NzNotificationService,
  19. private dictService: DictService,
  20. private i18NService: I18NService,
  21. private location: PlatformLocation,
  22. ) {}
  23. ngOnInit() {
  24. for (const i in this.location) {
  25. if (i === 'location') {
  26. this.locationUrl = this.location[i].href;
  27. break;
  28. }
  29. }
  30. this.getDictItems();
  31. }
  32. locationUrl = ''; //页面地址
  33. visible = false;
  34. drawerWidth = 900;
  35. title = '';
  36. listOfData = [];
  37. isSpinning = false;
  38. item = {
  39. id: '',
  40. itemText: '',
  41. itemValue: '',
  42. dictName: '',
  43. dictCode: '',
  44. };
  45. @ViewChild('categoryEdit') categoryEdit: BasedataMilestoneCategoryEditComponent;
  46. @HostListener('window:resize', ['$event'])
  47. onResize(event) {
  48. const width = event.target.innerWidth;
  49. if (width > 900) {
  50. this.drawerWidth = 900;
  51. } else {
  52. this.drawerWidth = width;
  53. }
  54. }
  55. dictItem: DictItem = {}; //处理查询条件
  56. page: any = {}; //分页参数对象
  57. getDictItems() {
  58. //根据不同菜单查询对应数据字典数据
  59. let dictId="";
  60. if (this.locationUrl.indexOf('milestone-category')!=-1) {
  61. //里程碑类型档案
  62. dictId = '0cbf1113fd44010fb464aa4d2daacf6a';
  63. }else if(this.locationUrl.indexOf('customer-classification')!=-1){
  64. //客商分类
  65. dictId='fb796929d89383ed42d22af60ff9a186'
  66. }else if(this.locationUrl.indexOf('information-sources')!=-1){
  67. //信息来源
  68. dictId='457c4161e45bb4b9243d2de77ce65543'
  69. }else if(this.locationUrl.indexOf('business-relations')!=-1){
  70. //商务关系
  71. dictId='a9fe3a6c0a685e2462094d88f98cda89'
  72. }else if(this.locationUrl.indexOf('customer-grouping')!=-1){
  73. //客商分组
  74. dictId='fb95c1dcba1cfb9f268abc8bff2612ba'
  75. }else if(this.locationUrl.indexOf('sleep-type')!=-1){
  76. //休眠类型
  77. dictId='15668e04b9b2c4e1d5f45df0e72ad3db'
  78. }else if(this.locationUrl.indexOf('unit-size')!=-1){
  79. //单位规模
  80. dictId='e1becd87bc51a88e2578ea8121d901fe'
  81. }else if(this.locationUrl.indexOf('customer-relationship')!=-1){
  82. //客户关系
  83. dictId='c0d7392b35800c89b340a74e1538e9e2'
  84. }else if(this.locationUrl.indexOf('value-level')!=-1){
  85. //价值级别
  86. dictId='2b6a80bf2f4d77c686fdd2d5d5fcef59'
  87. }
  88. if(dictId==''){
  89. this.notification.warning("未找到档案","");
  90. return;
  91. }
  92. // this.dictItem.dictId=this.item.id;
  93. this.item.id=dictId
  94. this.dictItem.dictId=dictId;
  95. this.isSpinning = true;
  96. this.dictService.getDictItems(this.dictItem).then(response => {
  97. this.listOfData = response.result.records;
  98. this.page = response.result;
  99. this.isSpinning = false;
  100. });
  101. }
  102. //页码点击事件
  103. pageIndexChange(event) {
  104. this.dictItem.pageNo = event; // 当前页码
  105. this.getDictItems();
  106. }
  107. config(item) {
  108. this.visible = true;
  109. this.title = this.i18NService.fanyi('configuration.dictionary');
  110. this.item = item;
  111. this.getDictItems();
  112. }
  113. close() {
  114. this.visible = false;
  115. }
  116. add() {
  117. this.categoryEdit.add(this.item.id);
  118. }
  119. edit(item) {
  120. this.categoryEdit.edit(item);
  121. }
  122. delete(id: string) {
  123. this.dictService.deleteDictItem(id).then(response => {
  124. if (response.success) {
  125. this.notification.success(this.i18NService.fanyi('successful.deletion'), '');
  126. this.getDictItems();
  127. } else {
  128. this.notification.error(
  129. this.i18NService.fanyi('delete.failed'),
  130. messageShared(this.i18NService, response.message),
  131. );
  132. }
  133. });
  134. }
  135. }