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.
 
 
 
 
 

1791 lines
70 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" v-if='(shopId == "1960543009070256129" && (shopOwnerPhone == username || username == dataList.createBy)) || shopId != "1960543009070256129"' @tap="goToAddGoods">编辑</view>
<view v-if="!isPrint" @tap="printBtn" class="print-btn">
打印
</view>
<view v-if="isPrint" @tap="isPrint=false" 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" v-if ='shopId != "1960543009070256129"'>
<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 class="box-right-price" v-else>
<view class="price-box" v-if="shopOwnerPhone == username || username == dataList.createBy">
<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 style="background: #fff;border: 1px solid #eee;">
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#007aff"></uni-segmented-control>
</view>
<view class="content" style="background: #fff;">
<view v-show="current === 0">
<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%':'64%'}">
{{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;" />
<uni-icons type="close" @tap="delSpec(item)" v-if="isPrint == false" size="30" color="#777"></uni-icons>
</view>
</view>
</view>
</view>
<view v-show="current === 1">
<view v-for="(item,index) in detailList" :key="index">
<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
<text style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
{{item.createTime}}
</text>
<text style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
操作:{{item.createByName}}
</text>
</view>
<uni-table border stripe emptyText="暂无更多数据" v-if ='shopId != "1960543009070256129"'>
<uni-tr style="background: #eee;">
<uni-th align="center" width="85">客户</uni-th>
<uni-th align="center" width="50">数量</uni-th>
<uni-th align="center" width="70">拿货价</uni-th>
<uni-th align="center" width="70">采购价</uni-th>
<uni-th align="center" width="70">总利润</uni-th>
</uni-tr>
<uni-tr @tap="xiaoshouDetail(item)">
<uni-td align="center">{{item.userName}}</uni-td>
<uni-td align="center">{{item.productCount}}</uni-td>
<uni-td align="center">{{item.saleDetailDTOList[0].discountAmount}}</uni-td>
<uni-td align="center">{{type == 0?(item.saleDetailDTOList[0].purchasePrice != null ? item.saleDetailDTOList[0].purchasePrice:0):0}}</uni-td>
<uni-td align="center">{{type == 0?item.lirun:0}}</uni-td>
</uni-tr>
</uni-table>
<uni-table border stripe emptyText="暂无更多数据" v-else>
<uni-tr style="background: #eee;">
<uni-th align="center" width="85">客户</uni-th>
<uni-th align="center" width="50">数量</uni-th>
<uni-th align="center" width="70">拿货价</uni-th>
</uni-tr>
<uni-tr @tap="xiaoshouDetail(item)">
<uni-td align="center">{{item.userName}}</uni-td>
<uni-td align="center">{{item.productCount}}</uni-td>
<uni-td align="center">{{item.saleDetailDTOList[0].discountAmount}}</uni-td>
</uni-tr>
</uni-table>
</view>
</view>
<view v-show="current === 2">
<view v-for="(item,index) in detailList" :key="index">
<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
<text style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
{{item.createTime}}
</text>
<text style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
操作:{{item.createByName?item.createByName:''}}
</text>
</view>
<uni-table border stripe emptyText="暂无更多数据">
<uni-tr style="background: #eee;">
<uni-th align="center" width="85">客户</uni-th>
<uni-th align="center" width="50">数量</uni-th>
<uni-th align="center" width="70">退货价</uni-th>
<uni-th align="center" width="70" v-if ='shopId != "1960543009070256129"'>采购价</uni-th>
</uni-tr>
<uni-tr @tap="tuihuoDetail(item)">
<uni-td align="center">{{item.userName?item.userName:''}}</uni-td>
<uni-td align="center">{{item.returnSaleDetailList[0].productCount?item.returnSaleDetailList[0].productCount:'0'}}</uni-td>
<uni-td align="center">{{item.returnSaleDetailList[0].discountAmount?item.returnSaleDetailList[0].discountAmount:'0'}}</uni-td>
<uni-td align="center" v-if ='shopId != "1960543009070256129"'>{{type == 0?(item.returnSaleDetailList[0].purchasePrice?item.returnSaleDetailList[0].purchasePrice:'0'):0}}</uni-td>
</uni-tr>
</uni-table>
</view>
</view>
<view v-show="current === 3">
<view v-for="(item,index) in detailList" :key="index" @tap="goDetail(item)">
<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
<text style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
{{item.purchase.createTime}}
</text>
<text style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
操作:{{item.purchase.createByName}}
</text>
</view>
<uni-table border stripe emptyText="暂无更多数据" v-if ='shopId != "1960543009070256129"'>
<uni-tr style="background: #eee;">
<uni-th align="center" width="85">供应商</uni-th>
<uni-th align="center" width="50">数量</uni-th>
<uni-th align="center" width="70">进货价</uni-th>
<uni-th align="center" width="70">总价</uni-th>
</uni-tr>
<uni-tr>
<uni-td align="center">{{item.purchase.supplierName == null ?'':item.purchase.supplierName}}</uni-td>
<uni-td align="center" @tap.stop="rukuDetail(item.purchaseDetails[0])"><text style="color:blue;text-decoration: underline;">{{item.purchase.totalAmount}}</text></uni-td>
<uni-td align="center">{{type == 0?(item.purchaseDetails[0].purchasePrice==null?0:item.purchaseDetails[0].purchasePrice):0}}</uni-td>
<uni-td align="center">{{type == 0?item.purchaseDetails[0].zPrice:0}}</uni-td>
</uni-tr>
</uni-table>
</view>
</view>
<view v-show="current === 4">
<view v-for="(item,index) in detailList" :key="index" @tap="goDetail(item)">
<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
<text style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
{{item.purchase.createTime}}
</text>
<text style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
操作:{{item.purchase.createByName}}
</text>
</view>
<uni-table border stripe emptyText="暂无更多数据" v-if ='shopId != "1960543009070256129"'>
<uni-tr style="background: #eee;">
<uni-th align="center" width="85">供应商</uni-th>
<uni-th align="center" width="50">数量</uni-th>
<uni-th align="center" width="70">进货价</uni-th>
<uni-th align="center" width="70">总价</uni-th>
</uni-tr>
<uni-tr>
<uni-td align="center">{{item.purchase.supplierName==null?'':item.purchase.supplierName}}</uni-td>
<uni-td align="center" @tap.stop="rukuDetail(item.purchaseDetails[0])"><text style="color:blue;text-decoration: underline;">{{item.purchase.totalAmount}}</text></uni-td>
<uni-td align="center">{{type == 0?(item.purchaseDetails[0].purchasePrice==null?0:item.purchaseDetails[0].purchasePrice):0}}</uni-td>
<uni-td align="center">{{type == 0?item.purchaseDetails[0].zPrice:0}}</uni-td>
</uni-tr>
</uni-table>
</view>
</view>
</view>
<!-- 打印选择框 -->
<uni-popup ref="payDialog" background-color="#fff">
<view class="popup-pay-content">
<uni-forms-item label="打印方式" name="type" labelWidth="170rpx">
<uni-data-select style="width: 100%" v-model="printingMethod" :localdata="typeList"></uni-data-select>
</uni-forms-item>
<uni-forms-item label="打印模板" name="shipType" labelWidth="170rpx" v-if='shopprintList.length > 0'>
<uni-data-select style="width: 100%" v-model="shopprintContent" :localdata="shopprintList"></uni-data-select>
</uni-forms-item>
<view class="popup-pay-title" style="margin-top: 50rpx;">
<text>请选择需要打印的字段</text>
</view>
<view class="content-fur" v-if="shopId != '1960543009070256129'">
<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="content-fur" v-if="shopId == '1960543009070256129'">
<view class="content-low" v-for="(item1,index1) in list1" :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-model="dataList.supplierName" 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-model="dataList.productSn" 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-model="dataList.productName" 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[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-model="dataList.price" type="digit" placeholder="请输入" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list[4].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-model="dataList.wholesalePrice" type="digit" placeholder="请输入批发价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.supplierName" type="text" placeholder="请输入供应商名称" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.productSn" type="text" placeholder="请输入货号" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.productName" type="text" placeholder="请输入品名" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.price" type="digit" placeholder="请输入日常价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[4].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-model="dataList.wholesalePrice" type="digit" placeholder="请输入直播价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view class="popup-pay-container" @tap="clickPrint">
确认
</view>
</view>
</uni-popup>
<!-- 自定义打印选择框 -->
<uni-popup ref="zidingyiDialog" background-color="#fff">
<view class="popup-pay-content">
<view class="popup-pay-title" style="border-bottom: 0;">
<text>打印方式</text>
</view>
<uni-data-select v-if="zidingyi" style="width: 100%" v-model="printingMethod" :localdata="typeList1"></uni-data-select>
<uni-data-select style="width: 100%" v-else v-model="printingMethod" :localdata="typeList"></uni-data-select>
<view class="popup-pay-title" style="border-bottom: 0;padding-top: 20rpx;" v-if='printingMethod == "0" || printingMethod == "1"'>
<text>打印二维码</text>
</view>
<uni-data-select v-if='printingMethod == "0" || printingMethod == "1"' style="width: 100%" v-model="isQRCode" :localdata="printQR"></uni-data-select>
<view class="popup-pay-title" style="border-bottom: 0;padding-top: 20rpx;" v-if='shopprintList.length > 0 && (printingMethod == "0" || printingMethod == "3")'>
<text>打印模板</text>
</view>
<uni-data-select v-if='shopprintList.length > 0 && (printingMethod == "0" || printingMethod == "3")' style="width: 100%" v-model="shopprintContent" @change="changeList" :localdata="shopprintList"></uni-data-select>
<view class="popup-pay-title" style="margin-top: 50rpx;text-align: center;">
<text>请选择需要打印的字段</text>
</view>
<view v-if='printingMethod != "6"' 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-model="color" :disabled="closetanPopup" type="text" placeholder="请输入颜色名" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if='printingMethod != "6"' 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-model="size" :disabled="closetanPopup" type="text" placeholder="请输入尺码值" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view 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-model="number" :disabled="closetanPopup" type="digit" placeholder="请输入数量" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if='printingMethod == "6"' 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-model="customizeText" @change="changeCustomize" type="text" placeholder="建议字符不超过两个" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view class="content-fur" v-if="shopId != '1960543009070256129' && printingMethod !='2' && printingMethod !='4' && printingMethod !='5' && printingMethod !='6'">
<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="content-fur" v-if="shopId == '1960543009070256129' && printingMethod !='2' && printingMethod !='4' && printingMethod !='5' && printingMethod !='6'">
<view class="content-low" v-for="(item1,index1) in list1" :key="index1"
@tap.stop="addMultipleType(item1)" :class="item1.checked?'checked':''">{{item1.type}}</view>
</view>
<view v-if="printingMethod =='2' || printingMethod =='4'" 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-model="dataList.productSn" :disabled="closetanPopup" 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[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-model="dataList.supplierName" :disabled="closetanPopup" 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-model="dataList.productSn" :disabled="closetanPopup" 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-model="dataList.productName" :disabled="closetanPopup" 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[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-model="dataList.price" :disabled="closetanPopup" type="digit" placeholder="请输入" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list[4].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-model="dataList.wholesalePrice" :disabled="closetanPopup" type="digit" placeholder="请输入批发价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.supplierName" :disabled="closetanPopup" type="text" placeholder="请输入供应商名称" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.productSn" :disabled="closetanPopup" type="text" placeholder="请输入货号" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.productName" :disabled="closetanPopup" type="text" placeholder="请输入品名" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[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-model="dataList.price" :disabled="closetanPopup" type="digit" placeholder="请输入日常价" style="display: flex;height: 80rpx;width: 300rpx;line-height: 80rpx;padding-left: 20rpx;border: 1px solid #eee;">
</view>
<view v-if="list1[4].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-model="dataList.wholesalePrice" :disabled="closetanPopup" type="digit" 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="onPrint1" :printNum="printNum" :defaultText="'打印'"></kk-printer>
</view>
</view>
</uni-popup>
<!-- 弹出商品规格 -->
<uni-popup ref="detailPopup" background-color="#fff">
<view class="detail-popup">
<view @tap="$refs.detailPopup.close()" style='width: 50rpx;height: 50rpx;position: absolute;right: 20rpx;top: 25rpx;'>
<uni-icons type="closeempty" color="red" size="22"></uni-icons>
</view>
<view style="height: 100rpx;line-height: 100rpx;font-weight: bold;font-size: 36rpx;text-align: center;">
</view>
<uni-table border stripe emptyText="暂无更多数据" style="margin-bottom: 20rpx;border-radius: 10px;">
<!-- 表头行 -->
<uni-tr style="background: #eee;">
<uni-th align="center" width="80">规格</uni-th>
<uni-th align="center" width="55">数量</uni-th>
</uni-tr>
<!-- 表格数据行 -->
<uni-tr v-for="(item,index) in GDList.stockLogList" :key="index">
<uni-td align="center">{{item.attributeList | sliceMsg}}</uni-td>
<uni-td align="center">{{item.productCount}}</uni-td>
</uni-tr>
</uni-table>
</view>
</uni-popup>
<!-- 弹出输入框 -->
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog ref="inputClose" mode="input" inputType="digit" title="采购价" placeholder="请输入采购价"
@confirm="changePrice"></uni-popup-dialog>
</uni-popup>
<view v-if="isPrint" class="bottom-btn">
<kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint" :printNum="printNum" :defaultText="'打印'"></kk-printer>
</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';
import base from '@/utils/ossUploadFile/base64.js';
export default {
data() {
return {
pageNum: 1, //分页的页码
pages:1,
dataList: [],
shopId:'',
closetanPopup:false,
detailList:[],
typeList1: [{
value: '0',
text: "厂标(40*60)"
},
{
value: '3',
text: "厂标(50*80)"
},
{
value: '1',
text: "二维码签(50*40)"
},
{
value: '5',
text: "标签(40*30)"
},
{
value: '2',
text: "大号标签居中(50*40)"
},
{
value: '4',
text: "大号标签居左(50*40)"
},
{
value: '6',
text: "标签居中(20*10)"
},
],
typeList: [{
value: '0',
text: "打印长票"
},
{
value: '1',
text: "打印短票"
},
],
printQR: [{
value: '0',
text: "打印"
},
{
value: '1',
text: "不打印"
},
],
isQRCode:'0',
GDList:[],
customizeText:'',
printingMethod:"0",
zidingyi:false,
shopprintContent:'',
shopOwnerPhone:uni.getStorageSync('shopOwnerPhone'),
username:uni.getStorageSync('username'),
shopprintList:[],
isPrint:false,
bufferData: [],
items:['库存', '销售明细', '销售退货','入库明细'],
current: 0,
horizontal: 'right',
pecsList:[],
defaultText:'',
type:uni.getStorageSync('type'),
size:'',
color:'',
number:'',
printNum:1,
list1:[{
type:'供应商',
checked:false,
text:''
},{
type:'货号',
checked:false,
text:''
},{
type:'品名',
checked:false,
text:''
},{
type:'日常价',
checked:false,
text:''
},{
type:'直播价',
checked:false,
text:''
}],
list:[{
type:'供应商',
checked:false,
text:''
},{
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
}],
printList:new Map(),
shippList:[],
yNum: 10,
}
},
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
},
onHide(){
setTimeout(res=>{
uni.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success(res) {
},fail(err){
}
})
},5000)
},
onLoad(option) {
// 初始化蓝牙模块
wx.openBluetoothAdapter({mode: 'central'})
this.getCategoryList()
this.dataList = JSON.parse(option.item);
},
onReachBottom() {
if (this.pageNum >= this.pages) return;
this.status = 'loading';
this.pageNum ++;
this.getWaitStorage();
},
onShow(){
this.shopId = uni.getStorageSync('shopId')
this.getShareList();
},
methods: {
changeList(){
if(this.shopprintContent != ''){
let newObj = JSON.parse(this.shopprintContent)
this.shippList = newObj
}
for(let i=0;i<this.shippList.length;i++){
if(this.shippList[i].leftIcon != ''){
for(let j = 0;j<this.shippList[i].leftIcon.length;j++){
this.getWeitu(this.shippList[i].leftIcon[j],i,j,'left')
}
}
if(this.shippList[i].rightIcon != ''){
for(let j = 0;j<this.shippList[i].rightIcon.length;j++){
this.getWeitu(this.shippList[i].rightIcon[j],i,j,'right')
//this.shippList[i].rightIcon[j] = "1FFFFFF01FFFFFF83000000830000008300000083000000830000009B000000F7FFFFFFC380000381C0000481300018810C7E608107FF808101C38081036CC0810638608106666081078360810600E0810FFFF08136006C81C60047830300C1C7018180E900FF009100000081000000810000008100000081FFFFFF800000000"
}
}
}
this.shopprintContent = JSON.stringify(this.shippList)
},
getWeitu(id,i,j,type){
let that = this
this.tui.request('/app/urlMapping/redirect', "get", {
notRedirect: true,
id: id,
}, false, false).then((res) => {
if(type == 'left'){
that.shippList[i].leftIcon[j] = res.message.split(': ')[1].replace(new RegExp('EG 4 32 32 32 ', 'g'), '')
}else{
that.shippList[i].rightIcon[j] = res.message.split(': ')[1].replace(new RegExp('EG 4 32 32 32 ', 'g'), '')
}
}).catch((res) => {})
},
getWaitStorage() {
this.status = 'loading';
var url;
if(this.current==1){ //销售
url = "/app/sale/getSaleListByProductId"
}else if(this.current==2){ //销售退货
url = "/app/return/getReturnSaleListByProductId"
}else if(this.current==3){ //入库
url = "/app/purchase/getPurchaseListByProductId"
}else if(this.current==4){ //退货
url = "/app/purchase/getPurchaseListByProductId"
}
this.tui.request(url, "post", {
productId: this.dataList.id,
pageSize: 10,
pageNum: this.pageNum
}, false, false).then((res) => {
this.status = 'nomore';
if (res.code == 200) {
// this.list = res.result.records
if (this.pages == 1) {
this.detailList = res.result.records
} else {
this.detailList = [...this.detailList, ...res.result.records]
}
if(this.current==1){
for(let i=0;i<this.detailList.length;i++){
this.detailList[i].lirun = 0
this.detailList[i].productCount = 0
for(let m=0;m<this.detailList[i].saleDetailDTOList.length;m++){
this.detailList[i].lirun += (Number(this.detailList[i].saleDetailDTOList[m].discountAmount) - Number(this.detailList[i].saleDetailDTOList[m].purchasePrice)) * Number(this.detailList[i].saleDetailDTOList[m].stockLogList1[0].productCount)
this.detailList[i].productCount += this.detailList[i].saleDetailDTOList[m].stockLogList1[0].productCount
}
this.detailList[i].lirun = this.detailList[i].lirun.toFixed(2)
}
}else if(this.current==2){
for(let i=0;i<this.detailList.length;i++){
this.detailList[i].returnSaleDetailList[0].productCount = 0
for(let m=0;m<this.detailList[i].returnSaleDetailList[0].stockLogList1.length;m++){
this.detailList[i].returnSaleDetailList[0].productCount += this.detailList[i].returnSaleDetailList[0].stockLogList1[m].productCount
}
}
}else if(this.current==3){
for(let i=0;i<this.detailList.length;i++){
for(let m=0;m<this.detailList[i].purchaseDetails.length;m++){
this.detailList[i].purchaseDetails[m].zPrice = this.detailList[i].purchaseDetails[m].productCount * this.detailList[i].purchaseDetails[m].purchasePrice
}
}
}
this.pages = res.result.pages
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//库存商品详情
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) => {})
},
changeCustomize(e){
this.customizeText = e.detail.value
},
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)
}
},
printBtn(){
this.$refs.payDialog.open('center')
},
//点击打印按钮
clickPrint() {
this.$refs.payDialog.close()
this.isPrint = !this.isPrint
},
emitPrint(){
this.closetanPopup = true
},
rukuDetail(item){
if(item){
item.stockLogList = []
for(let i=0;i<item.stockLogList1.length;i++){
item.stockLogList.push(item.stockLogList1[i])
}
this.GDList = item
this.$refs.detailPopup.open()
}
},
xiaoshouDetail(item){
if(item){
item.saleDetailDTOList[0].stockLogList = []
for(let i=0;i<item.saleDetailDTOList.length;i++){
item.saleDetailDTOList[0].stockLogList.push(item.saleDetailDTOList[i].stockLogList1[0])
}
this.GDList = item.saleDetailDTOList[0]
this.$refs.detailPopup.open()
}
},
tuihuoDetail(item){
if(item){
item.returnSaleDetailList[0].stockLogList = []
for(let i=0;i<item.returnSaleDetailList[0].stockLogList1.length;i++){
item.returnSaleDetailList[0].stockLogList.push(item.returnSaleDetailList[0].stockLogList1[i])
}
this.GDList = item.returnSaleDetailList[0]
this.$refs.detailPopup.open()
}
},
onClickItem(e) {
this.pageNum = 1
this.detailList = []
if (this.current !== e.currentIndex) {
this.current = e.currentIndex
}
if(e.currentIndex == 0){
this.getShareList();
}else if(e.currentIndex == 1){
this.getWaitStorage('1')
}else if(e.currentIndex == 2){
this.getWaitStorage('2')
}else if(e.currentIndex == 3){
this.getWaitStorage('3')
}
},
//点击打印按钮
clickzidingyiPrint() {
this.$refs.zidingyiDialog.close()
// this.isPrint = !this.isPrint
},
//选择多个规格保存
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
}else if(item1.type== '直播价'){
item1.text = this.dataList.wholesalePrice
}else if(item1.type== '日常价'){
item1.text = this.dataList.price
}else if(item1.type== '品名'){
item1.text = this.dataList.productName
}
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;
}
}
}
}
},
//去新增商品页编辑
goToAddGoods(){
uni.navigateTo({
url: "/package1/inventory/addGoods?dataList="+JSON.stringify(this.dataList)
})
},
delSpec(item){
let that = this;
uni.showModal({
title: "提示",
content: "确定删除此条库存吗?",
success: function(res) {
if(res.confirm){
that.tui.request('/app/stock/deleteStockById', "post", {
id:item.id
}, false, true).then((res1) => {
if (res1.code == 200) {
uni.showToast({
title: "删除成功",
icon: 'none'
})
that.getShareList()
if(item.stockCount > 0){
that.dataList.stockCount = that.dataList.stockCount - item.stockCount
uni.removeStorageSync('noReload')
}
} else {
uni.showToast({
title: "删除失败",
icon: 'none'
})
}
})
}
}
})
},
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) => {
if(item.productCount < 1){
this.tui.toast('请输入 '+ item.attributeList +' 数量再打印')
return
}
for(let i=0;i<item.productCount;i++){
that.yNum = 10
let shippList = []
if(that.shopprintContent != ''){
let newObj = JSON.parse(that.shopprintContent)
for (let as in newObj) {
let data = {
name:as,
value:newObj[as]
}
shippList.push(data)
}
}
if(this.printingMethod == "0"){ //长票打印
that.yNum = 20
let noBegin = true
let strCmd = blesdk.CreatCPCLPage(320, 480, 1, 0);
if(that.multipleList.indexOf('供应商') != -1){
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLSETBOLD('400');
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, (that.dataList.supplierName== null?'':that.dataList.supplierName))
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('0');
if(that.dataList.supplierName== null || that.dataList.supplierName== '' || that.multipleList.indexOf('供应商') == -1){
noBegin = false
strCmd += blesdk.addCPCLText('20', that.yNum += 30, '24', '0', 0, '品名: '+(that.dataList.productName== null?'':that.dataList.productName))
}else{
if(that.multipleList.indexOf('品名') != -1){
noBegin = false
strCmd += blesdk.addCPCLText('20', that.yNum += 60, '24', '0', 0, '品名: '+(that.dataList.productName== null?'':that.dataList.productName))
}
}
if(that.multipleList.indexOf('货号') != -1){
if(that.multipleList.indexOf('品名') != -1){
noBegin = false
strCmd += blesdk.addCPCLText('20', that.yNum += 40 , '24', '0', 0, '货号: '+that.dataList.productSn)
}else{
noBegin = false
strCmd += blesdk.addCPCLText('20', that.yNum += 60 , '24', '0', 0, '货号: '+that.dataList.productSn)
}
}
if(noBegin){
that.yNum += 20
}
strCmd += blesdk.addCPCLText('20', that.yNum += 40, '24', '0', 0, '规格: '+ that.sliceMsg(item.attributeList))
if(that.multipleList.indexOf('批发价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 40, '24', '0', 0, '批发价: '+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('零售价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 40, '24', '0', 0, '零售价: '+that.dataList.price)
}
if(that.multipleList.indexOf('直播价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 40, '24', '0', 0, '直播价: '+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('日常价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 40, '24', '0', 0, '日常价: '+that.dataList.price)
}
let codeWidth = 0
if(shippList.length > 0){
for(let j=0;j<shippList.length;j++){
strCmd += blesdk.addCPCLText('20', that.yNum += 40, '24', '0', 0, shippList[j].value.name+': '+shippList[j].value.value)
}
strCmd += blesdk.addCPCLLocation(1);
codeWidth = 310
}else{
strCmd += blesdk.addCPCLLocation(2);
codeWidth = that.yNum + 60
}
//这两家不打二维码
if(uni.getStorageSync('shopId') != '1852911225860657153' && uni.getStorageSync('shopId') != '1818888277105709056'){
strCmd += blesdk.addCPCLQRCode(0, codeWidth, 'M', '1', 4, [base.encode(that.dataList.id),base.encode(uni.getStorageSync('shopId').substring('10','12')),encodeURIComponent(that.sliceMsg(item.attributeList).split(' ')[0])+'-'+encodeURIComponent(that.sliceMsg(item.attributeList).split(' ')[1])]) //二维码
}
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}else{
let strCmd = blesdk.CreatCPCLPage(410, 320, 1, 0);
if(that.multipleList.indexOf('供应商') != -1){
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLSETBOLD('400');
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '2', 0, (that.dataList.supplierName== null?'':that.dataList.supplierName))
}
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('0')
if(that.multipleList.indexOf('品名') != -1){
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('30', that.yNum+=60, '24', '0', 0, '品名:'+(that.dataList.productName==null?'':that.dataList.productName))
}
strCmd += blesdk.addCPCLSETMAG(2, 2)
if(that.multipleList.indexOf('货号') != -1){
if(that.multipleList.indexOf('品名') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += 40, '24', '1', 0, '货号:'+that.dataList.productSn)
}else{
strCmd += blesdk.addCPCLText('30', that.yNum += 60, '24', '1', 0, '货号:'+that.dataList.productSn)
}
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, that.sliceMsg(item.attributeList))
if(that.multipleList.indexOf('批发价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '批发价:'+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('零售价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '零售价:'+that.dataList.price)
}
if(that.multipleList.indexOf('直播价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '直播价:'+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('日常价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '日常价:'+that.dataList.price)
}
strCmd += blesdk.addCPCLQRCode(240, 160, 'M', '1', 4, [base.encode(that.dataList.id),base.encode(uni.getStorageSync('shopId').substring('10','12')),encodeURIComponent(that.sliceMsg(item.attributeList).split(' ')[0])+'-'+encodeURIComponent(that.sliceMsg(item.attributeList).split(' ')[1])]) //二维码
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}
})
that.$nextTick(()=>{
uni.navigateBack({
delta: 1
})
})
},
countLeadingSpaces(str) {
const match = str.match(/^\s*/);
return match ? match[0].length : 0;
},
goDetail(item){
// uni.setStorageSync('noReload',true)
uni.navigateTo({
url: '/package1/index/waitStorageDetail?id=' + item.purchase.id
})
},
onPrint1(opt) {
let that = this
if(this.number == ''){
this.tui.toast('请输入'+ (this.number == ''?'数量':'')+'再打印')
return
}
if(this.zidingyi && (this.printingMethod == "2" || this.printingMethod == "4")){
for(let i=0;i<this.number;i++){
that.yNum = 56
let strCmd = blesdk.CreatCPCLPage(400, 320, 1, 0);
if(this.printingMethod == '2'){
strCmd += blesdk.addCPCLLocation(2);
}else{
strCmd += blesdk.addCPCLLocation(0);
}
strCmd += blesdk.addCPCLSETBOLD('500')
strCmd += blesdk.addCPCLSETMAG(2, 2)
if(this.printingMethod == '2'){
strCmd += blesdk.addCPCLText('20', that.yNum, '24', '1', 0, that.dataList.productSn)
strCmd += blesdk.addCPCLText('20', that.yNum+=80, '24', '0', 0, this.color)
strCmd += blesdk.addCPCLText('20', that.yNum+=80, '24', '0', 0, this.size)
}else{
strCmd += blesdk.addCPCLText('60', that.yNum, '24', '1', 0, that.dataList.productSn)
strCmd += blesdk.addCPCLText('60', that.yNum+=80, '24', '0', 0, this.color)
strCmd += blesdk.addCPCLText('60', that.yNum+=80, '24', '0', 0, this.size)
}
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}else if(this.printingMethod == "5"){
for(let i=0;i<this.number;i++){
that.yNum = 28
let strCmd = blesdk.CreatCPCLPage(400, 300, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('500')
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLText('110', that.yNum, '24', '1', 0, '款号:'+that.dataList.productSn)
strCmd += blesdk.addCPCLText('110', that.yNum+=60, '24', '0', 0, '颜色:'+this.color)
strCmd += blesdk.addCPCLText('110', that.yNum+=60, '24', '0', 0, '尺码:'+this.size)
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}else if(this.printingMethod == "6"){
let strCmd
for(let i=0;i<this.number;i++){
if((i+1) % 2 === 0){ //能被2整除的放到后面
if(this.customizeText.length < 3){
strCmd += blesdk.addCPCLText((((160-this.customizeText.length*40)/2)+200), '24', '24', '1', 0, this.customizeText)
}else{
strCmd += blesdk.addCPCLText('214', '24', '24', '1', 0, this.customizeText)
}
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}else{
strCmd = blesdk.CreatCPCLPage(360, 80, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('500')
strCmd += blesdk.addCPCLSETMAG(2, 2)
if(this.customizeText.length < 3){
strCmd += blesdk.addCPCLText((((160-this.customizeText.length*40)/2)+20), '24', '24', '1', 0, this.customizeText)
}else{
strCmd += blesdk.addCPCLText("34", '24', '24', '1', 0, this.customizeText)
}
if(this.number == (i+1)){
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
strCmd = ''
}
}
}
}else{
if(this.printingMethod == "0"){ //竖排打印
for(let i=0;i<this.number;i++){
that.yNum = 20
let bgineNum = 0
if(that.multipleList.indexOf('品名') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('货号') != -1){
bgineNum += 1
}
if(this.color != '' || this.size !=''){
bgineNum += 1
}
if(that.multipleList.indexOf('批发价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('零售价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('直播价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('日常价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('供应商') != -1){
bgineNum += 2
}
for(let j=0;j<that.shippList.length;j++){
if(that.shippList[j].name.length > 12){
let num = Math.ceil(Number(that.shippList[j].name.length) / 12)
bgineNum += num
}else{
bgineNum += 1
}
}
let offHeigth = 0
offHeigth = Math.ceil((400 - bgineNum * 24) / bgineNum)
if(bgineNum <= 7 && this.isQRCode == "0"){
offHeigth = 30
}
let strCmd = blesdk.CreatCPCLPage(320, 480, 1, 0);
strCmd += blesdk.addCPCLSETBOLD('1');
if(that.multipleList.indexOf('供应商') != -1){
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, (that.dataList.supplierName==null?'':that.dataList.supplierName))
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('20', that.yNum += 20, '24', '0', 0, '')
if(that.multipleList.indexOf('品名') != -1){
if(uni.getStorageSync('shopId') == '1853332569559535619'){
strCmd += blesdk.addCPCLSETMAG(2, 2)
}
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '品名: '+(that.dataList.productName==null?'':that.dataList.productName))
}
if(that.multipleList.indexOf('货号') != -1){
if(uni.getStorageSync('shopId') == '1853332569559535619'){
strCmd += blesdk.addCPCLSETMAG(2, 2)
}
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '货号: '+(that.dataList.productSn==null?'':that.dataList.productSn))
}
if(this.color != '' || this.size !=''){
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '规格: '+ this.color+' '+this.size)
}
if(that.multipleList.indexOf('批发价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '批发价: '+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('零售价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '零售价: '+that.dataList.price)
}
if(that.multipleList.indexOf('直播价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '直播价: '+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('日常价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += (25 + offHeigth), '24', '0', 0, '日常价: '+that.dataList.price)
}
let codeWidth = 0
if(that.shippList.length > 0){
for(let j=0;j<that.shippList.length;j++){
let iconWidth = 0
if(that.shippList[j].modelLeft == 'right'){
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLLocation(0);
let allWidth = 300
if((that.shippList[j].name + that.shippList[j].value).length > 0){
allWidth -= 20
}
iconWidth = Math.floor((allWidth - ((that.shippList[j].leftIcon.length + that.shippList[j].rightIcon.length) * 32 + (that.shippList[j].name + that.shippList[j].value).length * 25)) / 2)
}else{
strCmd += blesdk.addCPCLLocation(2);
}
}else{
strCmd += blesdk.addCPCLLocation(0);
}
if(that.shippList[j].modelBlod == 'notblod'){
strCmd += blesdk.addCPCLSETBOLD('0');
}else{
strCmd += blesdk.addCPCLSETBOLD('1');
}
let beginNum = ((that.shippList[j].name.length - that.shippList[j].name.replace(/^\s+/, ' ').length) * 25 + 20)
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
that.yNum += (32 + offHeigth)
}else{
that.yNum += (25 + offHeigth)
}
if(that.shippList[j].leftIcon.length >0){
iconWidth += 21
for(let m=0;m<that.shippList[j].leftIcon.length;m++){
strCmd += 'EG 4 32 ' + iconWidth +' '+ that.yNum +' '+ that.shippList[j].leftIcon[m] + ' '
iconWidth += 40
}
}
that.shippList[j].name = that.shippList[j].name.replace(/^\s+/, ' ')
if(that.shippList[j].value != ''){
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum + 4, '24', '0', 0, that.shippList[j].name+': '+that.shippList[j].value)
}else{
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum, '24', '0', 0, that.shippList[j].name+': '+that.shippList[j].value)
}
}else{
if(that.shippList[j].name.length > 12){
let num = Math.ceil(Number(that.shippList[j].name.length) / 12)
for(let i = 0;i<num;i++){
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum + 4 , '24', '0', 0, that.shippList[j].name.substring(i*12,(i+1)*12))
}else{
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum , '24', '0', 0, that.shippList[j].name.substring(i*12,(i+1)*12))
}
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
that.yNum += (32 + offHeigth)
}else{
that.yNum += (25 + offHeigth)
}
}
}else{
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum + 4 , '24', '0', 0, that.shippList[j].name)
}else{
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum , '24', '0', 0, that.shippList[j].name)
}
}
}
if(that.shippList[j].rightIcon.length >0){
let iconWidth1 = Number((that.shippList[j].name + that.shippList[j].value).length * 25 + 20) + iconWidth
for(let m=0;m<that.shippList[j].rightIcon.length;m++){
strCmd += 'EG 4 32 ' + iconWidth1 +' '+ that.yNum +' '+ that.shippList[j].rightIcon[m] + ' '
iconWidth1 += 40
}
}
}
strCmd += blesdk.addCPCLLocation(1);
codeWidth = 310
}else{
strCmd += blesdk.addCPCLLocation(2);
codeWidth = that.yNum + 60
}
if(this.isQRCode == "0"){
if(this.color != '' && this.size != ''){
strCmd += blesdk.addCPCLQRCode(0, codeWidth, 'M', '1', 4, [base.encode(that.dataList.id),base.encode(uni.getStorageSync('shopId').substring('10','12')),encodeURIComponent(this.color)+'-'+encodeURIComponent(this.size)]) //二维码
}else{
strCmd += blesdk.addCPCLQRCode(0, codeWidth, 'M', '1', 4, [base.encode(that.dataList.id),base.encode(uni.getStorageSync('shopId').substring('10','12'))]) //二维码
}
}
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}else if(this.printingMethod == "1"){
for(let i=0;i<this.number;i++){
that.yNum = 10
let strCmd = blesdk.CreatCPCLPage(400, 320, 1, 0);
if(that.multipleList.indexOf('供应商') != -1){
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLSETBOLD('400');
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '2', 0, (that.dataList.supplierName==null?'':that.dataList.supplierName))
}
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('0')
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('30', that.yNum+=60, '24', '0', 0, '商品名:'+(that.dataList.productName==null?'':that.dataList.productName))
strCmd += blesdk.addCPCLSETMAG(2, 2)
if(that.multipleList.indexOf('货号') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum+=40, '24', '1', 0, '货号:'+that.dataList.productSn)
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, this.color+' '+this.size)
if(that.multipleList.indexOf('批发价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '批发价:'+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('零售价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '零售价:'+that.dataList.price)
}
if(that.multipleList.indexOf('直播价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '直播价:'+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('日常价') != -1){
strCmd += blesdk.addCPCLText('30', that.countPrint(), '24', '0', 0, '日常价:'+that.dataList.price)
}
if(this.isQRCode == "0"){
if(this.color != '' && this.size != ''){
strCmd += blesdk.addCPCLQRCode(240, 160, 'M', '1', 4, [base.encode(that.dataList.id),base.encode(uni.getStorageSync('shopId').substring('10','12')),encodeURIComponent(this.color)+'-'+encodeURIComponent(this.size)]) //二维码
}else{
strCmd += blesdk.addCPCLQRCode(240, 160, 'H', '1', 4, [base.encode(that.dataList.id),base.encode(uni.getStorageSync('shopId').substring('10','12'))]) //二维码
}
}
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}else if(this.printingMethod == "3"){
for(let i=0;i<this.number;i++){
that.yNum = 20
let bgineNum = 0
if(that.multipleList.indexOf('品名') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('货号') != -1){
bgineNum += 1
}
if(this.color != '' || this.size !=''){
bgineNum += 1
}
if(that.multipleList.indexOf('批发价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('零售价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('直播价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('日常价') != -1){
bgineNum += 1
}
if(that.multipleList.indexOf('供应商') != -1){
bgineNum += 2
}
for(let j=0;j<that.shippList.length;j++){
if(that.shippList[j].name.length > 15){
let num = Math.ceil(Number(that.shippList[j].name.length) / 15)
bgineNum += num
}else{
bgineNum += 1
}
}
let offHeigth = 0
offHeigth = Math.ceil((560 - bgineNum * 24) / bgineNum)
let strCmd = blesdk.CreatCPCLPage(400, 640, 1, 0);
strCmd += blesdk.addCPCLSETBOLD('1');
if(that.multipleList.indexOf('供应商') != -1){
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, (that.dataList.supplierName==null?'':that.dataList.supplierName))
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('30', that.yNum += 30, '24', '0', 0, '')
if(that.multipleList.indexOf('品名') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '品名: '+(that.dataList.productName==null?'':that.dataList.productName))
}
if(that.multipleList.indexOf('货号') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '货号: '+(that.dataList.productSn==null?'':that.dataList.productSn))
}
if(this.color != '' || this.size !=''){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '规格: '+ this.color+' '+this.size)
}
if(that.multipleList.indexOf('批发价') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '批发价: '+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('零售价') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '零售价: '+that.dataList.price)
}
if(that.multipleList.indexOf('直播价') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '直播价: '+that.dataList.wholesalePrice)
}
if(that.multipleList.indexOf('日常价') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += (25 + offHeigth), '24', '0', 0, '日常价: '+that.dataList.price)
}
let codeWidth = 0
if(that.shippList.length > 0){
for(let j=0;j<that.shippList.length;j++){
let iconWidth = 0
if(that.shippList[j].modelLeft == 'right'){
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLLocation(0);
let allWidth = 370
if((that.shippList[j].name + that.shippList[j].value).length > 0){
allWidth -= 30
}
iconWidth = Math.floor((allWidth - ((that.shippList[j].leftIcon.length + that.shippList[j].rightIcon.length) * 32 + (that.shippList[j].name + that.shippList[j].value).length * 25)) / 2)
}else{
strCmd += blesdk.addCPCLLocation(2);
}
}else{
strCmd += blesdk.addCPCLLocation(0);
}
if(that.shippList[j].modelBlod == 'notblod'){
strCmd += blesdk.addCPCLSETBOLD('0');
}else{
strCmd += blesdk.addCPCLSETBOLD('1');
}
let beginNum = ((that.shippList[j].name.length - that.shippList[j].name.replace(/^\s+/, ' ').length) * 25 + 30)
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
that.yNum += (32 + offHeigth)
}else{
that.yNum += (25 + offHeigth)
}
if(that.shippList[j].leftIcon.length >0){
iconWidth += 31
for(let m=0;m<that.shippList[j].leftIcon.length;m++){
strCmd += 'EG 4 32 ' + iconWidth +' '+ that.yNum +' '+ that.shippList[j].leftIcon[m] + ' '
iconWidth += 40
}
}
that.shippList[j].name = that.shippList[j].name.replace(/^\s+/, ' ')
if(that.shippList[j].value != ''){
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum + 4, '24', '0', 0, that.shippList[j].name+': '+that.shippList[j].value)
}else{
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum, '24', '0', 0, that.shippList[j].name+': '+that.shippList[j].value)
}
}else{
if(that.shippList[j].name.length > 15){
let num = Math.ceil(Number(that.shippList[j].name.length) / 15)
for(let i = 0;i<num;i++){
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum + 4 , '24', '0', 0, that.shippList[j].name.substring(i*15,(i+1)*15))
}else{
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum , '24', '0', 0, that.shippList[j].name.substring(i*15,(i+1)*15))
}
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
that.yNum += (32 + offHeigth)
}else{
that.yNum += (25 + offHeigth)
}
}
}else{
if(that.shippList[j].leftIcon.length >0 || that.shippList[j].rightIcon.length >0){
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum + 4 , '24', '0', 0, that.shippList[j].name)
}else{
strCmd += blesdk.addCPCLText((beginNum + iconWidth).toString(), that.yNum , '24', '0', 0, that.shippList[j].name)
}
}
}
if(that.shippList[j].rightIcon.length >0){
let iconWidth1 = Number((that.shippList[j].name + that.shippList[j].value).length * 25 + 30) + iconWidth
for(let m=0;m<that.shippList[j].rightIcon.length;m++){
strCmd += 'EG 4 32 ' + iconWidth1 +' '+ that.yNum +' '+ that.shippList[j].rightIcon[m] + ' '
iconWidth1 += 40
}
}
}
strCmd += blesdk.addCPCLLocation(1);
codeWidth = 310
}else{
strCmd += blesdk.addCPCLLocation(2);
codeWidth = that.yNum + 60
}
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}
}
that.$nextTick(()=>{
uni.navigateBack({
delta: 1
})
})
},
//悬浮按钮
trigger(e) {
if(e.index==0){ //自定义打印
this.$refs.zidingyiDialog.open();
this.zidingyi = true
}else{
this.delGoods()
}
},
getCategoryList(){
this.tui.request("/app/shopprint/getList", "POST", {
shopId:uni.getStorageSync('shopId')
}, false, false).then((res) => {
if (res.code == 200) {
if(res.result != '' && res.result != null){
for(let i = 0; i < res.result.length; i++){
let data = {
value: res.result[i].content,
text: res.result[i].printName
}
this.shopprintList.push(data)
}
}
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
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) {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2];
let shopList = prevPage.$vm.shopList
for(let i=0;i<shopList.length;i++){
if(shopList[i].id == that.dataList.id){
shopList.splice(i, 1);
}
}
uni.navigateBack({
delta: 1
})
} else {
uni.showToast({
title: "删除失败",
icon: 'none'
})
}
})
}
}
})
}
}
}
</script>
<style lang="scss">
page {
height: 100%;
font-size: 24rpx;
}
.page1 {
display: flex;
flex-direction: column;
height: 100%;
font-size: 28rpx;
}
.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: 30rpx;
width: 500rpx;
height: auto;
max-height: 1000rpx;
overflow: scroll;
background-color: #fff;
}
.popup-pay-title {
font-size: 30rpx;
font-weight: bold;
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;
}
.detail-popup{
width: 500rpx;
min-height: 500rpx;
max-height: 1000rpx;
overflow: scroll;
}
@media screen and (min-width: 760px) {
.detail-popup{
max-height: 750px;
}
}
</style>