|
@@ -33,7 +33,7 @@ import { ref, onUnmounted } from 'vue'
|
|
|
import SpreadDesigner from '@/components/SpreadDesigner/spreadDesigner.vue'
|
|
import SpreadDesigner from '@/components/SpreadDesigner/spreadDesigner.vue'
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
import { getCheckerEquipmentDetailById, getDynamicTbVal, saveDynamicTbVal } from '@/api/task'
|
|
import { getCheckerEquipmentDetailById, getDynamicTbVal, saveDynamicTbVal } from '@/api/task'
|
|
|
-import { getStandardTemplate } from '@/api/index'
|
|
|
|
|
|
|
+import { getStandardTemplate, uploadFile } from '@/api/index'
|
|
|
import { getEnvBaseUrl } from '@/utils/index'
|
|
import { getEnvBaseUrl } from '@/utils/index'
|
|
|
import { PressureCheckerMyTaskStatus } from '@/utils/dictMap'
|
|
import { PressureCheckerMyTaskStatus } from '@/utils/dictMap'
|
|
|
|
|
|
|
@@ -200,8 +200,40 @@ const blobToBase64 = (blob: Blob): Promise<string> => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const uploadBase64Image = async (image: any): Promise<string | null> => {
|
|
|
|
|
+ const imgUrl = image.imgUrl || ''
|
|
|
|
|
+ const [header, rawBase64] = imgUrl.includes(',') ? imgUrl.split(',') : ['', imgUrl]
|
|
|
|
|
+ const mimeType = header.match(/data:(.*?);base64/)?.[1] || 'image/jpeg'
|
|
|
|
|
+ const fileName = `${image.shapeName || `image_${Date.now()}`}.${mimeType.split('/')[1] || 'jpg'}`
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const byteString = atob(rawBase64)
|
|
|
|
|
+ const ab = new ArrayBuffer(byteString.length)
|
|
|
|
|
+ const ia = new Uint8Array(ab)
|
|
|
|
|
+ for (let i = 0; i < byteString.length; i++) {
|
|
|
|
|
+ ia[i] = byteString.charCodeAt(i)
|
|
|
|
|
+ }
|
|
|
|
|
+ const blob = new Blob([ab], { type: mimeType })
|
|
|
|
|
+ const file = new File([blob], fileName, { type: mimeType })
|
|
|
|
|
+ const formData = new FormData()
|
|
|
|
|
+ formData.append('file', file)
|
|
|
|
|
+
|
|
|
|
|
+ const result = await uploadFile(formData)
|
|
|
|
|
+ if (result?.code === 0 && result.data) {
|
|
|
|
|
+ return result.data as string
|
|
|
|
|
+ }
|
|
|
|
|
+ uni.showToast({ title: result?.msg || '图片上传失败', icon: 'none' })
|
|
|
|
|
+ return null
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('图片上传异常:', error)
|
|
|
|
|
+ uni.showToast({ title: '图片上传失败', icon: 'none' })
|
|
|
|
|
+ return null
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const handleSave = async (data: any) => {
|
|
const handleSave = async (data: any) => {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ console.log('savedata......', data)
|
|
|
if (useOnline === '1') {
|
|
if (useOnline === '1') {
|
|
|
const instId = data.instId
|
|
const instId = data.instId
|
|
|
const reqData = {}
|
|
const reqData = {}
|
|
@@ -211,6 +243,52 @@ const handleSave = async (data: any) => {
|
|
|
}
|
|
}
|
|
|
reqData[key] = data.prepareJson[key]
|
|
reqData[key] = data.prepareJson[key]
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (data.images && data.images.length > 0) {
|
|
|
|
|
+ const shouldUplodImgList = data.images.filter((item: any) =>
|
|
|
|
|
+ item.shapeName?.startsWith('addPicture_'),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ if (shouldUplodImgList.length > 0) {
|
|
|
|
|
+ uni.showLoading({ title: '图片上传中...', mask: true })
|
|
|
|
|
+ for (const image of shouldUplodImgList) {
|
|
|
|
|
+ const uploadedUrl = await uploadBase64Image(image)
|
|
|
|
|
+ if (!uploadedUrl) {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ image.imgUrl = uploadedUrl
|
|
|
|
|
+ }
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const illustractionList = []
|
|
|
|
|
+ for (const element of data.images) {
|
|
|
|
|
+ if (element.shapeName.startsWith('addPicture_')) {
|
|
|
|
|
+ illustractionList.push({
|
|
|
|
|
+ url: element.imgUrl,
|
|
|
|
|
+ path: 'Illustration',
|
|
|
|
|
+ x: element.imgX,
|
|
|
|
|
+ y: element.imgY,
|
|
|
|
|
+ width: element.imgWidth,
|
|
|
|
|
+ height: element.imgHeight,
|
|
|
|
|
+ sheet: element.sheetName,
|
|
|
|
|
+ })
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ const originObj = JSON.parse(element.shapeName)
|
|
|
|
|
+ const updatedObj = Object.assign(originObj, {
|
|
|
|
|
+ x: element.imgX,
|
|
|
|
|
+ y: element.imgY,
|
|
|
|
|
+ width: element.imgWidth,
|
|
|
|
|
+ height: element.imgHeight,
|
|
|
|
|
+ })
|
|
|
|
|
+ illustractionList.push(updatedObj)
|
|
|
|
|
+ }
|
|
|
|
|
+ reqData['Illustration'] = JSON.stringify(illustractionList)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // console.log("reqD....", reqData)
|
|
|
const result = await saveDynamicTbVal({ params: reqData, instId })
|
|
const result = await saveDynamicTbVal({ params: reqData, instId })
|
|
|
if (result?.code === 0 && result?.data) {
|
|
if (result?.code === 0 && result?.data) {
|
|
|
uni.showToast({ title: '保存成功', icon: 'success' })
|
|
uni.showToast({ title: '保存成功', icon: 'success' })
|
|
@@ -333,6 +411,7 @@ const handleTakePhotoFromRN = async (photoData: any) => {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
console.log('RN拍照数据:', photoData)
|
|
console.log('RN拍照数据:', photoData)
|
|
|
|
|
+ spreadDesignerRef.value?.handleTakePhotoData?.(photoData)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 调起RN相机
|
|
// 调起RN相机
|