2 Commits

Author SHA1 Message Date
caoyan 178f422dc5 山西前缀修改 2026-10-08 16:09:34 +08:00
caoyan f0da970904 上传下载 2026-09-03 13:53:54 +08:00
18 changed files with 235 additions and 448 deletions
+12 -7
View File
@@ -1,5 +1,6 @@
import myAxios from './axios'
const sx = process.env.VUE_APP_CITY_TYPE == 'sx' ? '/ferry_service/ferryController/conveyor' : ''
const sx = ''
// const sx = process.env.VUE_APP_CITY_TYPE == 'sx' ? '/ferry_service/ferryController/conveyor' : ''
// 查询客户基本信息分页列表
export function getUserInfo(params) {
@@ -150,27 +151,31 @@ export function getStatisticAPI(params) {
// 签名上传
export function uploadNoting(params) {
return myAxios({
url: '/portal/file/minio/upload',
url: `${sx}/energy-effcicency-net-service/nxzdUserFileNet/upload`,
method: 'POST',
params: params
params: params,
unEncrypted: true
})
}
//图片上传
// 注意:不能手动设置 Content-Type,否则浏览器不会自动生成 multipart boundary;
// 需 unEncrypted 跳过请求拦截器加密,FormData 不能被 JSON.stringify+SM4 替换
export function uploadFile(params) {
// console.log(params);
// console.log(decrypt(params));
return myAxios({
url: '/file/minio/upload',
url: `${sx}/energy-effcicency-net-service/nxzdUserFileNet/upload`,
method: 'POST',
data: params
data: params,
unEncrypted: true
})
}
//图片读取
export function downloadFile(attach_id) {
return myAxios({
url: '/file/minio/download',
url: `${sx}/energy-effcicency-net-service/nxzdUserFileNet/download/${attach_id}`,
method: 'POST',
params: attach_id
responseType: 'blob',
})
}
// 生成诊断报告
+1 -2
View File
@@ -10,8 +10,7 @@ module.exports = {
*/
sidebarLogo: true,
menuExclude: [],
downloadUrl: `${process.env.VUE_APP_BASE_API}/proxy-cq/file/minio/download/`,
uploadUrl: `${process.env.VUE_APP_BASE_API}/file/minio/upload/`,
downloadUrl: `${process.env.VUE_APP_BASE_API}/energy-effcicency-net-service/nxzdUserFileNet/download/`,
statusCode: {
SUCCESS: 0
},
+43
View File
@@ -183,4 +183,47 @@ export function fileDown (downLoadUrl, fileName, id,data) {
// console.log("fileDownloadCallback 下载文件 回调 " + JSON.stringify(obj));
// }
/**
* 通过 POST 接口下载图片并返回 blob URL
* @param {string} attach_id 文件ID
* @returns {Promise<string>} blob URL
*/
export async function getImageBlobUrl(attach_id) {
try {
const { downloadFile } = await import('@/api/api')
const blob = await downloadFile(attach_id)
if (blob instanceof Blob && blob.size > 0) {
const type = blob.type && blob.type.startsWith('image/') ? blob.type : 'image/jpeg'
const imgBlob = new Blob([blob], { type })
const url = URL.createObjectURL(imgBlob)
console.log('getImageBlobUrl ok: id=', attach_id, 'type=', blob.type, 'size=', blob.size, 'url=', url)
return url
}
console.error('getImageBlobUrl 无效响应: id=', attach_id, 'isBlob=', blob instanceof Blob, 'size=', blob && blob.size, 'type=', blob && blob.type)
return ''
} catch (e) {
console.error('getImageBlobUrl 请求失败: id=', attach_id, e)
return ''
}
}
/**
* 通过 POST 接口下载文件并触发浏览器保存
* 注意:后端返回的是文件流(Blob),浏览器不会自动下载,需手动触发
* @param {string} attachId 文件ID
* @param {string} [fileName] 保存的文件名(带后缀),缺省为 'download'
*/
export async function downloadFileById(attachId, fileName) {
const { downloadFile } = await import('@/api/api')
const blob = await downloadFile(attachId)
if (!(blob instanceof Blob)) return
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = fileName || 'download'
document.body.appendChild(a)
a.click()
a.remove()
URL.revokeObjectURL(url)
}
export default service
+12 -5
View File
@@ -133,7 +133,7 @@
<script>
// import reportHeader from './report-header.vue'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import { mapState,mapMutations } from 'vuex'
import { setTitle } from '@/utils/dsbridge.js'
import { Notify } from 'vant'
@@ -150,6 +150,7 @@ export default {
return {
signed: '',
signFile: '',
imageUrlData: null,
flagModule:false,
isState: false
// EnergyReportInfo: {}
@@ -157,6 +158,15 @@ export default {
}
},
// components: { reportHeader },
watch: {
async '$store.getters.imageUrl'(val) {
if (val) {
this.imageUrlData = await getImageBlobUrl(val)
} else {
this.imageUrlData = null
}
}
},
created() {
setTitle('节能改造措施')
this.getEnergyReportInfo()
@@ -187,10 +197,7 @@ export default {
return true
},
imageUrl() {
if(this.$store.getters.imageUrl) {
return `${downloadUrl}${this.$store.getters.imageUrl}`
}
return null
return this.imageUrlData
},
show() {
return localStorage.getItem('show') === 'true'
+21 -26
View File
@@ -104,7 +104,7 @@ import {
// chooseAlbumAndTakePhoto,
} from '@/utils/dsbridge'
import { insertPositionData, getPositionData } from '@/api/api.js'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import {debounce} from '@/utils/common.js'
export default {
components: {
@@ -143,33 +143,28 @@ export default {
},
methods: {
// 查询打卡记录
getHistory(){
async getHistory(){
this.text1 = []
getPositionData({taskId: this.taskId}).then(res => {
console.log(res.code , res.data);
if(res.code == 0&&res.data){
// for (const key in this.formData) {
// if (Object.hasOwnProperty.call(this.formData, key)) {
// this.formData[key] = res.data[key]
// }
// }
this.formData = res.data
if (res.data.fileId) {
this.$set(this.text1,0, {
fileName: res.data.fileName,
fileId: res.data.fileId,
url: `${downloadUrl}${res.data.fileId}`
})
console.log(this.text1);
}
this.$forceUpdate()
this.showSubmit = true
}else{
this.showSubmit = true
this.getLocation()
this.getAddress()
const res = await getPositionData({taskId: this.taskId})
console.log(res.code , res.data);
if(res.code == 0&&res.data){
this.formData = res.data
if (res.data.fileId) {
const blobUrl = await getImageBlobUrl(res.data.fileId)
this.$set(this.text1,0, {
fileName: res.data.fileName,
fileId: res.data.fileId,
url: blobUrl
})
console.log(this.text1);
}
})
this.$forceUpdate()
this.showSubmit = true
}else{
this.showSubmit = true
this.getLocation()
this.getAddress()
}
},
// 获取当前位置
getLocation() {
+17 -16
View File
@@ -301,7 +301,7 @@ import mixin from '@/mixins/mixin'
// import { Toast } from 'vant'
import { getCode } from '@/api/common.js'
import { addEnergyEquip } from '@/api/energyConsumption'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import { Notify } from 'vant';
import { getLocationMessage, getPosition, chooseAlbumAndTakePhoto } from '@/utils/dsbridge'
import Loading from '@/components/loading'
@@ -313,7 +313,6 @@ import {
getInfo,
uploadFile,
changeSaveStateAPI,
// downloadFile,
duplicateCheck,
} from '@/api/api.js'
// import { debuglog } from 'util'
@@ -841,16 +840,18 @@ export default {
return formData
},
// 上传图片调用原生的方法 获取到绝对路径调用getImageFileFromUrl
onUpload () {
chooseAlbumAndTakePhoto((data) => {
async onUpload () {
chooseAlbumAndTakePhoto(async (data) => {
// this.saveGreenComeData(data)
let d = 'data:image/jpeg;base64,' + data
this.fileIamge = d
let params = this.base64ToFile(d,new Date().getTime().toString())
uploadFile(params).then((res) => {
uploadFile(params).then(async (res) => {
if (res.code === 0) {
const blobUrl = await getImageBlobUrl(res.data.attach_id)
this.fileList.push({
url:`${downloadUrl}${res.data.attach_id}`
url: blobUrl,
isImage: true,
})
this.fileIds.push(res.data.attach_id)
}
@@ -1228,23 +1229,26 @@ export default {
// })
// this.form.files.map(path => ({ url: `${downloadUrl}${path}` }))
if (res.data.text1) {
const url1 = `${downloadUrl}${res.data.text1}`
const url1 = await getImageBlobUrl(res.data.text1)
this.fileList.push({
url: url1,
isImage: true,
})
this.fileIds.push(res.data.text1)
}
if (res.data.text2) {
const url2 = `${downloadUrl}${res.data.text2}`
const url2 = await getImageBlobUrl(res.data.text2)
this.fileList.push({
url: url2,
isImage: true,
})
this.fileIds.push(res.data.text2)
}
if (res.data.text3) {
const url3 = `${downloadUrl}${res.data.text3}`
const url3 = await getImageBlobUrl(res.data.text3)
this.fileList.push({
url: url3,
isImage: true,
})
this.fileIds.push(res.data.text3)
}
@@ -1789,14 +1793,11 @@ export default {
return true
},
delImg(detail) {
let url = ''
if(!detail.file) {
url = detail.url.split('download/')[1]
}
const index = this.fileList.findIndex((ele)=> ele == detail)
const index2 = this.fileIds.findIndex((ele)=> ele == url)
this.fileList.splice(index, 1)
this.fileIds.splice(index2, 1)
if (index > -1) {
this.fileList.splice(index, 1)
this.fileIds.splice(index, 1)
}
// console.log(this.fileList)
// console.log(this.fileIds)
// return new Promise((resolve, reject) => {
+4 -4
View File
@@ -99,7 +99,7 @@
import { getCurrentUserEvaluate, getCurrentUserEvaluateAdd } from '@/api/evaluateAndReply'
import { Notify } from 'vant'
import Loading from '@/components/loading'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import {debounce} from '@/utils/common.js'
export default {
name: 'userEvaluate',
@@ -142,7 +142,7 @@ export default {
try {
if (res.code == 0) {
if (res.data.list.length > 0) {
res.data.list.forEach((v) => {
for (const v of res.data.list) {
if(v.nxzdEvaluateReplyDTOS && v.nxzdEvaluateReplyDTOS.length > 0) {
v.show = true
v.showTextArea = false
@@ -152,9 +152,9 @@ export default {
v.message = ''
}
if(v.image) {
v.image = `${downloadUrl}${v.image}`
v.image = await getImageBlobUrl(v.image)
}
})
}
this.list = res.data.list
this.reportLevel = res.data.list[0]
this.levelName(this.reportLevel.reportValue)
+12 -20
View File
@@ -125,7 +125,7 @@ import { pumpList, pumpRemove, enterprisGetInfo, enterprisEdit, enterprisAdd } f
import { Notify } from "vant";
import Uploader from '@/views/facilityManage/common-vue/uploader.vue'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
// import Header from "@/components/headerNew";
import {debounce} from '@/utils/common.js'
@@ -200,7 +200,7 @@ export default {
},
//安卓会调用的方法
onUpload(data, type) {
this[type] = [data[0].url]
this[type] = [data[0].fileId]
},
delImg(file, detail, type) {
@@ -242,21 +242,15 @@ export default {
}
if(this.text1.length > 0 && this.text1[0] instanceof Object) {
this.text1 = [this.text1[0].url.split('download/')[1]]
} else if(this.text1.length > 0 && this.text1[0].split('download/').length > 1) {
this.text1 = [this.text1[0].split('download/')[1]]
this.text1 = [this.text1[0].fileId]
}
if(this.text2.length > 0 && this.text2[0] instanceof Object) {
this.text2 = [this.text2[0].url.split('download/')[1]]
} else if(this.text2.length > 0 && this.text2[0].split('download/').length > 1) {
this.text2 = [this.text2[0].split('download/')[1]]
this.text2 = [this.text2[0].fileId]
}
if(this.text3.length > 0 && this.text3[0] instanceof Object) {
this.text3 = [this.text3[0].url.split('download/')[1]]
} else if(this.text3.length > 0 && this.text3[0].split('download/').length > 1) {
this.text3 = [this.text3[0].split('download/')[1]]
this.text3 = [this.text3[0].fileId]
}
const text = this.text1.concat(this.text2, this.text3)
@@ -266,14 +260,9 @@ export default {
//判断是否为对象格式
ifObj(imgList) {
console.log(imgList,'imgList');
imgList.forEach((v) => {
if(v instanceof Object && v.url.split('download/').length > 1) {
v.url = v.url.split('download/')[1]
}
})
const list = imgList.map((ele)=>{
if(ele instanceof Object) {
return ele.url
return ele.fileId
}
return ele
})
@@ -331,19 +320,22 @@ export default {
if(res.data.text2) {
if(res.data.text2.split(',')[0] != 0) {
this.text1.push({
url:`${downloadUrl}${res.data.text2.split(',')[0]}`
fileId: res.data.text2.split(',')[0],
url: await getImageBlobUrl(res.data.text2.split(',')[0])
})
}
if(res.data.text2.split(',')[1] != 0) {
this.text2.push({
url:`${downloadUrl}${res.data.text2.split(',')[1]}`
fileId: res.data.text2.split(',')[1],
url: await getImageBlobUrl(res.data.text2.split(',')[1])
})
}
if(res.data.text2.split(',')[2] != 0) {
this.text3.push({
url:`${downloadUrl}${res.data.text2.split(',')[2]}`
fileId: res.data.text2.split(',')[2],
url: await getImageBlobUrl(res.data.text2.split(',')[2])
})
}
+17 -15
View File
@@ -313,7 +313,7 @@ import { reformList, reformRemove } from '@/api/universalEnergy.js'
import { Notify } from 'vant'
import { formatymd } from '@/utils/timeUtil.js'
import { getLocationMessage, chooseAlbumAndTakePhoto } from '@/utils/dsbridge'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import {debounce} from '@/utils/common.js'
export default {
components: {
@@ -488,18 +488,20 @@ export default {
return true
},
// 上传图片调用原生的方法 获取到绝对路径调用getImageFileFromUrl
onUpload () {
async onUpload () {
console.log('进入chooseAlbumAndTakePhoto方法')
chooseAlbumAndTakePhoto((data) => {
chooseAlbumAndTakePhoto(async (data) => {
// this.saveGreenComeData(data)
let d = 'data:image/jpeg;base64,' + data
console.log('data', d);
this.fileIamge = d
let params = this.base64ToFile(d,new Date().getTime().toString())
uploadFile(params).then((res) => {
uploadFile(params).then(async (res) => {
if (res.code === 0) {
const blobUrl = await getImageBlobUrl(res.data.attach_id)
this.fileList.push({
url:`${downloadUrl}${res.data.attach_id}`
url: blobUrl,
isImage: true,
})
this.fileIds.push(res.data.attach_id)
}
@@ -508,14 +510,11 @@ export default {
})
},
delImg(detail) {
let url = ''
if(!detail.file) {
url = detail.url.split('download/')[1]
}
const index = this.fileList.findIndex((ele)=> ele == detail)
const index2 = this.fileIds.findIndex((ele)=> ele == url)
this.fileList.splice(index, 1)
this.fileIds.splice(index2, 1)
if (index > -1) {
this.fileList.splice(index, 1)
this.fileIds.splice(index, 1)
}
},
updateUserStatus() {
const params = {
@@ -661,23 +660,26 @@ export default {
}
this.address = res.data.address
if (res.data.text1) {
const url1 = `${downloadUrl}${res.data.text1}`
const url1 = await getImageBlobUrl(res.data.text1)
this.fileList.push({
url: url1,
isImage: true,
})
this.fileIds.push(res.data.text1)
}
if (res.data.text2) {
const url2 = `${downloadUrl}${res.data.text2}`
const url2 = await getImageBlobUrl(res.data.text2)
this.fileList.push({
url: url2,
isImage: true,
})
this.fileIds.push(res.data.text2)
}
if (res.data.text3) {
const url3 = `${downloadUrl}${res.data.text3}`
const url3 = await getImageBlobUrl(res.data.text3)
this.fileList.push({
url: url3,
isImage: true,
})
this.fileIds.push(res.data.text3)
}
+12 -20
View File
@@ -119,7 +119,7 @@ import { fanList, fanRemove, enterprisGetInfo, enterprisEdit, enterprisAdd } fro
import { Notify } from "vant";
import Uploader from '@/views/facilityManage/common-vue/uploader.vue'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import {debounce} from '@/utils/common.js'
// import Header from "@/components/headerNew";
@@ -201,7 +201,7 @@ export default {
},
//安卓会调用的方法
onUpload(data, type) {
this[type] = [data[0].url]
this[type] = [data[0].fileId]
},
delImg(file, detail, type) {
@@ -243,21 +243,15 @@ export default {
}
if(this.text1.length > 0 && this.text1[0] instanceof Object) {
this.text1 = [this.text1[0].url.split('download/')[1]]
} else if(this.text1.length > 0 && this.text1[0].split('download/').length > 1) {
this.text1 = [this.text1[0].split('download/')[1]]
this.text1 = [this.text1[0].fileId]
}
if(this.text2.length > 0 && this.text2[0] instanceof Object) {
this.text2 = [this.text2[0].url.split('download/')[1]]
} else if(this.text2.length > 0 && this.text2[0].split('download/').length > 1) {
this.text2 = [this.text2[0].split('download/')[1]]
this.text2 = [this.text2[0].fileId]
}
if(this.text3.length > 0 && this.text3[0] instanceof Object) {
this.text3 = [this.text3[0].url.split('download/')[1]]
} else if(this.text3.length > 0 && this.text3[0].split('download/').length > 1) {
this.text3 = [this.text3[0].split('download/')[1]]
this.text3 = [this.text3[0].fileId]
}
const text = this.text1.concat(this.text2, this.text3)
@@ -266,14 +260,9 @@ export default {
//判断是否为对象格式
ifObj(imgList) {
imgList.forEach((v) => {
if(v instanceof Object && v.url.split('download/').length > 1) {
v.url = v.url.split('download/')[1]
}
})
const list = imgList.map((ele)=>{
if(ele instanceof Object) {
return ele.url
return ele.fileId
}
return ele
})
@@ -334,19 +323,22 @@ export default {
if(res.data.text3) {
if(res.data.text3.split(',')[0] != 0) {
this.text1.push({
url:`${downloadUrl}${res.data.text3.split(',')[0]}`
fileId: res.data.text3.split(',')[0],
url: await getImageBlobUrl(res.data.text3.split(',')[0])
})
}
if(res.data.text3.split(',')[1] != 0) {
this.text2.push({
url:`${downloadUrl}${res.data.text3.split(',')[1]}`
fileId: res.data.text3.split(',')[1],
url: await getImageBlobUrl(res.data.text3.split(',')[1])
})
}
if(res.data.text3.split(',')[2] != 0) {
this.text3.push({
url:`${downloadUrl}${res.data.text3.split(',')[2]}`
fileId: res.data.text3.split(',')[2],
url: await getImageBlobUrl(res.data.text3.split(',')[2])
})
}
if(res.data.text1) {
+12 -20
View File
@@ -125,7 +125,7 @@ import {
import { distributeList, distributeRemove, enterprisGetInfo, enterprisEdit, enterprisAdd } from "@/api/universalEnergy.js";
import { Notify } from "vant";
import Uploader from '@/views/facilityManage/common-vue/uploader.vue'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
// import Header from "@/components/headerNew";
import {debounce} from '@/utils/common.js'
@@ -242,7 +242,7 @@ export default {
},
//安卓会调用的方法
onUpload(data, type) {
this[type] = [data[0].url]
this[type] = [data[0].fileId]
},
delImg(file, detail, type) {
@@ -285,21 +285,15 @@ export default {
if(this.text1.length > 0 && this.text1[0] instanceof Object) {
this.text1 = [this.text1[0].url.split('download/')[1]]
} else if(this.text1.length > 0 && this.text1[0].split('download/').length > 1) {
this.text1 = [this.text1[0].split('download/')[1]]
this.text1 = [this.text1[0].fileId]
}
if(this.text2.length > 0 && this.text2[0] instanceof Object) {
this.text2 = [this.text2[0].url.split('download/')[1]]
} else if(this.text2.length > 0 && this.text2[0].split('download/').length > 1) {
this.text2 = [this.text2[0].split('download/')[1]]
this.text2 = [this.text2[0].fileId]
}
if(this.text3.length > 0 && this.text3[0] instanceof Object) {
this.text3 = [this.text3[0].url.split('download/')[1]]
} else if(this.text3.length > 0 && this.text3[0].split('download/').length > 1) {
this.text3 = [this.text3[0].split('download/')[1]]
this.text3 = [this.text3[0].fileId]
}
@@ -308,14 +302,9 @@ export default {
},
//判断是否为对象格式
ifObj(imgList) {
imgList.forEach((v) => {
if(v instanceof Object && v.url.split('download/').length > 1) {
v.url = v.url.split('download/')[1]
}
})
const list = imgList.map((ele)=>{
if(ele instanceof Object) {
return ele.url
return ele.fileId
}
return ele
})
@@ -371,19 +360,22 @@ export default {
if(res.data.text1) {
if(res.data.text1.split(',')[0] != 0) {
this.text1.push({
url:`${downloadUrl}${res.data.text1.split(',')[0]}`
fileId: res.data.text1.split(',')[0],
url: await getImageBlobUrl(res.data.text1.split(',')[0])
})
}
if(res.data.text1.split(',')[1] != 0) {
this.text2.push({
url:`${downloadUrl}${res.data.text1.split(',')[1]}`
fileId: res.data.text1.split(',')[1],
url: await getImageBlobUrl(res.data.text1.split(',')[1])
})
}
if(res.data.text1.split(',')[2] != 0) {
this.text3.push({
url:`${downloadUrl}${res.data.text1.split(',')[2]}`
fileId: res.data.text1.split(',')[2],
url: await getImageBlobUrl(res.data.text1.split(',')[2])
})
}
if(res.data.text2) {
+12 -21
View File
@@ -122,7 +122,7 @@ import { airList, airRemove, enterprisGetInfo, enterprisEdit, enterprisAdd } fro
import { Notify } from "vant";
import Uploader from '@/views/facilityManage/common-vue/uploader.vue'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
// import Header from "@/components/headerNew"
import {debounce} from '@/utils/common.js'
export default {
@@ -203,8 +203,7 @@ export default {
},
//安卓会调用的方法
onUpload(data, type) {
this[type] = [data[0].url]
this[type] = [data[0].fileId]
},
delImg(file, detail, type) {
@@ -246,21 +245,15 @@ export default {
}
if(this.text1.length > 0 && this.text1[0] instanceof Object) {
this.text1 = [this.text1[0].url.split('download/')[1]]
} else if(this.text1.length > 0 && this.text1[0].split('download/').length > 1) {
this.text1 = [this.text1[0].split('download/')[1]]
this.text1 = [this.text1[0].fileId]
}
if(this.text2.length > 0 && this.text2[0] instanceof Object) {
this.text2 = [this.text2[0].url.split('download/')[1]]
} else if(this.text2.length > 0 && this.text2[0].split('download/').length > 1) {
this.text2 = [this.text2[0].split('download/')[1]]
this.text2 = [this.text2[0].fileId]
}
if(this.text3.length > 0 && this.text3[0] instanceof Object) {
this.text3 = [this.text3[0].url.split('download/')[1]]
} else if(this.text3.length > 0 && this.text3[0].split('download/').length > 1) {
this.text3 = [this.text3[0].split('download/')[1]]
this.text3 = [this.text3[0].fileId]
}
const text = this.text1.concat(this.text2, this.text3)
@@ -269,14 +262,9 @@ export default {
//判断是否为对象格式
ifObj(imgList) {
imgList.forEach((v) => {
if(v instanceof Object && v.url.split('download/').length > 1) {
v.url = v.url.split('download/')[1]
}
})
const list = imgList.map((ele)=>{
if(ele instanceof Object) {
return ele.url
return ele.fileId
}
return ele
})
@@ -334,19 +322,22 @@ export default {
if(res.data.text4) {
if(res.data.text4.split(',')[0] != 0) {
this.text1.push({
url:`${downloadUrl}${res.data.text4.split(',')[0]}`
fileId: res.data.text4.split(',')[0],
url: await getImageBlobUrl(res.data.text4.split(',')[0])
})
}
if(res.data.text4.split(',')[1] != 0) {
this.text2.push({
url:`${downloadUrl}${res.data.text4.split(',')[1]}`
fileId: res.data.text4.split(',')[1],
url: await getImageBlobUrl(res.data.text4.split(',')[1])
})
}
if(res.data.text4.split(',')[2] != 0) {
this.text3.push({
url:`${downloadUrl}${res.data.text4.split(',')[2]}`
fileId: res.data.text4.split(',')[2],
url: await getImageBlobUrl(res.data.text4.split(',')[2])
})
}
@@ -144,7 +144,7 @@ import { pureDigital } from '../pattern'
import VanPickerNew from "@/components/vanPickerNew";
import Year from "../common-vue/year.vue";
import mixin from "@/mixins/mixin";
import { downloadUrl } from "@/settings";
import { getImageBlobUrl } from "@/utils/index";
import Uploader from "../common-vue/uploader.vue";
import btnUploader from "../common-vue/btnUploader.vue";
@@ -642,19 +642,19 @@ export default {
}
},
//图片回显展示
picShow(formList, name) {
async picShow(formList, name) {
console.log(formList,name);
const picList = formList.map((ele) => {
if (ele.split(`${downloadUrl}`).length > 1) {
const picList = await Promise.all(formList.map(async (ele) => {
if (ele.startsWith('blob:')) {
return {
url: ele,
};
}
ele = `${downloadUrl}${ele}`;
const blobUrl = await getImageBlobUrl(ele);
return {
url: ele,
url: blobUrl,
};
});
}));
switch (name) {
case "ktExter":
@@ -826,7 +826,7 @@ export default {
if (this.exteriorImage1.length > 0) {
this.form1.exteriorImage = this.exteriorImage1.map((ele) => {
if (ele.url) {
return ele = ele.url.split('download/')[1]
return ele.fileId || ele
} else {
return ele
}
@@ -835,7 +835,7 @@ export default {
if (this.tagImage1.length > 0) {
this.form1.tagImage = this.tagImage1.map((ele) => {
if (ele.url) {
return ele = ele.url.split('download/')[1]
return ele.fileId || ele
} else {
return ele
}
@@ -844,7 +844,7 @@ export default {
if (this.markImage1.length > 0) {
this.form1.markImage = this.markImage1.map((ele) => {
if (ele.url) {
return ele = ele.url.split('download/')[1]
return ele.fileId || ele
} else {
return ele
}
@@ -1,215 +0,0 @@
<template>
<!-- :after-read="afterRead" -->
<!-- :after-read="afterRead" -->
<van-uploader
v-model="fileList"
:disabled="disableImg"
multiple
:deletable="deletable"
:max-count="1"
:before-read="beforeRead"
:afterRead="afterRead"
:before-delete="delImg"
@click-upload="onUpload"
accept="image/*"
>
<div class="uploader" >
<van-icon name="plus" class="uploader-icon" />
</div>
</van-uploader>
</template>
<script>
import { uploadFile } from '@/api/api.js'
import { chooseAlbumAndTakePhoto } from '@/utils/dsbridge'
import { downloadUrl } from '@/settings'
import { addWaterMarker } from '@/utils/marker'
import { Base64ToFile } from '@/utils/base64'
export default {
props: {
type: {
type: String,
default: '',
},
value: {
type: Array,
default: () => [],
},
deletable: {
type: Boolean,
default: true,
},
},
data() {
return {
disableImg: false,
fileList: this.value,
activTimer: null,
}
},
mounted() {
this.activTimer = setTimeout(() => {
this.fileList = this.value
}, 200)
},
beforeDestroy() {
clearTimeout(this.activTimer)
this.fileList = []
},
methods: {
base64ToFile(data, fileName) {
const dataArr = data.split(',')
const byteString = window.atob(dataArr[1])
const options = {
type: 'image/jpeg',
endings: 'native',
}
const u8Arr = new Uint8Array(byteString.length)
for (let i = 0; i < byteString.length; i++) {
u8Arr[i] = byteString.charCodeAt(i)
}
let formData = new FormData()
let fileOfBlob = new File([u8Arr], fileName + '.jpg', options) //返回文件流
formData.append('file', fileOfBlob)
return formData
},
// 上传图片调用原生的方法 获取到绝对路径调用getImageFileFromUrl
onUpload() {
this.fileList= []
console.log('--------chooseAlbumAndTakePhoto---', 'onUpload')
chooseAlbumAndTakePhoto(async (data) => {
console.log('--------onUpload---', data)
let d = 'data:image/jpeg;base64,' + data
this.fileIamge = d
// let params = this.base64ToFile(d, new Date().getTime().toString())
// console.log('--------params---', params)
let img = Base64ToFile(d,'image/jpeg',new Date().getTime().toString() + ".jpg")
console.log('-------------------------onUpload---', img);
let blob = await addWaterMarker(img, 'image')
console.log('-------------------------blob---', blob);
let params = new FormData()
let file = new File([blob], img.name)
params.append('file', file)
console.log('-------------------------file---', file);
const res = await uploadFile(params)
console.log('--------res---', res)
if (res.code == 0) {
this.fileList.push({
fileName: res.data.original_name,
fileId: res.data.attach_id,
url: `${downloadUrl}${res.data.attach_id}`,
})
this.$emit('onUpload', this.fileList, this.type)
}
})
},
async afterRead(file) {
this.fileList= []
this.disableImg = true
let params = new FormData()
params.append('file', file.file)
console.log(file.file)
console.log(params)
// console.log(decryptParseToJSON(a),77777777);
const res = await uploadFile(params)
if (res.code == 0) {
this.disableImg = false
this.fileList.push({
fileName: res.data.original_name,
fileId: res.data.attach_id,
url: `${downloadUrl}${res.data.attach_id}`,
})
this.$emit('onUpload', this.fileList, this.type)
// this.$emit('afterRead', res.data, this.type)
}else{
this.disableImg = false
}
return true
},
beforeRead(img) {
if(!img){
return
}
return new Promise(async(resolve, reject) => {
let blob = await addWaterMarker(img, 'blob')
blob.name = img.name
let file = new File([blob], img.name)
resolve(file)
})
}, //压缩图片
compressFiles(fileObj) {
let type = fileObj.type
return new Promise((resolve, reject) => {
let reader = new FileReader()
reader.readAsDataURL(fileObj)
reader.onload = function (e) {
let image = new Image() //新建一个img标签(不嵌入DOM节点,仅做canvas操作)
image.src = e.target.result //让该标签加载base64格式的原图
image.onload = function () {
//图片加载完毕后再通过canvas压缩图片,否则图片还没加载完就压缩,结果图片是全黑的
let canvas = document.createElement('canvas'), //创建一个canvas元素
context = canvas.getContext('2d'), //context相当于画笔,里面有各种可以进行绘图的API
imageWidth = image.width / 2, //压缩后图片的宽度,这里设置为缩小一半
imageHeight = image.height / 2, //压缩后图片的高度,这里设置为缩小一半
data = '' //存储压缩后的图片
canvas.width = imageWidth //设置绘图的宽度
canvas.height = imageHeight //设置绘图的高度
//使用drawImage重新设置img标签中的图片大小,实现压缩。drawImage方法的参数可以自行查阅W3C
context.drawImage(image, 0, 0, imageWidth, imageHeight)
//使用toDataURL将canvas上的图片转换为base64格式
data = canvas.toDataURL(type)
canvas.toBlob(function (blob) {
const f = new File([blob], fileObj.name, { type })
resolve(f)
}, type)
}
}
})
},
delImg(file, detail) {
this.fileList.splice(detail.index, 1)
this.$emit('delImg', file, detail, this.type)
},
checkImgisUpload(list) {
if (this.fileList && list && this.fileList.length == list.length) {
return false
} else {
return true
}
},
},
}
</script>
<style lang='less' scoped>
/deep/ .van-uploader__preview-image {
padding: 10px;
box-sizing: border-box;
background: #fff;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
border-radius: 10px;
margin-left: 20px;
margin-top: 10px;
}
/deep/ .van-uploader__preview-delete {
margin-top: 10px;
}
.uploader {
width: 2.133333rem;
height: 2.133333rem;
background: #f7f7f7;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
margin: 10px 0 10px 20px;
.uploader-icon {
font-size: 30px;
color: #ababab;
}
}
</style>
@@ -21,7 +21,7 @@
<script>
import { uploadFile } from '@/api/api.js'
import { chooseAlbumAndTakePhoto } from '@/utils/dsbridge'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
export default {
props: {
type: {
@@ -41,17 +41,23 @@ export default {
data() {
return {
disableImg: false,
fileList: this.value,
activTimer: null,
fileList: [],
}
},
mounted() {
this.activTimer = setTimeout(() => {
this.fileList = this.value
}, 200)
watch: {
// 父组件异步回填(如历史记录 getHistory 晚于 mounted)时同步列表;
// 上传后父组件把 value 改写为 [url字符串] 时不覆盖本地回显
value: {
handler(val) {
if (val && val.length && val.every(item => typeof item === 'object')) {
this.fileList = val.map(item => ({ ...item, isImage: true }))
}
},
immediate: true,
deep: true,
},
},
beforeDestroy() {
clearTimeout(this.activTimer)
this.fileList = []
},
methods: {
@@ -83,10 +89,14 @@ export default {
const res = await uploadFile(params)
console.log('--------res---', res)
if (res.code == 0) {
const blobUrl = await getImageBlobUrl(res.data.attach_id)
console.log('--------回显 blobUrl---', blobUrl)
if (!blobUrl) return
this.fileList.push({
fileName: res.data.original_name,
fileId: res.data.attach_id,
url: `${downloadUrl}${res.data.attach_id}`,
url: blobUrl,
isImage: true,
})
this.$emit('onUpload', this.fileList, this.type)
}
@@ -130,7 +130,7 @@ import mixin from '@/mixins/mixin'
import Uploader from '../common-vue/uploader.vue'
import Radio from '../common-vue/radio.vue'
import { dataMode } from '../common'
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import { pureDigital } from '../pattern'
import btnUploader from "../common-vue/btnUploader.vue";
@@ -330,29 +330,29 @@ export default {
console.log(this.edgl, this.hyl);
if (this.form.exteriorImage) {
const list = this.form.exteriorImage.split(',')
this.exteriorImage = list.map((ele) => {
this.exteriorImage = await Promise.all(list.map(async (ele) => {
return {
url: `${downloadUrl}${ele}`,
url: await getImageBlobUrl(ele),
}
})
}))
console.log(this.exteriorImage,'123')
}
if (this.form.tagImage) {
const list = this.form.tagImage.split(',')
this.tagImage = list.map((ele) => {
this.tagImage = await Promise.all(list.map(async (ele) => {
return {
url: `${downloadUrl}${ele}`,
url: await getImageBlobUrl(ele),
}
})
}))
console.log(this.tagImage)
}
if (this.form.markImage) {
const list = this.form.markImage.split(',')
this.markImage = list.map((ele) => {
this.markImage = await Promise.all(list.map(async (ele) => {
return {
url: `${downloadUrl}${ele}`,
url: await getImageBlobUrl(ele),
}
})
}))
console.log(this.markImage)
}
} else {
@@ -537,14 +537,9 @@ export default {
},
//判断是否为对象格式
ifObj(imgList) {
imgList.forEach((v) => {
if(v instanceof Object && v.url.split('download/').length > 1) {
v.url = v.url.split('download/')[1]
}
})
const list = imgList.map((ele)=>{
if(ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
+8 -36
View File
@@ -592,28 +592,19 @@ export default {
if(this.commonForm.nxzdRefrigeSystemDTO.length > 0) {
this.commonForm.nxzdRefrigeSystemDTO.forEach((v) => {
if (v.exteriorImage && v.exteriorImage instanceof Array) {
v.exteriorImage.forEach((ev) => {
if (ev.url && ev.url.split('download/').length > 1) {
ev.url = ev.url.split('download/')[1]
}
})
const list = v.exteriorImage.map((ele) => {
if (ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
v.exteriorImage = list.join(',')
}
if (v.tagImage && v.tagImage instanceof Array) {
v.tagImage.forEach((ev) => {
if (ev.url && ev.url.split('download/').length > 1) {
ev.url = ev.url.split('download/')[1]
}
})
const list1 = v.tagImage.map((ele) => {
if (ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
@@ -621,14 +612,9 @@ export default {
}
if (v.markImage && v.markImage instanceof Array) {
v.markImage.forEach((ev) => {
if (ev.url && ev.url.split('download/').length > 1) {
ev.url = ev.url.split('download/')[1]
}
})
const list2 = v.markImage.map((ele) => {
if (ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
@@ -641,28 +627,19 @@ export default {
if(this.commonForm.nxzdHeatSystemDTO.length > 0) {
this.commonForm.nxzdHeatSystemDTO.forEach((v)=> {
if (v.exteriorImage && v.exteriorImage instanceof Array) {
v.exteriorImage.forEach((ev) => {
if (ev.url && ev.url.split('download/').length > 1) {
ev.url = ev.url.split('download/')[1]
}
})
const list = v.exteriorImage.map((ele) => {
if (ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
v.exteriorImage = list.join(',')
}
if (v.tagImage && v.tagImage instanceof Array) {
v.tagImage.forEach((ev) => {
if (ev.url && ev.url.split('download/').length > 1) {
ev.url = ev.url.split('download/')[1]
}
})
const list1 = v.tagImage.map((ele) => {
if (ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
@@ -670,14 +647,9 @@ export default {
}
if (v.markImage && v.markImage instanceof Array) {
v.markImage.forEach((ev) => {
if (ev.url && ev.url.split('download/').length > 1) {
ev.url = ev.url.split('download/')[1]
}
})
const list2 = v.markImage.map((ele) => {
if (ele instanceof Object) {
return ele.url
return ele.fileId || ele.url
}
return ele
})
+12 -6
View File
@@ -169,7 +169,7 @@
</template>
<script>
import { downloadUrl } from '@/settings'
import { getImageBlobUrl } from '@/utils/index'
import commonTitle from './components/commonTitle.vue'
import electro from './components/electro.vue'
import refrom from './components/refrom.vue'
@@ -197,6 +197,7 @@ export default {
data() {
return {
signFile: '',
imageUrlData: null,
signedtwo: '',
value1: '',
loading2: false,
@@ -228,6 +229,15 @@ export default {
Loading
},
watch: {
async signFile(val) {
if (val) {
this.imageUrlData = await getImageBlobUrl(val)
} else {
this.imageUrlData = null
}
}
},
mounted() {
window.outputPdf = this.outputPdf
this.userLevel()
@@ -247,11 +257,7 @@ export default {
return true
},
imageUrl() {
console.log(this.signFile);
if(this.signFile) {
return `${downloadUrl}${this.signFile}`
}
return null
return this.imageUrlData
},
reportYear() {
if (this.EnergyReportInfo.reportYear) {