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
b6914212
Commit
b6914212
authored
Jul 17, 2025
by
zhuzhequan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
35b79680
56dcbfaa
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
41 deletions
+70
-41
src/server/utils/index.js
+0
-2
src/views/design/head/index.vue
+67
-39
src/views/design/main/index.vue
+3
-0
No files found.
src/server/utils/index.js
View file @
b6914212
...
@@ -51,8 +51,6 @@ export const downloadImage = (list) => {
...
@@ -51,8 +51,6 @@ export const downloadImage = (list) => {
// console.log("Formatted Folder Name:", folderName); // 检查替换结果
// console.log("Formatted Folder Name:", folderName); // 检查替换结果
let
dirPath
=
path
.
join
(
process
.
cwd
(),
`./print/Input/`
);
let
dirPath
=
path
.
join
(
process
.
cwd
(),
`./print/Input/`
);
console
.
log
(
64
,
dirPath
);
if
(
!
fs
.
existsSync
(
dirPath
))
{
if
(
!
fs
.
existsSync
(
dirPath
))
{
fs
.
mkdirSync
(
dirPath
);
fs
.
mkdirSync
(
dirPath
);
}
}
...
...
src/views/design/head/index.vue
View file @
b6914212
...
@@ -19,11 +19,11 @@ export default {
...
@@ -19,11 +19,11 @@ export default {
user
:
{
user
:
{
default
:
{
default
:
{
avatar
:
""
,
avatar
:
""
,
factory
:
{}
factory
:
{}
,
},
},
type
:
Object
type
:
Object
,
},
},
factoryType
:
{
type
:
String
,
default
:
"CN"
}
factoryType
:
{
type
:
String
,
default
:
"CN"
}
,
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -34,20 +34,20 @@ export default {
...
@@ -34,20 +34,20 @@ export default {
cacheList
:
[
cacheList
:
[
{
{
label
:
"清除当前登录信息"
,
label
:
"清除当前登录信息"
,
value
:
"token"
value
:
"token"
,
},
},
{
{
label
:
"登录记录"
,
label
:
"登录记录"
,
value
:
"userList"
value
:
"userList"
,
},
},
{
{
label
:
"打印预设"
,
label
:
"打印预设"
,
value
:
"print-setting"
value
:
"print-setting"
,
},
},
{
{
label
:
"系统设置"
,
label
:
"系统设置"
,
value
:
"setting"
value
:
"setting"
,
}
}
,
],
],
selectGridIndex
:
0
,
selectGridIndex
:
0
,
pkg
,
pkg
,
...
@@ -62,7 +62,7 @@ export default {
...
@@ -62,7 +62,7 @@ export default {
unit
:
"inch"
,
unit
:
"inch"
,
language
:
"cn"
,
language
:
"cn"
,
autoPrint
:
false
,
autoPrint
:
false
,
gridSpacing
:
1
gridSpacing
:
1
,
},
},
imgList
:
[],
imgList
:
[],
detail
:
null
,
detail
:
null
,
...
@@ -81,8 +81,8 @@ export default {
...
@@ -81,8 +81,8 @@ export default {
"hsva(120, 40, 94, 0.5)"
,
"hsva(120, 40, 94, 0.5)"
,
"hsl(181, 100%, 37%)"
,
"hsl(181, 100%, 37%)"
,
"hsla(209, 100%, 56%, 0.73)"
,
"hsla(209, 100%, 56%, 0.73)"
,
"#c7158577"
"#c7158577"
,
]
]
,
};
};
},
},
computed
:
{
computed
:
{
...
@@ -90,7 +90,7 @@ export default {
...
@@ -90,7 +90,7 @@ export default {
return
this
.
$store
.
getters
.
getActionList
;
return
this
.
$store
.
getters
.
getActionList
;
},
},
...
mapState
([
"grid"
,
"defaultProportion"
,
"countryList"
])
...
mapState
([
"grid"
,
"defaultProportion"
,
"countryList"
])
,
},
},
mounted
()
{
mounted
()
{
// console.log(pkg, "pkg");
// console.log(pkg, "pkg");
...
@@ -115,8 +115,8 @@ export default {
...
@@ -115,8 +115,8 @@ export default {
bus
.
$emit
(
"busEmit"
,
{
type
:
"updateSystemSetting"
});
bus
.
$emit
(
"busEmit"
,
{
type
:
"updateSystemSetting"
});
},
},
deep
:
true
deep
:
true
,
}
}
,
},
},
methods
:
{
methods
:
{
checkUpdate
()
{
checkUpdate
()
{
...
@@ -135,14 +135,13 @@ export default {
...
@@ -135,14 +135,13 @@ export default {
this
.
$confirm
(
"是否退出登录?"
,
"提示"
,
{
this
.
$confirm
(
"是否退出登录?"
,
"提示"
,
{
confirmButtonText
:
"确定"
,
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
type
:
"warning"
,
})
})
.
then
(()
=>
{
.
then
(()
=>
{
this
.
$dataStore
.
delete
(
"user"
);
this
.
$dataStore
.
delete
(
"user"
);
this
.
$router
.
push
(
"/"
);
this
.
$router
.
push
(
"/"
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{});
});
break
;
break
;
case
"cache"
:
case
"cache"
:
...
@@ -157,10 +156,9 @@ export default {
...
@@ -157,10 +156,9 @@ export default {
.
post
(
"/completeDelivery"
,
{
.
post
(
"/completeDelivery"
,
{
id
:
data
.
id
,
id
:
data
.
id
,
type
:
this
.
factoryType
,
type
:
this
.
factoryType
,
podJomallOrderUsId
:
data
.
podJomallOrderUsId
podJomallOrderUsId
:
data
.
podJomallOrderUsId
,
})
})
.
then
(()
=>
{
.
then
(()
=>
{});
});
this
.
$message
.
success
(
"操作成功"
);
this
.
$message
.
success
(
"操作成功"
);
},
},
async
sureData
()
{
async
sureData
()
{
...
@@ -170,7 +168,7 @@ export default {
...
@@ -170,7 +168,7 @@ export default {
this
.
$confirm
(
`确定生产完成?`
,
"提示"
,
{
this
.
$confirm
(
`确定生产完成?`
,
"提示"
,
{
confirmButtonText
:
"确定"
,
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
type
:
"warning"
,
}).
then
(
async
()
=>
{
}).
then
(
async
()
=>
{
await
this
.
setData
(
this
.
detail
);
await
this
.
setData
(
this
.
detail
);
});
});
...
@@ -182,7 +180,7 @@ export default {
...
@@ -182,7 +180,7 @@ export default {
this
.
$confirm
(
"是否确定清除?"
,
"提示"
,
{
this
.
$confirm
(
"是否确定清除?"
,
"提示"
,
{
confirmButtonText
:
"确定"
,
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
type
:
"warning"
,
})
})
.
then
(()
=>
{
.
then
(()
=>
{
for
(
let
k
of
this
.
checkList
)
{
for
(
let
k
of
this
.
checkList
)
{
...
@@ -204,15 +202,14 @@ export default {
...
@@ -204,15 +202,14 @@ export default {
}
}
window
.
location
.
reload
();
window
.
location
.
reload
();
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{});
});
},
},
drawImage
(
canvas
,
item
)
{
drawImage
(
canvas
,
item
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
try
{
axios
axios
.
get
(
item
?.
src
,
{
.
get
(
item
?.
src
,
{
responseType
:
"blob"
responseType
:
"blob"
,
})
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
// console.log("item", item);
// console.log("item", item);
...
@@ -288,7 +285,7 @@ export default {
...
@@ -288,7 +285,7 @@ export default {
return
this
.
$message
.
warning
(
"请扫描生产单号"
);
return
this
.
$message
.
warning
(
"请扫描生产单号"
);
let
params
=
{
let
params
=
{
productionNo
:
this
.
detail
.
factorySubOrderNumber
,
productionNo
:
this
.
detail
.
factorySubOrderNumber
,
imgList
:
this
.
imgList
imgList
:
this
.
imgList
,
};
};
let
res
=
await
this
.
$api
.
post
(
"/downloadByDesignId"
,
params
);
let
res
=
await
this
.
$api
.
post
(
"/downloadByDesignId"
,
params
);
...
@@ -314,7 +311,7 @@ export default {
...
@@ -314,7 +311,7 @@ export default {
el
.
images
.
forEach
((
item
)
=>
{
el
.
images
.
forEach
((
item
)
=>
{
imageResList
.
push
({
imageResList
.
push
({
productionFile
:
item
,
productionFile
:
item
,
title
:
el
.
title
title
:
el
.
title
,
});
});
});
});
});
});
...
@@ -342,7 +339,7 @@ export default {
...
@@ -342,7 +339,7 @@ export default {
let
res
=
await
this
.
$api
.
post
(
"/downloadBySubOrderNumber"
,
{
let
res
=
await
this
.
$api
.
post
(
"/downloadBySubOrderNumber"
,
{
ids
:
[
this
.
detail
.
id
],
ids
:
[
this
.
detail
.
id
],
device
:
this
.
$store
.
state
.
desktopDevice
,
device
:
this
.
$store
.
state
.
desktopDevice
,
type
:
this
.
factoryType
type
:
this
.
factoryType
,
});
});
if
(
!
res
.
data
.
length
)
return
this
.
$message
.
warning
(
"未找到素材图!"
);
if
(
!
res
.
data
.
length
)
return
this
.
$message
.
warning
(
"未找到素材图!"
);
res
.
data
.
forEach
((
el
)
=>
{
res
.
data
.
forEach
((
el
)
=>
{
...
@@ -376,7 +373,7 @@ export default {
...
@@ -376,7 +373,7 @@ export default {
value: imageResList.map((el, index) => {
value: imageResList.map((el, index) => {
el.designId = el.designId || index;
el.designId = el.designId || index;
return el;
return el;
})
})
,
};
};
if (
if (
this.detail.mssWidth &&
this.detail.mssWidth &&
...
@@ -385,12 +382,11 @@ export default {
...
@@ -385,12 +382,11 @@ export default {
) {
) {
obj.size = {
obj.size = {
width: this.detail.mssWidth,
width: this.detail.mssWidth,
height: this.detail.mssHeight
height: this.detail.mssHeight
,
};
};
}
}
bus.$emit("
busEmit
", obj);
bus.$emit("
busEmit
", obj);
}
}
},
},
async getDataInfo() {
async getDataInfo() {
if (
if (
...
@@ -407,16 +403,22 @@ export default {
...
@@ -407,16 +403,22 @@ export default {
if (!this.isAutoFinish && !this.isFirst)
if (!this.isAutoFinish && !this.isFirst)
this.$confirm("
请注意自动完成上一单未勾选
", "
提示
", {
this.$confirm("
请注意自动完成上一单未勾选
", "
提示
", {
confirmButtonText: "
确定
",
confirmButtonText: "
确定
",
type: "
warning
"
type: "
warning
"
,
});
});
try {
try {
this.cleanDirectorySync();
} catch (error) {
console.error("
清理目录时发生错误
:
", error.message);
}
try {
//查找生产单号信息传给第二个显示器
//查找生产单号信息传给第二个显示器
const findByPodProductionNo = await this.$api.post(
const findByPodProductionNo = await this.$api.post(
"
/
findByPodProductionNo
",
"
/
findByPodProductionNo
",
{
{
thirdSubOrderNumber: this.productionNo,
thirdSubOrderNumber: this.productionNo,
type: this.factoryType
type: this.factoryType
,
}
}
);
);
this.detail = findByPodProductionNo.data;
this.detail = findByPodProductionNo.data;
...
@@ -476,7 +478,7 @@ export default {
...
@@ -476,7 +478,7 @@ export default {
unit: "
mm
",
unit: "
mm
",
language: "
cn
",
language: "
cn
",
autoPrint: false,
autoPrint: false,
gridSpacing: 10
gridSpacing: 10
,
};
};
this.$message.success("
重置应用程序设置成功
");
this.$message.success("
重置应用程序设置成功
");
},
},
...
@@ -497,8 +499,8 @@ export default {
...
@@ -497,8 +499,8 @@ export default {
formData.append("
file
", f);
formData.append("
file
", f);
let { data } = await this.$api.post("
/
uploadImage
", formData, {
let { data } = await this.$api.post("
/
uploadImage
", formData, {
headers: {
headers: {
"
Content
-
Type
": "
application
/
x
-
www
-
form
-
urlencoded
"
"
Content
-
Type
": "
application
/
x
-
www
-
form
-
urlencoded
"
,
}
}
,
});
});
bus.$emit("
busEmit
", { type: "
uploadImage
", value: data });
bus.$emit("
busEmit
", { type: "
uploadImage
", value: data });
return false;
return false;
...
@@ -518,7 +520,7 @@ export default {
...
@@ -518,7 +520,7 @@ export default {
this.$store.commit("
updateSystemSetting
", {
this.$store.commit("
updateSystemSetting
", {
field: "
gridValue
",
field: "
gridValue
",
value: this.grid[i]
value: this.grid[i]
,
});
});
bus.$emit("
busEmit
", { type: "
grid
", value: this.grid[i] });
bus.$emit("
busEmit
", { type: "
grid
", value: this.grid[i] });
},
},
...
@@ -543,14 +545,14 @@ export default {
...
@@ -543,14 +545,14 @@ export default {
const outputPath = path.join(outputDir, outputFileName);
const outputPath = path.join(outputDir, outputFileName);
const params = {
const params = {
inputPath: el.productionFile,
inputPath: el.productionFile,
outputPath: outputPath
outputPath: outputPath
,
};
};
const res = await this.$api.post("
/
processImage
", params);
const res = await this.$api.post("
/
processImage
", params);
fs.unlinkSync(el.productionFile);
fs.unlinkSync(el.productionFile);
return {
return {
fileName: outputFileName,
fileName: outputFileName,
productionFile: res.msg[0]?.outputPath,
productionFile: res.msg[0]?.outputPath,
designId: el.designId || index
designId: el.designId || index
,
};
};
} catch (error) {
} catch (error) {
console.error(`处理失败: ${el.productionFile}`, error);
console.error(`处理失败: ${el.productionFile}`, error);
...
@@ -585,8 +587,34 @@ export default {
...
@@ -585,8 +587,34 @@ export default {
}
}
return "";
return "";
},
async cleanDirectorySync() {
let dirPath = path.join(process.cwd(), `./print/Input`);
if (!fs.existsSync(dirPath)) {
console.log(`目录不存在: ${dirPath}`);
return;
}
}
try {
const files = fs.readdirSync(dirPath, { withFileTypes: true });
for (const file of files) {
const fullPath = path.join(dirPath, file.name);
if (
file.isFile() &&
path.extname(file.name).toLowerCase() === "
.
png
"
) {
await fs.promises.unlink(fullPath);
console.log(`已删除文件: ${fullPath}`);
}
}
}
} catch (error) {
if (error.code === "
ENOENT
") {
console.warn(`目录不存在: ${dirPath}`);
} else {
console.error(`清理错误: ${error.message}`);
}
}
},
},
};
};
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
...
...
src/views/design/main/index.vue
View file @
b6914212
...
@@ -820,6 +820,8 @@ export default {
...
@@ -820,6 +820,8 @@ export default {
this
.
checkList
.
map
(
async
(
el
)
=>
{
this
.
checkList
.
map
(
async
(
el
)
=>
{
try
{
try
{
const
outputDir
=
path
.
dirname
(
el
.
productionFile
);
const
outputDir
=
path
.
dirname
(
el
.
productionFile
);
console
.
log
(
outputDir
);
const
outputFileName
=
`
${
uuid
.
v4
()}
.png`
;
const
outputFileName
=
`
${
uuid
.
v4
()}
.png`
;
const
outputPath
=
path
.
join
(
outputDir
,
outputFileName
);
const
outputPath
=
path
.
join
(
outputDir
,
outputFileName
);
const
params
=
{
const
params
=
{
...
@@ -839,6 +841,7 @@ export default {
...
@@ -839,6 +841,7 @@ export default {
})
})
);
);
console
.
log
(
"processQueue"
,
processQueue
);
console
.
log
(
"processQueue"
,
processQueue
);
// 等待所有异步操作完成
// 等待所有异步操作完成
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
100
));
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
100
));
const
newMap
=
new
Map
(
processQueue
.
map
((
el
)
=>
[
el
.
designId
,
el
]));
const
newMap
=
new
Map
(
processQueue
.
map
((
el
)
=>
[
el
.
designId
,
el
]));
...
...
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