Commit c91f80ca authored by xinzhedeai's avatar xinzhedeai

add:坡面数据为空画布清空处理。 po台阶与设备数据加工独立处理。

parent 0c191572
...@@ -248,6 +248,20 @@ export default { ...@@ -248,6 +248,20 @@ export default {
}); });
}, },
methods: { methods: {
/** 清空画布内容及配置 */
clearCanvas() {
if (this.ctx) {
// 清除画布绘制内容(基于当前坐标系)
this.ctx.save();
this.ctx.setTransform(1, 0, 0, 1, 0, 0); // 恢复默认坐标系
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); // 清空整个画布
this.ctx.restore();
}
// 重置配置数据(避免残留)
this.canvasDataReal.poConfigs = [];
this.canvasDataReal.guanConfigs = [];
this.canvasDataReal.lineConfigs = [];
},
getCanvasData() { getCanvasData() {
const params = { ...this.form.query }; const params = { ...this.form.query };
request({ request({
...@@ -256,16 +270,19 @@ export default { ...@@ -256,16 +270,19 @@ export default {
params, params,
}).then(async (res) => { }).then(async (res) => {
const data = res.body; const data = res.body;
console.log("接口数据", data);
// 判断数据是否为空(根据实际接口返回结构调整) if (!data.length) {
// const isEmpty = // 数据为空时清空画布
// !data.jrxStepsDtoList?.length || !data.equipmentDataList?.length; this.clearCanvas();
// this.canvasDataEmpty = isEmpty; // 更新空数据状态 return;
}
// if (!isEmpty) {
await this.handleCanvasData(data); console.log("剖面接口数据", data);
this.initCanvas(); console.table(JSON.parse(JSON.stringify(data[0].jrxStepsDtoList)))
// } console.table(JSON.parse(JSON.stringify(data[0].equipmentDataList)))
await this.handleCanvasData(data);
this.initCanvas();
}); });
}, },
handleCanvasData(list = []) { handleCanvasData(list = []) {
...@@ -297,27 +314,29 @@ export default { ...@@ -297,27 +314,29 @@ export default {
//第一层台阶的开孔深度和设备图片相除的系数 //第一层台阶的开孔深度和设备图片相除的系数
const sbHeightModulus = poumian.equipmentDataList[0].jrxTrepanning; // / 130; const sbHeightModulus = poumian.equipmentDataList[0].jrxTrepanning; // / 130;
for (let index = 0; index < poCount; index++) {
// 坡数据数据格式处理 // 坡数据数据格式处理
poumian.jrxStepsDtoList.forEach((po, poIndex)=>{
this.canvasDataReal.poConfigs.push({ this.canvasDataReal.poConfigs.push({
x: 0, x: 0,
y: canvasHeight - (index + 1) * poH, y: canvasHeight - (poIndex + 1) * poH,
width: canvasWidth - (index + 1) * po_pad_right, width: canvasWidth - (poIndex + 1) * po_pad_right,
height: poH, height: poH,
}); });
})
// 管孔数据数据格式处理
poumian.equipmentDataList.forEach((equipment, equipIndex)=>{
const po = this.canvasDataReal.poConfigs[equipIndex]
// 管孔数据数据格式处理 // 管孔数据数据格式处理
this.canvasDataReal.guanConfigs.push({ this.canvasDataReal.guanConfigs.push({
x: this.canvasDataReal.poConfigs[index].width * 0.75, x: po.width * 0.75,
y: y: canvasHeight - po.height * (equipIndex + 1) + 30,
canvasHeight -
this.canvasDataReal.poConfigs[index].height * (index + 1) +
30,
width: 6, width: 6,
height: height: equipment.jrxTrepanning * sbHeightModulus,
poumian.equipmentDataList[index].jrxTrepanning * sbHeightModulus,
image: "guanImage", image: "guanImage",
}); });
} })
// 警戒线逻辑- 初始话基本数据结构 // 警戒线逻辑- 初始话基本数据结构
for (let index1 = 0; index1 < lineCount; index1++) { for (let index1 = 0; index1 < lineCount; index1++) {
...@@ -345,7 +364,11 @@ export default { ...@@ -345,7 +364,11 @@ export default {
}); });
}); });
console.log("this.canvasDataReal", this.canvasDataReal); console.log("坡面处理完毕数据", this.canvasDataReal);
console.table(JSON.parse(JSON.stringify(this.canvasDataReal.poConfigs)))
console.table(JSON.parse(JSON.stringify(this.canvasDataReal.guanConfigs)))
console.table(JSON.parse(JSON.stringify(this.canvasDataReal.lineConfigs)))
resolve(); // 数据处理完成后触发resolve resolve(); // 数据处理完成后触发resolve
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment