|
@ -70,7 +70,7 @@
|
|
|
</div>
|
|
|
|
|
|
<Scan @onComplete="onComplete" v-show="step==2" @onBack="step=1"/>
|
|
|
<Result @outDrug="sendShipment" :rsType.sync="rsType" :orderdetail="orderdetail" v-show="step==3" @onBack="step=2"/>
|
|
|
<Result @outDrug="sendShipment" @onPrint="SetPrintPage" :rsType.sync="rsType" :orderdetail="orderdetail" v-show="step==3" @onBack="step=2" @onBackIndex="step=1"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
@ -85,11 +85,11 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
deviceNum: 'dev_001',
|
|
|
deviceNum: this.$route.query.deviceNum,//14912202107000001500000000000000
|
|
|
step: 0,
|
|
|
curImg: '',
|
|
|
illustrationMskShow: false,
|
|
|
|
|
|
socketUrl: '',
|
|
|
path: "ws://yik.ab-inbev.vip/c/websocket/",
|
|
|
socket: "",
|
|
|
mess: [],
|
|
@ -101,11 +101,13 @@ export default {
|
|
|
orderdetail: [],
|
|
|
rsType: 1,
|
|
|
imgList: [],
|
|
|
videoList: []
|
|
|
videoList: [],
|
|
|
inCheckBarcode: false,
|
|
|
orderInfo: ''
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
|
|
|
|
console.log(_.groupBy([{a: 1,},{a: 1,},{a: 2,},{a: 1,},], 'a'))
|
|
|
},
|
|
|
methods: {
|
|
|
devinfoAdvList(){
|
|
@ -155,14 +157,17 @@ export default {
|
|
|
v.success = false
|
|
|
})
|
|
|
this.orderdetail = res.obj.list
|
|
|
this.orderInfo = res.obj
|
|
|
this.rsType = res.obj.status==1? 1 : 2
|
|
|
this.step = 3
|
|
|
} else {
|
|
|
this.$toast(res.message || '获取订单失败')
|
|
|
}
|
|
|
this.inCheckBarcode = false
|
|
|
})
|
|
|
.catch(err=>{
|
|
|
console.error(err)
|
|
|
this.inCheckBarcode = false
|
|
|
})
|
|
|
},
|
|
|
init: function() {
|
|
@ -170,12 +175,14 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
this.devinfoAdvList()
|
|
|
this.path += this.deviceNum + "_T"
|
|
|
if(!this.socketUrl){
|
|
|
this.socketUrl = this.path + this.deviceNum + "_T"
|
|
|
}
|
|
|
if (typeof(WebSocket) === "undefined") {
|
|
|
alert("您的浏览器不支持socket")
|
|
|
} else {
|
|
|
// 实例化socket
|
|
|
this.socket = new WebSocket(this.path)
|
|
|
this.socket = new WebSocket(this.socketUrl)
|
|
|
// 监听socket连接
|
|
|
this.socket.onopen = this.open
|
|
|
// 监听socket错误信息
|
|
@ -206,33 +213,36 @@ export default {
|
|
|
this.mess.push(msg.data); //返回数据信息,包含医保瞳
|
|
|
var msgobj = JSON.parse(msg.data)
|
|
|
if (msgobj.type == 'ShipInfo') {
|
|
|
if (msgobj.mess.indexOf("异常") < 0) {
|
|
|
var item = this.orderdetail[this.currindex]
|
|
|
if (msgobj.mess == ( item.layerNo +";"+ item.wayerNo) ) {
|
|
|
this.updateOrderOutStatus(item.id, 2, msgobj.mess)
|
|
|
this.currindex++;
|
|
|
if (this.orderdetail.length > this.currindex) {
|
|
|
this.$loading(`正在出第${this.currindex+1}个药..`)
|
|
|
this.nextShipment(this.orderdetail[this.currindex]);
|
|
|
} else {
|
|
|
this.$dialog.alert({
|
|
|
title: '出药提示',
|
|
|
message: '出药完成',
|
|
|
confirmButtonText: "返回首页"
|
|
|
}).then(() => {
|
|
|
this.step = 1
|
|
|
});
|
|
|
this.$toast.clear()
|
|
|
setTimeout(()=>{
|
|
|
this.shipComplete()
|
|
|
}, 200)
|
|
|
}
|
|
|
} else {
|
|
|
this.$toast(msg.data.mess)
|
|
|
this.updateOrderOutStatus(item.id, 3, msgobj.mess)
|
|
|
this.shipComplete(msgobj.mess)
|
|
|
}
|
|
|
} else if (msgobj.type == 'BarCodeInfo') {
|
|
|
if (msgobj.mess.indexOf("异常") != -1) {
|
|
|
this.$toast(msg.data.mess)
|
|
|
console.log(msg.data.mess)
|
|
|
this.$toast(msgobj.mess)
|
|
|
console.log(msgobj.mess)
|
|
|
return
|
|
|
}
|
|
|
if(this.inCheckBarcode || this.step!=2){
|
|
|
return
|
|
|
}
|
|
|
this.checkOrderAndReturn({pickUpNum: msg.data.mess})
|
|
|
this.checkOrderAndReturn({pickUpNum: msgobj.mess})
|
|
|
} else if(msgobj.type == 'CardInfo'){
|
|
|
if (msgobj.mess.indexOf("异常") != -1) {
|
|
|
this.$toast(msg.data.mess)
|
|
|
this.$toast(msgobj.mess)
|
|
|
return
|
|
|
}
|
|
|
var arr = msgobj.mess.split("\n");
|
|
@ -242,6 +252,14 @@ export default {
|
|
|
json[tmp[0]] = tmp[1]
|
|
|
});
|
|
|
this.checkOrderAndReturn({cardNum: json['卡号']})
|
|
|
} else if(msgobj.type == 'PrintComplete'){
|
|
|
this.$dialog.alert({
|
|
|
title: '',
|
|
|
message: '打印完成',
|
|
|
confirmButtonText: "返回首页"
|
|
|
}).then(() => {
|
|
|
this.step = 1
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
sendReadCard: function() {
|
|
@ -259,13 +277,7 @@ export default {
|
|
|
if (this.orderdetail.length > this.currindex) {
|
|
|
this.nextShipment(this.orderdetail[this.currindex]);
|
|
|
} else {
|
|
|
this.$dialog.alert({
|
|
|
title: '出药提示',
|
|
|
message: '出药完成',
|
|
|
confirmButtonText: "返回首页"
|
|
|
}).then(() => {
|
|
|
this.step = 1
|
|
|
});
|
|
|
this.shipComplete()
|
|
|
}
|
|
|
},
|
|
|
nextShipment: function(row) {
|
|
@ -318,6 +330,111 @@ export default {
|
|
|
}
|
|
|
this.socket.send(JSON.stringify(obj));
|
|
|
},
|
|
|
SetPrintPage: function() {
|
|
|
// string type; //text 文本 |line 间隔行|barcode 条码|qrcode 二维码|reset 重置打印机 |nline 走纸【进行【
|
|
|
// string text; //文本内容
|
|
|
// int nLan;//文本编码类型0:GBK 1:UTF-8
|
|
|
// int nOrgx;//打印的文本位置,各值定义如下:-1 左对齐 -2 居中对齐 -3 右对齐 >=0 在第n点位置开始打印
|
|
|
// int nWidthTimes;//字符宽度放大的倍数,范围[0,7]
|
|
|
// int nHeightTimes;// 字符高度放大的倍数,范围[0,7]
|
|
|
// int FontType;//打印的字体类型,各值定义如下:度值 定义 0: 12*24 1: 9*17
|
|
|
// int nFontStyle;// 打印的字体类型,各值定义如下:需要合并的把两个值相加得到整数回传 值 定义0x00 正常0x08 加粗0x80 1点下划线0x100 2点下划线0x200 倒置打印 0x400 反显、黑底白字0x1000 每个字符顺时针旋转 90
|
|
|
// int nBarcodeType;//打印的条码类型,各值定义如下:值 类型 0x41 UPC-A 0x42 UPC-E 0x43 EAN13 0x44 EAN80x45 CODE39 0x46 ITF0x47 CODABAR0x48 CODE93
|
|
|
// int nUnitWidth;// 打印的条码宽度,值范围[1,6]
|
|
|
// int nUnitHeight;//打印的条码高度,值范围[1,255]
|
|
|
// int FontPosition;//可读字符(HRI)的打印位置,各值定义如下:值 定义 0 不打印1 条码上方2 条码下方 3 条码上方和下方
|
|
|
// int nWidth;// 二维码的宽度,取值范围[1,6}二维码单元宽度越大,QR码越大。
|
|
|
// int nVersion;// 二维码的规格,取值范围[0,16],0表示自动计算版本。 二维码码版本越大,能编码的字符就越多,QR码也越大。
|
|
|
// int nErrlevenl;//二维码纠错等级,取值[1,4]
|
|
|
|
|
|
var printcon =[
|
|
|
{type:"reset"},
|
|
|
{type:"nline"},
|
|
|
{type:"text", text:"智能药柜\n小票凭据\n",nLan:0,nOrgx:-2,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0},
|
|
|
{type:"text", text:"--------------------------------\n",nLan:0,nOrgx:-2,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0},
|
|
|
];
|
|
|
var allPrice = 0, allcount = 0
|
|
|
var obj = _.groupBy(this.orderdetail.concat([]), 'drugCode')
|
|
|
var list = []
|
|
|
for(var k in obj){
|
|
|
var tem = obj[k]
|
|
|
tem[0].quantity = tem.length
|
|
|
list.push(tem[0])
|
|
|
tem.forEach(v=>{
|
|
|
allPrice += v.price
|
|
|
allcount += 1
|
|
|
})
|
|
|
}
|
|
|
list.forEach(v=>{
|
|
|
printcon.push({
|
|
|
type:"text", text: (v.drugName)+"\n",nLan:0,nOrgx:-1,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0
|
|
|
})
|
|
|
printcon.push({
|
|
|
type:"text", text: `单价:${v.price}元 数量:${v.quantity}\n药品编码:${v.drugCode}\n规格:${v.specif}\n剂型:${v.dosForm||''}\n`,nLan:0,nOrgx:-1,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0
|
|
|
})
|
|
|
printcon.push({type:"line"})
|
|
|
})
|
|
|
var {date, phone, num, remark, time, community, qrCodeContent} = this.orderInfo
|
|
|
printcon.push({
|
|
|
type:"text", text: `药品总价:${(allPrice).toFixed(2)}元\n药品数量:${allcount}\n订单金额:${allPrice.toFixed(2)}元\n`,nLan:0,nOrgx:-1,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0
|
|
|
})
|
|
|
printcon.push({type:"text", text:"--------------------------------\n",nLan:0,nOrgx:-2,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0})
|
|
|
printcon.push({
|
|
|
type:"text", text: `商家名称:${community}\n客服电话:${phone}\n药柜编码:${this.deviceNum}\n销售单号:${num}\n取药日期:${date}\n取药时间:${time}\n`,nLan:0,nOrgx:-1,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0
|
|
|
})
|
|
|
|
|
|
printcon.push({type:"text", text:"--------------------------------\n",nLan:0,nOrgx:-2,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0})
|
|
|
if(remark){
|
|
|
printcon.push({
|
|
|
type:"text", text: `备注:${remark}\n`,nLan:0,nOrgx:-1,nWidthTimes:0,nHeightTimes:0,FontType:0,nFontStyle:0
|
|
|
})
|
|
|
}
|
|
|
if(qrCodeContent){
|
|
|
printcon.push({type:"qrcode",text:"qrCodeContent",nWidth:6,nVersion:0,nErrlevenl:4})
|
|
|
}
|
|
|
|
|
|
printcon.push({type:"nline"})
|
|
|
printcon.push({type:"nline"})
|
|
|
printcon.push({type:"nline"})
|
|
|
printcon.push({type:"nline"})
|
|
|
printcon.push({type:"nline"})
|
|
|
|
|
|
var obj = {
|
|
|
type: "PrintPage",
|
|
|
mess: JSON.stringify(printcon),
|
|
|
}
|
|
|
this.socket.send(JSON.stringify(obj));
|
|
|
},
|
|
|
updateOrderOutStatus(shipmentLogId, status, msg){
|
|
|
var p = {
|
|
|
shipmentLogId,
|
|
|
status,
|
|
|
msg: msg || ''
|
|
|
}
|
|
|
console.log('updateOrderOutStatus', p)
|
|
|
medicineAbinetApi
|
|
|
.updateOrderOutStatus(p)
|
|
|
.then(res=>{
|
|
|
console.log('updateOrderOutStatus', res)
|
|
|
})
|
|
|
.catch(err=>{
|
|
|
console.error(err)
|
|
|
})
|
|
|
},
|
|
|
shipComplete(msg){
|
|
|
this.$toast.clear()
|
|
|
if(msg){
|
|
|
this.$dialog.alert({
|
|
|
title: '',
|
|
|
message: '出药异常中断,请联系管理员',
|
|
|
confirmButtonText: "返回首页"
|
|
|
}).then(() => {
|
|
|
this.step = 1
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
this.rsType = 4
|
|
|
}
|
|
|
},
|
|
|
destroyed() {
|
|
|
this.forceClose = true
|