导入跳转
This commit is contained in:
@@ -69,51 +69,31 @@
|
||||
<a-form-item label="测点名称" name="placeName">
|
||||
<a-input v-model:value="form.placeName" placeholder="请输入测点名称" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="点位编码" name="placeCode">
|
||||
<a-input v-model:value="form.placeCode" placeholder="请输入点位编码" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属城区" name="area">
|
||||
<a-input v-model:value="form.area" placeholder="请输入所属城区" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属路段" name="road">
|
||||
<a-input v-model:value="form.road" placeholder="请输入所属路段" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="路长" name="roadLength">
|
||||
<a-input type="number" v-model:value="form.roadLength" placeholder="请输入所属路长" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="路宽" name="roadWidth">
|
||||
<a-input type="number" v-model:value="form.roadWidth" placeholder="请输入所属路宽" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="测点经度" name="placeLng">
|
||||
<a-input v-model:value="form.placeLng" placeholder="请输入测点经度" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="测点纬度" name="placeLat">
|
||||
<a-input v-model:value="form.placeLat" placeholder="请输入测点纬度" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="机动车车道数" name="motorway">
|
||||
<a-input type="number" v-model:value="form.motorway" placeholder="请输入机动车车道数" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="车道类别" name="motorwayType">
|
||||
<a-input v-model:value="form.motorwayType" placeholder="请输入车道类别" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="道路等级" name="motorwayLevel">
|
||||
<a-input v-model:value="form.motorwayLevel" placeholder="请输入道路等级" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="测点参照物" name="refObj">
|
||||
<a-input v-model:value="form.refObj" placeholder="请输入测点参照物" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="道路覆盖人口(万人)" name="people">
|
||||
<a-input v-model:value="form.people" placeholder="请输入道路覆盖人口(万人)" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="监测站名" name="station">
|
||||
<a-input v-model:value="form.station" placeholder="请输入监测站名" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="监测仪器型号" name="monitorInstrumentModel">
|
||||
<a-input v-model:value="form.monitorInstrumentModel" placeholder="请输入测监测仪器型号" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="监测仪器编号" name="monitorInstrumentCode">
|
||||
<a-input v-model:value="form.monitorInstrumentCode" placeholder="请输入监测仪器编号" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="监测前校准值" name="beforeMonitorValue">
|
||||
<a-input v-model:value="form.beforeMonitorValue" placeholder="请输入监测前校准值" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="监测后校准值" name="afterMonitorValue">
|
||||
<a-input v-model:value="form.afterMonitorValue" placeholder="请输入监测后校准值" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="声校准器测量声压值" name="soundPressureValue">
|
||||
<a-input v-model:value="form.soundPressureValue" placeholder="请输入声校准器测量声压值" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="声校准仪器型号" name="soundInstrumentModel">
|
||||
<a-input v-model:value="form.soundInstrumentModel" placeholder="请输入声校准仪器型号" allow-clear/>
|
||||
</a-form-item>
|
||||
<a-form-item label="声校准仪器编号" name="soundInstrumentCode">
|
||||
<a-input v-model:value="form.soundInstrumentCode" placeholder="请输入声校准仪器编号" allow-clear/>
|
||||
<a-form-item label="点位等级" name="regionLevel">
|
||||
<a-input v-model:value="form.regionLevel" placeholder="请输入点位等级" allow-clear/>
|
||||
</a-form-item>
|
||||
|
||||
</a-form>
|
||||
</a-modal>
|
||||
<!-- 表格 -->
|
||||
@@ -159,6 +139,13 @@
|
||||
>删除
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
<a-upload
|
||||
:before-upload="importFile"
|
||||
:showUploadList="false"
|
||||
accept=".xls,.xlsx,.csv"
|
||||
>
|
||||
<a-button>导入</a-button>
|
||||
</a-upload>
|
||||
<a-button @click="exportData" type="primary">导出</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
@@ -200,10 +187,12 @@ import {
|
||||
removePlace,
|
||||
removeBatchPlace,
|
||||
copyBatchPlace,
|
||||
getColumnOptions
|
||||
getColumnOptions,
|
||||
savePlaceBatch
|
||||
} from "@/api/ecology/noise/road-noise-place";
|
||||
import {DownOutlined} from '@ant-design/icons-vue';
|
||||
import XLSX from "xlsx";
|
||||
import {Modal} from "ant-design-vue";
|
||||
// import moment from "moment";
|
||||
export default {
|
||||
name: "RoadNoisePlace",
|
||||
@@ -216,86 +205,15 @@ export default {
|
||||
selection: [],
|
||||
// 表格列配置
|
||||
columns: [
|
||||
{
|
||||
title: "年份",
|
||||
dataIndex: "year",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "测点名称",
|
||||
dataIndex: "placeName",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "测点经度",
|
||||
dataIndex: "placeLng",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "测点纬度",
|
||||
dataIndex: "placeLat",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "机动车车道数",
|
||||
dataIndex: "motorway",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "车道类别",
|
||||
dataIndex: "motorwayType",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "道路等级",
|
||||
dataIndex: "motorwayLevel",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "测点参照物",
|
||||
dataIndex: "refObj",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "道路覆盖人口(万人)",
|
||||
dataIndex: "people",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "监测站名",
|
||||
dataIndex: "station",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "监测仪器型号",
|
||||
dataIndex: "monitorInstrumentModel",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "监测仪器编号",
|
||||
dataIndex: "monitorInstrumentCode",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "监测前校准值",
|
||||
dataIndex: "beforeMonitorValue",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "声校准器测量声压值",
|
||||
dataIndex: "soundPressureValue",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "声校准仪器型号",
|
||||
dataIndex: "soundInstrumentModel",
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: "声校准仪器编号",
|
||||
dataIndex: "soundInstrumentCode",
|
||||
sorter: true,
|
||||
},
|
||||
{title: "年份",dataIndex: "year",sorter: true,},
|
||||
{title: "测点名称",dataIndex: "placeName",sorter: true,},
|
||||
{title: "点位编码",dataIndex: "placeCode",sorter: true,},
|
||||
{title: "所属城区",dataIndex: "area",sorter: true,},
|
||||
{title: "所属路段",dataIndex: "road",sorter: true,},
|
||||
{title: "路长",dataIndex: "roadLength",sorter: true,},
|
||||
{title: "路宽",dataIndex: "roadWidth",sorter: true,},
|
||||
{title: "测点经度",dataIndex: "placeLng",sorter: true, },
|
||||
{title: "测点纬度",dataIndex: "placeLat",sorter: true,},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
@@ -321,10 +239,10 @@ export default {
|
||||
form: {},
|
||||
loading: false,
|
||||
rules: {
|
||||
year: [{required: true, message: '请输入年份'}],
|
||||
placeName: [{required: true, message: '请选择测点名称'}],
|
||||
placeLng: [{required: true, message: '请输入测点经度',},],
|
||||
placeLat: [{required: true, message: '请输入测点纬度',},],
|
||||
// year: [{required: true, message: '请输入年份'}],
|
||||
// placeName: [{required: true, message: '请选择测点名称'}],
|
||||
// placeLng: [{required: true, message: '请输入测点经度',},],
|
||||
// placeLat: [{required: true, message: '请输入测点纬度',},],
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -474,7 +392,97 @@ export default {
|
||||
|
||||
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
||||
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
|
||||
}
|
||||
},
|
||||
importFile(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 reportDate = aoa[1][0].replace(/[^\d]+/g, "-");
|
||||
const roadNoiseList = aoa.filter(
|
||||
(item) => {
|
||||
return item.length >= 10 && item[0] && !item[0].toString().includes("年")
|
||||
}
|
||||
);
|
||||
|
||||
// 解析成对象数组
|
||||
const billData = roadNoiseList.map(item=>{
|
||||
return {
|
||||
year:item[0],
|
||||
placeCode:item[1],
|
||||
placeName:item[2],
|
||||
road:item[3],
|
||||
area:item[4],
|
||||
roadLength:item[5],
|
||||
roadWidth:item[6],
|
||||
placeLng:item[7],
|
||||
placeLat:item[8],
|
||||
regionLevel:item[9],
|
||||
}
|
||||
});
|
||||
|
||||
if (!billData || billData.length == 0) {
|
||||
hide();
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "找不到可用数据",
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (billData.length > 0) {
|
||||
// 上传到服务器
|
||||
savePlaceBatch(billData)
|
||||
.then((res) => {
|
||||
if (res.data.code == 0) {
|
||||
Modal.success({
|
||||
title: "导入成功",
|
||||
content: `成功导入${
|
||||
billData.length
|
||||
}条数据`,
|
||||
});
|
||||
this.reload();
|
||||
this.getOptions();
|
||||
} 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;
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user