新增县级,农村取水量导入

This commit is contained in:
710356044
2022-01-21 22:40:09 +08:00
parent 00f536bf79
commit 356923bff6
5 changed files with 143 additions and 14 deletions

View File

@@ -51,7 +51,10 @@ const updateDrinkingWaterVillage = function (data) {
return axios.put("/drinkingWaterVillage/drinkingWaterVillage",data)
}
//批量修改取水量
const updateVillageWaterWithdrawal=function(data){
return axios.put("/drinkingWaterVillage/drinkingWaterVillage/updateVillageWater",data)
}
// -------------------------统计---------------------
const pageDrinkingWaterVillageStatisticUrl = '/drinkingWaterVillage/drinkingWaterVillage/VillageAnalysePage';
@@ -89,6 +92,6 @@ export {
getColumnOptions,
listAll,
getGisBase,
getGisArea
getGisArea,
updateVillageWaterWithdrawal
}

View File

@@ -1,5 +1,6 @@
//地表水表格
const tableColumns = [
{title:"取水量",dataIndex:"waterWithdrawal",sorter:true},
{title:"断面代码",dataIndex:"sectionCode",sorter:true},
{title: "省",dataIndex: "province",sorter: true,},
{title: "市",dataIndex: "city",sorter: true,},

View File

@@ -136,5 +136,14 @@ export default {
};
return row;
})
}
},
importWaterWithdrawalData(excelData){
return excelData.map(item => {
const row = {
place:item[0],
waterWithdrawal:item[1],
}
return row;
})
}
}

View File

@@ -118,6 +118,25 @@
<a-popconfirm :title="`确认删除${record.billName}吗?`" ok-text="Yes" cancel-text="No" @confirm="remove(record)">
<a-button type="primary" danger shape="round" size="small">删除</a-button>
</a-popconfirm>
<a-upload
:before-upload="file=>importWaterWithdrawal(file,record)"
:showUploadList="false"
accept=".xls,.xlsx,.csv"
>
<!-- <a-button
:disabled="isCity(record)"
type="primary"
shape="round"
size="small"
>取水量导入</a-button
> -->
<a-button
type="primary"
shape="round"
size="small"
>取水量导入</a-button
>
</a-upload>
</a-space>
</template>
</ele-pro-table>
@@ -132,13 +151,16 @@
EditOutlined
} from '@ant-design/icons-vue';
import { Modal } from 'ant-design-vue';
import utils from "./utils";
import XLSX from "xlsx";
import {
pageBillUrl,
// saveDrinkingWaterVillageBill,
removeDrinkingWaterVillageBill,
removeBatchDrinkingWaterVillageBill,
updateDrinkingWaterVillageBill,
verifyDrinkingWaterVillageBill
verifyDrinkingWaterVillageBill,
updateVillageWaterWithdrawal
} from "@/api/ecology/drinking-water-village";
import moment from "moment";
export default {
@@ -271,7 +293,94 @@
};
},
methods: {
/*取水量导入 */
importWaterWithdrawal(file,record) {
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 aoa1 = XLSX.utils.sheet_to_json(
workbook.Sheets[sheetNames[0]], {
header: 1,
});
const drinkingWaterList = aoa1.filter((item) => {
return (
item[0] && !item[0].includes("取水点") && !item[0].includes("合计")
);
});
const drinkingWaterVillageBillId=record.drinkingWaterVillageBillId;
// drinkingWaterList.drinkingWaterBillId=record.drinkingWaterBillId;
// 解析成对象数组
// const billName1 = file.name;
const billData1 = utils.importWaterWithdrawalData(drinkingWaterList);
// console.log(drinkingWaterList.length);
// console.log(billData1.place);
if (!billData1 || billData1.length == 0) {
hide();
Modal.error({
title: "导入失败",
content: "找不到可用数据",
});
return;
}
if (billData1.length > 0) {
updateVillageWaterWithdrawal({
// drinkingWaterBillId:record.drinkingWaterBillId,
id:drinkingWaterVillageBillId,
waterWithdrawals: billData1,
})
.then((res) => {
if (res.data.code == 0) {
Modal.success({
title: "导入成功",
content: `成功导入${billData1.length}条数据`,
});
this.$refs.water && this.$refs.water.reload();
} else {
Modal.error({
title: "导入失败",
content: "数据上传出错1",
});
}
})
.catch(() => {
Modal.error({
title: "导入失败",
content: "数据上传出错2",
});
})
.finally(() => {
hide();
});
}
} catch (error) {
hide();
Modal.error({
title: "导入失败",
content: error.message,
});
console.log(error);
}
};
reader.readAsArrayBuffer(file);
return false;
},
/* 刷新表格 */
reload() {

View File

@@ -196,12 +196,18 @@
accept=".xls,.xlsx,.csv"
>
<a-button
<!-- <a-button
:disabled="isCity(record)"
type="primary"
shape="round"
size="small"
>取水量导入</a-button
> -->
<a-button
type="primary"
shape="round"
size="small"
>取水量导入</a-button
>
</a-upload>
</a-space>
@@ -355,14 +361,15 @@ export default {
methods: {
/* 判断是否是市级,用于取水量导入 */
isCity(record) {
if (record.regionLevel === "市级") {
return false;
} else {
return true;
}
},
/*市级取水量导入 */
// isCity(record) {
// if (record.regionLevel === "市级") {
// return false;
// } else {
// return true;
// }
// },
/*取水量导入 */
importWaterWithdrawal(file,record) {
const hide = this.$message.loading("导入中..", 0);
let reader = new FileReader();