whyczyk
2021-06-03 b338da47d239be85c2a1415c96be4a8d958aea4b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<template>
  <div class="container">
    <flex-layout>
      <page-panel class="page-list-banner" :border="true" slot="header">
        <div slot="title" class="page-panel-title">
          <span class="title-pillar"></span>
          历史数据
        </div>
        <div class="table-layout">
          <div class="table-row">
            <div class="table-cell text-right">试验类型</div>
            <div class="table-cell">
              <el-select size="small" v-model="type">
                <el-option label="全部" :value="null"></el-option>
                <el-option v-for="(item, index) in types" :key="'job_' + index" :label="item.value" :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div class="table-cell text-right">时间范围</div>
            <div class="table-cell">
              <el-date-picker v-model="startTime1" size="small" class="time_box" type="date" placeholder="选择日期"
                value-format="yyyy-MM-dd"></el-date-picker>
              -
              <el-date-picker v-model="startTime2" size="small" class="time_box" type="date" placeholder="选择日期"
                value-format="yyyy-MM-dd"></el-date-picker>
            </div>
          </div>
        </div>
        <div class="banner-btn-grp">
          <div class="el-pagination-btns">
            <el-button type="primary" @click="getList" round size="mini" icon="el-icon-search">查询
            </el-button>
          </div>
          <div class="el-pagination-btns">
            <el-button type="warning" @click="resetParams" round size="mini" icon="el-icon-refresh-right">重置</el-button>
          </div>
        </div>
      </page-panel>
      <page-panel title="数据列表" class="flex-page-content">
        <!-- <template slot="btnGrp">
          <el-button type="primary" @click="resetParams" size="mini" icon="el-icon-download">导入</el-button>
          <el-button type="danger" size="mini" icon="el-icon-delete">清空</el-button>
        </template> -->
        <el-table stripe size="mini" header-row-class-name="header-primary" height="100%" :data="table.datas"
          v-loading="table.loading" element-loading-background="rgba(0, 0, 0, 0.8)">
          <el-table-column :prop="item.prop" :label="item.label" :width="item.width" :resizable="false" align="center"
            v-for="(item,index) in table.headers" :key="index">
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button type="success" size="mini" @click="seeDetails(scope.row)">查看历史数据</el-button>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="试验报告" width="180" align="center">
            <template slot-scope="scope">
              <el-button type="primary" size="mini" @click="view(scope.row)">查看</el-button>
              <el-button type="danger" size="mini" @click="download(scope.row)">下载</el-button>
            </template>
          </el-table-column>
        </el-table>
      </page-panel>
      <div class="flex-page-footer" slot="footer">
        <el-pagination size="mini" :current-page="page.pageCurr" :page-sizes="[10, 20, 30, 50, 100]"
          :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="page.pageAll"
          @current-change="currentChange" @size-change="sizeChange"></el-pagination>
      </div>
    </flex-layout>
    <!-- 启动 弹窗 -->
    <el-dialog title="预览" width="1000px" top="0" :visible.sync="showReport" :close-on-click-modal="false"
      class="dialog-center" :modal-append-to-body="false">
      <iframe src="./testConclusion.pdf" width="1000" height="560px" frameborder="0"></iframe>
    </el-dialog>
  </div>
</template>
 
<script>
  import pagePanel from '@/components/pagePanel';
  import {
    experimentPage
  } from './js/api';
 
  export default {
    data() {
      return {
        types: [{
          value: '绕组试验'
        }, {
          value: '空载试验'
        }, {
          value: '负载试验'
        }, {
          value: '升温试验'
        }, {
          value: '超速试验'
        }, {
          value: '空载反电动势试验'
        }, {
          value: '振动测试试验'
        }, {
          value: '耐压测试试验'
        }, {
          value: '转动惯量测定试验'
        }],
        type: null,
        startTime1: null,
        startTime2: null,
        table: {
          headers: [{
            prop: "startTime",
            label: "历史数据时间",
          }, {
            prop: "name",
            label: "实验名称",
          }, {
            prop: "type",
            label: "试验类型",
          }, {
            prop: "duration",
            label: "试验时长",
          }, {
            prop: "username",
            label: "试验负责人",
          }],
          datas: [],
          loading: false
        },
        page: {
          pageCurr: 1,
          pageSize: 10,
          pageAll: 0
        },
        showReport: false
      };
    },
    components: {
      pagePanel
    },
    methods: {
      view() {
        // console.log('view', obj);
        this.showReport = true;
      },
      download() {
        // console.log('download');
        const link = document.createElement("a");
        link.href = encodeURI('./testConclusion.pdf');
        link.download = 'testConclusion.pdf';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      },
      // 查询用户列表
      getList() {
        let params = {
          pageNum: this.page.pageCurr,
          pageSize: this.page.pageSize
        };
        let data = {
          type: this.type,
          startTime1: this.startTime1,
          startTime2: this.startTime2,
        };
        experimentPage(params, data).then((res) => {
          if (res.data.code == 1) {
            res = res.data.data;
            this.page.pageAll = res.total;
            this.table.datas = res.list;
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      // 重置搜索条件
      resetParams() {
 
      },
      seeDetails() {
        this.$router.push({
          path: '/index/historyDataDetails',
        }).catch(err => {
          console.log(err)
        });
      },
      currentChange(value) {
        this.page.pageCurr = value;
        this.getList();
      },
      sizeChange(value) {
        this.page.pageCurr = 1;
        this.page.pageSize = value;
        this.getList();
      }
    },
    mounted() {
      this.getList();
    },
    beforeDestroy() {
 
    }
  };
</script>
 
<style scoped>
  .container {
    height: 100%;
  }
 
  .page-list-banner {
    margin-bottom: 10px;
  }
</style>