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
09ed996b
Commit
09ed996b
authored
Apr 21, 2025
by
linjinhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试提交
parent
8814bdc9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
168 additions
and
71 deletions
+168
-71
.gitignore
+8
-2
logs/2025-04-19/print.json
+0
-0
src/server/entity/function.js
+29
-10
src/server/utils/index.js
+87
-16
src/views/design/detail/index.vue
+27
-29
src/views/design/head/index.vue
+14
-13
src/views/design/main/index.vue
+3
-1
No files found.
.gitignore
View file @
09ed996b
...
...
@@ -22,4 +22,10 @@ yarn-error.log*
*.sw?
#Electron-builder output
/dist_electron
\ No newline at end of file
/dist_electron
# 排除 print/Input 目录下的 .bat 文件
!/print/Input/*.bat
print/Profile/*
/logs
\ No newline at end of file
logs/2025-04-19/print.json
View file @
09ed996b
This diff is collapsed.
Click to expand it.
src/server/entity/function.js
View file @
09ed996b
import
{
downloadImage
,
toSend
,
writeProfileXml
}
from
"@/server/utils"
;
import
{
downloadImage
,
downloadOtherImage
,
toSend
,
writeProfileXml
,
}
from
"@/server/utils"
;
import
axios
from
"axios"
;
import
{
returnLogFilePath
}
from
"../utils/log"
;
var
request
=
require
(
"request"
);
...
...
@@ -57,13 +62,16 @@ export default {
}
},
downloadBySubOrderNumber
:
async
(
req
,
res
)
=>
{
console
.
log
(
66
,
req
.
body
);
const
params
=
[...
req
.
body
];
params
.
pop
();
const
token
=
req
.
headers
[
"jwt-token"
];
try
{
let
{
data
,
}
=
await
axios
.
post
(
`
${
env
}
/factory/podJomallOrder/downloadByProduction`
,
req
.
body
,
params
,
{
headers
:
{
"jwt-token"
:
token
}
}
);
let
files
=
[];
...
...
@@ -72,15 +80,26 @@ export default {
files
=
files
.
map
((
el
)
=>
{
return
{
url
:
`
${
fileEnv
}${
el
}
`
};
});
downloadImage
(
files
)
.
then
((
data
)
=>
{
console
.
log
(
77
,
data
);
res
.
json
({
code
:
200
,
data
});
})
.
catch
((
err
)
=>
{
res
.
json
({
code
:
500
,
msg
:
err
});
});
if
(
req
.
body
[
1
]
===
1
)
{
downloadImage
(
files
)
.
then
((
data
)
=>
{
res
.
json
({
code
:
200
,
data
});
})
.
catch
((
err
)
=>
{
res
.
json
({
code
:
500
,
msg
:
err
});
});
}
else
{
downloadOtherImage
(
files
)
.
then
((
data
)
=>
{
console
.
log
(
77
,
data
);
res
.
json
({
code
:
200
,
data
});
})
.
catch
((
err
)
=>
{
res
.
json
({
code
:
500
,
msg
:
err
});
});
}
}
else
{
res
.
json
(
data
);
}
...
...
src/server/utils/index.js
View file @
09ed996b
...
...
@@ -48,6 +48,79 @@ function zip(from, to) {
export
const
downloadImage
=
(
list
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
// console.log("Formatted Folder Name:", folderName); // 检查替换结果
let
dirPath
=
path
.
join
(
process
.
cwd
(),
`./print/Input/`
);
console
.
log
(
64
,
dirPath
);
if
(
!
fs
.
existsSync
(
dirPath
))
{
fs
.
mkdirSync
(
dirPath
);
}
let
count
=
0
;
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
if
(
list
[
i
].
url
&&
list
[
i
].
url
.
includes
(
"http"
))
{
let
fileName
=
""
;
let
type
=
2
;
let
flag
=
[
".zip"
,
".gzip"
,
".tar"
,
".taz"
,
".rar"
,
".7z"
,
".gz"
,
".bz2"
,
].
filter
((
el
)
=>
list
[
i
].
url
.
toLowerCase
().
includes
(
el
)).
length
>
0
;
if
(
flag
)
{
fileName
=
list
[
i
].
url
.
split
(
"/"
)[
list
[
i
].
url
.
split
(
"/"
).
length
-
1
];
type
=
1
;
}
else
{
fileName
=
uuid
.
v4
()
+
".png"
;
type
=
2
;
}
let
p
=
path
.
join
(
process
.
cwd
(),
"./print/Input/"
+
fileName
);
let
stream
=
fs
.
createWriteStream
(
p
);
request
(
list
[
i
].
url
)
.
pipe
(
stream
)
.
on
(
"close"
,
async
function
()
{
if
(
type
===
1
)
{
list
[
i
].
list
=
await
zip
(
p
,
dirPath
);
if
(
count
===
list
.
length
-
1
)
{
resolve
(
list
);
}
}
else
{
if
(
!
list
[
i
].
list
)
list
[
i
].
list
=
[];
const
filename
=
list
[
i
].
url
.
split
(
"/"
)[
list
[
i
].
url
.
split
(
"/"
).
length
-
1
];
list
[
i
].
list
.
push
({
fileName
,
productionFile
:
p
,
designId
:
filename
.
split
(
"_GCPS"
)[
0
],
});
}
if
(
count
===
list
.
length
-
1
)
{
// console.log(list);
resolve
(
list
);
}
count
++
;
});
}
}
}
catch
(
err
)
{
console
.
log
(
err
);
reject
(
err
);
}
});
};
export
function
downloadOtherImage
(
list
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
const
currentDate
=
new
Date
();
// 将 UTC 时间转换为中国时间 (UTC + 8小时)
...
...
@@ -66,15 +139,14 @@ export const downloadImage = (list) => {
.
split
(
"T"
)[
1
]
.
replace
(
/:/g
,
"-"
)
.
split
(
"."
)[
0
];
console
.
log
(
"Formatted Folder Name:"
,
folderName
);
// 检查替换结果
// let dirPath = path.join(process.cwd(), `./print/Input/`);
let
dirPath
=
path
.
join
(
process
.
cwd
(),
`./print/Input/
${
folderName
}
`
);
console
.
log
(
64
,
dirPath
);
if
(
!
fs
.
existsSync
(
dirPath
))
{
fs
.
mkdirSync
(
dirPath
);
let
otherTypePath
=
path
.
join
(
process
.
cwd
(),
`./print/Input/
${
folderName
}
`
);
if
(
!
fs
.
existsSync
(
otherTypePath
))
{
fs
.
mkdirSync
(
otherTypePath
);
}
let
count
=
0
;
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
if
(
list
[
i
].
url
&&
list
[
i
].
url
.
includes
(
"http"
))
{
...
...
@@ -100,14 +172,13 @@ export const downloadImage = (list) => {
fileName
=
uuid
.
v4
()
+
".png"
;
type
=
2
;
}
let
p
=
path
.
join
(
dirPath
,
fileName
);
// 保存到新文件夹
// let p = path.join(process.cwd(), "./print/Input/" + fileName);
let
stream
=
fs
.
createWriteStream
(
p
);
let
otherP
=
path
.
join
(
otherTypePath
,
fileName
);
// 保存到新文件夹
let
otherstream
=
fs
.
createWriteStream
(
otherP
);
request
(
list
[
i
].
url
)
.
pipe
(
stream
)
.
pipe
(
other
stream
)
.
on
(
"close"
,
async
function
()
{
if
(
type
===
1
)
{
list
[
i
].
list
=
await
zip
(
p
,
dir
Path
);
list
[
i
].
list
=
await
zip
(
otherP
,
otherType
Path
);
if
(
count
===
list
.
length
-
1
)
{
resolve
(
list
);
}
...
...
@@ -118,12 +189,12 @@ export const downloadImage = (list) => {
];
list
[
i
].
list
.
push
({
fileName
,
productionFile
:
p
,
productionFile
:
otherP
,
designId
:
filename
.
split
(
"_GCPS"
)[
0
],
});
}
if
(
count
===
list
.
length
-
1
)
{
console
.
log
(
list
);
//
console.log(list);
resolve
(
list
);
}
count
++
;
...
...
@@ -135,7 +206,7 @@ export const downloadImage = (list) => {
reject
(
err
);
}
});
}
;
}
// 传递素材给前端
export
const
sendImg
=
(
filename
=
"sample.png"
)
=>
{
...
...
src/views/design/detail/index.vue
View file @
09ed996b
...
...
@@ -21,7 +21,7 @@ export default {
isAutoSure
:
false
,
currentStatus
:
"IN_PRODUCTION"
,
detail
:
{
imgList
:
[]
imgList
:
[]
,
},
dialogVisible
:
false
,
audios
:
{
...
...
@@ -29,10 +29,10 @@ export default {
weight_success
:
require
(
`../../../assets/audio/weight_success.mp3`
),
weight_repeat
:
require
(
`../../../assets/audio/weight_repeat.mp3`
),
weight_search_error
:
require
(
`../../../assets/audio/weight_search_error.mp3`
),
weight_search_success
:
require
(
`../../../assets/audio/weight_search_success.mp3`
)
weight_search_success
:
require
(
`../../../assets/audio/weight_search_success.mp3`
)
,
},
productInfo
:
{},
TrackingNumber
:
""
TrackingNumber
:
""
,
};
},
methods
:
{
...
...
@@ -46,7 +46,7 @@ export default {
{
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
type
:
"warning"
,
}
).
then
(()
=>
{
this
.
setData
();
...
...
@@ -62,11 +62,11 @@ export default {
let
data
=
this
.
currentStatus
==
"IN_PRODUCTION"
?
{
id
:
this
.
detail
.
id
id
:
this
.
detail
.
id
,
}
:
{
list
:
[
this
.
detail
],
...
this
.
shipForm
...
this
.
shipForm
,
};
if
(
data
.
list
)
{
data
.
list
[
0
].
note
=
...
...
@@ -93,26 +93,26 @@ export default {
}
let
params
=
{
productionNo
:
this
.
detail
.
podProductionNo
,
method
:
"POST"
method
:
"POST"
,
};
if
(
data
===
1
)
{
params
=
{
...
params
,
...{
designId
}
designId
,
}
,
};
}
else
if
(
data
===
2
)
{
params
=
{
...
params
,
...{
negativeDesignId
:
designId
}
negativeDesignId
:
designId
,
}
,
};
}
downloadFile
(
"podDesignCenter/downloadByDesignId"
,
params
)
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
const
{
data
,
fileName
}
=
res
;
let
url
=
window
.
URL
.
createObjectURL
(
data
);
// 生成一个a标签
...
...
@@ -124,7 +124,7 @@ export default {
link
.
click
();
window
.
URL
.
revokeObjectURL
(
url
);
})
.
catch
(
err
=>
{
.
catch
(
(
err
)
=>
{
console
.
log
(
err
);
});
},
...
...
@@ -174,26 +174,26 @@ export default {
if
(
!
d
.
imageAry
)
{
arr
=
[
{
url
:
d
.
variantImage
,
title
:
"正面"
,
id
:
d
.
designId
},
{
url
:
d
.
negativeImage
,
title
:
"反面"
,
id
:
d
.
negativeDesignId
}
].
filter
(
el
=>
el
.
url
);
{
url
:
d
.
negativeImage
,
title
:
"反面"
,
id
:
d
.
negativeDesignId
}
,
].
filter
(
(
el
)
=>
el
.
url
);
}
else
{
arr
=
typeof
d
.
imageAry
==
"string"
?
JSON
.
parse
(
d
.
imageAry
)
:
d
.
imageAry
;
arr
=
arr
.
concat
([
{
url
:
d
.
negativeImage
,
title
:
"反面"
,
id
:
d
.
negativeDesignId
}
{
url
:
d
.
negativeImage
,
title
:
"反面"
,
id
:
d
.
negativeDesignId
}
,
]);
}
const
result
=
[];
console
.
log
(
arr
);
arr
=
arr
.
filter
(
el
=>
el
.
url
);
arr
=
arr
.
map
(
el
=>
{
arr
=
arr
.
filter
(
(
el
)
=>
el
.
url
);
arr
=
arr
.
map
(
(
el
)
=>
{
return
{
...
el
,
...{
url
:
el
.
url
.
includes
(
"http"
)
?
el
.
url
:
window
.
location
.
origin
+
"/upload/erp"
+
el
.
url
}
:
window
.
location
.
origin
+
"/upload/erp"
+
el
.
url
,
}
,
};
});
...
...
@@ -224,8 +224,8 @@ export default {
}
});
}
}
}
}
,
}
,
};
</
script
>
...
...
@@ -311,10 +311,7 @@ export default {
{{
detail
?.
userMark
}}
</p>
</div>
<div
:title=
"String(detail?.factoryOrderNumber)"
class=
"div-item"
>
<div
:title=
"String(detail?.factoryOrderNumber)"
class=
"div-item"
>
<span
style=
"font-size: 18px"
>
订单号
</span>
<p
style=
"color: red; font-size: 22px"
>
{{
detail
?.
factoryOrderNumber
}}
...
...
@@ -333,7 +330,7 @@ export default {
style=
"margin-left: 5px"
v-if=
"detail.podProductionNo"
:style=
"
{
color: detail.customizedQuantity > 1 ? 'red' : '#67C23A'
color: detail.customizedQuantity > 1 ? 'red' : '#67C23A'
,
}"
>
{{
detail
.
customizedQuantity
>
1
?
"多"
:
"单"
}}
...
...
@@ -361,7 +358,9 @@ export default {
</div>
<div
:title=
"detail.color"
class=
"div-item"
>
<span>
颜色
</span>
<p>
{{
detail
.
baseSku
?
detail
.
baseSku
.
split
(
"_"
)[
1
]:
null
}}
</p>
<p>
{{
detail
.
baseSku
?
detail
.
baseSku
.
split
(
"_"
)[
1
]
:
null
}}
</p>
</div>
<div
:title=
"detail.size"
class=
"div-item"
>
<span>
尺寸
</span>
...
...
@@ -500,7 +499,6 @@ export default {
</div>
</div>
</div>
</div>
</div>
</
template
>
...
...
src/views/design/head/index.vue
View file @
09ed996b
...
...
@@ -6,6 +6,7 @@ import { grid } from "../data";
import
pkg
from
"../../../../package.json"
;
import
UpdateDialog
from
"@/views/design/updateDialog.vue"
;
// import path from "path"; // 引入 path 模块
import
store
from
"@/store/index.js"
;
export
default
{
components
:
{
PrintDialog
,
UpdateDialog
},
...
...
@@ -220,6 +221,7 @@ export default {
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let
res
=
await
this
.
$api
.
post
(
"/downloadBySubOrderNumber"
,
[
this
.
detail
.
id
,
this
.
$store
.
state
.
desktopDevice
,
]);
this
.
imgList
=
[];
res
.
data
.
forEach
((
el
)
=>
{
...
...
@@ -239,15 +241,7 @@ export default {
});
console
.
log
(
arr
,
"arr"
);
res
.
data
=
arr
.
filter
((
el
)
=>
el
.
type
!==
1
);
bus
.
$emit
(
"busEmit"
,
{
type
:
"sendFile"
,
value
:
res
.
data
,
size
:
{
width
:
35
,
height
:
39
},
});
this
.
productionNo
=
""
;
this
.
$refs
.
searchRef
.
focus
();
// 延迟后强制激活窗口
if
(
this
.
desktopDevice
!==
1
)
{
if
(
this
.
imgList
.
length
)
{
...
...
@@ -262,7 +256,17 @@ export default {
// 删除最后一个部分,即文件名
}, 500);
}
} else {
bus.$emit("
busEmit
", {
type: "
sendFile
",
value: res.data,
size: { width: 35, height: 39 },
});
}
this.productionNo = "";
this.$refs.searchRef.focus();
} catch (err) {
this.productionNo = "";
this.$refs.searchRef.focus();
...
...
@@ -344,11 +348,8 @@ export default {
},
changeDesktopDeviceFn(value) {
this.$store.commit("
changeDesktopDevice
", value);
if (value === 2) {
this.$store.commit("
changeImgList
", []);
}
console.log(347, value);
this.$store.commit("
changeImgList
", []);
console.log(347, store.state.desktopDevice);
},
},
};
...
...
src/views/design/main/index.vue
View file @
09ed996b
...
...
@@ -141,6 +141,8 @@ export default {
if
(
newValue
==
2
)
{
this
.
imgList
=
[];
this
.
selectImgList
=
[];
this
.
selectIndex
=
-
1
;
this
.
selectImgIndex
=
0
;
}
},
},
...
...
@@ -611,7 +613,7 @@ export default {
this
.
imgList
=
[];
this
.
selectIndex
=
-
1
;
if
(
value
.
length
>
0
)
{
console
.
log
(
value
);
console
.
log
(
111
,
value
);
this
.
selectImgList
=
value
;
this
.
selectImgIndex
=
0
;
this
.
getBackFile
({
files
:
[
value
[
0
]],
size
},
(
file
)
=>
{
...
...
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