Browse Source

修改打印

master
wangfukang 1 month ago
parent
commit
fd32e5086d
  1. 7
      package2/login/login.vue
  2. 9
      package2/other/logisticsSystemSet.vue
  3. 365
      package2/other/newLogisticsIndex.vue

7
package2/login/login.vue

@ -332,6 +332,13 @@
if (res.code == 200) { if (res.code == 200) {
let printMethod = JSON.parse(res.result.logiticsCompany.printMethod) let printMethod = JSON.parse(res.result.logiticsCompany.printMethod)
uni.setStorageSync('remark',res.result.logiticsCompany.remark) uni.setStorageSync('remark',res.result.logiticsCompany.remark)
uni.setStorageSync('companyTel',res.result.logiticsCompany.companyTel)
if(res.result.logisticsUser == null || res.result.logisticsUser == undefined){
uni.setStorageSync('wluserType',0)
}else{
uni.setStorageSync('wluserType',res.result.logisticsUser.userRole)
}
if(printMethod == null){ if(printMethod == null){
uni.setStorageSync('wlNum',1) uni.setStorageSync('wlNum',1)
}else{ }else{

9
package2/other/logisticsSystemSet.vue

@ -38,6 +38,12 @@
<textarea name="" id="" cols="30" rows="10" maxlength="-1" v-model="remark" style="width: 80%;line-height: 40rpx;margin:0 10rpx;border: 1px solid #eee;padding-left: 20rpx;"></textarea> <textarea name="" id="" cols="30" rows="10" maxlength="-1" v-model="remark" style="width: 80%;line-height: 40rpx;margin:0 10rpx;border: 1px solid #eee;padding-left: 20rpx;"></textarea>
</view> </view>
</view> </view>
<view style="width: 95%;margin: 0 auto;background: #fff;border-radius: 10px;padding: 15rpx;">
<view style="display: flex;">
<view style="width: 20%;height: 80rpx;line-height: 80rpx;">联系方式:</view>
<textarea name="" id="" cols="30" rows="10" maxlength="-1" v-model="companyTel" style="width: 80%;line-height: 40rpx;margin:0 10rpx;border: 1px solid #eee;padding-left: 20rpx;"></textarea>
</view>
</view>
<view style="background: #fff;width: 100%;height: 120rpx;position: fixed;bottom: 0;"> <view style="background: #fff;width: 100%;height: 120rpx;position: fixed;bottom: 0;">
<view @tap="editPrintWay" style="text-align: center;border-radius: 20rpx;font-size: 36rpx;width: 95%;margin: 15rpx auto 0;height: 90rpx;background: #088FEB;color: #fff;line-height: 90rpx;"> <view @tap="editPrintWay" style="text-align: center;border-radius: 20rpx;font-size: 36rpx;width: 95%;margin: 15rpx auto 0;height: 90rpx;background: #088FEB;color: #fff;line-height: 90rpx;">
修改 修改
@ -73,6 +79,7 @@
current: 0, current: 0,
wlNum:uni.getStorageSync('wlNum')?uni.getStorageSync('wlNum'):1, wlNum:uni.getStorageSync('wlNum')?uni.getStorageSync('wlNum'):1,
remark:uni.getStorageSync('remark')?uni.getStorageSync('remark'):"", remark:uni.getStorageSync('remark')?uni.getStorageSync('remark'):"",
companyTel:uni.getStorageSync('companyTel')?uni.getStorageSync('companyTel'):""
} }
}, },
onLoad(){ onLoad(){
@ -129,11 +136,13 @@
} }
} }
uni.setStorageSync('remark',this.remark) uni.setStorageSync('remark',this.remark)
uni.setStorageSync('companyTel',this.companyTel)
uni.request({ uni.request({
url: this.tui.interfaceUrl() + '/app/logitics/updateLogiticsCompany', url: this.tui.interfaceUrl() + '/app/logitics/updateLogiticsCompany',
data: { data: {
id:uni.getStorageSync('transCompany'), id:uni.getStorageSync('transCompany'),
printMethod:JSON.stringify(printMethod), printMethod:JSON.stringify(printMethod),
companyTel:this.companyTel,
remark:this.remark remark:this.remark
}, },
header: { header: {

365
package2/other/newLogisticsIndex.vue

@ -4,7 +4,11 @@
<view class="IndexContent"> <view class="IndexContent">
<view class="contentPadding"> <view class="contentPadding">
<view style="width: 95%;display: flex;margin: 0 auto;"> <view style="width: 95%;display: flex;margin: 0 auto;">
<view class="top-btn" style="width: 100%;" @tap="gokaidan">开单</view> <view v-if = "wluserType != 2" class="top-btn" style="width: 100%;" @tap="gokaidan">开单</view>
<view v-else class="top-btn" style="width: 100%;">
<kk-printer ref="kkprinter" :bufferData="bufferData" :defaultText="'打印票据'"
@onPrint="goPrintList"></kk-printer>
</view>
</view> </view>
<view class="title"> <view class="title">
<i class="iconfont icon-xiaoshouyuce"> 今日营收详情 <i class="iconfont icon-xiaoshouyuce"> 今日营收详情
@ -71,10 +75,10 @@
<view class="uni-body"> <view class="uni-body">
<text class="cardText">接站人:{{item.receivingUserName}}</text> <text class="cardText">接站人:{{item.receivingUserName}}</text>
</view> </view>
<view @tap.stop="goAddOrderPage(item)" style="position: absolute;bottom: 20rpx;right: 20rpx;color: #00B5FF;"> <view v-if = "wluserType != 2" @tap.stop="goAddOrderPage(item)" style="position: absolute;bottom: 20rpx;right: 20rpx;color: #00B5FF;">
修改订单 修改订单
</view> </view>
<view @tap.stop="delOrder(item)" style="position: absolute;bottom: 100rpx;right: 20rpx;color: #00B5FF;"> <view v-if = "wluserType != 2" @tap.stop="delOrder(item)" style="position: absolute;bottom: 100rpx;right: 20rpx;color: #00B5FF;">
删除订单 删除订单
</view> </view>
<view v-if="item.changeCount != '0'" style="position: absolute;top: 140rpx;right: 20rpx;color: #00B5FF;"> <view v-if="item.changeCount != '0'" style="position: absolute;top: 140rpx;right: 20rpx;color: #00B5FF;">
@ -137,6 +141,10 @@
</view> </view>
</template> </template>
<script> <script>
import util from '@/components/kk-printer/utils/util.js';
import * as blesdk from '@/components/kk-printer/utils/bluetoolth.js';
import kkPrinter from '@/components/kk-printer/index.vue';
import gbk from '@/components/kk-printer/utils/printUtil-GBK.js';
export default { export default {
data() { data() {
return { return {
@ -152,6 +160,7 @@
range:[], range:[],
lineValue:'', lineValue:'',
comPanyList:[], comPanyList:[],
wluserType:uni.getStorageSync('wluserType'),
companyValue:'', companyValue:'',
stationName:'', stationName:'',
stationValue:{ stationValue:{
@ -164,10 +173,17 @@
arrivalStationId:'', arrivalStationId:'',
lineRange:[], lineRange:[],
companyRange:[], companyRange:[],
bufferDataList:[],
orderStatistics:{}, orderStatistics:{},
stationRange:[] bufferData:[],
stationRange:[],
shopRemark:[],
companyTel:''
} }
}, },
components: {
kkPrinter
},
onShareAppMessage() { onShareAppMessage() {
return { return {
title: '查看我的物流单', title: '查看我的物流单',
@ -183,6 +199,10 @@
this.getLine() this.getLine()
this.getLineByCompany('') this.getLineByCompany('')
this.getAllNum() this.getAllNum()
//
wx.openBluetoothAdapter({
mode: 'central'
})
}, },
onLoad() { onLoad() {
let that = this; let that = this;
@ -192,6 +212,191 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: this.shopName title: this.shopName
}); });
if(uni.getStorageSync('remark')){
let remark = uni.getStorageSync('remark')
this.shopRemark = remark.split('\n');
}
if(uni.getStorageSync('companyTel')){
this.companyTel = uni.getStorageSync('companyTel')
}
//
for(let i=1;i<=this.orderList.length;i++){
//let strCmd = blesdk.CreatCPCLPage(600, 480, 1, 0,0);
let strCmd = blesdk.CreatCPCLPage(780, 1590, 1, 0,0);
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLText('-30', 1100, '24', '1', 1, this.orderList[i].companyName)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('50', 1500, '24', '0.5', 1, '开票日期:'+ this.orderList[i].createTime + ' 发站:' +this.orderList[i].goStationName +'-->'+ this.orderList[i].arrivalStationName +' 卸货地点:'+ this.orderList[i].arrivalStationName +' 货号:'+this.orderList[i].orderNumber)
//
strCmd += blesdk.addCPCLText('90', 1290, '24', '0', 1, '收货人')
strCmd += blesdk.addCPCLLine(80, 1200, 125, 1200, 2);
strCmd += blesdk.addCPCLText('90', 1180, '24', '0', 1, this.orderList[i].receiverName)
strCmd += blesdk.addCPCLLine(80, 1070, 125, 1070, 2);
strCmd += blesdk.addCPCLText('90', 1050, '24', '0', 1, '电话')
strCmd += blesdk.addCPCLLine(80, 970, 125, 970, 2);
strCmd += blesdk.addCPCLText('90', 960, '24', '0', 1, this.orderList[i].receiverMobile)
strCmd += blesdk.addCPCLLine(80, 760, 125, 760, 2);
strCmd += blesdk.addCPCLText('90', 740, '24', '0', 1, '票号')
strCmd += blesdk.addCPCLLine(80, 660, 125, 660, 2);
strCmd += blesdk.addCPCLText('90', 640, '24', '0', 1, '')
//
strCmd += blesdk.addCPCLText('135', 1290, '24', '0', 1, '发货人')
strCmd += blesdk.addCPCLLine(125, 1200, 170, 1200, 2);
strCmd += blesdk.addCPCLText('135', 1180, '24', '0', 1, this.orderList[i].shipperName)
strCmd += blesdk.addCPCLLine(125, 1070, 170, 1070, 2);
strCmd += blesdk.addCPCLText('135', 1050, '24', '0', 1, '电话')
strCmd += blesdk.addCPCLLine(125, 970, 170, 970, 2);
strCmd += blesdk.addCPCLText('135', 960, '24', '0', 1, this.orderList[i].shipperMobile)
strCmd += blesdk.addCPCLLine(125, 760, 170, 760, 2);
strCmd += blesdk.addCPCLText('135', 740, '24', '0', 1, '身份证')
strCmd += blesdk.addCPCLLine(125, 630, 170, 630, 2);
strCmd += blesdk.addCPCLText('135', 620, '24', '0', 1, '')
//
strCmd += blesdk.addCPCLText('180', 1290, '24', '0', 1, '货名')
strCmd += blesdk.addCPCLLine(170, 1200, 215, 1200, 2);
strCmd += blesdk.addCPCLText('180', 1180, '24', '0', 1, '件数')
strCmd += blesdk.addCPCLLine(170, 1070, 215, 1070, 2);
strCmd += blesdk.addCPCLText('180', 1050, '24', '0', 1, '付款方式')
strCmd += blesdk.addCPCLLine(170, 900, 215, 900, 2);
strCmd += blesdk.addCPCLText('180', 890, '24', '0', 1, '运费')
strCmd += blesdk.addCPCLLine(170, 800, 215, 800, 2);
strCmd += blesdk.addCPCLText('180', 790, '24', '0', 1, '送货')
strCmd += blesdk.addCPCLLine(170, 700, 215, 700, 2);
strCmd += blesdk.addCPCLText('180', 690, '24', '0', 1, '中转')
strCmd += blesdk.addCPCLLine(170, 600, 215, 600, 2);
strCmd += blesdk.addCPCLText('180', 590, '24', '0', 1, '工本费')
strCmd += blesdk.addCPCLLine(170, 500, 215, 500, 2);
strCmd += blesdk.addCPCLText('180', 490, '24', '0', 1, '保费')
strCmd += blesdk.addCPCLLine(170, 400, 215, 400, 2);
strCmd += blesdk.addCPCLText('180', 390, '24', '0', 1, '垫付')
strCmd += blesdk.addCPCLLine(170, 300, 215, 300, 2);
strCmd += blesdk.addCPCLText('180', 290, '24', '0', 1, '代收款')
strCmd += blesdk.addCPCLLine(170, 200, 215, 200, 2);
strCmd += blesdk.addCPCLText('180', 190, '24', '0', 1, '货到付款')
//
strCmd += blesdk.addCPCLText('225', 1290, '24', '0', 1, this.orderList[i].objectName)
strCmd += blesdk.addCPCLLine(215, 1200, 260, 1200, 2);
strCmd += blesdk.addCPCLText('225', 1180, '24', '0', 1, this.orderList[i].count)
strCmd += blesdk.addCPCLLine(215, 1070, 260, 1070, 2);
strCmd += blesdk.addCPCLText('225', 1050, '24', '0', 1, this.orderList[i].methodOfSettlement == 0 ?'现金':this.orderList[i].methodOfSettlement == 1 ?'月付':this.orderList[i].methodOfSettlement == 2 ?'到付':'')
strCmd += blesdk.addCPCLLine(215, 900, 260, 900, 2);
strCmd += blesdk.addCPCLText('225', 890, '24', '0', 1, this.orderList[i].freight)
strCmd += blesdk.addCPCLLine(215, 800, 260, 800, 2);
strCmd += blesdk.addCPCLText('225', 790, '24', '0', 1, this.orderList[i].deliveryFee)
strCmd += blesdk.addCPCLLine(215, 700, 260, 700, 2);
strCmd += blesdk.addCPCLText('225', 690, '24', '0', 1, this.orderList[i].transitFee)
strCmd += blesdk.addCPCLLine(215, 600, 260, 600, 2);
strCmd += blesdk.addCPCLText('225', 590, '24', '0', 1, this.orderList[i].cost)
strCmd += blesdk.addCPCLLine(215, 500, 260, 500, 2);
strCmd += blesdk.addCPCLText('225', 490, '24', '0', 1, this.orderList[i].premium)
strCmd += blesdk.addCPCLLine(215, 400, 260, 400, 2);
strCmd += blesdk.addCPCLText('225', 390, '24', '0', 1, '')
strCmd += blesdk.addCPCLLine(215, 300, 260, 300, 2);
strCmd += blesdk.addCPCLText('225', 290, '24', '0', 1, this.orderList[i].paymentForGoods)
strCmd += blesdk.addCPCLLine(215, 200, 260, 200, 2);
let allmoney = Number(this.orderList[i].premium)+Number(this.orderList[i].cost)+Number(this.orderList[i].freight)+Number(this.orderList[i].deliveryFee)+Number(this.orderList[i].transitFee)
if(this.orderList[i].methodOfSettlement == 2){
strCmd += blesdk.addCPCLText('225', 190, '24', '0', 1, allmoney)
}else{
strCmd += blesdk.addCPCLText('225', 190, '24', '0', 1, '')
}
//
strCmd += blesdk.addCPCLText('270', 1290, '24', '0', 1, '运费合计:'+this.convertToChineseNumeral1(allmoney)+'元整 ¥'+allmoney)
strCmd += blesdk.addCPCLLine(260, 700, 305, 700, 2);
strCmd += blesdk.addCPCLText('270', 690, '24', '0', 1, '代收款:'+this.convertToChineseNumeral1(Number(this.orderList[i].paymentForGoods))+'元整 ¥'+this.orderList[i].paymentForGoods)
//
strCmd += blesdk.addCPCLText('315', 1290, '24', '0', 1, '备注')
strCmd += blesdk.addCPCLLine(305, 700, 350, 700, 2);
strCmd += blesdk.addCPCLText('315', 690, '24', '0', 1, '特别声明')
//
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('360', 1290, '24', '0', 1, '注')
strCmd += blesdk.addCPCLText('390', 1290, '24', '0', 1, '意')
strCmd += blesdk.addCPCLText('420', 1290, '24', '0', 1, '事')
strCmd += blesdk.addCPCLText('450', 1290, '24', '0', 1, '项')
strCmd += blesdk.addCPCLLine(350, 1260, 475, 1260, 2);
if(this.shopRemark.length > 0){
for(let q = 0;q<this.shopRemark.length;q++){
strCmd += blesdk.addCPCLText('360', 1250, '24', '0', 1, this.shopRemark[q])
}
}
//
strCmd += blesdk.addCPCLText('485', 1290, '24', '0', 1, this.companyTel)
//线
strCmd += blesdk.addCPCLLine(80, 1500, 510, 1500, 2);
//线
strCmd += blesdk.addCPCLLine(80, 1300, 510, 1300, 2);
//线
strCmd += blesdk.addCPCLLine(80, 80, 510, 80, 2);
//线
strCmd += blesdk.addCPCLLine(80, 1500, 80, 80, 2);
//线
strCmd += blesdk.addCPCLLine(125, 1300, 125, 80, 2);
//线
strCmd += blesdk.addCPCLLine(170, 1300, 170, 80, 2);
//线
strCmd += blesdk.addCPCLLine(215, 1300, 215, 80, 2);
//线
strCmd += blesdk.addCPCLLine(260, 1300, 260, 80, 2);
//线
strCmd += blesdk.addCPCLLine(305, 1300, 305, 80, 2);
//线
strCmd += blesdk.addCPCLLine(350, 1300, 350, 80, 2);
//线
strCmd += blesdk.addCPCLLine(475, 1300, 475, 80, 2);
//线
strCmd += blesdk.addCPCLLine(520, 1500, 520, 80, 2);
// strCmd += blesdk.addCPCLLine(50, 1500, 250, 100, 2);
/*
strCmd += blesdk.addCPCLLine(10,140,570,140,2) //线
strCmd += blesdk.addCPCLLine(382,140,382,316,2) //线
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLText('20', 160, '24', '0', 0, '到站:'+ arrivalStationName)
strCmd += blesdk.addCPCLLine(10,220,382,220,2) //线
strCmd += blesdk.addCPCLText('20', 248, '24', '0', 0, '收:'+receiverName)
strCmd += blesdk.addCPCLLine(10,316,570,316,2) //线
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('20', 336, '24', '0', 0, '共'+ this.itemData.count + '件')
strCmd += blesdk.addCPCLText('112', 336, '24', '0', 0, '自提')
strCmd += blesdk.addCPCLLine(170,316,170,450,2) //线
strCmd += blesdk.addCPCLText('186', 336, '24', '0', 0, '单号:'+ orderNumber + '-' +i)
strCmd += blesdk.addCPCLLine(10,376,570,376,2) //线
strCmd += blesdk.addCPCLText('20', 396, '24', '0', 0, this.itemData.receiverMobile == 'undefined' || this.itemData.receiverMobile == null ? '' : this.itemData.receiverMobile)
strCmd += blesdk.addCPCLText('186', 396, '24', '0', 0, '备注:'+this.itemData.remark)
strCmd += blesdk.addCPCLQRCode(400, 150 , 'H', '1', 4, orderNumber) //二维码 */
strCmd += blesdk.addCPCLPrint();
that.bufferDataList.push(strCmd);
}
}, },
onReachBottom() { onReachBottom() {
if (this.pageNum >= this.pages) return; if (this.pageNum >= this.pages) return;
@ -200,6 +405,74 @@
this.getOrderList(); this.getOrderList();
}, },
methods: { methods: {
goPrintList() {
this.bufferData = this.bufferDataList
// this.xierushuju(this.bufferData)
this.$nextTick(() => {
setTimeout(res => {
this.bufferData = []
}, 1000 * this.orderList.length)
uni.hideLoading();
})
},
xierushuju() {
let that = this;
//
if (this.defaultText == '小标签') {
that.$emit('onPrintSmall1');
} else if (this.defaultText == '确认打印') {
that.$emit('goPrint');
} else {
that.$emit('onPrint');
}
that.$nextTick(() => {
var dataStr = ''
for (let m = 0; m < that.bufferData.length; m++) {
dataStr += that.bufferData[m]
}
const maxChunk = that.deviceType == 'android' ? 20 : 180;
const delay = that.deviceType == 'android' ? 20 : 180;
let buffer = gbk.strToGBKByte(dataStr)
for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
setTimeout(that._writeBLECharacteristicValue, j * delay, subPackage);
}
})
return;
},
_writeBLECharacteristicValue(buffer) {
let that = this;
wx.writeBLECharacteristicValue({
deviceId: uni.getStorageSync('deviceId'),
serviceId: uni.getStorageSync('serviceId'),
characteristicId: uni.getStorageSync('characteristicId'),
value: buffer,
success(res) {
},
fail(res) {
wx.closeBLEConnection({
deviceId: uni.getStorageSync('deviceId'),
success(res) {
}
})
if (uni.getStorageSync('deviceId')) {
that.xierushuju()
} else {
that.jiantingshebei()
}
}
})
uni.hideLoading();
},
getLineByCompany(id){ getLineByCompany(id){
if(id == ''){ if(id == ''){
let data = { let data = {
@ -247,6 +520,88 @@
} }
}) })
}, },
convertToChineseNumeral1(money) {
let fu = false
if (money == 0) {
return '零元整'
}
if (JSON.stringify(money).indexOf('-') != -1) {
money = JSON.stringify(money).split('-')[1]
fu = true
}
const cnNums = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
const cnIntRadice = ['', '拾', '佰', '仟']
const cnIntUnits = ['', '万', '亿', '兆']
const cnDecUnits = ['角', '分', '毫', '厘']
const cnInteger = '整'
const cnIntLast = '元'
const maxNum = 999999999999999.9999
let integerNum
let decimalNum
let chineseStr = ''
let parts
if (money == '') {
return ''
}
money = parseFloat(money)
if (money >= maxNum) {
return ''
}
if (money == 0) {
chineseStr = cnNums[0] + cnIntLast + cnInteger
return chineseStr
}
money = money.toString()
if (money.indexOf('.') == -1) {
integerNum = money
decimalNum = ''
} else {
parts = money.split('.')
integerNum = parts[0]
decimalNum = parts[1].substr(0, 4)
}
if (parseInt(integerNum, 10) > 0) {
let zeroCount = 0
const IntLen = integerNum.length
for (let i = 0; i < IntLen; i++) {
const n = integerNum.substr(i, 1)
const p = IntLen - i - 1
const q = p / 4
const m = p % 4
if (n == '0') {
zeroCount++
} else {
if (zeroCount > 0) {
chineseStr += cnNums[0]
}
zeroCount = 0
chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]
}
if (m == 0 && zeroCount < 4) {
chineseStr += cnIntUnits[q]
}
}
chineseStr += cnIntLast
}
if (decimalNum != '') {
const decLen = decimalNum.length
for (let i = 0; i < decLen; i++) {
const n = decimalNum.substr(i, 1)
if (n != '0') {
chineseStr += cnNums[Number(n)] + cnDecUnits[i]
}
}
}
if (chineseStr == '') {
chineseStr += cnNums[0] + cnIntLast + cnInteger
} else if (decimalNum == '') {
chineseStr += cnInteger
}
if (fu == true) {
chineseStr = '负' + chineseStr
}
return chineseStr
},
getAllNum(){ getAllNum(){
let currentTime = new Date(); let currentTime = new Date();
let year = currentTime.getFullYear(); let year = currentTime.getFullYear();
@ -345,7 +700,7 @@
url: this.tui.interfaceUrl() + '/app/logisticsOrder/getLogisticsOrderPageList', url: this.tui.interfaceUrl() + '/app/logisticsOrder/getLogisticsOrderPageList',
data:{ //stationId data:{ //stationId
pageNum:this.pageNum, pageNum:this.pageNum,
pageSize:"10", pageSize:this.wluserType == '2' ? "1000" : "10",
companyName:"", companyName:"",
companyId:this.companyId, companyId:this.companyId,
circuitName:"", circuitName:"",

Loading…
Cancel
Save