平板端快衣店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

554 lines
15 KiB

<template>
<view class="page1">
<view class="content-box">
<view class="right-box">
<view class="box-left">
<img class="img-radius" :src="dataList.productPicture" alt="" v-if="dataList.productPicture">
<view class="noPic" v-else>暂无图片</view>
</view>
<view class="box-right">
<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 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> -->
</view>
</view>
</view>
<view class="box-right-price">
<view class="price-box" v-if="type == 0">
<text>{{dataList.purchasePrice == null ? '暂无':dataList.purchasePrice}}</text>
<text>平均采购价</text>
</view>
<view class="price-box">
<text>{{dataList.wholesalePrice == null ? '暂无':dataList.wholesalePrice}}</text>
<text>批发价</text>
</view>
<view class="price-box">
<text>{{dataList.price == null ? '暂无':dataList.price}}</text>
<text>零售价</text>
</view>
<view class="price-box">
<text>{{dataList.stockCount == null ? '暂无':dataList.stockCount}}</text>
<text>库存</text>
</view>
</view>
</view>
<view class="container-box" v-for="(item,index) in pecsList" :key='index'>
<view class="prec-list">
<view class="prec-list-box" :style="{width:isPrint?'40%':'70%'}">
{{item.attributeList | sliceMsg}}
</view>
<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>
<!-- 打印选择框 -->
<uni-popup ref="payDialog" background-color="#fff">
<view class="popup-pay-content">
<view class="popup-pay-title" style="margin-top: 50rpx;">
<text>请选择需要打印的字段</text>
</view>
<view class="content-fur">
<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 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>
<!-- 弹出输入框 -->
<uni-popup ref="inputDialog" type="dialog">
<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 v-if="!isPrint" ref="fab" :content="content" :horizontal="horizontal"
@trigger="trigger" />
</view>
</template>
<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';
export default {
data() {
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: [{
iconPath: '/static/images/tabbar/home.png',
selectedIconPath: '/static/images/tabbar/home-sel.png',
text: '销售明细',
active: false
},{
iconPath: '/static/images/tabbar/home.png',
selectedIconPath: '/static/images/tabbar/home-sel.png',
text: '入库明细',
active: false
},{
iconPath: '/static/images/tabbar/home.png',
selectedIconPath: '/static/images/tabbar/home-sel.png',
text: '删除商品',
active: false
}],
printList:new Map(),
yNum: 10,
isShow:true
}
},
filters: {
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + '/'
}
}
return name;
},
maxNum(val){
if(val >= 10){
return 10
}else if(val < 0){
return 0
}
}
},
components: {
kkPrinter
},
onLoad(option) {
// 初始化蓝牙模块
wx.openBluetoothAdapter({mode: 'central'})
this.dataList = JSON.parse(option.item);
this.type = uni.getStorageSync('type')
},
onShow(){
this.getShareList();
},
methods: {
//库存商品详情
getShareList() {
this.tui.request("/app/stock/productCount", "GET", {
productId: this.dataList.id
}, false, true).then((res) => {
if (res.code == 200) {
this.pecsList = res.result
} else {
this.tui.toast(res.message)
}
}).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)
}else{
for(var i=0;i<this.multipleList.length;i++){
if(this.multipleList[i] == item1.type){ //相同
this.multipleList.splice(i,1)
return;
}else{ //不同
if(i+1 == this.multipleList.length){
this.multipleList.push(item1.type)
return;
}
}
}
}
console.log(this.multipleList)
},
//去新增商品页编辑
goToAddGoods(){
uni.navigateTo({
url: "/package1/inventory/addGoods?dataList="+JSON.stringify(this.dataList)
})
},
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + ' '
}
}
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) {
if(e.index==0){ //销售明细
uni.navigateTo({
url: '/package1/inventory/getProductIdToList?type=0&id=' + this.dataList.id
})
}else if(e.index==1){
uni.navigateTo({
url: '/package1/inventory/getProductIdToList?type=1&id=' + this.dataList.id
})
}else{
this.delGoods()
}
},
delGoods(){
let that = this;
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
if(res.confirm){
that.tui.request('/app/product/delById', "post", {
id:that.dataList.id
}, false, true).then((res1) => {
if (res1.code == 200) {
uni.navigateBack({
delta: 1
})
} else {
uni.showToast({
title: "删除失败",
icon: 'none'
})
}
})
}
}
})
}
}
}
</script>
<style lang="scss">
page {
height: 100%;
}
.page1 {
display: flex;
flex-direction: column;
height: 100%;
}
.content-box {
background: #fff;
}
.right-box {
width: 100%;
height: 220rpx;
display: flex;
border-bottom: 1px solid #eee;
position: relative;
}
.box-left {
width: 170rpx;
height: 170rpx;
background-size: 100%;
margin: 25rpx;
border-radius: 20rpx;
}
.box-left img {
width: 100%;
height: 100%;
}
.box-right {
margin-top: 20rpx;
flex: 1;
display: flex;
flex-direction: column;
position: relative;
}
.box-right-name {
font-size: 30rpx;
font-weight: bold;
padding-left: 20rpx;
height: 30%;
}
.box-right-num {
padding: 5rpx 0;
color: #777;
padding-left: 20rpx;
height: 30%;
}
.box-right-price {
display: flex;
font-size: 25rpx;
height: 100rpx;
}
.price-box {
flex: 1;
text-align: center;
display: flex;
flex-direction: column;
margin-top: 20rpx;
}
.container-box {
border-top: 10px solid #eee;
}
.price-box text:first-child {
color: #ffa200
}
.edit-btn {
width: 100rpx;
height: 60rpx;
line-height: 60rpx;
color: #fff;
background: #0072E3;
position: absolute;
top: 105rpx;
right: 40rpx;
border-radius: 10px;
text-align: center;
}
.prec-list {
height: 80rpx;
line-height: 80rpx;
background: #fff;
display: flex;
font-size: 32rpx;
border-bottom: 1px solid #eee;
}
.prec-list-box {
height: 70rpx;
line-height: 70rpx;
padding: 0 30rpx;
overflow: hidden;
}
.noPic{
border-radius: 10px;
width: 150rpx;
height: 150rpx;
// margin: 30rpx 0 0 30rpx;
text-align: center;
line-height: 140rpx;
color: #777;
background: #eee;
}
.popup-pay-content {
align-items: center;
justify-content: center;
padding: 15px;
width: 500rpx;
height: auto;
max-height: 1000rpx;
overflow: scroll;
background-color: #fff;
}
.popup-pay-title {
font-size: 30rpx;
font-weight: bold;
text-align: center;
position: relative;
border-bottom: 1px solid #eee;
padding-bottom: 20rpx;
}
.popup-pay-container {
margin-top: 40rpx;
height: 100rpx;
border-radius: 10px;
background: #088FEB;
line-height: 100rpx;
text-align: center;
border-bottom: 1px solid #eee;
border-top: 1px solid #eee;
color: #fff;
}
.checked{
background: #60F3FF;
color: #fff !important;
}
.content-fur {
padding-bottom: 25rpx;
border-bottom: 1px solid #eee;
}
.content-low {
width: auto;
border: 1px solid #eee;
display: inline-block;
min-width: 90rpx;
padding: 5rpx;
font-size: 35rpx;
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>