heyujie
2021-02-25 58417c8de3cce002d75402ac805363de1d9b17a9
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
<template>
  <div class="transfer-memo">
    <div class="filter-bar flex-box">
      <div>
        <label>操作时间:</label>
        <el-date-picker
          v-model="searchTime"
          type="datetimerange"
          size="small"
          :picker-options="pickerOptions"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          align="right"
        ></el-date-picker>
      </div>
      <div>
        <label>操作人:</label>
        <div>
          <el-input v-model="Operator" size="small"></el-input>
        </div>
      </div>
      <div>
        <label>转储状态:</label>
        <div>
          <el-select v-model="Status" size="small">
            <el-option value="" label="全部"></el-option>
            <el-option
              v-for="item in allTransferStatus"
              :key="item.id"
              :value="item.name"
              :label="item.name"
            ></el-option>
          </el-select>
        </div>
      </div>
      <div class="btns">
        <el-button type="primary" size="small" @click="renderTable">查询</el-button>
        <el-button type="primary" size="small" @click="resetFilter">重置</el-button>
      </div>
    </div>
    <div class="table-area">
      <el-table :data="tableData" fit>
        <el-table-column prop="OperaterDate" label="操作时间"></el-table-column>
        <el-table-column prop="Operator" label="操作人"></el-table-column>
        <el-table-column prop="tranferDevice" label="转储设备名称">
          <template slot-scope="scope">
            <div>
              设备{{scope.row.DeviceID}}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="SlotID" label="卡槽位置">
          <template slot-scope="scope">
            <div>
              插槽{{scope.row.SlotID}}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="Status" label="转储状态"></el-table-column>
        <el-table-column prop="Cover" label="现场图片"></el-table-column>
        <el-table-column prop="Content" label="转储内容"></el-table-column>
      </el-table>
      <el-pagination
        class="pagination-under-table"
        @size-change="handleTableSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="PageIndex"
        :page-size="PageSize"
        :page-sizes="pageSizes"
        layout="total,sizes, prev, pager, next"
        :total="tableTotal"
      ></el-pagination>
    </div>
  </div>
</template>
 
<script>
import { getTransferStatusList,getTransferRecord } from "@/api/shuohuang"
export default {
  data () {
    return {
      pickerOptions: {
        shortcuts: [{
          text: '今天',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setHours(0, 0, 0);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '昨天',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24);
            start.setHours(0, 0, 0);
            end.setTime(end.getTime() - 3600 * 1000 * 24);
            end.setHours(23, 59, 59);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '近三天',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 3);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '近一周',
          onClick (picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            //start.setHours(0,0,0);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      Status: '',
      Operator: '',
      allTransferStatus: [],
      tableData: [],
      tableTotal: 0,
      PageIndex: 1,
      pageSizes: [8, 15, 20],
      PageSize: 8,
      searchTime: [this.$moment(new Date().getTime() - 3600 * 1000 * 24 * 5).format("YYYY-MM-DD HH:mm:ss"), this.$moment(new Date()).format("YYYY-MM-DD HH:mm:ss")],
    }
  },
  mounted () {
    this.renderTable();
    this.renderTransferStatusList();
  },
  methods: {
    handleCurrentChange(){
      this.renderTable();
    },
    resetFilter(){
      this.searchTime = [];
      this.Operator = '';
      this.Status = '';
      this.renderTable();
    },
    handleTableSizeChange (size) {
      this.tablePageSize = size;
      this.renderTable();
    },
    renderTransferStatusList(){
      let _this = this;
      getTransferStatusList().then(res=>{
        _this.allTransferStatus = res.data.map((item,index)=>{
          return {
            id: 'sta'+index,
            name: item
          }
        });
      })
    },
    renderTable () {
      let _this = this;
      let params = {
        Operator: this.Operator,
        Status: this.Status,
        PageIndex: this.PageIndex,
        PageSize: this.PageSize,
        StartDate: this.searchTime ? this.searchTime[0]:'',
        EndDate: this.searchTime ? this.searchTime[1]:'',
      };
      
      getTransferRecord(params).then(res=>{
        _this.tableData = res.data;
        _this.tableTotal = res.total;
      })
    }
  }
}
</script>
 
<style lang="scss">
.transfer-memo {
  padding: 20px;
  .filter-bar.flex-box {
    & > div {
      display: flex;
      align-items: center;
      margin-right: 10px;
      label {
        padding-right: 10px;
      }
    }
  }
  .el-table {
    border: 1px solid #dedede;
    margin-top: 10px;
    th {
      background: #f5f5f5;
      color: #333;
    }
    .operation {
      cursor: pointer;
    }
  }
  .pagination-under-table{
    margin-top: 20px;
  }
}
</style>