소스 검색

预览旋转修改

duy 1 개월 전
부모
커밋
dd226c6936
1개의 변경된 파일17개의 추가작업 그리고 10개의 파일을 삭제
  1. 17 10
      src/components/plugins/table-form/hc-form-upload.vue

+ 17 - 10
src/components/plugins/table-form/hc-form-upload.vue

@@ -95,11 +95,7 @@ const props = defineProps({
         type: [Number, String],
         default: '相片',
     },
-    // 新增pkeyId属性,用于接口参数
-    pkeyId: {
-        type: [Number, String],
-        default: '',
-    },
+
 })
 
 // 事件
@@ -120,13 +116,20 @@ const rotatedBlob = ref(null)
 
 const action = '/api/blade-manager/exceltab/add-buss-imginfo'
 const accept = 'image/png,image/jpg,image/jpeg'
-
+const oldUrl = ref('')
 // 监听props变化
-watch(() => [props.src, props.keyname, props.pkeyId], 
+watch(() => [props.src, props.keyname], 
 ([src, keyname]) => {
     isSrc.value = src
+ 
+        // 只在initialSrc未设置时才赋值(保留第一次的src)
+    if (oldUrl.value === '' && src) {
+        oldUrl.value = src
+        console.log( oldUrl.value, ' oldUrl.value')
+        
+    }
     isKeyName.value = keyname
-})
+}, { immediate: true })
 
 // 上传进度
 const uploadprogress = () => {
@@ -212,8 +215,10 @@ const confirmRotation = async () => {
         const formData = new FormData()
         formData.append('file', blob, `rotated-${Date.now()}.png`)
         // 添加新参数
-        formData.append('pkeyId', props.pkeyId)
-        formData.append('keyname', isKeyName.value)
+  
+        
+        formData.append('oldUrl', oldUrl.value)
+      
 
         // 调用上传接口
         const response = await fetch(action, {
@@ -253,6 +258,8 @@ const confirmRotation = async () => {
 const rotateImageAndGetBlob = (imageUrl, degrees) => {
     return new Promise((resolve, reject) => {
         const img = new Image()
+       
+    
         img.crossOrigin = 'anonymous'
         img.onload = function () {
             const canvas = document.createElement('canvas')