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
c3ac02c5
Commit
c3ac02c5
authored
Dec 23, 2024
by
zhuzhequan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加打印日志
parent
d2185f56
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
8 deletions
+84
-8
src/server/entity/function.js
+23
-0
src/server/routes/index.js
+2
-0
src/server/utils/log.js
+1
-1
src/views/design/head/index.vue
+3
-0
src/views/design/head/printDialog.vue
+38
-4
src/views/design/main/imgSetting.vue
+17
-3
No files found.
src/server/entity/function.js
View file @
c3ac02c5
...
@@ -11,10 +11,33 @@ const path = require("path");
...
@@ -11,10 +11,33 @@ const path = require("path");
const
fs
=
require
(
"fs"
);
const
fs
=
require
(
"fs"
);
const
os
=
require
(
"os"
);
const
os
=
require
(
"os"
);
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
{
returnLogFilePath
}
from
"../utils/log"
;
axios
.
defaults
.
timeout
=
12600000
;
axios
.
defaults
.
timeout
=
12600000
;
const
multiparty
=
require
(
"multiparty"
);
const
multiparty
=
require
(
"multiparty"
);
export
default
{
export
default
{
writePrintLog
:
async
(
req
,
res
)
=>
{
try
{
let
body
=
req
.
body
;
let
p
=
path
.
join
(
returnLogFilePath
(),
"print.json"
);
p
=
p
.
replace
(
"
\\
api.log"
,
""
);
console
.
log
(
p
);
let
data
=
[];
if
(
!
fs
.
existsSync
(
p
))
{
fs
.
writeFileSync
(
p
,
"[]"
);
data
=
[];
}
else
{
data
=
fs
.
readFileSync
(
p
,
{
encoding
:
"utf-8"
});
data
=
JSON
.
parse
(
data
);
}
data
.
push
(
body
);
fs
.
writeFileSync
(
p
,
JSON
.
stringify
(
data
));
res
.
json
({
code
:
200
});
}
catch
(
e
)
{
res
.
json
({
code
:
500
,
msg
:
e
});
}
},
getPodProductionInfo
:
async
(
req
,
res
)
=>
{
getPodProductionInfo
:
async
(
req
,
res
)
=>
{
const
token
=
req
.
headers
[
"jwt-token"
];
const
token
=
req
.
headers
[
"jwt-token"
];
const
company
=
req
.
headers
[
"company"
];
const
company
=
req
.
headers
[
"company"
];
...
...
src/server/routes/index.js
View file @
c3ac02c5
...
@@ -8,6 +8,8 @@ let router = express.Router();
...
@@ -8,6 +8,8 @@ let router = express.Router();
// 执行打印命令
// 执行打印命令
router
.
post
(
"/toPrint"
,
fn
.
toPrint
);
router
.
post
(
"/toPrint"
,
fn
.
toPrint
);
// 打印日志添加
router
.
post
(
"/writePrintLog"
,
fn
.
writePrintLog
);
// 登录接口
// 登录接口
router
.
post
(
"/login"
,
fn
.
login
);
router
.
post
(
"/login"
,
fn
.
login
);
// 获取本地文件返回
// 获取本地文件返回
...
...
src/server/utils/log.js
View file @
c3ac02c5
...
@@ -3,7 +3,7 @@ const moment = require("moment");
...
@@ -3,7 +3,7 @@ const moment = require("moment");
const
fs
=
require
(
"fs"
);
const
fs
=
require
(
"fs"
);
const
path
=
require
(
"path"
);
const
path
=
require
(
"path"
);
function
returnLogFilePath
()
{
export
function
returnLogFilePath
()
{
const
today
=
moment
(
new
Date
()).
format
(
"YYYY-MM-DD"
);
const
today
=
moment
(
new
Date
()).
format
(
"YYYY-MM-DD"
);
const
low_path
=
process
.
cwd
();
const
low_path
=
process
.
cwd
();
const
dir
=
path
.
join
(
low_path
,
`/logs/
${
today
}
`
);
const
dir
=
path
.
join
(
low_path
,
`/logs/
${
today
}
`
);
...
...
src/views/design/head/index.vue
View file @
c3ac02c5
...
@@ -256,6 +256,7 @@ export default {
...
@@ -256,6 +256,7 @@ export default {
let
res
=
await
this
.
$api
.
post
(
"/getPodProductionInfo"
,
{
let
res
=
await
this
.
$api
.
post
(
"/getPodProductionInfo"
,
{
productionNo
:
this
.
productionNo
productionNo
:
this
.
productionNo
});
});
this
.
$dataStore
.
set
(
'production_no'
,
this
.
productionNo
)
if
(
res
.
data
.
length
===
0
)
if
(
res
.
data
.
length
===
0
)
return
this
.
$message
.
warning
(
"未找到素材图!"
);
return
this
.
$message
.
warning
(
"未找到素材图!"
);
let
arr
=
[];
let
arr
=
[];
...
@@ -275,7 +276,9 @@ export default {
...
@@ -275,7 +276,9 @@ export default {
console
.
log
(
arr
,
"arr"
);
console
.
log
(
arr
,
"arr"
);
res
.
data
=
arr
.
filter
(
el
=>
el
.
type
!==
1
);
res
.
data
=
arr
.
filter
(
el
=>
el
.
type
!==
1
);
bus
.
$emit
(
"busEmit"
,
{
type
:
"sendFile"
,
value
:
res
.
data
});
bus
.
$emit
(
"busEmit"
,
{
type
:
"sendFile"
,
value
:
res
.
data
});
this
.
productionNo
=
""
;
this
.
productionNo
=
""
;
this
.
$refs
.
searchRef
.
focus
();
this
.
$refs
.
searchRef
.
focus
();
}
catch
(
err
)
{
}
catch
(
err
)
{
this
.
productionNo
=
""
;
this
.
productionNo
=
""
;
...
...
src/views/design/head/printDialog.vue
View file @
c3ac02c5
...
@@ -3,11 +3,13 @@ import fieldDescription from "./fieldDescription";
...
@@ -3,11 +3,13 @@ import fieldDescription from "./fieldDescription";
import
{
ipcRenderer
}
from
"electron"
;
import
{
ipcRenderer
}
from
"electron"
;
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
html2canvas
from
"html2canvas"
;
import
html2canvas
from
"html2canvas"
;
import
moment
from
"moment"
;
import
pkg
from
"../../../../package.json"
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
dialogShow
:
true
,
dialogShow
:
true
,
pkg
,
axios
,
axios
,
fieldDescription
,
fieldDescription
,
printerList
:
[],
printerList
:
[],
...
@@ -119,6 +121,13 @@ export default {
...
@@ -119,6 +121,13 @@ export default {
}
}
},
},
watch
:
{
watch
:
{
printSetting
:
{
handler
()
{
this
.
$dataStore
.
set
(
"print-setting"
,
this
.
printSetting
);
},
deep
:
true
,
immediate
:
true
},
visible
()
{
visible
()
{
this
.
dialogShow
=
this
.
visible
;
this
.
dialogShow
=
this
.
visible
;
}
}
...
@@ -274,7 +283,6 @@ export default {
...
@@ -274,7 +283,6 @@ export default {
async
getPrintCmd
()
{
async
getPrintCmd
()
{
if
(
this
.
imgList
.
length
===
0
)
if
(
this
.
imgList
.
length
===
0
)
return
this
.
$message
.
warning
(
"素材不能为空"
);
return
this
.
$message
.
warning
(
"素材不能为空"
);
console
.
log
(
this
.
imgList
[
0
]);
if
(
this
.
imgList
.
length
>
1
)
{
if
(
this
.
imgList
.
length
>
1
)
{
let
dom
=
document
.
getElementsByClassName
(
"drr"
);
let
dom
=
document
.
getElementsByClassName
(
"drr"
);
for
(
let
i
=
0
;
i
<
dom
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
dom
.
length
;
i
++
)
{
...
@@ -341,9 +349,33 @@ export default {
...
@@ -341,9 +349,33 @@ export default {
print_cmd
print_cmd
}
}
};
};
await
this
.
toWritePrintLog
(
data
);
let
res
=
await
this
.
$api
.
post
(
"/toPrint"
,
data
);
let
res
=
await
this
.
$api
.
post
(
"/toPrint"
,
data
);
this
.
$message
.
success
(
res
.
msg
);
this
.
$message
.
success
(
res
.
msg
);
},
},
async
toWritePrintLog
(
send_api_data
)
{
let
head_setting
=
this
.
$dataStore
.
get
(
"setting"
);
let
position_before_px
=
this
.
$dataStore
.
get
(
"position-before-px"
);
// 图片的位置信息 px
let
position_after_px
=
this
.
$dataStore
.
get
(
"position-after-px"
);
// 图片根据单位转换后的px
let
position_unit
=
this
.
$dataStore
.
get
(
"position_unit"
);
// 图片根据单位转换后的px
let
print_time
=
moment
(
new
Date
()).
format
(
"YYYY-MM-DD HH:mm:ss"
);
// 打印的时间
let
production_no
=
this
.
$dataStore
.
get
(
"production_no"
);
// 打印的单号
let
print_setting
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
printSetting
));
// 打印的设置
let
version
=
this
.
pkg
.
version
let
data
=
{
head_setting
,
version
,
print_setting
,
production_no
,
print_time
,
position_unit
,
position_after_px
,
position_before_px
,
send_api_data
};
await
this
.
$api
.
post
(
"/writePrintLog"
,
data
);
},
async
getPrinter
()
{
async
getPrinter
()
{
ipcRenderer
.
send
(
"allPrint"
);
ipcRenderer
.
send
(
"allPrint"
);
ipcRenderer
.
once
(
"printName"
,
(
event
,
data
)
=>
{
ipcRenderer
.
once
(
"printName"
,
(
event
,
data
)
=>
{
...
@@ -1014,7 +1046,8 @@ export default {
...
@@ -1014,7 +1046,8 @@ export default {
background-color
:
blueviolet
;
background-color
:
blueviolet
;
color
:
white
;
color
:
white
;
justify-content
:
center
;
justify-content
:
center
;
i{
i
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
display
:
flex
;
display
:
flex
;
...
@@ -1038,7 +1071,8 @@ export default {
...
@@ -1038,7 +1071,8 @@ export default {
background-color
:
blueviolet
;
background-color
:
blueviolet
;
color
:
white
;
color
:
white
;
justify-content
:
center
;
justify-content
:
center
;
i{
i
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
display
:
flex
;
display
:
flex
;
...
...
src/views/design/main/imgSetting.vue
View file @
c3ac02c5
...
@@ -41,10 +41,16 @@ export default {
...
@@ -41,10 +41,16 @@ export default {
item
:
{
item
:
{
handler
()
{
handler
()
{
if
(
this
.
item
)
{
if
(
this
.
item
)
{
let
setting
=
this
.
$dataStore
.
get
(
"setting"
);
this
.
$dataStore
.
set
(
"position-before-px"
,
JSON
.
parse
(
JSON
.
stringify
(
this
.
item
)));
console
.
log
(
"setting"
,
setting
);
this
.
item
.
y
=
(
this
.
item
.
y
-
this
.
item
.
h
/
2
);
this
.
item
.
y
=
(
this
.
item
.
y
-
this
.
item
.
h
/
2
);
this
.
item
.
x
=
(
this
.
item
.
x
-
this
.
item
.
w
/
2
);
this
.
item
.
x
=
(
this
.
item
.
x
-
this
.
item
.
w
/
2
);
console
.
log
(
this
.
item
.
x
,
this
.
item
.
y
,
this
.
item
.
h
);
console
.
log
(
this
.
item
.
x
,
this
.
item
.
y
,
this
.
item
.
h
);
let
setting
=
this
.
$dataStore
.
get
(
"setting"
);
let
x_mm
,
w_mm
,
h_mm
,
y_mm
;
let
x_mm
,
w_mm
,
h_mm
,
y_mm
;
if
(
setting
.
unit
===
"mm"
)
{
if
(
setting
.
unit
===
"mm"
)
{
x_mm
=
Number
((
this
.
item
.
x
*
0.84183
).
toFixed
(
2
));
x_mm
=
Number
((
this
.
item
.
x
*
0.84183
).
toFixed
(
2
));
...
@@ -71,6 +77,7 @@ export default {
...
@@ -71,6 +77,7 @@ export default {
// this.form.sh = h_mm
// this.form.sh = h_mm
// this.form.sw = w_mm
// this.form.sw = w_mm
this
.
form
.
r
=
this
.
item
.
r
;
this
.
form
.
r
=
this
.
item
.
r
;
this
.
$dataStore
.
set
(
`position-after-px`
,
JSON
.
parse
(
JSON
.
stringify
(
this
.
form
)));
}
}
},
},
immediate
:
true
,
immediate
:
true
,
...
@@ -103,10 +110,11 @@ export default {
...
@@ -103,10 +110,11 @@ export default {
f
.
h
=
(
Number
((
f
.
h
/
0.84183
)
*
25.4
).
toFixed
(
2
));
f
.
h
=
(
Number
((
f
.
h
/
0.84183
)
*
25.4
).
toFixed
(
2
));
}
}
f
.
zIndex
=
Number
((
f
.
zIndex
));
f
.
zIndex
=
Number
((
f
.
zIndex
));
for
(
let
k
in
f
)
{
for
(
let
k
in
f
)
{
f
[
k
]
=
Number
(
f
[
k
])
f
[
k
]
=
Number
(
f
[
k
])
;
}
}
this
.
$emit
(
"change"
,
f
);
this
.
$emit
(
"change"
,
f
);
this
.
$dataStore
.
set
(
'position_unit'
,
JSON
.
parse
(
JSON
.
stringify
(
f
)))
},
},
addValue
(
f
)
{
addValue
(
f
)
{
...
@@ -253,6 +261,7 @@ export default {
...
@@ -253,6 +261,7 @@ export default {
.img-form
{
.img-form
{
padding
:
10px
;
padding
:
10px
;
}
}
::v-deep
{
::v-deep
{
.el-drawer__header
{
.el-drawer__header
{
border-bottom
:
1px
solid
#ececec
;
border-bottom
:
1px
solid
#ececec
;
...
@@ -260,13 +269,16 @@ export default {
...
@@ -260,13 +269,16 @@ export default {
margin-bottom
:
20px
;
margin-bottom
:
20px
;
}
}
}
}
.form-content
{
.form-content
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
}
}
.set-value
{
.set-value
{
height
:
100%
;
height
:
100%
;
margin-left
:
6px
;
margin-left
:
6px
;
i
{
i
{
width
:
20px
;
width
:
20px
;
height
:
12px
;
height
:
12px
;
...
@@ -275,11 +287,13 @@ export default {
...
@@ -275,11 +287,13 @@ export default {
line-height
:
12px
;
line-height
:
12px
;
cursor
:
pointer
;
cursor
:
pointer
;
border
:
1px
solid
transparent
;
border
:
1px
solid
transparent
;
&:hover
{
&:hover
{
border-color
:
#ececec
;
border-color
:
#ececec
;
}
}
}
}
}
}
.drawer
{
.drawer
{
width
:
300px
;
width
:
300px
;
bottom
:
0
;
bottom
:
0
;
...
...
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