feat: 打印机设置支持ip

This commit is contained in:
caoqianming 2025-12-30 10:38:14 +08:00
parent f88e3d27c8
commit d87662ce33
3 changed files with 19 additions and 4 deletions

View File

@ -548,9 +548,9 @@ export default {
}, },
prints: { prints: {
name: "打印", name: "打印",
req: async function (data) { req: async function (ip, data) {
// return await http.post("http://localhost:8080/prints/", data); // return await http.post("http://localhost:8080/prints/", data);
return await http.post("http://127.0.0.1:8080/prints/", data); return await http.post(`http://${ip}:8080/prints/`, data);
}, },
}, },
ana:{ ana:{

View File

@ -90,6 +90,11 @@
</el-dropdown> </el-dropdown>
</div> </div>
<el-dialog title="打印机设置" v-model="setNameVisible" width="600px"> <el-dialog title="打印机设置" v-model="setNameVisible" width="600px">
<el-form label-width="100px">
<el-form-item label="打印机IP">
<el-input v-model="printer_ip"></el-input>
</el-form-item>
</el-form>
<el-form label-width="100px"> <el-form label-width="100px">
<el-form-item label="打印机名称"> <el-form-item label="打印机名称">
<el-input v-model="printer_name"></el-input> <el-input v-model="printer_name"></el-input>
@ -138,6 +143,7 @@ export default {
scanId:'', scanId:'',
scanType:'', scanType:'',
printer_name:'', printer_name:'',
printer_ip:'',
scanVisible:false, scanVisible:false,
}; };
}, },
@ -157,6 +163,7 @@ export default {
this.userName = userInfo.username; this.userName = userInfo.username;
this.userNameF = this.userName.substring(0, 1); this.userNameF = this.userName.substring(0, 1);
this.printer_name = localStorage.getItem("printer_name") || ""; this.printer_name = localStorage.getItem("printer_name") || "";
this.printer_ip = localStorage.getItem("printer_ip") || "127.0.0.1";
}, },
methods: { methods: {
openBook() { openBook() {
@ -250,7 +257,10 @@ export default {
this.setNameVisible=true; this.setNameVisible=true;
}, },
savePrinter(){ savePrinter(){
this.$TOOL.setPrint(this.printer_name); this.$TOOL.setPrint({
"printer_name":this.printer_name,
"printer_ip":this.printer_ip
});
this.setNameVisible=false; this.setNameVisible=false;
}, },
// //

View File

@ -140,8 +140,13 @@ tool.screen = function (element) {
} }
} }
tool.setPrint = function (val) { tool.setPrint = function (val) {
if (val.printer_name) {
localStorage.setItem('printer_name', val.printer_name)
localStorage.setItem('printer_ip', val.printer_ip)
}else{
localStorage.setItem('printer_name', val) localStorage.setItem('printer_name', val)
} }
}
/* 复制对象 */ /* 复制对象 */
tool.objCopy = function (obj) { tool.objCopy = function (obj) {
return JSON.parse(JSON.stringify(obj)); return JSON.parse(JSON.stringify(obj));