party-user.component.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import {Component, OnInit, ViewChild} from '@angular/core';
  2. import {AlertController, IonInfiniteScroll, ModalController, NavController} from "@ionic/angular";
  3. import {ActivatedRoute, Router} from "@angular/router";
  4. import {ConfigService, RequsetData} from "../../../../service/config.service";
  5. import {UserService} from "../../../../service/user.service";
  6. import {SearchComponent} from "../../../../comm/modal/search/search.component";
  7. import {PartyUserApi} from "../../../../api/partyuser";
  8. @Component({
  9. selector: 'app-party-user',
  10. templateUrl: './party-user.component.html',
  11. styleUrls: ['./party-user.component.scss'],
  12. })
  13. export class PartyUserComponent implements OnInit {
  14. @ViewChild(IonInfiniteScroll, {static: true}) infiniteScroll: IonInfiniteScroll;
  15. webServerHost: string = '';
  16. dataList: any[] = [];
  17. searchParams: any = {
  18. pageIndex: 1,
  19. pageSize: 30,
  20. dzzdm: '',
  21. szdzbdm: '',
  22. userId: this.userService.GetUser().userid,
  23. xm: '',
  24. rybmList: '',
  25. ryztList: '',
  26. age_begin: '',
  27. age_end: '',
  28. partyGroupId: '',
  29. sqrdrq_begin: '',
  30. sqrdrq_end: ''
  31. };
  32. total: number = 30;
  33. fieldList: any[] = [
  34. {label: '姓名', name: 'xm', type: 'text', value: '', placeholder: '输入党员名称'},
  35. {
  36. label: '年龄',
  37. name: '',
  38. type: 'group-number',
  39. inputs: [{name: 'age_begin', type: 'number', value: '', placeholder: '输入最小年龄'}, {
  40. name: 'age_end',
  41. type: 'number',
  42. value: '',
  43. placeholder: '输入最大年龄'
  44. }]
  45. },
  46. {
  47. label: '政治面貌',
  48. name: 'ryztList',
  49. type: 'select',
  50. dicParams: {
  51. getUrl: 'getRyztList',
  52. dicTypeKey: '',
  53. textField: 'hzmc',
  54. valueField: 'bm',
  55. ismulti: true,
  56. filter: it => it.bm == "2" || it.bm == "3"
  57. },
  58. dicList: []
  59. },
  60. {
  61. label: '性别',
  62. name: 'xb',
  63. type: 'select',
  64. dicParams: {
  65. getUrl: '',
  66. dicTypeKey: '',
  67. textField: 'hzmc',
  68. valueField: 'bm',
  69. ismulti: false
  70. },
  71. dicList: [{hzmc: '男', bm: 1}, {hzmc: '女', bm: 2}]
  72. },
  73. {
  74. label: '学历',
  75. name: 'xl',
  76. type: 'select-down',
  77. value: '',
  78. dicParams: {
  79. getUrl: 'getEducationList',
  80. dicTypeKey: '',
  81. textField: 'HZMC',
  82. valueField: 'BM',
  83. ismulti: false
  84. },
  85. dicList: []
  86. },
  87. {
  88. label: '入党时间',
  89. name: '',
  90. type: 'group-datetime',
  91. inputs: [{name: 'sqrdrq_begin', type: 'datetime', value: '', placeholder: '开始时间'}, {
  92. name: 'sqrdrq_end',
  93. type: 'datetime',
  94. value: '',
  95. placeholder: '结束时间'
  96. }]
  97. }
  98. ];
  99. constructor(private router: Router, private routeInfo: ActivatedRoute, private configService: ConfigService, private userService: UserService, public alertController: AlertController, public modalController: ModalController, private navCtrl: NavController
  100. , private partyUserApi: PartyUserApi) {
  101. }
  102. ngOnInit() {
  103. this.configService.GetConfig().subscribe((config) => {
  104. this.webServerHost = config.webServerHost;
  105. });
  106. this.searchParams.dzzdm = this.searchParams.dzzdm || this.userService.GetUser().dataDzzdm;
  107. this.reload();
  108. //this.getRyztList();
  109. }
  110. getList() {
  111. this.partyUserApi.getList(this.searchParams).subscribe((data: RequsetData) => {
  112. if (data.success) {
  113. this.dataList = this.dataList.concat(data.item.list);
  114. this.total = data.item.total;
  115. }
  116. });
  117. }
  118. getRyztList() {
  119. /*this.configService.HttpGetRomote(this.getRyztUrl).subscribe((data: RequsetData) => {
  120. if (data.success) {
  121. this.fieldList[2].dicList = data.item.filter(it => it.bm == "2" || it.bm == "3");
  122. }
  123. });*/
  124. }
  125. reload() {
  126. this.dataList = [];
  127. this.searchParams.pageIndex = 1;
  128. this.total = 30;
  129. this.getList();
  130. }
  131. scroll(event) {
  132. setTimeout(() => {
  133. event.target.complete();
  134. if (this.total > this.searchParams.pageIndex * this.searchParams.pageSize) {
  135. this.searchParams.pageIndex += 1;
  136. this.getList();
  137. }
  138. }, 500);
  139. }
  140. async search() {
  141. const modal = await this.modalController.create({
  142. component: SearchComponent,
  143. componentProps: {
  144. 'fieldList': this.fieldList
  145. },
  146. cssClass: 'search-modal'
  147. });
  148. await modal.present();
  149. const {data} = await modal.onWillDismiss();
  150. if (data && data.success) {
  151. this.searchParams.xm = data.params.xm;
  152. this.searchParams.age_begin = data.params.age_begin;
  153. this.searchParams.age_end = data.params.age_end;
  154. this.searchParams.ryztList = data.params.ryztList;
  155. this.searchParams.xb = data.params.xb;
  156. this.searchParams.xl = data.params.xl;
  157. this.searchParams.sqrdrq_begin = data.params.sqrdrq_begin;
  158. this.searchParams.sqrdrq_end = data.params.sqrdrq_end;
  159. if (data.params.age_begin && data.params.age_end) {
  160. if (data.params.age_end < data.params.age_begin) {
  161. this.searchParams.age_begin = data.params.age_end;
  162. this.searchParams.age_end = data.params.age_begin;
  163. this.fieldList[1].inputs[0].value = data.params.age_end;
  164. this.fieldList[1].inputs[1].value = data.params.age_begin;
  165. }
  166. }
  167. this.reload();
  168. }
  169. }
  170. searchChange(event) {
  171. this.fieldList[0].value = event.detail.value;
  172. this.searchParams.xm = event.detail.value;
  173. this.reload();
  174. }
  175. dzzdmChange() {
  176. if (this.searchParams.dzzdm) {
  177. this.reload();
  178. }
  179. }
  180. partyGroupIdChange() {
  181. if (this.searchParams.partyGroupId) {
  182. this.reload();
  183. }
  184. }
  185. detail(user) {
  186. if (user.LEADTYPE == 0 || (user.LEADTYPE == 1 && user.isAdmin)) {
  187. this.router.navigate(['./detail'], {
  188. relativeTo: this.routeInfo,
  189. queryParams: {random: Math.random(), rybm: user.RYBM}
  190. });
  191. }
  192. }
  193. }