|
@@ -62,29 +62,34 @@
|
|
|
</td>
|
|
|
<td class="excelPickerTd">
|
|
|
<el-date-picker
|
|
|
- v-model="value1[index]"
|
|
|
- type="monthrange"
|
|
|
- @change="value1Change(index)"
|
|
|
- range-separator="至"
|
|
|
- start-placeholder="开始日期"
|
|
|
- end-placeholder="结束日期"
|
|
|
class="mr15"
|
|
|
+ format="YYYY-MM"
|
|
|
+ v-model="dateArray[index]"
|
|
|
+ type="month"
|
|
|
+ placeholder="请选择"
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</td>
|
|
|
<td>
|
|
|
- <el-input
|
|
|
- placeholder="请输入时间间隔"
|
|
|
- type="number"
|
|
|
- v-model="inputVal[index]"
|
|
|
- @change="inputValChange(index)"
|
|
|
- ></el-input>
|
|
|
+ <el-select
|
|
|
+ v-model="timeData[index]"
|
|
|
+ clearable
|
|
|
+ placeholder="Select"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in timeArray"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</td>
|
|
|
<td width="120px">
|
|
|
<el-button
|
|
|
type="text"
|
|
|
style="cursor: pointer"
|
|
|
- @click="thisExport(index)"
|
|
|
+ @click="singleExport(index)"
|
|
|
>导出
|
|
|
</el-button>
|
|
|
</td>
|
|
@@ -110,8 +115,23 @@ export default {
|
|
|
rqChecked: true, //日期单击checkbox状态【为true时,下方任意日期选择与当前选择同步】
|
|
|
sjChecked: true, //时间间隔checkbox状态【为true时,下方任意时间选择与当前选择同步】
|
|
|
tableData: [], //表格数据
|
|
|
- value1: [], //日期数组,默认一个月的,当用户改变某一个时,找到对应下标去改数据
|
|
|
- inputVal: [], //时间同上
|
|
|
+ dateArray: [], //日期数组,默认一个月的,当用户改变某一个时,找到对应下标去改数据
|
|
|
+ //时间同上
|
|
|
+ timeArray: [
|
|
|
+ {
|
|
|
+ label: "5分钟",
|
|
|
+ value: "300",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "10分钟",
|
|
|
+ value: "600",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "15分钟",
|
|
|
+ value: "900",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ timeData: [],
|
|
|
startTs: [], //起始时间,通过下标去找对应的时间
|
|
|
endTs: [], //结束时间
|
|
|
muBan: {
|
|
@@ -147,26 +167,6 @@ export default {
|
|
|
this.tableVal();
|
|
|
},
|
|
|
methods: {
|
|
|
- value1Change(index) {
|
|
|
- //日期数组,默认一个月的,当用户改变某一个时,找到对应下标去改数据
|
|
|
- if (this.rqChecked) {
|
|
|
- var date = this.value1[index];
|
|
|
- this.value1 = [];
|
|
|
- this.tableData.forEach((ele, index) => {
|
|
|
- this.value1.push(date);
|
|
|
- this.time(index, date);
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- inputValChange(index) {
|
|
|
- if (this.sjChecked) {
|
|
|
- var sj = this.inputVal[index];
|
|
|
- this.inputVal = [];
|
|
|
- this.tableData.forEach((ele, index) => {
|
|
|
- this.inputVal.push(sj);
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
rqCheck() {
|
|
|
this.rqChecked = event.target.checked;
|
|
|
},
|
|
@@ -177,14 +177,35 @@ export default {
|
|
|
//模板切换,改变按钮颜色
|
|
|
this.templateId = a;
|
|
|
},
|
|
|
- thisExport(index) {
|
|
|
+ singleExport(index) {
|
|
|
//当前导出,index为下标
|
|
|
let that = this;
|
|
|
- that.single = true;
|
|
|
- // 下面的是通过下标找到对应的数据,请求ajax
|
|
|
- that.time(index, that.value1[index]);
|
|
|
- that.stations[index] = that.tableData[index].value;
|
|
|
- that.allExportF(0, index);
|
|
|
+ that.API.requestData({
|
|
|
+ method: "GET",
|
|
|
+ subUrl: "export/downloadFile",
|
|
|
+ data: {
|
|
|
+ station: that.tableData[index].value,
|
|
|
+ templateId: "2" || that.templateId,
|
|
|
+ month: that.dateArray[index].formatDate("yyyy-MM"),
|
|
|
+ interval: that.timeData[index],
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ var filename = res.data.name;
|
|
|
+ var eleLink = document.createElement("a");
|
|
|
+
|
|
|
+ const downloadLink = (res.data.path + "\\" + filename)
|
|
|
+ .replace(/\\/g, "/")
|
|
|
+ .replace(/http:\//g, "http://")
|
|
|
+ .replace(/https:\//g, "http://");
|
|
|
+
|
|
|
+ eleLink.download = downloadLink;
|
|
|
+ eleLink.style.display = "none";
|
|
|
+ eleLink.href = downloadLink;
|
|
|
+ document.body.appendChild(eleLink);
|
|
|
+ eleLink.click();
|
|
|
+ document.body.removeChild(eleLink);
|
|
|
+ },
|
|
|
+ });
|
|
|
},
|
|
|
tableVal() {
|
|
|
let that = this;
|
|
@@ -192,42 +213,31 @@ export default {
|
|
|
method: "GET",
|
|
|
subUrl: "export/databases",
|
|
|
success(res) {
|
|
|
- if (res.code === 200) {
|
|
|
- const arr3 = [];
|
|
|
- const arr4 = [];
|
|
|
- var data = []; //项目列表
|
|
|
- res.data.forEach((item, index) => {
|
|
|
- const value = Object.keys(item)[0];
|
|
|
- arr3.push(value);
|
|
|
- arr4.push(item[value]);
|
|
|
- data.push({
|
|
|
- fdc: item[value],
|
|
|
- value: value,
|
|
|
- });
|
|
|
- that.inputVal.push(1800);
|
|
|
+ const arr3 = [];
|
|
|
+ const arr4 = [];
|
|
|
+ var data = []; //项目列表
|
|
|
+ res.data.forEach((item, index) => {
|
|
|
+ const value = Object.keys(item)[0];
|
|
|
+ arr3.push(value);
|
|
|
+ arr4.push(item[value]);
|
|
|
+ data.push({
|
|
|
+ fdc: item[value],
|
|
|
+ value: value,
|
|
|
});
|
|
|
- that.stations = arr3;
|
|
|
- that.zipNames = arr4;
|
|
|
- that.tableData = data;
|
|
|
- that.defaultValue1();
|
|
|
- }
|
|
|
+ that.timeData.push("300");
|
|
|
+ });
|
|
|
+ that.stations = arr3;
|
|
|
+ that.zipNames = arr4;
|
|
|
+ that.tableData = data;
|
|
|
+ that.defaultValue1();
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
defaultValue1() {
|
|
|
- //默认时间区间
|
|
|
- const end = new Date();
|
|
|
const start = new Date();
|
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
|
|
|
- /////////////
|
|
|
- var nowDate = new Date();
|
|
|
- var year = nowDate.getFullYear();
|
|
|
- var month = nowDate.getMonth();
|
|
|
- var day = nowDate.getDate();
|
|
|
-
|
|
|
+ start.setTime(start.getTime());
|
|
|
this.tableData.forEach((ele, index) => {
|
|
|
- this.value1.push([start, end]);
|
|
|
- this.time(index, [start, end]);
|
|
|
+ this.dateArray.push(start);
|
|
|
});
|
|
|
},
|
|
|
formatJson(filterVal, jsonData) {
|
|
@@ -236,7 +246,48 @@ export default {
|
|
|
},
|
|
|
allExport() {
|
|
|
//一键导出
|
|
|
- this.allExportF(0);
|
|
|
+ let that = this;
|
|
|
+
|
|
|
+ let station = [];
|
|
|
+ that.tableData.forEach((ele) => {
|
|
|
+ station.push(ele.value);
|
|
|
+ });
|
|
|
+
|
|
|
+ let month = [];
|
|
|
+ that.dateArray.forEach((ele) => {
|
|
|
+ month.push(ele.formatDate("yyyy-MM"));
|
|
|
+ });
|
|
|
+
|
|
|
+ let interval = [];
|
|
|
+ that.timeData.forEach((ele) => {
|
|
|
+ interval.push(ele);
|
|
|
+ });
|
|
|
+ that.API.requestData({
|
|
|
+ method: "GET",
|
|
|
+ subUrl: "export/downloadFile",
|
|
|
+ data: {
|
|
|
+ station: station.toString(),
|
|
|
+ templateId: "2" || that.templateId,
|
|
|
+ month: month.toString(),
|
|
|
+ interval: interval.toString(),
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ var filename = res.data.name;
|
|
|
+ var eleLink = document.createElement("a");
|
|
|
+
|
|
|
+ const downloadLink = (res.data.path + "\\" + filename)
|
|
|
+ .replace(/\\/g, "/")
|
|
|
+ .replace(/http:\//g, "http://")
|
|
|
+ .replace(/https:\//g, "http://");
|
|
|
+
|
|
|
+ eleLink.download = downloadLink;
|
|
|
+ eleLink.style.display = "none";
|
|
|
+ eleLink.href = downloadLink;
|
|
|
+ document.body.appendChild(eleLink);
|
|
|
+ eleLink.click();
|
|
|
+ document.body.removeChild(eleLink);
|
|
|
+ },
|
|
|
+ });
|
|
|
},
|
|
|
allExportF(_index, thisIndex) {
|
|
|
//_index递归递增,thisIndex单击导出【下标】
|
|
@@ -473,11 +524,6 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- time(index, val) {
|
|
|
- //时间转时间戳
|
|
|
- this.startTs[index] = Date.parse(new Date(val[0]));
|
|
|
- this.endTs[index] = Date.parse(new Date(val[1]) + 86400000);
|
|
|
- },
|
|
|
},
|
|
|
};
|
|
|
</script>
|