Merge remote-tracking branch 'origin/huku'

This commit is contained in:
2021-12-15 13:02:22 +08:00
14 changed files with 381 additions and 247 deletions

View File

@@ -61,13 +61,14 @@
</template>
<script>
import XLSX from "xlsx";
import utils from "./utils";
// import XLSX from "xlsx";
// import utils from "./utils";
import {Modal} from "ant-design-vue";
import WaterBill from "./water-bill.vue";
import SpecialBill from "./special-bill.vue";
import {saveLakeBill} from "@/api/ecology/lake";
import {saveLakeBill as saveSpecialLake} from "@/api/ecology/special-lake";
// import {saveLakeBill} from "@/api/ecology/lake";
// import {saveLakeBill as saveSpecialLake} from "@/api/ecology/special-lake";
import {importCityOther,importCppointCity,importSpecial} from "@/api/ecology/water/lake/import";
export default {
name: "LakeCollectIndex",
@@ -87,255 +88,303 @@ export default {
/* 导入本地excel文件 */
importFileInnerCity(file) {
const hide = this.$message.loading("导入中..", 0);
let reader = new FileReader();
reader.onload = (e) => {
try {
let data = new Uint8Array(e.target.result);
let workbook = XLSX.read(data, {
type: "array",
});
//0.昼间数据 1.夜间数据 2.其他信息
let sheetNames = workbook.SheetNames;
// 解析成二维数组
let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
header: 1,
});
const reportDate = aoa[2][0].replace(/[^\d]+/g, "-");
const lakeList = aoa.filter(
(item) => {
return item.length >= 24 && item[0] && !item[0].includes("点位名称");
}
);
// 解析成对象数组
const billName = file.name;
const billData = utils.toInnerCityLakeObjData(lakeList, reportDate);
if (!billData || billData.length == 0) {
hide()
Modal.error({
title: "导入失败",
content: "找不到数据",
});
return;
}
const tasks = [];
if (billData.length > 0) {
tasks.push(
saveLakeBill({
reportTime: new Date(reportDate).getTime(),
billName: billName,
regionLevel: "市级",
lakeLibraryInnerCityList: billData,
})
);
const formData = new FormData();
formData.append('file', file);
importCityOther(formData).then(res=>{
console.log(res)
if(!res.data.code){
Modal.success({ title:res.data.msg, });
}else{
Modal.error({ title:res.data.msg || '文件导入失败', });
}
hide()
}).catch(err=>{
console.log(err)
Modal.error({ title:err.data.msg || '文件导入失败', });
hide()
})
// let reader = new FileReader();
// reader.onload = (e) => {
// try {
// let data = new Uint8Array(e.target.result);
// let workbook = XLSX.read(data, {
// type: "array",
// });
// //0.昼间数据 1.夜间数据 2.其他信息
// let sheetNames = workbook.SheetNames;
// // 解析成二维数组
// let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
// header: 1,
// });
// const reportDate = aoa[2][0].replace(/[^\d]+/g, "-");
// const lakeList = aoa.filter(
// (item) => {
// return item.length >= 24 && item[0] && !item[0].includes("点位名称");
// }
// );
// 上传到服务器
// // 解析成对象数组
// const billName = file.name;
// const billData = utils.toInnerCityLakeObjData(lakeList, reportDate);
// if (!billData || billData.length == 0) {
// hide()
// Modal.error({
// title: "导入失败",
// content: "找不到数据",
// });
// return;
// }
// const tasks = [];
// if (billData.length > 0) {
// tasks.push(
// saveLakeBill({
// reportTime: new Date(reportDate).getTime(),
// billName: billName,
// regionLevel: "市级",
// lakeLibraryInnerCityList: billData,
// })
// );
// }
Promise.all(tasks)
.then((res) => {
if (res[0].data.code == 0) {
Modal.success({
title: "导入成功",
content: `成功导入${billData.length}条数据`,
});
this.$refs.water && this.$refs.water.reload();
} else {
Modal.error({
title: "导入失败",
content: "数据上传出错",
});
}
})
.catch(() => {
Modal.error({
title: "导入失败",
content: "数据上传出错",
});
})
.finally(() => {
hide();
});
} catch (error) {
hide();
Modal.error({
title: "导入失败",
content: error.message,
});
}
// console.log(billData);
};
reader.readAsArrayBuffer(file);
// // 上传到服务器
// Promise.all(tasks)
// .then((res) => {
// if (res[0].data.code == 0) {
// Modal.success({
// title: "导入成功",
// content: `成功导入${billData.length}条数据`,
// });
// this.$refs.water && this.$refs.water.reload();
// } else {
// Modal.error({
// title: "导入失败",
// content: "数据上传出错",
// });
// }
// })
// .catch(() => {
// Modal.error({
// title: "导入失败",
// content: "数据上传出错",
// });
// })
// .finally(() => {
// hide();
// });
// } catch (error) {
// hide();
// Modal.error({
// title: "导入失败",
// content: error.message,
// });
// }
// // console.log(billData);
// };
// reader.readAsArrayBuffer(file);
return false;
},
importFileWuxiang(file) {
const hide = this.$message.loading("导入中..", 0);
let reader = new FileReader();
reader.onload = (e) => {
try {
let data = new Uint8Array(e.target.result);
let workbook = XLSX.read(data, {
type: "array",
});
let sheetNames = workbook.SheetNames;
// 解析成二维数组
let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
header: 1,
});
const lakeList = aoa.filter(
(item) => {
return item.length >= 24 && item[0] && !item[0].includes("点位名称");
}
);
// 解析成对象数组
const billName = file.name;
const billData = utils.toWuxiangLakeObjData(lakeList);
if (!billData || billData.length == 0) {
hide()
Modal.error({
title: "导入失败",
content: "找不到数据",
});
return;
}
const tasks = [];
if (billData.length > 0) {
tasks.push(
saveLakeBill({
billName: billName,
lakeLibraryInnerCityList: billData,
})
);
const formData = new FormData();
formData.append('file', file);
importCppointCity(formData).then(res=>{
console.log(res)
if(!res.data.code){
Modal.success({ title:res.data.msg, });
}else{
Modal.error({ title:res.data.msg || '文件导入失败', });
}
hide()
}).catch(err=>{
console.log(err)
Modal.error({ title:err.data.msg || '文件导入失败', });
hide()
})
// 上传到服务器
// let reader = new FileReader();
// reader.onload = (e) => {
// try {
// let data = new Uint8Array(e.target.result);
// let workbook = XLSX.read(data, {
// type: "array",
// });
// let sheetNames = workbook.SheetNames;
// // 解析成二维数组
// let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
// header: 1,
// });
// const lakeList = aoa.filter(
// (item) => {
// return item.length >= 24 && item[0] && !item[0].includes("点位名称");
// }
// );
// // 解析成对象数组
// const billName = file.name;
// const billData = utils.toWuxiangLakeObjData(lakeList);
// if (!billData || billData.length == 0) {
// hide()
// Modal.error({
// title: "导入失败",
// content: "找不到数据",
// });
// return;
// }
// const tasks = [];
// if (billData.length > 0) {
// tasks.push(
// saveLakeBill({
// billName: billName,
// lakeLibraryInnerCityList: billData,
// })
// );
// }
Promise.all(tasks)
.then((res) => {
if (res[0].data.code == 0) {
Modal.success({
title: "导入成功",
content: `成功导入${billData.length}条数据`,
});
this.$refs.water && this.$refs.water.reload();
} else {
Modal.error({
title: "导入失败",
content: "数据上传出错",
});
}
})
.catch(() => {
Modal.error({
title: "导入失败",
content: "数据上传出错",
});
})
.finally(() => {
hide();
});
} catch (error) {
hide();
Modal.error({
title: "导入失败",
content: error.message,
});
}
// console.log(billData);
};
reader.readAsArrayBuffer(file);
// // 上传到服务器
// Promise.all(tasks)
// .then((res) => {
// if (res[0].data.code == 0) {
// Modal.success({
// title: "导入成功",
// content: `成功导入${billData.length}条数据`,
// });
// this.$refs.water && this.$refs.water.reload();
// } else {
// Modal.error({
// title: "导入失败",
// content: "数据上传出错",
// });
// }
// })
// .catch(() => {
// Modal.error({
// title: "导入失败",
// content: "数据上传出错",
// });
// })
// .finally(() => {
// hide();
// });
// } catch (error) {
// hide();
// Modal.error({
// title: "导入失败",
// content: error.message,
// });
// }
// // console.log(billData);
// };
// reader.readAsArrayBuffer(file);
return false;
},
importFileSpecial(file) {
const hide = this.$message.loading("导入中..", 0);
let reader = new FileReader();
reader.onload = (e) => {
try {
let data = new Uint8Array(e.target.result);
let workbook = XLSX.read(data, {
type: "array",
});
let sheetNames = workbook.SheetNames;
// 解析成二维数组
let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
header: 1,
});
const lakeList = aoa.filter(
(item) => {
return item.length >= 24 && item[1] && !item[1].includes("测站名称");
}
);
// 解析成对象数组
const billName = file.name;
const billData = utils.toSpecialLakeData(lakeList);
if (!billData || billData.length == 0) {
hide()
Modal.error({
title: "导入失败",
content: "找不到数据",
});
return;
}
const tasks = [];
if (billData.length > 0) {
tasks.push(
saveSpecialLake({
billName: billName,
lakeLibrarySpecialList: billData,
})
);
const formData = new FormData();
formData.append('file', file);
importSpecial(formData).then(res=>{
console.log(res)
if(!res.data.code){
Modal.success({ title:res.data.msg, });
}else{
Modal.error({ title:res.data.msg || '文件导入失败', });
}
hide()
}).catch(err=>{
console.log(err)
Modal.error({ title:err.data.msg || '文件导入失败', });
hide()
})
// let reader = new FileReader();
// reader.onload = (e) => {
// try {
// let data = new Uint8Array(e.target.result);
// let workbook = XLSX.read(data, {
// type: "array",
// });
// let sheetNames = workbook.SheetNames;
// // 解析成二维数组
// let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
// header: 1,
// });
// const lakeList = aoa.filter(
// (item) => {
// return item.length >= 24 && item[1] && !item[1].includes("测站名称");
// }
// );
// // 解析成对象数组
// const billName = file.name;
// const billData = utils.toSpecialLakeData(lakeList);
// if (!billData || billData.length == 0) {
// hide()
// Modal.error({
// title: "导入失败",
// content: "找不到数据",
// });
// return;
// }
// const tasks = [];
// if (billData.length > 0) {
// tasks.push(
// saveSpecialLake({
// billName: billName,
// lakeLibrarySpecialList: billData,
// })
// );
// }
// 上传到服务器
// // 上传到服务器
Promise.all(tasks)
.then((res) => {
if (res[0].data.code == 0) {
Modal.success({
title: "导入成功",
content: `成功导入${billData.length}条数据`,
});
this.$refs.special && this.$refs.special.reload();
} else {
Modal.error({
title: "导入失败",
content: "数据上传出错",
});
}
// Promise.all(tasks)
// .then((res) => {
// if (res[0].data.code == 0) {
// Modal.success({
// title: "导入成功",
// content: `成功导入${billData.length}条数据`,
// });
// this.$refs.special && this.$refs.special.reload();
// } else {
// Modal.error({
// title: "导入失败",
// content: "数据上传出错",
// });
// }
})
.catch(() => {
Modal.error({
title: "导入失败",
content: "数据上传出错",
});
})
.finally(() => {
hide();
});
} catch (error) {
hide();
Modal.error({
title: "导入失败",
content: error.message,
});
}
// console.log(billData);
};
reader.readAsArrayBuffer(file);
// })
// .catch(() => {
// Modal.error({
// title: "导入失败",
// content: "数据上传出错",
// });
// })
// .finally(() => {
// hide();
// });
// } catch (error) {
// hide();
// Modal.error({
// title: "导入失败",
// content: error.message,
// });
// }
// // console.log(billData);
// };
// reader.readAsArrayBuffer(file);
return false;
},

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:loading="loading"
:datasource="datasource"
@@ -145,7 +144,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
@@ -60,6 +59,13 @@ export default {
selection: [],
// 表格列配置
columns: [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "类别", dataIndex: "type", sorter: true,},
{title: "点位名称", dataIndex: "pointName", sorter: true,},
@@ -125,7 +131,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
@@ -61,6 +60,13 @@ export default {
selection: [],
// 表格列配置
columns: [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "类别", dataIndex: "type", sorter: true,},
{title: "点位名称", dataIndex: "pointName", sorter: true,},
@@ -129,7 +135,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
@@ -187,6 +186,13 @@ export default {
})
}
this.columns = [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{ title: "类别", dataIndex: "type", sorter: true },
{ title: "点位名称", dataIndex: "pointName", sorter: true},
...addCloumns
@@ -237,7 +243,7 @@ export default {
arr.push(th1)
arr.push(th2)
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = this.sColumns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -24,6 +24,13 @@ const innerFilterColumns = [
]
const innerTableColumns = [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "断面名称", dataIndex: "pointName", sorter: true,},
{title: "水温(℃)", dataIndex: "waterTemperature", sorter: true,},
@@ -53,6 +60,13 @@ const innerTableColumns = [
];
const averageTableColumns = [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "断面名称", dataIndex: "pointName", sorter: true,},
{title: "水温(℃)", dataIndex: "waterTemperature", sorter: true,},

View File

@@ -6,12 +6,12 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
:loading="loading"
:where="where"
row-key="lakeLibraryInnerCityId"
:scroll="{ x: 'max-content' }"
@done="(d) => (data = d.data)"
>
@@ -156,7 +156,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:loading="loading"
:datasource="datasource"
@@ -144,7 +143,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
@@ -61,6 +60,13 @@ export default {
selection: [],
// 表格列配置
columns: [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "类别", dataIndex: "type", sorter: true,},
{title: "点位名称", dataIndex: "pointName", sorter: true,},
@@ -126,7 +132,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
@@ -61,6 +60,13 @@ export default {
selection: [],
// 表格列配置
columns: [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "类别", dataIndex: "type", sorter: true,},
{title: "点位名称", dataIndex: "pointName", sorter: true,},
@@ -129,7 +135,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
:datasource="datasource"
:columns="columns"
@@ -187,6 +186,13 @@ export default {
})
}
this.columns = [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{ title: "类别", dataIndex: "type", sorter: true },
{ title: "点位名称", dataIndex: "pointName", sorter: true},
...addCloumns
@@ -237,7 +243,7 @@ export default {
arr.push(th1)
arr.push(th2)
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = this.sColumns.map((item) => d[item.dataIndex]);
arr.push(td);
});

View File

@@ -24,6 +24,13 @@ const innerFilterColumns = [
]
const innerTableColumns = [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "断面名称", dataIndex: "pointName", sorter: true,},
{title: "水温(℃)", dataIndex: "waterTemperature", sorter: true,},
@@ -53,6 +60,13 @@ const innerTableColumns = [
];
const averageTableColumns = [
{
key: 'index',
dataIndex: 'index',
width: 48,
align: 'center',
customRender: ({index}) => index + 1
},
{title: "监测时间", dataIndex: "monitorTime", sorter: true,},
{title: "断面名称", dataIndex: "pointName", sorter: true,},
{title: "水温(℃)", dataIndex: "waterTemperature", sorter: true,},

View File

@@ -6,7 +6,6 @@
<search :searchForm="searchForm" :filterKeys="filterKeys" @search="searchData" @exportFile="exportFile" @filterColumns="changeFilter" :visiable="visiable"/>
<!-- 表格 -->
<ele-pro-table
v-model:selection="selectionList"
ref="table"
row-key="lakeLibrarySpecialId"
:datasource="datasource"
@@ -157,7 +156,7 @@ export default {
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
this.datasource.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});