|
|
|
@ -10,7 +10,12 @@ |
|
|
|
<view class="box-right-name">{{dataList.productName == null ? '暂无':dataList.productName}} ({{dataList.productSn == null ? '暂无':dataList.productSn}})</view> |
|
|
|
<view class="box-right-num">供应商:{{dataList.supplierName == null ? '暂无':dataList.supplierName}}</view> |
|
|
|
<view class="edit-btn" @tap="goToAddGoods">编辑</view> |
|
|
|
<view @tap="clickPrint" style="width: 100rpx;height: 60rpx;line-height: 60rpx;color: #fff !important;background: #0072E3;position: absolute;top: 30rpx;right: 40rpx;border-radius: 10px;text-align: center;">打印</view> |
|
|
|
<view v-if="!isPrint" @tap="printBtn" class="print-btn"> |
|
|
|
打印 |
|
|
|
</view> |
|
|
|
<view v-if="isPrint" @tap="printBtn" class="print-btn"> |
|
|
|
取消 |
|
|
|
</view> |
|
|
|
<view class="box-right-num" style="color:#ffa200;"> |
|
|
|
<text style="padding-right: 20rpx;">{{dataList.delFlag==1?'已上架':'已下架'}}</text> |
|
|
|
<!-- <text>{{dataList.delFlag==0?'已上架':'已下架'}}</text> --> |
|
|
|
@ -38,11 +43,15 @@ |
|
|
|
</view> |
|
|
|
<view class="container-box" v-for="(item,index) in pecsList" :key='index'> |
|
|
|
<view class="prec-list"> |
|
|
|
<view class="prec-list-box" style="width: 70%;"> |
|
|
|
<view class="prec-list-box" :style="{width:isPrint?'40%':'70%'}"> |
|
|
|
{{item.attributeList | sliceMsg}} |
|
|
|
</view> |
|
|
|
<view class="prec-list-box" style="font-size: 26rpx;"> |
|
|
|
<view class="prec-list-box" style="font-size: 26rpx;width: 26%;"> |
|
|
|
数量:{{item.stockCount}} |
|
|
|
</view> |
|
|
|
<view> |
|
|
|
<uni-number-box v-if="isPrint" v-model="item.productCount" max="10000" |
|
|
|
@change="changeNumBtn(item)" style="margin-top: 10rpx;display: block;" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -56,8 +65,32 @@ |
|
|
|
<view class="content-low" v-for="(item1,index1) in list" :key="index1" |
|
|
|
@tap.stop="addMultipleType(item1)" :class="item1.checked?'checked':''">{{item1.type}}</view> |
|
|
|
</view> |
|
|
|
<view class="popup-pay-container" > |
|
|
|
<kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint" :defaultText="'打印'"></kk-printer> |
|
|
|
<view v-if="list[0].checked" style="display: flex;height: 80rpx;width: 100%;line-height: 80rpx;margin-top: 20rpx;"> |
|
|
|
<text style="display:inline-block;width:100rpx;font-size:22rpx;"> |
|
|
|
供应商: |
|
|
|
</text> |
|
|
|
<input v-if="isShow" v-model="dataList.supplierName" @change="changeText" type="text" placeholder="请输入供应商名称" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;"> |
|
|
|
</view> |
|
|
|
<view v-if="list[1].checked" style="display: flex;height: 80rpx;width: 100%;line-height: 80rpx;margin-top: 20rpx;"> |
|
|
|
<text style="display:inline-block;width:100rpx;font-size:22rpx;"> |
|
|
|
货号: |
|
|
|
</text> |
|
|
|
<input v-if="isShow" v-model="dataList.productSn" @change="changeText" type="text" placeholder="请输入货号" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;"> |
|
|
|
</view> |
|
|
|
<view v-if="list[2].checked" style="display: flex;height: 80rpx;width: 100%;line-height: 80rpx;margin-top: 20rpx;"> |
|
|
|
<text style="display:inline-block;width:100rpx;font-size:22rpx;"> |
|
|
|
零售价: |
|
|
|
</text> |
|
|
|
<input v-if="isShow" v-model="dataList.price" @change="changeText" type="number" placeholder="请输入零售价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;"> |
|
|
|
</view> |
|
|
|
<view v-if="list[3].checked" style="display: flex;height: 80rpx;width: 100%;line-height: 80rpx;margin-top: 20rpx;"> |
|
|
|
<text style="display:inline-block;width:100rpx;font-size:22rpx;"> |
|
|
|
批发价: |
|
|
|
</text> |
|
|
|
<input v-if="isShow" v-model="dataList.wholesalePrice" @change="changeText" type="number" placeholder="请输入批发价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;"> |
|
|
|
</view> |
|
|
|
<view class="popup-pay-container"> |
|
|
|
<kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint" :printNum="printNum" :defaultText="'打印'"></kk-printer> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
@ -66,8 +99,9 @@ |
|
|
|
<uni-popup-dialog ref="inputClose" mode="input" title="采购价" placeholder="请输入采购价" |
|
|
|
@confirm="changePrice"></uni-popup-dialog> |
|
|
|
</uni-popup> |
|
|
|
<view v-if="isPrint" @tap="clickPrint" class="bottom-btn">确认打印</view> |
|
|
|
<!-- 右下角悬浮按钮 --> |
|
|
|
<uni-fab ref="fab" :content="content" :horizontal="horizontal" |
|
|
|
<uni-fab v-if="!isPrint" ref="fab" :content="content" :horizontal="horizontal" |
|
|
|
@trigger="trigger" /> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
@ -81,23 +115,29 @@ |
|
|
|
return { |
|
|
|
pageNum: 1, //分页的页码 |
|
|
|
dataList: [], |
|
|
|
isPrint:false, |
|
|
|
bufferData: [], |
|
|
|
horizontal: 'right', |
|
|
|
pecsList:[], |
|
|
|
defaultText:'', |
|
|
|
type:'', |
|
|
|
printNum:1, |
|
|
|
list:[{ |
|
|
|
type:'供应商', |
|
|
|
checked:false, |
|
|
|
text:'' |
|
|
|
},{ |
|
|
|
type:'货号', |
|
|
|
checked:false, |
|
|
|
text:'' |
|
|
|
},{ |
|
|
|
type:'零售价', |
|
|
|
checked:false, |
|
|
|
text:'' |
|
|
|
},{ |
|
|
|
type:'批发价', |
|
|
|
checked:false, |
|
|
|
text:'' |
|
|
|
}], |
|
|
|
multipleList:[], |
|
|
|
content: [{ |
|
|
|
@ -115,7 +155,10 @@ |
|
|
|
selectedIconPath: '/static/images/tabbar/home-sel.png', |
|
|
|
text: '删除商品', |
|
|
|
active: false |
|
|
|
}] |
|
|
|
}], |
|
|
|
printList:new Map(), |
|
|
|
yNum: 10, |
|
|
|
isShow:true |
|
|
|
} |
|
|
|
}, |
|
|
|
filters: { |
|
|
|
@ -140,7 +183,9 @@ |
|
|
|
components: { |
|
|
|
kkPrinter |
|
|
|
}, |
|
|
|
onLoad(option) { |
|
|
|
onLoad(option) { |
|
|
|
// 初始化蓝牙模块 |
|
|
|
wx.openBluetoothAdapter({mode: 'central'}) |
|
|
|
this.dataList = JSON.parse(option.item); |
|
|
|
this.type = uni.getStorageSync('type') |
|
|
|
}, |
|
|
|
@ -161,13 +206,42 @@ |
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
|
|
}, |
|
|
|
changeText(){ |
|
|
|
console.log(this.dataList) |
|
|
|
}, |
|
|
|
clickShow(){ |
|
|
|
this.isShow = false |
|
|
|
}, |
|
|
|
changeNumBtn(item){ |
|
|
|
if(this.printList.has(item.attributeList) == true){ // map中已经有当前值 |
|
|
|
if(item.productCount == 0){ |
|
|
|
this.printList.delete(item.attributeList) |
|
|
|
}else{ |
|
|
|
this.printList.get(item.attributeList).productCount = item.productCount |
|
|
|
} |
|
|
|
}else{ |
|
|
|
this.printList.set(item.attributeList,item) |
|
|
|
} |
|
|
|
console.log('打印的数组',this.printList) |
|
|
|
}, |
|
|
|
printBtn(){ |
|
|
|
this.isPrint = !this.isPrint |
|
|
|
}, |
|
|
|
//点击打印按钮 |
|
|
|
clickPrint() { |
|
|
|
this.$refs.payDialog.open('center') |
|
|
|
}, |
|
|
|
//选择多个规格保存 |
|
|
|
addMultipleType(item1){ |
|
|
|
|
|
|
|
if(item1.type== '供应商'){ |
|
|
|
item1.text = this.dataList.supplierName |
|
|
|
}else if(item1.type== '货号'){ |
|
|
|
item1.text = this.dataList.productSn |
|
|
|
}else if(item1.type== '零售价'){ |
|
|
|
item1.text = this.dataList.price |
|
|
|
}else if(item1.type== '批发价'){ |
|
|
|
item1.text = this.dataList.wholesalePrice |
|
|
|
} |
|
|
|
item1.checked = !item1.checked |
|
|
|
if(this.multipleList == ''){ |
|
|
|
this.multipleList.push(item1.type) |
|
|
|
@ -184,7 +258,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(this.multipleList); |
|
|
|
console.log(this.multipleList) |
|
|
|
}, |
|
|
|
//去新增商品页编辑 |
|
|
|
goToAddGoods(){ |
|
|
|
@ -192,30 +266,52 @@ |
|
|
|
url: "/package1/inventory/addGoods?dataList="+JSON.stringify(this.dataList) |
|
|
|
}) |
|
|
|
}, |
|
|
|
onPrint(opt) { |
|
|
|
let strCmd = blesdk.CreatCPCLPage(440, 320, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, '商品名:'+this.dataList.productName) |
|
|
|
if(this.multipleList.indexOf('货号') != -1){ |
|
|
|
console.log(this.multipleList.indexOf('货号')) |
|
|
|
strCmd += blesdk.addCPCLText('0', '80', '24', '0', 0, '货 号:'+this.dataList.productSn) |
|
|
|
} |
|
|
|
if(this.multipleList.indexOf('供应商') != -1){ |
|
|
|
console.log(this.multipleList.indexOf('供应商')) |
|
|
|
strCmd += blesdk.addCPCLText('0', '130', '24', '0', 0, '供应商:'+this.dataList.supplierName) |
|
|
|
} |
|
|
|
if(this.multipleList.indexOf('批发价') != -1){ |
|
|
|
console.log(this.multipleList.indexOf('批发价')) |
|
|
|
strCmd += blesdk.addCPCLText('0', '180', '24', '0', 0, '批发价:'+this.dataList.wholesalePrice) |
|
|
|
} |
|
|
|
if(this.multipleList.indexOf('零售价') != -1){ |
|
|
|
console.log(this.multipleList.indexOf('零售价')) |
|
|
|
strCmd += blesdk.addCPCLText('0', '230', '24', '0', 0, '零售价:'+this.dataList.price) |
|
|
|
sliceMsg(val) { |
|
|
|
var name = '' |
|
|
|
if (typeof(val) == 'string') { |
|
|
|
let newObj = JSON.parse(val) |
|
|
|
for (let as in newObj) { |
|
|
|
name += newObj[as] + ' ' |
|
|
|
} |
|
|
|
} |
|
|
|
strCmd += blesdk.addCPCLQRCode(200, 140, 'H', '1', 6, [this.dataList.id,uni.getStorageSync('shopId')]) //二维码 |
|
|
|
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
this.$refs.payDialog.close(); |
|
|
|
return name; |
|
|
|
}, |
|
|
|
//计算打印机当前行高度 |
|
|
|
countPrint(){ |
|
|
|
return this.yNum += 50 |
|
|
|
}, |
|
|
|
onPrint(opt) { |
|
|
|
let that = this |
|
|
|
this.printList.forEach((item, index) => { |
|
|
|
|
|
|
|
for(let i=0;i<item.productCount;i++){ |
|
|
|
that.yNum = 10 |
|
|
|
let strCmd = blesdk.CreatCPCLPage(440, 320, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLText('0', '10', '24', '0', 0, '商品名:'+that.dataList.productName) |
|
|
|
if(that.multipleList.indexOf('货号') != -1){ |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '货 号:'+that.dataList.productSn) |
|
|
|
} |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '规 格:'+ that.sliceMsg(item.attributeList)) |
|
|
|
if(that.multipleList.indexOf('供应商') != -1){ |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '供应商:'+that.dataList.supplierName) |
|
|
|
} |
|
|
|
if(that.multipleList.indexOf('批发价') != -1){ |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '批发价:'+that.dataList.wholesalePrice) |
|
|
|
} |
|
|
|
if(that.multipleList.indexOf('零售价') != -1){ |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '零售价:'+that.dataList.price) |
|
|
|
} |
|
|
|
strCmd += blesdk.addCPCLQRCode(200, 140, 'H', '1', 6, [that.dataList.id,uni.getStorageSync('shopId')]) //二维码 |
|
|
|
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
} |
|
|
|
}) |
|
|
|
that.$nextTick(()=>{ |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
//悬浮按钮 |
|
|
|
trigger(e) { |
|
|
|
@ -399,7 +495,7 @@ |
|
|
|
padding-bottom: 20rpx; |
|
|
|
} |
|
|
|
.popup-pay-container { |
|
|
|
margin-top: 20rpx; |
|
|
|
margin-top: 40rpx; |
|
|
|
height: 100rpx; |
|
|
|
border-radius: 10px; |
|
|
|
background: #088FEB; |
|
|
|
@ -415,6 +511,7 @@ |
|
|
|
} |
|
|
|
.content-fur { |
|
|
|
padding-bottom: 25rpx; |
|
|
|
border-bottom: 1px solid #eee; |
|
|
|
} |
|
|
|
|
|
|
|
.content-low { |
|
|
|
@ -427,5 +524,31 @@ |
|
|
|
text-align: center; |
|
|
|
color: #777; |
|
|
|
margin: 20rpx 0 0 20rpx; |
|
|
|
} |
|
|
|
.print-btn{ |
|
|
|
width: 100rpx; |
|
|
|
height: 60rpx; |
|
|
|
line-height: 60rpx; |
|
|
|
color: #fff !important; |
|
|
|
background: #0072E3; |
|
|
|
position: absolute; |
|
|
|
top: 30rpx; |
|
|
|
right: 40rpx; |
|
|
|
border-radius: 10px; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
.bottom-btn{ |
|
|
|
width: 200rpx; |
|
|
|
height: 80rpx; |
|
|
|
line-height: 80rpx; |
|
|
|
color: #fff; |
|
|
|
background: #0072E3; |
|
|
|
border-radius: 80rpx; |
|
|
|
text-align: center; |
|
|
|
position: fixed; |
|
|
|
bottom: 75rpx; |
|
|
|
right: 0; |
|
|
|
left: 0; |
|
|
|
margin: auto; |
|
|
|
} |
|
|
|
</style> |