|
@@ -0,0 +1,147 @@
|
|
|
+import {Component, OnInit, ViewChild} from '@angular/core';
|
|
|
+import {AlertController, IonInfiniteScroll, LoadingController, ModalController, NavController} from "@ionic/angular";
|
|
|
+import {ActivatedRoute, Router} from "@angular/router";
|
|
|
+import {ConfigService, RequsetData} from "../../../../service/config.service";
|
|
|
+import {UserService} from "../../../../service/user.service";
|
|
|
+import {SearchComponent} from "../../../../comm/modal/search/search.component";
|
|
|
+import {DzzfcApi, reqParams} from "../../../../api/propagandawork/dzzfc";
|
|
|
+import {AlertModal} from "../../../../comm/modal/alert";
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-dzzfc-list',
|
|
|
+ templateUrl: './list.component.html',
|
|
|
+ styleUrls: ['./list.component.scss'],
|
|
|
+})
|
|
|
+export class DzzfcListComponent implements OnInit {
|
|
|
+
|
|
|
+ @ViewChild(IonInfiniteScroll, {static: true}) infiniteScroll: IonInfiniteScroll;
|
|
|
+
|
|
|
+ webServerHost: string = '';
|
|
|
+ userInfo: any = {};
|
|
|
+ dataList: any[] = [];
|
|
|
+ searchParams: reqParams = {
|
|
|
+ pageindex: 1,
|
|
|
+ pagesize: 15,
|
|
|
+ dzzdm: '',
|
|
|
+ ztmc: '',
|
|
|
+ fcType: null
|
|
|
+ };
|
|
|
+ total: number = 15;
|
|
|
+ fieldList: any[] = [{label: '主题名称', name: 'ztmc', type: 'text', value: '', placeholder: '输入主题名称'},
|
|
|
+ {
|
|
|
+ label: '类别',
|
|
|
+ name: 'fcType',
|
|
|
+ type: 'select',
|
|
|
+ value: '',
|
|
|
+ dicParams: {
|
|
|
+ getUrl: 'getDictionaryList',
|
|
|
+ dicTypeKey: 'fcType',
|
|
|
+ textField: 'dicvalue',
|
|
|
+ valueField: 'dickey',
|
|
|
+ ismulti: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ constructor(private router: Router, private routeInfo: ActivatedRoute, private configService: ConfigService, private userService: UserService, public modalController: ModalController, private navCtrl: NavController
|
|
|
+ , private dzzfcApi: DzzfcApi, private alertModal: AlertModal) {
|
|
|
+ }
|
|
|
+
|
|
|
+ ngOnInit() {
|
|
|
+ this.userInfo = this.userService.GetUser();
|
|
|
+ this.routeInfo.queryParams.subscribe(params => {
|
|
|
+ debugger;
|
|
|
+ this.searchParams.dzzdm = this.searchParams.dzzdm || this.userService.GetUser().dataDzzdm;
|
|
|
+ this.reload();
|
|
|
+ });
|
|
|
+ this.configService.GetConfig().subscribe((config) => {
|
|
|
+ this.webServerHost = config.webServerHost;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ getList() {
|
|
|
+ this.dzzfcApi.getList(this.searchParams).subscribe((data: RequsetData) => {
|
|
|
+ if (data.success) {
|
|
|
+ this.dataList = this.dataList.concat(data.item.list);
|
|
|
+ this.total = data.item.total;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ reload() {
|
|
|
+ this.dataList = [];
|
|
|
+ this.searchParams.pageindex = 1;
|
|
|
+ this.total = 15;
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+
|
|
|
+ scroll(event) {
|
|
|
+ setTimeout(() => {
|
|
|
+ event.target.complete();
|
|
|
+ if (this.total > this.searchParams.pageindex * this.searchParams.pagesize) {
|
|
|
+ this.searchParams.pageindex += 1;
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+
|
|
|
+ yearChange(e) {
|
|
|
+ this.reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ searchChange(event) {
|
|
|
+ this.fieldList[0].value = event.detail.value;
|
|
|
+ this.searchParams.ztmc = event.detail.value;
|
|
|
+ this.reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ async search() {
|
|
|
+ const modal = await this.modalController.create({
|
|
|
+ component: SearchComponent,
|
|
|
+ componentProps: {
|
|
|
+ 'fieldList': this.fieldList
|
|
|
+ },
|
|
|
+ cssClass: 'search-modal'
|
|
|
+ });
|
|
|
+
|
|
|
+ await modal.present();
|
|
|
+
|
|
|
+ const {data} = await modal.onWillDismiss();
|
|
|
+ if (data && data.success) {
|
|
|
+ this.searchParams.ztmc = data.params.ztmc;
|
|
|
+ this.searchParams.fcType = data.params.fcType;
|
|
|
+ this.reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ detail(item) {
|
|
|
+ this.router.navigate(['./detail'], {
|
|
|
+ relativeTo: this.routeInfo,
|
|
|
+ queryParams: {random: Math.random(),id: item.id}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ add() {
|
|
|
+ this.router.navigate(['./edit'], {
|
|
|
+ relativeTo: this.routeInfo,
|
|
|
+ queryParams: {random: Math.random(), op: 0}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ delete(id) {
|
|
|
+ this.alertModal.confirm("确认删除?", () => {
|
|
|
+ this.alertModal.loading("正在删除").then((loading) => {
|
|
|
+ this.dzzfcApi.delete(id).subscribe((fdata: RequsetData) => {
|
|
|
+ loading.dismiss();
|
|
|
+ if (fdata.success) {
|
|
|
+ this.reload();
|
|
|
+ }
|
|
|
+ this.alertModal.alert(fdata.msg);
|
|
|
+ }, () => {
|
|
|
+ loading.dismiss();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+}
|