|
@@ -173,9 +173,10 @@ import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
|
const printInfo = ref({
|
|
const printInfo = ref({
|
|
ip: '',
|
|
ip: '',
|
|
- port: '9100'
|
|
|
|
|
|
+ port: '9100',
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+
|
|
const urlConfig = ref('http://zhongyao.fscuc.cn')
|
|
const urlConfig = ref('http://zhongyao.fscuc.cn')
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
const plug= uni.requireNativePlugin('Html5app-Gprinter');
|
|
const plug= uni.requireNativePlugin('Html5app-Gprinter');
|
|
@@ -186,6 +187,7 @@ const connectThenPrint = ()=>{
|
|
const ipReg = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
|
const ipReg = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
|
if(ipReg.test(printInfo.value.ip)){
|
|
if(ipReg.test(printInfo.value.ip)){
|
|
if(RegExp.$1<256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256){
|
|
if(RegExp.$1<256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256){
|
|
|
|
+ uni.$showMsg('打印机连接成功!', 500)
|
|
plug.connectIP({"ip":printInfo.value.ip,"port":printInfo.value.port},ret=>{
|
|
plug.connectIP({"ip":printInfo.value.ip,"port":printInfo.value.port},ret=>{
|
|
console.log('connectPrint>>ret',ret)
|
|
console.log('connectPrint>>ret',ret)
|
|
const res = JSON.parse(JSON.stringify(ret))
|
|
const res = JSON.parse(JSON.stringify(ret))
|
|
@@ -194,31 +196,22 @@ const connectThenPrint = ()=>{
|
|
// initPrint.value = true
|
|
// initPrint.value = true
|
|
console.log('printInfo>>>', printInfo.value)
|
|
console.log('printInfo>>>', printInfo.value)
|
|
uni.setStorageSync('hasPrinter', '1')
|
|
uni.setStorageSync('hasPrinter', '1')
|
|
|
|
+
|
|
uni.setStorageSync('printerIp', printInfo.value.ip)
|
|
uni.setStorageSync('printerIp', printInfo.value.ip)
|
|
// _this.tip=JSON.stringify(ret);
|
|
// _this.tip=JSON.stringify(ret);
|
|
// console.log(_this.tip);
|
|
// console.log(_this.tip);
|
|
// 关闭配置弹窗
|
|
// 关闭配置弹窗
|
|
proxy.$refs.printerDialog.close()
|
|
proxy.$refs.printerDialog.close()
|
|
- printerTsc()
|
|
|
|
|
|
+ printerTsc()
|
|
|
|
|
|
- // // 打印成功后调用/userPrescription/sendToUser
|
|
|
|
- // const res1 = sendToUser({
|
|
|
|
- // token: uni.getStorageSync('token'),
|
|
|
|
- // data: JSON.stringify({id:uni.getStorageSync('userId')})
|
|
|
|
- // })
|
|
|
|
- // console.log('sendToUser res1',res1)
|
|
|
|
- // if (res1.code !== 200){
|
|
|
|
- // uni.$showMsg(res1.msg, 2000)
|
|
|
|
- // }
|
|
|
|
|
|
+ if(uni.getStorageSync('hasPrinter') == '1'){
|
|
|
|
+ deploy()
|
|
|
|
+ }
|
|
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url:"/pages/index/index"
|
|
|
|
- })
|
|
|
|
|
|
|
|
} else{
|
|
} else{
|
|
uni.$showMsg('打印机连接失败,请重试!', 500)
|
|
uni.$showMsg('打印机连接失败,请重试!', 500)
|
|
}
|
|
}
|
|
-
|
|
|
|
});
|
|
});
|
|
} else{
|
|
} else{
|
|
uni.$showMsg('ip地址有误,请重试!', 2000)
|
|
uni.$showMsg('ip地址有误,请重试!', 2000)
|
|
@@ -374,7 +367,7 @@ const editForm =ref({
|
|
coreId: ''
|
|
coreId: ''
|
|
})
|
|
})
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
-
|
|
|
|
|
|
+printInfo.value.ip = uni.getStorageSync('printerIp')
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -520,6 +513,7 @@ const cancelConfig = () => {
|
|
|
|
|
|
const handleSubmit = debounce(async()=>{
|
|
const handleSubmit = debounce(async()=>{
|
|
console.log('handleSubmit>>>',editForm.value)
|
|
console.log('handleSubmit>>>',editForm.value)
|
|
|
|
+ console.log('isPrint.value>>', isPrint.value)
|
|
|
|
|
|
if(isPrint.value){
|
|
if(isPrint.value){
|
|
// 直接调用接口,然后打印
|
|
// 直接调用接口,然后打印
|
|
@@ -539,8 +533,8 @@ const handleSubmit = debounce(async()=>{
|
|
// todo 判断打印机是否连接成功,hasPrinter=='1'连接成功则开始打印,否则弹窗配置打印机,配置成功打印机后关闭弹窗直接打印
|
|
// todo 判断打印机是否连接成功,hasPrinter=='1'连接成功则开始打印,否则弹窗配置打印机,配置成功打印机后关闭弹窗直接打印
|
|
if(uni.getStorageSync('hasPrinter') == '1'){
|
|
if(uni.getStorageSync('hasPrinter') == '1'){
|
|
printerTsc()
|
|
printerTsc()
|
|
- console.log("uni.getStorageSync('token')",uni.getStorageSync('token'))
|
|
|
|
|
|
|
|
|
|
+ const tmp = await deploy()
|
|
uni.redirectTo({
|
|
uni.redirectTo({
|
|
url:"/pages/index/index"
|
|
url:"/pages/index/index"
|
|
})
|
|
})
|
|
@@ -572,17 +566,7 @@ const dialogConfirm = debounce(async()=>{
|
|
if(uni.getStorageSync('hasPrinter') == '1'){
|
|
if(uni.getStorageSync('hasPrinter') == '1'){
|
|
printerTsc()
|
|
printerTsc()
|
|
console.log("uni.getStorageSync('token')",uni.getStorageSync('token'))
|
|
console.log("uni.getStorageSync('token')",uni.getStorageSync('token'))
|
|
- // const res = await sendToUser({
|
|
|
|
- // token: uni.getStorageSync('token'),
|
|
|
|
- // data: JSON.stringify({id:uni.getStorageSync('userId')})
|
|
|
|
- // })
|
|
|
|
- // const ret = await updateOrderStatus({
|
|
|
|
- // token: uni.getStorageSync('token'),
|
|
|
|
- // data: {
|
|
|
|
- // id:v.value.id,
|
|
|
|
- // status:'1',
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ const ret1 = await deploy()
|
|
uni.redirectTo({
|
|
uni.redirectTo({
|
|
url:"/pages/index/index"
|
|
url:"/pages/index/index"
|
|
})
|
|
})
|
|
@@ -618,6 +602,42 @@ const dialogClose = debounce(async()=>{
|
|
})
|
|
})
|
|
},500)
|
|
},500)
|
|
|
|
|
|
|
|
+const deploy = async() => {
|
|
|
|
+ const {data:res} = await saveDepoly({
|
|
|
|
+ token: uni.getStorageSync('token'),
|
|
|
|
+ data: JSON.stringify(editForm.value)
|
|
|
|
+ })
|
|
|
|
+ if(res.code===200){
|
|
|
|
+ console.log('depoly success>>>')
|
|
|
|
+ }
|
|
|
|
+ const res1 = await sendToUser({
|
|
|
|
+ token: uni.getStorageSync('token'),
|
|
|
|
+ data: JSON.stringify({id:uni.getStorageSync('userId')})
|
|
|
|
+ })
|
|
|
|
+ const ret2 = await updateOrderStatus({
|
|
|
|
+ token: uni.getStorageSync('token'),
|
|
|
|
+ data: {
|
|
|
|
+ id:v.value.id,
|
|
|
|
+ status:'1',
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ console.log('updateOrderStatus >>ret2',ret2)
|
|
|
|
+ // 保存ip和端口
|
|
|
|
+ console.log("保存ip和端口", uni.getStorageSync('userId'),printInfo.value.ip, printInfo.value.port)
|
|
|
|
+ const res2 = await setIp({
|
|
|
|
+ token: uni.getStorageSync('token'),
|
|
|
|
+ data: JSON.stringify({userId:uni.getStorageSync('userId'),ip:printInfo.value.ip,port:printInfo.value.port})
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if (res2.data.code !== 200){
|
|
|
|
+ // uni.$showMsg('保存ip和端口数据异常', 2000)
|
|
|
|
+ console.log("保存ip和端口数据异常", res2)
|
|
|
|
+ }
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url:"/pages/index/index"
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
const selectUpload = debounce((e)=>{
|
|
const selectUpload = debounce((e)=>{
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
title: "上传中"
|
|
title: "上传中"
|
|
@@ -743,44 +763,8 @@ const printerTsc = ()=>{
|
|
// let _this=this;
|
|
// let _this=this;
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
- plug.printer({TSC:data}, ret => {
|
|
|
|
- // _this.tip = JSON.stringify(ret);
|
|
|
|
- // console.log('print data', data)
|
|
|
|
- // console.log('ret',ret)
|
|
|
|
- // console.log('ret.code',ret.code)
|
|
|
|
- // const err = JSON.parse(ret)
|
|
|
|
- // console.log('err',err)
|
|
|
|
- if(ret.code==1){
|
|
|
|
- uni.$showMsg('打印失败,打印机未连接,请先连接打印机', 2000)
|
|
|
|
- console.log('666')
|
|
|
|
- } else {
|
|
|
|
- const {data:res} = saveDepoly({
|
|
|
|
- token: uni.getStorageSync('token'),
|
|
|
|
- data: JSON.stringify(editForm.value)
|
|
|
|
- })
|
|
|
|
- if(res.code===200){
|
|
|
|
- console.log('depoly success>>>')
|
|
|
|
- }
|
|
|
|
- const res1 = sendToUser({
|
|
|
|
- token: uni.getStorageSync('token'),
|
|
|
|
- data: JSON.stringify({id:uni.getStorageSync('userId')})
|
|
|
|
- })
|
|
|
|
- const ret = updateOrderStatus({
|
|
|
|
- token: uni.getStorageSync('token'),
|
|
|
|
- data: {
|
|
|
|
- id:v.value.id,
|
|
|
|
- status:'1',
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // 保持ip和端口
|
|
|
|
- const res2 = setIp({
|
|
|
|
- token: uni.getStorageSync('token'),
|
|
|
|
- data: JSON.stringify({userId:uni.getStorageSync('userId'),ip:printInfo.value.ip,port:printInfo.value.port})
|
|
|
|
- })
|
|
|
|
- if (res2.code !== 200){
|
|
|
|
- uni.$showMsg(res2.msg, 2000)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ plug.printer({TSC:data}, (ret) => {
|
|
|
|
+ const tip = JSON.stringify(ret);
|
|
})
|
|
})
|
|
// #endif
|
|
// #endif
|
|
|
|
|