Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
electron-printer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhuzhequan
electron-printer
Commits
5c58f588
Commit
5c58f588
authored
Jul 14, 2025
by
zhuzhequan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
扫码逻辑代码整理
parent
4e672b59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
130 deletions
+90
-130
src/views/design/head/index.vue
+89
-123
src/views/design/main/index.vue
+1
-7
No files found.
src/views/design/head/index.vue
View file @
5c58f588
...
...
@@ -297,6 +297,92 @@ export default {
let
res
=
await
this
.
$api
.
post
(
"/downloadByDesignId"
,
params
);
this
.
$message
.
success
(
res
.
msg
);
},
async
hasDesignImagesCanvasJsonList
(
designImagesCanvasJsonList
){
let
imageResList
=
[]
if
(
this
.
detail
.
adjustable
&&
designImagesCanvasJsonList
)
{
designImagesCanvasJsonList
=
JSON
.
parse
(
designImagesCanvasJsonList
);
if
(
designImagesCanvasJsonList
[
0
].
images
){
designImagesCanvasJsonList
.
forEach
((
el
)
=>
{
el
.
images
.
forEach
((
item
)
=>
{
imageResList
.
push
({
productionFile
:
item
,
title
:
el
.
title
});
});
});
}
else
{
let
imageList
=
await
this
.
canvasToImage
(
designImagesCanvasJsonList
);
let
fm
=
new
FormData
();
for
(
let
img
of
imageList
)
{
let
filename
=
uuid
.
v4
().
replace
(
"-"
,
""
)
+
".png"
;
fm
.
append
(
"files"
,
this
.
base64ToFile
(
img
,
filename
));
}
// console.log("fm", fm);
let
Sres
=
await
this
.
$api
.
post
(
"/saveToPng"
,
fm
);
Sres
.
data
.
forEach
((
item
,
i
)
=>
{
item
.
title
=
designImagesCanvasJsonList
[
i
].
options
.
title
;
item
.
productionFile
=
item
.
url
;
});
imageResList
=
Sres
.
data
;
}
}
if
(
!
imageResList
.
length
){
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let
res
=
await
this
.
$api
.
post
(
"/downloadBySubOrderNumber"
,
{
ids
:
[
this
.
detail
.
id
],
device
:
this
.
$store
.
state
.
desktopDevice
,
type
:
this
.
factoryType
,
});
if
(
res
.
data
.
length
===
0
)
return
this
.
$message
.
warning
(
"未找到素材图!"
);
this
.
imgList
=
[];
res
.
data
.
forEach
((
el
)
=>
{
imageResList
=
imageResList
.
concat
(
el
.
list
||
[]);
});
}
if
(
this
.
checked
)
{
imageResList
=
await
this
.
cutImgFn
(
imageResList
);
imageResList
.
forEach
((
el
)
=>
{
el
.
isCut
=
true
;
});
}
// 延迟后强制激活窗口
if
(
this
.
desktopDevice
!==
1
)
{
if
(
imageResList
.
length
)
{
let
pathUrl
=
imageResList
[
0
].
productionFile
;
setTimeout
(
async
()
=>
{
// await this.focusExplorerWindow(pathUrl);
const
pathParts
=
pathUrl
.
split
(
"
\
\"
);
pathParts.pop();
// 使用 join() 将剩余部分重新拼接成路径
const folderPath = pathParts.join("
\\
");
ipcRenderer.send("
select
-
files
", folderPath);
// 删除最后一个部分,即文件名
}, 500);
}
}else{
let obj = {
type: "
sendFile
",
value: imageResList.map((el, index) => {
el.designId = el.designId || index;
return el;
})
};
if (
this.detail.mssWidth &&
this.detail.adjustable &&
this.detail.mssHeight
) {
obj.size = {
width: this.detail.mssWidth,
height: this.detail.mssHeight
};
}
bus.$emit("
busEmit
", obj);
}
},
async getDataInfo() {
if (
this.detail &&
...
...
@@ -325,131 +411,11 @@ export default {
}
);
this.detail = findByPodProductionNo.data;
// console.log("detail111111", findByPodProductionNo);
let
imageResList
=
[];
this.imgList = [];
let
designImagesCanvasJsonList
=
this
.
detail
.
drParam
if
(
designImagesCanvasJsonList
)
{
designImagesCanvasJsonList
=
JSON
.
parse
(
designImagesCanvasJsonList
);
if
(
this
.
detail
.
adjustable
)
{
let
imageList
=
await
this
.
canvasToImage
(
designImagesCanvasJsonList
);
let
fm
=
new
FormData
();
for
(
let
img
of
imageList
)
{
let
filename
=
uuid
.
v4
().
replace
(
"-"
,
""
)
+
".png"
;
fm
.
append
(
"files"
,
this
.
base64ToFile
(
img
,
filename
));
}
// console.log("fm", fm);
let
Sres
=
await
this
.
$api
.
post
(
"/saveToPng"
,
fm
);
Sres
.
data
.
forEach
((
item
,
i
)
=>
{
item
.
title
=
designImagesCanvasJsonList
[
i
].
options
.
title
;
item
.
productionFile
=
item
.
url
;
});
imageResList
=
Sres
.
data
;
this
.
imgList
=
[];
if
(
this
.
checked
)
{
imageResList
=
await
this
.
cutImgFn
(
imageResList
);
imageResList
.
forEach
((
el
)
=>
{
el
.
isCut
=
true
;
});
}
}
else
{
this
.
imgList
=
[];
designImagesCanvasJsonList
.
forEach
((
el
)
=>
{
el
.
images
.
forEach
((
item
)
=>
{
this
.
imgList
.
push
({
productionFile
:
item
,
title
:
el
.
title
});
});
});
}
}
let designImagesCanvasJsonList = this.detail.drParam
await this.hasDesignImagesCanvasJsonList(designImagesCanvasJsonList);
this.$store.commit("
setProductDetail
", findByPodProductionNo.data);
ipcRenderer.send("
win
-
subScreen
", findByPodProductionNo.data);
if
(
imageResList
&&
imageResList
.
length
)
{
let
obj
=
{
type
:
"sendFile"
,
value
:
imageResList
.
map
((
el
,
index
)
=>
{
el
.
designId
=
el
.
designId
||
index
;
return
el
;
})
};
if
(
this
.
detail
.
mssWidth
&&
this
.
detail
.
adjustable
&&
this
.
detail
.
mssHeight
)
{
obj
.
size
=
{
width
:
this
.
detail
.
mssWidth
,
height
:
this
.
detail
.
mssHeight
};
}
bus
.
$emit
(
"busEmit"
,
obj
);
}
else
{
if
(
!
this
.
imgList
.
length
){
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let
res
=
await
this
.
$api
.
post
(
"/downloadBySubOrderNumber"
,
{
ids
:
[
this
.
detail
.
id
],
device
:
this
.
$store
.
state
.
desktopDevice
,
type
:
this
.
factoryType
,
});
if
(
res
.
data
.
length
===
0
)
return
this
.
$message
.
warning
(
"未找到素材图!"
);
res
.
data
.
forEach
((
el
)
=>
{
this
.
imgList
=
this
.
imgList
.
concat
(
el
.
list
||
[]);
});
}
// res.data = arr.filter((el) => el.type !== 1);
let
newImgList
;
if
(
this
.
imgList
.
length
)
if
(
this
.
checked
)
{
newImgList
=
await
this
.
cutImgFn
(
this
.
imgList
);
newImgList
.
forEach
((
el
)
=>
{
el
.
isCut
=
true
;
});
}
else
{
newImgList
=
this
.
imgList
;
}
// 延迟后强制激活窗口
if
(
this
.
desktopDevice
!==
1
)
{
if
(
this
.
imgList
.
length
)
{
let
pathUrl
=
this
.
imgList
[
0
].
productionFile
;
setTimeout
(
async
()
=>
{
// await this.focusExplorerWindow(pathUrl);
const
pathParts
=
pathUrl
.
split
(
"
\
\"
);
pathParts.pop();
// 使用 join() 将剩余部分重新拼接成路径
const folderPath = pathParts.join("
\\
");
ipcRenderer.send("
select
-
files
", folderPath);
// 删除最后一个部分,即文件名
}, 500);
}
} else {
console.log("
newImgList
", newImgList);
let obj = {
type: "
sendFile
",
value: newImgList.map((el, index) => {
el.designId = el.designId || index;
return el;
})
};
if (
this.detail.mssWidth &&
this.detail.adjustable &&
this.detail.mssHeight
) {
obj.size = {
width: this.detail.mssWidth,
height: this.detail.mssHeight
};
}
bus.$emit("
busEmit
", obj);
}
}
this.$dataStore.set("
production_no
", this.productionNo);
this.productionNo = "";
this.$refs.searchRef.focus();
...
...
@@ -556,7 +522,7 @@ export default {
console.log(347, store.state.desktopDevice);
},
async cutImgFn(arr) {
if (!arr.length) return;
if (!arr.length) return
arr
;
console.log(arr);
try {
...
...
src/views/design/main/index.vue
View file @
5c58f588
...
...
@@ -652,7 +652,6 @@ export default {
that
.
$nextTick
(
async
()
=>
{
let
w
=
bw
/
2
;
let
h
=
bh
/
2
;
let
width_px
,
height_px
,
rate
,
x
,
y
;
if
(
size
&&
!
files
[
i
].
isCut
)
{
width_px
=
that
.
WHproportion
*
mmToPx
(
size
.
width
);
...
...
@@ -1053,12 +1052,7 @@ export default {
});
break
;
case
"sendFile"
:
console
.
log
(
"sendFile"
);
if
(
size
)
{
this
.
hasSize
=
true
;
}
else
{
this
.
hasSize
=
false
;
}
this
.
hasSize
=
!!
size
;
this
.
detail
.
designImageSize
=
size
;
console
.
log
(
this
.
detail
,
"this.detail"
);
this
.
imgList
=
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment