平板端快衣店
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.
 
 
 
 
 

431 lines
11 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 @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 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: 70%;">
{{item.attributeList | sliceMsg}}
</view>
<view class="prec-list-box" style="font-size: 26rpx;">
数量:{{item.stockCount}}
</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 class="popup-pay-container" >
<kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint" :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>
<!-- 右下角悬浮按钮 -->
<uni-fab 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: [],
bufferData: [],
horizontal: 'right',
pecsList:[],
defaultText:'',
type:'',
list:[{
type:'供应商',
checked:false,
},{
type:'货号',
checked:false,
},{
type:'零售价',
checked:false,
},{
type:'批发价',
checked:false,
}],
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
}]
}
},
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) {
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) => {})
},
//点击打印按钮
clickPrint() {
this.$refs.payDialog.open('center')
},
//选择多个规格保存
addMultipleType(item1){
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: "/pages/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)
}
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();
},
//悬浮按钮
trigger(e) {
if(e.index==0){ //销售明细
uni.navigateTo({
url: '/pages/inventory/getProductIdToList?type=0&id=' + this.dataList.id
})
}else if(e.index==1){
uni.navigateTo({
url: '/pages/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, false).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: 20rpx;
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;
}
.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;
}
</style>