feat: 设备

dev_ksck
chenhc 3 days ago
parent 77155ee977
commit 7f6670bc29

@ -295,7 +295,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=image2&name=' this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=device&name='
this.imgList = [] this.imgList = []
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -586,7 +586,7 @@ export default {
if (row.inspectImage.substr(-1) == ',') { if (row.inspectImage.substr(-1) == ',') {
row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1); row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -586,7 +586,7 @@ export default {
if (row.inspectImage.substr(-1) == ',') { if (row.inspectImage.substr(-1) == ',') {
row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1); row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -690,7 +690,7 @@ export default {
if (row.inspectImage.substr(-1) == ',') { if (row.inspectImage.substr(-1) == ',') {
row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1); row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -460,7 +460,7 @@ export default {
if (row.inspectImage.substr(-1) == ',') { if (row.inspectImage.substr(-1) == ',') {
row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1); row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -533,7 +533,7 @@ export default {
if (row.inspectImage.substr(-1) == ',') { if (row.inspectImage.substr(-1) == ',') {
row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1); row.inspectImage = row.inspectImage.slice(0, row.inspectImage.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.inspectImage, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -438,7 +438,7 @@ export default {
if(row.uploadImage.substr(-1) == ','){ if(row.uploadImage.substr(-1) == ','){
row.uploadImage=row.uploadImage.slice(0, row.uploadImage.length-1); row.uploadImage=row.uploadImage.slice(0, row.uploadImage.length-1);
} }
this.certFileUrl = this.BASE_URL +"/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL +"/udiwms/image/register/file/getImage?type=device&name=";
console.log(this.certFileUrl + "========"); console.log(this.certFileUrl + "========");
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.uploadImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.uploadImage, certFileUrl: this.certFileUrl}).then(response => {

@ -415,7 +415,7 @@ export default {
if (row.substr(-1) == ',') { if (row.substr(-1) == ',') {
row = row.slice(0, row.length - 1); row = row.slice(0, row.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
console.log(this.certFileUrl + "========"); console.log(this.certFileUrl + "========");
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row, certFileUrl: this.certFileUrl}).then(response => {

@ -400,7 +400,7 @@ export default {
if (row.uploadImage.substr(-1) == ',') { if (row.uploadImage.substr(-1) == ',') {
row.uploadImage = row.uploadImage.slice(0, row.uploadImage.length - 1); row.uploadImage = row.uploadImage.slice(0, row.uploadImage.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
console.log(this.certFileUrl + "========"); console.log(this.certFileUrl + "========");
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.uploadImage, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.uploadImage, certFileUrl: this.certFileUrl}).then(response => {

@ -346,7 +346,7 @@ export default {
if (row.substr(-1) == ',') { if (row.substr(-1) == ',') {
row = row.slice(0, row.length - 1); row = row.slice(0, row.length - 1);
} }
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
console.log(this.certFileUrl + "========"); console.log(this.certFileUrl + "========");
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row, certFileUrl: this.certFileUrl}).then(response => {

@ -307,7 +307,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.filePath, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.filePath, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -294,7 +294,7 @@ export default {
// //
showImgViewer(row) { showImgViewer(row) {
// URL // URL
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
// PDF // PDF

@ -289,9 +289,71 @@ export default {
this.getDeviceCertList() this.getDeviceCertList()
}, },
async showImgViewer(row) {
const BASE_API = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = [];
//
const files = row.filePath.split(',')
.map(path => path.trim())
.filter(Boolean);
//
const fileGroups = files.reduce((acc, file) => {
const type = file.split('.').pop().toLowerCase();
type === 'pdf' ? acc.pdf.push(file) : acc.images.push(file);
return acc;
}, { pdf: [], images: [] });
//
const imagePreviews = await Promise.all(
fileGroups.images.map(file =>
previewImage({
imageUrl: file,
certFileUrl: this.certFileUrl
}).then(res => res.code === 20000 ? res.data : null)
)
);
//
const validImages = imagePreviews.filter(Boolean);
if (validImages.length > 0) {
this.imgList = validImages;
this.imgViewerVisible = true;
this.lockScroll();
}
// PDFPDF
fileGroups.pdf.forEach(pdf => {
const pdfUrl = `${BASE_API}${encodeURIComponent(pdf)}`;
window.open(pdfUrl, '_blank', 'noopener');
});
},
// /
lockScroll() {
document.body.style.overflow = 'hidden';
const preventDefault = e => e.preventDefault();
document.addEventListener('touchmove', preventDefault, { passive: false });
this.__scrollHandler = preventDefault;
},
unlockScroll() {
document.body.style.overflow = '';
if (this.__scrollHandler) {
document.removeEventListener('touchmove', this.__scrollHandler);
}
},
//
closeImageViewer() {
this.imgViewerVisible = false;
this.unlockScroll();
},
// //
showImgViewer(row) { showImgViewer2(row) {
this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=image2&name=' this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=device&name='
this.imgList = [] this.imgList = []
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -297,41 +297,89 @@ export default {
}, },
// //
showImgViewer(row) { //
// URL async showImgViewer(row) {
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; //
this.certFileUrl = `${this.BASE_URL}/udiwms/image/register/file/getImage?type=device&name=`;
this.imgList = []; this.imgList = [];
// PDF //
const isPdf = row.filePath.toLowerCase().includes('.pdf'); const filePaths = row.filePath
if (isPdf) { .split(',')
// PDF .map(path => path.trim().replace(/[^\w\-.]/g, '')) //
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { .filter(Boolean);
if (response.code === 20000) {
// PDF //
this.imgList = response.data; const { pdfs, images } = filePaths.reduce((acc, file) => {
window.open(this.imgList, '_blank'); const extension = file.split('.').pop().toLowerCase();
// if (extension === 'pdf') {
// UI acc.pdfs.push(file);
this.imgViewerVisible = false; } else if (['png', 'jpg', 'jpeg'].includes(extension)) {
} acc.images.push(file);
}); }
} else { return acc;
// PDF }, { pdfs: [], images: [] });
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { //
this.imgList = response.data; if (images.length > 0) {
try {
const previewTasks = images.map(file =>
previewImage({
imageUrl: file,
certFileUrl: this.certFileUrl
}).then(res => res.code === 20000 ? res.data : null)
);
const validImages = (await Promise.all(previewTasks)).filter(Boolean);
if (validImages.length) {
this.imgList = validImages;
this.imgViewerVisible = true; this.imgViewerVisible = true;
// this.lockScroll();
const m = (e) => { }
e.preventDefault(); } catch (error) {
}; console.error('图片加载异常:', error);
document.body.style.overflow = 'hidden'; }
document.addEventListener("touchmove", m, false); }
// PDF
if (pdfs.length > 0) {
let popupAttempts = 0;
const openPdfWindow = (fileName, index) => {
const fullUrl = `${this.certFileUrl}${encodeURIComponent(fileName)}`;
const newWindow = window.open(fullUrl, `pdf_${Date.now()}`);
if (!newWindow || newWindow.closed) {
if (popupAttempts++ === 0) {
this.$confirm('检测到弹窗拦截请允许打开PDF', '提示', {
confirmButtonText: '立即允许',
cancelButtonText: '取消'
}).then(() => {
window.open(fullUrl, '_blank', 'noopener');
});
}
} else {
newWindow.focus();
} }
};
//
pdfs.forEach((file, index) => {
setTimeout(() => openPdfWindow(file, index), index * 300);
}); });
} }
}, },
//
lockScroll() {
document.documentElement.style.overflow = 'hidden';
document.documentElement.style.touchAction = 'none';
},
unlockScroll() {
document.documentElement.style.overflow = '';
document.documentElement.style.touchAction = '';
}
,
closeImgViewer() { closeImgViewer() {
this.imgViewerVisible = false this.imgViewerVisible = false
const m = (e) => { const m = (e) => {

@ -287,7 +287,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=image2&name=' this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=device&name='
this.imgList = [] this.imgList = []
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -299,7 +299,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.filePath, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.filePath, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -329,7 +329,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
this.imgList = []; this.imgList = [];
previewImage({imageUrl: row.filePath, certFileUrl: this.certFileUrl}).then(response => { previewImage({imageUrl: row.filePath, certFileUrl: this.certFileUrl}).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -287,7 +287,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=image2&name=' this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=device&name='
this.imgList = [] this.imgList = []
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -287,7 +287,7 @@ export default {
}, },
// //
showImgViewer(row) { showImgViewer(row) {
this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=image2&name=' this.certFileUrl = this.BASE_URL + '/udiwms/image/register/file/getImage?type=device&name='
this.imgList = [] this.imgList = []
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { if (response.code === 20000) {

@ -293,41 +293,90 @@ export default {
}, },
// //
showImgViewer(row) { //
// URL //
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; async showImgViewer(row) {
//
this.certFileUrl = `${this.BASE_URL}/udiwms/image/register/file/getImage?type=device&name=`;
this.imgList = []; this.imgList = [];
// PDF //
const isPdf = row.filePath.toLowerCase().includes('.pdf'); const filePaths = row.filePath
if (isPdf) { .split(',')
// PDF .map(path => path.trim().replace(/[^\w\-.]/g, '')) //
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => { .filter(Boolean);
if (response.code === 20000) {
// PDF //
this.imgList = response.data; const { pdfs, images } = filePaths.reduce((acc, file) => {
window.open(this.imgList, '_blank'); const extension = file.split('.').pop().toLowerCase();
// if (extension === 'pdf') {
// UI acc.pdfs.push(file);
this.imgViewerVisible = false; } else if (['png', 'jpg', 'jpeg'].includes(extension)) {
} acc.images.push(file);
}); }
} else { return acc;
// PDF }, { pdfs: [], images: [] });
previewImage({ imageUrl: row.filePath, certFileUrl: this.certFileUrl }).then(response => {
if (response.code === 20000) { //
this.imgList = response.data; if (images.length > 0) {
try {
const previewTasks = images.map(file =>
previewImage({
imageUrl: file,
certFileUrl: this.certFileUrl
}).then(res => res.code === 20000 ? res.data : null)
);
const validImages = (await Promise.all(previewTasks)).filter(Boolean);
if (validImages.length) {
this.imgList = validImages;
this.imgViewerVisible = true; this.imgViewerVisible = true;
// this.lockScroll();
const m = (e) => { }
e.preventDefault(); } catch (error) {
}; console.error('图片加载异常:', error);
document.body.style.overflow = 'hidden'; }
document.addEventListener("touchmove", m, false); }
// PDF
if (pdfs.length > 0) {
let popupAttempts = 0;
const openPdfWindow = (fileName, index) => {
const fullUrl = `${this.certFileUrl}${encodeURIComponent(fileName)}`;
const newWindow = window.open(fullUrl, `pdf_${Date.now()}`);
if (!newWindow || newWindow.closed) {
if (popupAttempts++ === 0) {
this.$confirm('检测到弹窗拦截请允许打开PDF', '提示', {
confirmButtonText: '立即允许',
cancelButtonText: '取消'
}).then(() => {
window.open(fullUrl, '_blank', 'noopener');
});
}
} else {
newWindow.focus();
} }
};
//
pdfs.forEach((file, index) => {
setTimeout(() => openPdfWindow(file, index), index * 300);
}); });
} }
}, },
//
lockScroll() {
document.documentElement.style.overflow = 'hidden';
document.documentElement.style.touchAction = 'none';
},
unlockScroll() {
document.documentElement.style.overflow = '';
document.documentElement.style.touchAction = '';
}
,
closeImgViewer() { closeImgViewer() {
this.imgViewerVisible = false; this.imgViewerVisible = false;
const m = (e) => { const m = (e) => {

@ -119,7 +119,7 @@
:on-success="uploadHandleSuccess" :on-success="uploadHandleSuccess"
:on-error="uploadHandleError" :on-error="uploadHandleError"
:file-list="fileList" :file-list="fileList"
:data="{type:'image2'}" :data="{type:'device'}"
:auto-upload="true"> :auto-upload="true">
<el-button slot="trigger" size="small" type="primary" :disabled="formData.auditStatus == 1"> <el-button slot="trigger" size="small" type="primary" :disabled="formData.auditStatus == 1">
{{ choiceFile }} {{ choiceFile }}
@ -351,7 +351,7 @@ export default {
}, },
toViewCompanyCert() { toViewCompanyCert() {
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name="; this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=device&name=";
window.open(this.certFileUrl + this.formData.filePath); window.open(this.certFileUrl + this.formData.filePath);
}, },
}, },

Loading…
Cancel
Save