index.vue
9.46 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<template>
<div class="app-container">
<el-row>
<el-col :span="14" class="spacing-top-5">
<!-- 查询 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="50px">
<el-form-item label="日期" prop="dateValue">
<el-date-picker v-model="dateValue" type="daterange" align="right" unlink-panels
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
value-format="yyyy-MM-dd" @change="getBatchs">
</el-date-picker>
</el-form-item>
<el-form-item label="批次" prop="flowNum">
<el-select v-model="flowNum" filterable placeholder="请选择" style="width: 200px;">
<el-option v-for="item in batchsList" :key="item.flow_num" :label="item.flow_name"
:value="item.flow_num + ',' + item.flow_name">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="10" v-if="isCheck">
<el-descriptions :column="3" border style="width: 100%;">
<el-descriptions-item label="重保次数" label-class-name="my-checkname"
content-class-name="my-checkvalue">
{{ checkData.count }}
</el-descriptions-item>
<el-descriptions-item label="参与人数" label-class-name="my-checkname"
content-class-name="my-checkvalue">
{{ checkData.personCnt }}
</el-descriptions-item>
<el-descriptions-item label="参与公司数" label-class-name="my-checkname"
content-class-name="my-checkvalue">
{{ checkData.companyCnt }}
</el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
<!-- 下载 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-col>
</el-row>
<!-- element table组件 -->
<div v-if="tableShow">
<el-table :data="dataList" style="width: 100%" :span-method="objectSpanMethod" :height=tableHeight>
<template v-for="(item, index) in headers">
<el-table-column prop="" :label="item" align="center" min-width="110" v-if="index < 3" fixed>
<template slot-scope="scope">
<div>
{{ scope.row[index] }}
</div>
</template>
</el-table-column>
<el-table-column prop="" :label="item" v-else align="center">
<el-table-column prop="" label="姓名" align="center">
<template slot-scope="scope">
{{ scope.row[index + index - 3] }}
</template>
</el-table-column>
<el-table-column prop="" label="手机号" align="center" min-width="110">
<template slot-scope="scope">
{{ scope.row[index + index - 2] }}
</template>
</el-table-column>
</el-table-column>
</template>
</el-table>
</div>
</div>
</template>
<script>
import { getDutyList, getBatchList, dutyInfoStatistics } from "@/api/view/vduty";
export default {
name:"Vduty",
data() {
return {
queryParams: {},
dateValue: [],
// element table数据结构
dataList: [],
headers: [],
spanArr: [],
batchsList: [],//批次列表
flowNum: '',//批次
tableShow: false,
checkData: {},
isCheck: false,
};
},
created() {
let startDate = this.getDaysAgo();
let endDate = this.getToday();
this.dateValue.push(startDate, endDate);
// 批次
this.getBatchs();
},
mounted() {
// 设置表格高度
this.tableHeight = window.innerHeight - 180
// 监听浏览器窗口变化,动态计算表格高度,
window.onresize = () => {
return (() => {
this.tableHeight = window.innerHeight - 180
})()
}
},
methods: {
getToday() {
//获取当前日期
let myDate = new Date();
let nowY = myDate.getFullYear();
let nowM = myDate.getMonth() + 1;
let nowD = myDate.getDate();
let endDate =
nowY +
"-" +
(nowM < 10 ? "0" + nowM : nowM) +
"-" +
(nowD < 10 ? "0" + nowD : nowD); //当前日期
return endDate;
},
getDaysAgo() {
let myDate = new Date();
let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 90); //最后一个数字可改,天数
let lastY = lw.getFullYear();
let lastM = lw.getMonth() + 1;
let lastD = lw.getDate();
let startData =
lastY +
"-" +
(lastM < 10 ? "0" + lastM : lastM) +
"-" +
(lastD < 10 ? "0" + lastD : lastD);
return startData;
},
// 批次
getBatchs() {
let params = {};
params.beginTime = this.dateValue.length == 0 ? '' : this.dateValue[0];
params.endTime = this.dateValue.length == 0 ? '' : this.dateValue[1];
getBatchList(params).then((res) => {
this.batchsList = res.filter(item => item);
this.flowNum = res[0].flow_num + ',' + res[0].flow_name;
this.getDuty();
this.getDutyInfo();
})
},
// 列表
getDuty() {
this.dataList = [];
this.headers = [];
this.flowName = this.flowNum.split(',')[1]
getDutyList({ flowNum: this.flowNum.split(',')[0] }).then((res) => {
this.dataList = res.data;
this.headers = res.headers;
this.tableShow = true;
})
},
getDutyInfo() {
this.isCheck = false;
let parameter = {}
parameter.beginTime = this.dateValue.length == 0 ? '' : this.dateValue[0];
parameter.endTime = this.dateValue.length == 0 ? '' : this.dateValue[1];
parameter.flowNum = this.flowNum.split(',')[0];
dutyInfoStatistics(parameter).then((res) => {
this.checkData = res.data;
this.isCheck = true;
})
},
// 搜索
handleQuery() {
this.tableShow = false;
this.getDuty();
this.getDutyInfo();
},
// 重置
resetQuery() {
this.resetForm("queryForm");
this.flowNum = '';
this.dateValue = [];
let startDate = this.getDaysAgo();
let endDate = this.getToday();
this.dateValue.push(startDate, endDate);
this.getBatchs();
},
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0 || columnIndex === 1) {
if (rowIndex % 2 === 0) {
return {
rowspan: 2,
colspan: 1
};
} else {
return {
rowspan: 0,
colspan: 0
};
}
}
},
/** 导出按钮操作 */
handleExport() {
this.download('resource/duty/export?flowNum=' + this.flowNum.split(',')[0] + '&flowName=' + this.flowName, {}, `${this.flowName}-值班信息-${new Date().getTime()}.xlsx`)
},
},
}
</script>
<style scoped>
.resume_table {
width: 100%;
table-layout: fixed;
border: none;
}
.resume_table thead td {
background: #f7f9fc;
font-weight: bold;
padding: 9px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
border: none;
}
.resume_table tbody td {
padding: 18px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
border: none;
}
.resume_table tbody tr:nth-child(2n) {
background: #f7f9fc;
}
.tc td {
text-align: center;
}
</style>
<style>
.my-checkvalue {
width: 95px;
font-size: 18px;
font-weight: bold;
text-align: center !important;
height: 20px !important;
line-height: 20px !important;
}
.my-checkname {
background: #f4f9fb !important;
text-align: center !important;
height: 20px !important;
line-height: 20px !important;
}
</style>