1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import { Component, OnInit } from "@angular/core";
- import { ActivatedRoute, Router } from "@angular/router";
- import { MainService } from "../../services/main.service";
- import { ToolService } from "../../services/tool.service";
- import { NzMessageService } from 'ng-zorro-antd';
- import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
- @Component({
- selector: "app-questionnaire-answer",
- templateUrl: "./questionnaire-answer.component.html",
- styleUrls: ["./questionnaire-answer.component.less"],
- })
- export class QuestionnaireAnswerComponent implements OnInit {
- constructor(
- private mainService: MainService,
- private route: ActivatedRoute,
- private router: Router,
- private tool: ToolService,
- private message: NzMessageService
- ) {}
- userInfo: any = JSON.parse(localStorage.getItem("user")) || {}; //登录用户信息
- listOfData: any[] = []; //表格数据
- listOfDataTh: any[] = []; //表格数据
- pageIndex: number = 1; //表格当前页码
- pageSize: number = 10; //表格每页展示条数
- listLength: number = 10; //表格总数据量
- currentHospital; //当前院区
- ngOnInit() {
- this.currentHospital = this.tool.getCurrentHospital();
- this.getList(1);
- }
- // 初始化增删改按钮
- coopBtns: any = {};
- // 导出
- loading2 = false;
- export() {
- let postData = {
- idx: 0,
- sum: 99999,
- qmId: this.route.snapshot.queryParams.id,
- };
- this.loading2 = true;
- this.mainService.exportReport("survey", postData).subscribe(
- (data) => {
- this.loading2 = false;
- this.message.create('success', `导出成功`);
- var file = new Blob([data], {
- type: "application/vnd.ms-excel",
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement("a");
- a.href = fileURL;
- a.target = "_blank";
- a.download = `回收数据.xls`;
- document.body.appendChild(a);
- a.click();
- },
- (err) => {
- this.loading2 = false;
- this.message.create('error', `导出失败`);
- }
- );
- }
- // 表格数据
- loading1 = false;
- getList(type) {
- if (type == 1) {
- this.pageIndex = 1;
- }
- let postData = {
- idx: this.pageIndex - 1,
- sum: this.pageSize,
- qmId: this.route.snapshot.queryParams.id
- };
- this.loading1 = true;
- this.mainService
- .listQuestionnaire(postData)
- .subscribe((data:any) => {
- this.loading1 = false;
- if (data.status == 200) {
- this.listOfData = data.data?data.data.answers:[];
- // if(data.data && data.data.answers){
- // data.data.answers
- // }
- this.listOfDataTh = data.data?data.data.infos:[];
- this.listLength = data.totalNum;
- }
- });
- }
- }
|