修改删除逻辑

main
scrin 1 month ago
parent af3da73033
commit 0c9d2cf975

@ -192,10 +192,11 @@
<el-button style="margin-right: 16px" @click="batchShild"></el-button> <el-button style="margin-right: 16px" @click="batchShild"></el-button>
</el-popover> </el-popover>
</div> </div>
{{ tableData1 }}
<el-table <el-table
ref="table1Ref" ref="table1Ref"
highlight-current-row highlight-current-row
:data="tableData1.slice((currentPage1 - 1) * pageSize1, currentPage1 * pageSize1)" :data="tableData1Computed"
style="width: 100%" style="width: 100%"
@row-click="table1Current" @row-click="table1Current"
> >
@ -694,7 +695,7 @@
</template> </template>
<script setup lang="jsx"> <script setup lang="jsx">
import Ruler from "@/components/ruler.vue"; import Ruler from "@/components/ruler.vue";
import {onMounted, ref, watch} from "vue"; import {onMounted, ref, watch,computed } from "vue";
import { import {
addShildData, addShildData,
DeleteCData, DeleteCData,
@ -988,6 +989,10 @@ const getShildTableList = () => {
// //
const tableData1 = ref([]) const tableData1 = ref([])
const tableData1Computed = computed(() => {
console.log(tableData1.value.slice((currentPage1.value - 1) * pageSize1.value, currentPage1.value * pageSize1.value))
return tableData1.value.slice((currentPage1.value - 1) * pageSize1.value, currentPage1.value * pageSize1.value)
});
// //
const uploadRef = ref(null) const uploadRef = ref(null)
const uploadFiles = async (e) => { const uploadFiles = async (e) => {
@ -1128,7 +1133,10 @@ function lonLatToXY(lon, lat, lat0) {
} }
function calcRectangleFromPoints(points) { function calcRectangleFromPoints(points) {
if (!points || points.length !== 4) throw new Error("必须传入4个点"); if (!points || points.length !== 4) {
console.log("必须传入4个点");
return
}
const p1raw = points.find(p => p.name === "点位1") || points[0]; const p1raw = points.find(p => p.name === "点位1") || points[0];
const p2raw = points.find(p => p.name === "点位2") || points[1]; const p2raw = points.find(p => p.name === "点位2") || points[1];
const p3raw = points.find(p => p.name === "点位3") || points[2]; const p3raw = points.find(p => p.name === "点位3") || points[2];
@ -1162,7 +1170,8 @@ function calcRectangleFromPoints(points) {
function getLocalPositionRelativeToP4(point, rectPoints, rectInfo) { function getLocalPositionRelativeToP4(point, rectPoints, rectInfo) {
if (!rectInfo || typeof rectInfo.angle !== 'number') { if (!rectInfo || typeof rectInfo.angle !== 'number') {
throw new Error("rectInfo.angle 必须是由 calcRectangleFromPoints 得到的角度"); console.log("rectInfo.angle 必须是由 calcRectangleFromPoints 得到的角度");
return
} }
const lat0 = rectPoints.reduce((a, b) => a + b.lat, 0) / rectPoints.length; const lat0 = rectPoints.reduce((a, b) => a + b.lat, 0) / rectPoints.length;
@ -1198,12 +1207,12 @@ const getDeviationValue = (e) => {
} }
// //
const correctDeviation = (e) => { const correctDeviation = (e) => {
let numH = deviationValue.value.y let numH = deviationValue.value.y || 0
let numW = deviationValue.value.x let numW = deviationValue.value.x || 0
let Ratio = e.y / numH let Ratio = e?.y / numH
return { return {
...e, ...e,
x: e.x - numW * Ratio x: e?.x - numW * Ratio
} }
} }
const getPoint = (k) => { const getPoint = (k) => {
@ -1377,6 +1386,7 @@ const getDotsData = () => {
}).filter(v => v)] }).filter(v => v)]
} }
watch(() => JSON.stringify([tableData1.value, areaPoints.value]), (oldVal, newVal) => { watch(() => JSON.stringify([tableData1.value, areaPoints.value]), (oldVal, newVal) => {
console.log(tableData1.value)
localStorage.setItem('tableData1', JSON.stringify(tableData1.value)); localStorage.setItem('tableData1', JSON.stringify(tableData1.value));
getDotsData() getDotsData()
}, {deep: true}) }, {deep: true})
@ -1388,9 +1398,22 @@ onMounted(() => {
// testFun() // testFun()
getDotsData() getDotsData()
setTimeout(() => { setTimeout(() => {
tableData1.value = JSON.parse(localStorage.getItem('tableData1') || '[]') const storedStr = localStorage.getItem('tableData1');
if (!storedStr) {
},100) console.log('localStorage中无数据');
return;
}
const storedData = JSON.parse(storedStr);
if (!Array.isArray(storedData)) {
console.error('存储的数据不是数组');
return;
}
tableData1.value.splice(0, tableData1.value.length, ...storedData);
if (table1Ref.value) {
table1Ref.value.doLayout(); //
}
console.log('加载成功,数据长度:', tableData1.value.length);
}, 1000)
}) })

Loading…
Cancel
Save