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
f3919697
Commit
f3919697
authored
Apr 29, 2025
by
zhuzhequan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加自动打印逻辑
parent
f487e64e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
137 deletions
+91
-137
print/Input/15faacbd-667d-4972-8102-6ae7502c42dd.png
+0
-0
print/Input/85ba8d14-4d14-4087-a00f-eef94a71c137.png
+0
-0
src/server/entity/function.js
+45
-18
src/server/routes/index.js
+3
-0
src/views/design/head/index.vue
+0
-0
src/views/design/main/index.vue
+43
-119
No files found.
print/Input/15faacbd-667d-4972-8102-6ae7502c42dd.png
deleted
100644 → 0
View file @
f487e64e
184 KB
print/Input/85ba8d14-4d14-4087-a00f-eef94a71c137.png
deleted
100644 → 0
View file @
f487e64e
This diff is collapsed.
Click to expand it.
src/server/entity/function.js
View file @
f3919697
...
@@ -2,12 +2,12 @@ import {
...
@@ -2,12 +2,12 @@ import {
downloadImage
,
downloadImage
,
downloadOtherImage
,
downloadOtherImage
,
toSend
,
toSend
,
writeProfileXml
,
writeProfileXml
}
from
"@/server/utils"
;
}
from
"@/server/utils"
;
const
{
const
{
cropImageTransparentEdges
,
cropImageTransparentEdges
,
cropTransparentEdges
,
cropTransparentEdges
,
processImages
,
processImages
}
=
require
(
"../utils/setImage"
);
}
=
require
(
"../utils/setImage"
);
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
{
returnLogFilePath
}
from
"../utils/log"
;
import
{
returnLogFilePath
}
from
"../utils/log"
;
...
@@ -15,13 +15,11 @@ var request = require("request");
...
@@ -15,13 +15,11 @@ var request = require("request");
const
compressing
=
require
(
"compressing"
);
const
compressing
=
require
(
"compressing"
);
const
uuid
=
require
(
"uuid"
);
const
uuid
=
require
(
"uuid"
);
const
path
=
require
(
"path"
);
const
path
=
require
(
"path"
);
const
fs
=
require
(
"fs"
);
const
fs
=
require
(
"fs"
);
const
os
=
require
(
"os"
);
const
os
=
require
(
"os"
);
const
{
app
}
=
require
(
"electron"
);
const
{
app
}
=
require
(
"electron"
);
let
fileEnv
,
env
,
visionUrl
;
let
fileEnv
,
env
,
visionUrl
;
axios
.
defaults
.
timeout
=
12600000
;
axios
.
defaults
.
timeout
=
12600000
;
const
multiparty
=
require
(
"multiparty"
);
const
multiparty
=
require
(
"multiparty"
);
function
readEnv
()
{
function
readEnv
()
{
...
@@ -74,7 +72,7 @@ export default {
...
@@ -74,7 +72,7 @@ export default {
const
token
=
req
.
headers
[
"jwt-token"
];
const
token
=
req
.
headers
[
"jwt-token"
];
try
{
try
{
let
{
let
{
data
,
data
}
=
await
axios
.
post
(
}
=
await
axios
.
post
(
`
${
env
}
/factory/podJomallOrder/downloadByProduction`
,
`
${
env
}
/factory/podJomallOrder/downloadByProduction`
,
[
req
.
body
[
0
]],
[
req
.
body
[
0
]],
...
@@ -83,27 +81,27 @@ export default {
...
@@ -83,27 +81,27 @@ export default {
let
files
=
[];
let
files
=
[];
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
files
=
data
.
data
;
files
=
data
.
data
;
files
=
files
.
map
(
(
el
)
=>
{
files
=
files
.
map
(
el
=>
{
return
{
url
:
`
${
fileEnv
}${
el
}
`
};
return
{
url
:
`
${
fileEnv
}${
el
}
`
};
});
});
// res.json({ code: 200, data: "" });
// res.json({ code: 200, data: "" });
// return;
// return;
if
(
req
.
body
[
1
]
===
1
)
{
if
(
req
.
body
[
1
]
===
1
)
{
downloadImage
(
files
)
downloadImage
(
files
)
.
then
(
(
data
)
=>
{
.
then
(
data
=>
{
res
.
json
({
code
:
200
,
data
});
res
.
json
({
code
:
200
,
data
});
})
})
.
catch
(
(
err
)
=>
{
.
catch
(
err
=>
{
res
.
json
({
code
:
500
,
msg
:
err
});
res
.
json
({
code
:
500
,
msg
:
err
});
});
});
}
else
{
}
else
{
downloadOtherImage
(
files
)
downloadOtherImage
(
files
)
.
then
(
(
data
)
=>
{
.
then
(
data
=>
{
console
.
log
(
77
,
data
);
console
.
log
(
77
,
data
);
res
.
json
({
code
:
200
,
data
});
res
.
json
({
code
:
200
,
data
});
})
})
.
catch
(
(
err
)
=>
{
.
catch
(
err
=>
{
res
.
json
({
code
:
500
,
msg
:
err
});
res
.
json
({
code
:
500
,
msg
:
err
});
});
});
}
}
...
@@ -123,7 +121,7 @@ export default {
...
@@ -123,7 +121,7 @@ export default {
`
${
env
}
/factory/podJomallOrderProduct/getSubOrderByThirdSubOrderNumber`
,
`
${
env
}
/factory/podJomallOrderProduct/getSubOrderByThirdSubOrderNumber`
,
{
{
params
:
q
,
params
:
q
,
headers
:
{
"jwt-token"
:
token
}
,
headers
:
{
"jwt-token"
:
token
}
}
}
);
);
res
.
json
(
data
);
res
.
json
(
data
);
...
@@ -147,7 +145,7 @@ export default {
...
@@ -147,7 +145,7 @@ export default {
const
token
=
req
.
headers
[
"jwt-token"
];
const
token
=
req
.
headers
[
"jwt-token"
];
try
{
try
{
let
{
let
{
data
,
data
}
=
await
axios
.
post
(
}
=
await
axios
.
post
(
`
${
env
}
/factory/podJomallOrderProduct/completeDelivery`
,
`
${
env
}
/factory/podJomallOrderProduct/completeDelivery`
,
req
.
body
,
req
.
body
,
...
@@ -180,7 +178,7 @@ export default {
...
@@ -180,7 +178,7 @@ export default {
console
.
log
(
"success"
);
console
.
log
(
"success"
);
res
.
json
({
res
.
json
({
code
:
200
,
code
:
200
,
msg
:
q
.
productionNo
+
".zip"
+
"已下载到桌面"
,
msg
:
q
.
productionNo
+
".zip"
+
"已下载到桌面"
});
});
})
})
.
on
(
"error"
,
()
=>
{
.
on
(
"error"
,
()
=>
{
...
@@ -222,8 +220,8 @@ export default {
...
@@ -222,8 +220,8 @@ export default {
code
:
200
,
code
:
200
,
data
:
{
data
:
{
fileName
,
fileName
,
url
:
path
.
join
(
process
.
cwd
(),
"./print/Input/"
+
fileName
)
,
url
:
path
.
join
(
process
.
cwd
(),
"./print/Input/"
+
fileName
)
}
,
}
});
});
}
}
});
});
...
@@ -275,10 +273,10 @@ export default {
...
@@ -275,10 +273,10 @@ export default {
console
.
log
(
249
,
body
);
console
.
log
(
249
,
body
);
toSend
(
body
)
toSend
(
body
)
.
then
(
(
r
)
=>
{
.
then
(
r
=>
{
res
.
send
({
code
:
200
,
msg
:
"操作成功"
});
res
.
send
({
code
:
200
,
msg
:
"操作成功"
});
})
})
.
catch
(
(
err
)
=>
{
.
catch
(
err
=>
{
res
.
send
({
code
:
500
,
msg
:
err
});
res
.
send
({
code
:
500
,
msg
:
err
});
});
});
},
},
...
@@ -317,7 +315,7 @@ export default {
...
@@ -317,7 +315,7 @@ export default {
fs
.
unlinkSync
(
from
);
fs
.
unlinkSync
(
from
);
res
.
json
({
code
:
200
,
msg
:
"更新成功"
});
res
.
json
({
code
:
200
,
msg
:
"更新成功"
});
})
})
.
catch
(
(
err
)
=>
{
.
catch
(
err
=>
{
res
.
json
({
code
:
500
,
msg
:
err
.
message
});
res
.
json
({
code
:
500
,
msg
:
err
.
message
});
});
});
});
});
...
@@ -358,4 +356,33 @@ export default {
...
@@ -358,4 +356,33 @@ export default {
res
.
json
({
code
:
500
,
msg
:
err
.
message
});
res
.
json
({
code
:
500
,
msg
:
err
.
message
});
}
}
},
},
saveToPng
:
async
(
req
,
res
)
=>
{
try
{
const
p
=
path
.
join
(
process
.
cwd
(),
"./print/Input/"
);
const
form
=
new
multiparty
.
Form
({
uploadDir
:
p
});
form
.
parse
(
req
,
function
(
err
,
fields
,
files
)
{
console
.
log
(
fields
,
files
,
err
);
if
(
err
)
{
res
.
send
({
code
:
500
,
err
});
}
else
{
let
list
=
[];
files
.
files
.
forEach
(
file
=>
{
let
fileName
=
uuid
.
v4
()
+
".png"
;
fs
.
renameSync
(
file
.
path
,
path
.
join
(
p
,
fileName
));
list
.
push
({
fileName
,
url
:
path
.
join
(
process
.
cwd
(),
"./print/Input/"
+
fileName
)
});
});
res
.
json
({
code
:
200
,
data
:
list
});
}
});
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
json
({
code
:
500
,
msg
:
err
});
}
}
};
};
src/server/routes/index.js
View file @
f3919697
...
@@ -37,4 +37,7 @@ router.post("/imageListTransparentEdges", fn.imageListTransparentEdges);
...
@@ -37,4 +37,7 @@ router.post("/imageListTransparentEdges", fn.imageListTransparentEdges);
// 处理图片并输出结果
// 处理图片并输出结果
router
.
post
(
"/processImage"
,
fn
.
processImage
);
router
.
post
(
"/processImage"
,
fn
.
processImage
);
// 保存生成后得图片返回地址
router
.
post
(
"/saveToPng"
,
fn
.
saveToPng
);
export
{
router
as
default
};
export
{
router
as
default
};
src/views/design/head/index.vue
View file @
f3919697
This diff is collapsed.
Click to expand it.
src/views/design/main/index.vue
View file @
f3919697
...
@@ -226,10 +226,7 @@ export default {
...
@@ -226,10 +226,7 @@ export default {
productDetail
(
newValue
)
{
productDetail
(
newValue
)
{
this
.
detail
=
{
...
newValue
};
this
.
detail
=
{
...
newValue
};
if
(
typeof
this
.
detail
.
imageAry
==
"string"
)
{
if
(
typeof
this
.
detail
.
imageAry
==
"string"
)
{
this
.
detail
.
imageAry
=
JSON
.
parse
(
this
.
detail
.
imageAry
).
map
((
el
)
=>
{
this
.
detail
.
imageAry
=
JSON
.
parse
(
this
.
detail
.
imageAry
).
filter
(
el
=>
el
.
title
)
if
(
!
el
.
title
)
el
.
title
=
1
;
return
el
;
});
const
otherArr
=
this
.
detail
.
imageAry
.
filter
((
el
)
=>
el
.
title
==
1
);
const
otherArr
=
this
.
detail
.
imageAry
.
filter
((
el
)
=>
el
.
title
==
1
);
this
.
detail
.
AimageAry
=
[
this
.
detail
.
AimageAry
=
[
...
this
.
detail
.
imageAry
.
filter
((
el
)
=>
el
.
title
===
"正"
),
...
this
.
detail
.
imageAry
.
filter
((
el
)
=>
el
.
title
===
"正"
),
...
@@ -366,12 +363,21 @@ export default {
...
@@ -366,12 +363,21 @@ export default {
return
mm1
.
width
;
return
mm1
.
width
;
},
},
setDesignImg
(
title
){
let
img
=
this
.
selectImgList
.
find
(
it
=>
it
.
title
===
title
)
if
(
img
){
console
.
log
(
this
.
detail
.
designImageSize
,
'this.detail.size'
);
this
.
getBackFile
({
files
:
[
img
]
,
size
:
this
.
detail
.
designImageSize
},
(
file
)
=>
{
this
.
imgHistoryList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
)));
});
}
},
selectImg
(
it
,
i
)
{
selectImg
(
it
,
i
)
{
// this.selectImgIndexList.push(i)
// this.selectImgIndexList.push(i)
let
item
=
this
.
imgList
.
find
((
img
)
=>
img
.
fileName
===
it
.
fileName
);
let
item
=
this
.
imgList
.
find
((
img
)
=>
img
.
fileName
===
it
.
fileName
);
if
(
item
)
return
;
if
(
item
)
return
;
// this.selectImgIndexList = Array.from(new Set(this.selectImgIndexList))
// this.selectImgIndexList = Array.from(new Set(this.selectImgIndexList))
this
.
getBackFile
({
files
:
[
it
]
},
(
file
)
=>
{
this
.
getBackFile
({
files
:
[
it
]
,
size
:
null
},
(
file
)
=>
{
this
.
imgHistoryList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
)));
this
.
imgHistoryList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
)));
});
});
},
},
...
@@ -526,18 +532,27 @@ export default {
...
@@ -526,18 +532,27 @@ export default {
};
};
});
});
},
},
getComputedName
(
title
){
let
img
=
this
.
selectImgList
.
find
(
it
=>
it
.
title
===
title
)
return
img
?.
fileName
},
getComputedTitle
(
title
){
console
.
log
(
this
.
selectImgList
,
'this.selectImgList'
);
let
img
=
this
.
selectImgList
.
find
(
it
=>
it
.
title
===
title
)
return
img
?.
url
},
getBackFile
({
files
,
size
},
callback
)
{
getBackFile
({
files
,
size
},
callback
)
{
let
that
=
this
;
let
that
=
this
;
let
bw
=
document
.
getElementById
(
"line"
).
clientWidth
;
let
bw
=
window
.
getComputedStyle
(
document
.
getElementsByClassName
(
'grid'
)[
0
]).
width
bw
=
Number
(
bw
.
replace
(
'px'
,
''
))
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
{
files
[
i
].
url
=
files
[
i
].
productionFile
;
files
[
i
].
url
=
files
[
i
].
productionFile
||
files
[
i
].
url
that
.
$nextTick
(
async
()
=>
{
that
.
$nextTick
(
async
()
=>
{
let
w
=
document
.
getElementById
(
"line"
).
clientWidth
/
2
;
let
w
=
bw
/
2
;
let
width_px
,
height_px
,
rate
;
let
width_px
,
height_px
,
rate
;
if
(
size
)
{
if
(
size
)
{
width_px
=
mmToPx
(
size
.
width
);
width_px
=
mmToPx
(
size
.
width
);
height_px
=
mmToPx
(
size
.
height
);
height_px
=
mmToPx
(
size
.
height
);
console
.
log
(
width_px
,
height_px
,
"w,h"
);
rate
=
height_px
/
width_px
;
rate
=
height_px
/
width_px
;
}
else
{
}
else
{
let
data
=
await
that
.
getImageSize
(
files
[
i
].
url
);
let
data
=
await
that
.
getImageSize
(
files
[
i
].
url
);
...
@@ -783,17 +798,19 @@ export default {
...
@@ -783,17 +798,19 @@ export default {
});
});
break
;
break
;
case
"sendFile"
:
case
"sendFile"
:
console
.
log
(
'sendFile'
);
if
(
size
){
if
(
size
){
this
.
hasSize
=
true
this
.
hasSize
=
true
}
else
{
}
else
{
this
.
hasSize
=
false
this
.
hasSize
=
false
}
}
this
.
imgList
=
[];
this
.
detail
.
designImageSize
=
size
this
.
imgList
=
[]
this
.
selectIndex
=
-
1
;
this
.
selectIndex
=
-
1
;
if
(
value
.
length
>
0
)
{
if
(
value
.
length
>
0
)
{
this
.
selectImgList
=
value
;
this
.
selectImgList
=
value
;
this
.
selectImgIndex
=
0
;
this
.
selectImgIndex
=
0
;
this
.
getBackFile
({
files
:
[
value
[
0
]],
size
},
(
file
)
=>
{
this
.
getBackFile
({
files
:
[
value
[
0
]],
size
:
this
.
detail
.
designImageSize
||
null
},
(
file
)
=>
{
this
.
imgHistoryList
.
push
(
this
.
imgHistoryList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
))
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
))
);
);
...
@@ -845,113 +862,20 @@ export default {
...
@@ -845,113 +862,20 @@ export default {
>
>
</div>
</div>
</div>
</div>
<el-table
border
:data=
"detail.imageAry"
>
<el-row
class=
"main"
>
<el-table-column
label=
"打印区域"
prop=
"title"
></el-table-column>
<el-col
:span=
"6"
>
<el-table-column
label=
"效果图"
prop=
"title"
>
<div
class=
"text-center"
>
打印区域
</div>
<template
slot-scope=
"
{row}">
</el-col>
<img
class=
"full-width"
:src=
"row.url"
alt=
""
/>
</
template
>
<el-col
:span=
"9"
class=
"effectPic border-col"
>
</el-table-column>
<div
class=
"pic-title"
>
效果图
</div>
<el-table-column
label=
"素材图"
prop=
"title"
>
</el-col>
<
template
slot-scope=
"{row}"
>
<img
style=
"cursor: pointer"
@
click=
"setDesignImg(row.title)"
v-if=
"getComputedTitle(row.title)"
class=
"full-width"
:src=
"getComputedTitle(row.title)"
alt=
""
/>
<el-col
:span=
"9"
>
<span>
{{
getComputedName
(
row
.
title
)
}}
</span>
<div
class=
"pic-title"
>
素材图
</div>
</
template
>
</el-col>
</el-table-column>
</el-table>
<el-row
class=
"border-row"
>
<el-col
:span=
"6"
class=
"text-center"
><div>
A面
</div></el-col>
<el-col
:span=
"9"
class=
"border-col text-center"
>
<el-carousel
v-if=
"detail.AimageAry?.length"
height=
"170px"
:autoplay=
"false"
indicator-position=
"none"
style=
"width: 100%;"
>
<el-carousel-item
v-for=
"(item, index) in detail.AimageAry"
:key=
"index"
>
<img
class=
"full-width"
:src=
"item.url"
alt=
""
/>
</el-carousel-item>
</el-carousel>
<div
v-else
>
</div>
</el-col>
<el-col
:span=
"9"
style=
"overflow: hidden;align-items: stretch;flex-grow: 1"
>
<el-checkbox-group
v-if=
"selectImgList.length"
v-model=
"checkList"
>
<el-checkbox
:label=
"selectImgList[0]"
:class=
"
{
imgchecked: checkList.includes(selectImgList[0]),
}"
>
<div
class=
"img-item"
@
click
.
stop
.
prevent=
"selectImg(selectImgList[0], 0)"
>
<img
style=
"width: 140px"
:src=
"selectImgList[0].productionFile"
/>
<span>
{{
selectImgList
[
0
].
designId
}}
</span>
</div>
</el-checkbox>
</el-checkbox-group>
</el-col>
</el-row>
<el-row
class=
"border-row"
>
<el-col
:span=
"6"
class=
"text-center"
><div>
B面
</div></el-col>
<el-col
:span=
"9"
class=
"border-col text-center"
>
<el-carousel
v-if=
"detail.BimageAry?.length"
height=
"170px"
:autoplay=
"false"
indicator-position=
"none"
style=
"width: 100%;"
>
<el-carousel-item
v-for=
"(item, index) in detail.BimageAry"
:key=
"index"
>
<img
class=
"full-width"
:src=
"item.url"
alt=
""
/>
</el-carousel-item>
</el-carousel>
<div
v-else
>
</div>
</el-col>
<el-col
:span=
"9"
style=
"overflow: hidden;"
>
<el-checkbox-group
v-if=
"selectImgList.length > 1"
v-model=
"checkList"
>
<el-checkbox
:label=
"selectImgList[1]"
:class=
"
{
imgchecked: checkList.includes(selectImgList[1]),
}"
>
<div
class=
"img-item"
@
click
.
stop
.
prevent=
"selectImg(selectImgList[1], 1)"
>
<img
style=
"width: 140px"
:src=
"selectImgList[1].productionFile"
/>
<span>
{{
selectImgList
[
1
].
designId
}}
</span>
</div>
</el-checkbox>
</el-checkbox-group>
</el-col>
</el-row>
</el-row>
</div>
</div>
<div
class=
"product-information"
>
<div
class=
"product-information"
>
<div
class=
"title"
>
<div
class=
"title"
>
...
@@ -1224,7 +1148,7 @@ export default {
...
@@ -1224,7 +1148,7 @@ export default {
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"print-tip"
v-if=
"
i
mgList.length"
>
<div
class=
"print-tip"
v-if=
"
detail && detail.designImageSize && selectI
mgList.length"
>
<b
style=
"color: green"
v-if=
"hasSize "
>
该生产单无需拖动设计,直接打印
</b>
<b
style=
"color: green"
v-if=
"hasSize "
>
该生产单无需拖动设计,直接打印
</b>
<b
style=
"color: red"
v-else
>
该生产单需要拖动设计打印
</b>
<b
style=
"color: red"
v-else
>
该生产单需要拖动设计打印
</b>
</div>
</div>
...
...
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