廖井涛
2025-11-21 6dd74d6739305ba7ab51c43b83d166bdf9e12c52
north-glass-erp/northglass-erp/src/components/sd/order/UpdateAlienEditor.vue
@@ -40,7 +40,7 @@
const emits = defineEmits(['getUploadPicture'])
let fileName=ref(null)
let fileDate=ref(null)
let fileData=ref(null)
let fileJson=ref({
  quadrilateral:null,
  polygon:null
@@ -155,27 +155,27 @@
//绘制自由多边形
const getproject = () => {
    validate1()
    if(leafer!==undefined){
      leafer.clear()
    }
    leafer=new Leafer({ view: 'canvas' })
    points.value = [datas1.value + (parseInt(data5.value) / big), datas2.value - (parseInt(data6.value) / big), datas3.value + (parseInt(data1.value) / big), datas4.value + (parseInt(data2.value) / big),
      datas5.value - (parseInt(data3.value) / big), datas6.value + (parseInt(data4.value) / big), datas7.value - (parseInt(data7.value) / big), datas8.value - (parseInt(data8.value) / big)]
    fileJson.value.quadrilateral=[parseInt(data5.value),parseInt(data6.value),parseInt(data1.value),parseInt(data2.value),
      parseInt(data3.value),parseInt(data4.value),parseInt(data7.value),parseInt(data8.value)]
    fileJson.value.polygon=null
    states.value=false
  validate1()
  if(leafer!==undefined){
    leafer.clear()
  }
  leafer=new Leafer({ view: 'canvas' })
  points.value = [datas1.value + (parseInt(data5.value) / big), datas2.value - (parseInt(data6.value) / big), datas3.value + (parseInt(data1.value) / big), datas4.value + (parseInt(data2.value) / big),
    datas5.value - (parseInt(data3.value) / big), datas6.value + (parseInt(data4.value) / big), datas7.value - (parseInt(data7.value) / big), datas8.value - (parseInt(data8.value) / big)]
  fileJson.value.quadrilateral=[parseInt(data5.value),parseInt(data6.value),parseInt(data1.value),parseInt(data2.value),
    parseInt(data3.value),parseInt(data4.value),parseInt(data7.value),parseInt(data8.value)]
  fileJson.value.polygon=null
  states.value=false
    const polygon = new Polygon({
      points: points.value,
      stroke: '#f00',
      zIndex: 1
    })
    leafer.add(polygon)
    load()
    state.value=true
    exportToDXF(1)
  const polygon = new Polygon({
    points: points.value,
    stroke: '#f00',
    zIndex: 1
  })
  leafer.add(polygon)
  load()
  state.value=true
  exportToDXF(1)
}
@@ -188,8 +188,8 @@
    let r=parseInt(circle.value.r)
    if(x>0 && y>0 && r>0){
      const ellipse = new Ellipse({
        x:x/ big,
        y:(y-r*2)/ big,
        x:(x-r)/ big,
        y:(y-r)/ big,
        width: r*2 / big,
        height: r*2 / big,
        stroke: '#f00',
@@ -206,7 +206,7 @@
      circle.value.r=0
      exportToDXF(1)
    }else{
      ElMessage.warning("请输入大于0的有效参数")
      ElMessage.warning(t('basicData.greater0Msg'))
    }
  }
@@ -242,7 +242,7 @@
      rect.value.h=0
      exportToDXF(1)
    }else{
      ElMessage.warning("请输入大于0的有效参数")
      ElMessage.warning(t('basicData.greater0Msg'))
    }
  }
@@ -342,40 +342,40 @@
      for (let i=0;i<list.length;i++) {
        let curr=list[i]
      // 排除自身坐标
      if (curr[0] == xy[0] && curr[1] == xy[1]) {
        continue;
      }
      // 筛选x≥目标x的坐标(只考虑递增方向的候选)
      if (curr[0] < xy[0]) {
        continue;
      }
      // 第一次找到候选,直接赋值
      if (best == null) {
        best = xy;
        continue;
      }
      if (curr[0] == best[0]) {
        // x相同则比较y:y更小则更优
        if (curr[1] < best[1]) {
          best = curr;
          index=i
        // 排除自身坐标
        if (curr[0] == xy[0] && curr[1] == xy[1]) {
          continue;
        }
        // 筛选x≥目标x的坐标(只考虑递增方向的候选)
        if (curr[0] < xy[0]) {
          continue;
        }
        // 第一次找到候选,直接赋值
        if (best == null) {
          best = xy;
          continue;
        }
        if (curr[0] == best[0]) {
          // x相同则比较y:y更小则更优
          if (curr[1] < best[1]) {
            best = curr;
            index=i
          }
        }
      }
    }
      break;
    case 2: // x轴递减:找x≤当前x的坐标中,x最大的;x相同则y最大的
      for (let i=0;i<list.length;i++) {
        let curr=list[i]
      // 排除自身坐标
      if (curr[0] == xy[0] && curr[1] == xy[1]) {
        continue;
      }
      // 筛选x≤目标x的坐标(只考虑递减方向的候选)
      if (curr[0] > xy[0]) {
        continue;
      }
        // 排除自身坐标
        if (curr[0] == xy[0] && curr[1] == xy[1]) {
          continue;
        }
        // 筛选x≤目标x的坐标(只考虑递减方向的候选)
        if (curr[0] > xy[0]) {
          continue;
        }
        // 第一次找到候选,直接赋值
        if (best == null) {
          best = xy;
@@ -388,20 +388,20 @@
            index=i
          }
        }
    }
      }
      break;
    case 3: // y轴递增:找y≥当前y的坐标中,y最小的;y相同则x最小的
      for (let i=0;i<list.length;i++) {
        let curr=list[i]
      // 排除自身坐标
      if (curr[0] == xy[0] && curr[1] == xy[1]) {
        continue;
      }
      // 筛选y≥目标y的坐标(只考虑递增方向的候选)
      if (curr[1] < xy[1]) {
        continue;
      }
        // 排除自身坐标
        if (curr[0] == xy[0] && curr[1] == xy[1]) {
          continue;
        }
        // 筛选y≥目标y的坐标(只考虑递增方向的候选)
        if (curr[1] < xy[1]) {
          continue;
        }
        // 第一次找到候选,直接赋值
        if (best == null) {
          best = xy;
@@ -414,24 +414,24 @@
            index=i
          }
        }
    }
      }
      break;
    case 4: // y轴递减:找y≤当前y的坐标中,y最大的;y相同则x最大的
      for (let i=0;i<list.length;i++) {
        let curr=list[i]
      // 排除自身坐标
      if (curr[0] == xy[0] && curr[1] == xy[1]) {
        continue;
      }
      // 筛选y≤目标y的坐标(只考虑递减方向的候选)
      if (curr[1] > xy[1]) {
        continue;
      }
      if (best == null) {
        best = xy;
        continue;
      }
        // 排除自身坐标
        if (curr[0] == xy[0] && curr[1] == xy[1]) {
          continue;
        }
        // 筛选y≤目标y的坐标(只考虑递减方向的候选)
        if (curr[1] > xy[1]) {
          continue;
        }
        if (best == null) {
          best = xy;
          continue;
        }
        if (curr[1] == best[1]) {
          // y相同则比较x:x更小则更优
          if (curr[0] > best[0]) {
@@ -439,7 +439,7 @@
            index=i
          }
        }
    }
      }
      break;
    default: // 无效方向
@@ -600,8 +600,8 @@
    pointsRect.value.forEach(rect => {
      if(rect.type=="round"){
        const x = rect.x+rect.width;
        const y = maxY-minY-rect.y+rect.width;
        const x = rect.x;
        const y = maxY-minY-rect.y;
        const radius = rect.width;
        if (dxf.drawCircle) {
          dxf.drawCircle(x, y, radius, { layer: '0' });
@@ -638,12 +638,12 @@
  const base64 = await fileToBase64(blob);
  if(value===1){
    fileName.value="map.dxf"
    fileDate.value=base64.replace(/^data:.+;base64,/, "")
    fileData.value=base64.replace(/^data:.+;base64,/, "")
  }
  else if(value===2&&state.value){
    saveAs(blob, 'map.dxf');
  }else{
    ElMessage.warning("该格式不支持导出")
    ElMessage.warning(t('basicData.notExport'))
  }
}
@@ -689,7 +689,7 @@
        handleFileUpload()
        fileName.value=file.name
        fileDate.value=base64.replace(/^data:.+;base64,/, "")
        fileData.value=base64.replace(/^data:.+;base64,/, "")
      } catch (error) {
        console.error('解析DXF文件时出错:', error);
      }
@@ -804,37 +804,37 @@
            pointsRect.value.push({id:pointsRect.value.length+1,type:'rect',shap:"▢",x:entity.vertices[0].x,y:entity.vertices[0].y,
              width:entity.vertices[2].x-entity.vertices[0].x,
              height:entity.vertices[1].y-entity.vertices[0].y
                ,x1:entity.vertices[0].x,y1:entity.vertices[0].y})
              ,x1:round(entity.vertices[0].x),y1:round(entity.vertices[0].y)})
          }
            const polygon = new Polygon({
              points: point,
              stroke: '#f00',
              zIndex: 1
            })
            setTimeout(() => {
              leafer.add(polygon);
            }, 30);
          const polygon = new Polygon({
            points: point,
            stroke: '#f00',
            zIndex: 1
          })
          setTimeout(() => {
            leafer.add(polygon);
          }, 30);
          break;
        case 'CIRCLE':
            let CIRCLEX=(entity.center.x-minX-entity.radius)/big
            let CIRCLEY=((maxY - minY)-(entity.center.y-minY+entity.radius))/big
            if(big<(entity.radius * 2) / 400){
              big = (entity.radius * 2) / 400
              main.style.width = entity.radius * 2 / big + "px"
              main.style.height = entity.radius * 2 / big + "px"
              width.innerHTML = round(entity.radius * 2, 2)
              height.innerHTML = round(entity.radius * 2, 2)
              CIRCLEX=0
              CIRCLEY=0
            }
            let x=entity.center.x-minX-entity.radius
            let y=(maxY - minY)-(entity.center.y-minY-entity.radius)
          let CIRCLEX=(entity.center.x-minX-entity.radius)/big
          let CIRCLEY=((maxY - minY)-(entity.center.y-minY+entity.radius))/big
          if(big<(entity.radius * 2) / 400){
            big = (entity.radius * 2) / 400
            main.style.width = entity.radius * 2 / big + "px"
            main.style.height = entity.radius * 2 / big + "px"
            width.innerHTML = round(entity.radius * 2, 2)
            height.innerHTML = round(entity.radius * 2, 2)
            CIRCLEX=0
            CIRCLEY=0
          }
          let x=entity.center.x-minX
          let y=(maxY - minY)-(entity.center.y-minY)
          pointsRect.value.push({id:pointsRect.value.length+1,type:'round',shap:"〇",x:x,y:y,width:entity.radius,
            x1:x,y1:entity.center.y-minY-entity.radius})
            x1:round(x),y1:round(entity.center.y-minY)})
          const ellipse = new Ellipse({
            x:CIRCLEX,
            y:CIRCLEY,
@@ -1025,13 +1025,13 @@
//保存方法
const save =  () => {
  if(fileName.value!=null&&fileDate.value!=null){
  if(fileName.value!=null&&fileData.value!=null){
    fileJson.value.quadrilateral=[parseInt(data5.value),parseInt(data6.value),parseInt(data1.value),parseInt(data2.value),
      parseInt(data3.value),parseInt(data4.value),parseInt(data7.value),parseInt(data8.value)]
    if(fileJson.value.quadrilateral==null&&fileJson.value.polygon==null){
      fileJson.value=null
    }
    emits('getUploadPicture', fileName.value,fileDate.value,fileJson.value)
    emits('getUploadPicture', fileName.value,fileData.value,fileJson.value)
  }else{
    ElMessage.warning("未参与修改")
@@ -1243,8 +1243,8 @@
        let y=parseInt(rect.y)
        let r=parseInt(rect.width)
        const ellipse = new Ellipse({
          x:x/ big,
          y:(y-r*2)/ big,
          x:(x-r)/ big,
          y:(y-r)/ big,
          width: r*2 / big,
          height: r*2 / big,
          stroke: '#f00',
@@ -1311,7 +1311,7 @@
    <el-button type="primary" @click="save()">{{$t('basicData.save')}}</el-button>
  </div>
 <div style="position: absolute;margin-top: 373px;margin-left: 300px;">
  <div style="position: absolute;margin-top: 373px;margin-left: 300px;">
    <el-select v-model="select1" @change="handleChange" style="width: 100px;height: 40px;font-size: 8px">
      <el-option value="1" :label="$t('order.edgeAngleCurvature')"></el-option>