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

783 lines
19 KiB

3 years ago
<template>
<view class="page1">
2 months ago
<view style="position: fixed;top: 0;z-index: 99;height: 70px;width: 100%;display: flex;background: #fff;padding-top: 30px;">
<uni-icons type="left" size='10' @tap="backPage"></uni-icons>
3 years ago
</view>
2 months ago
<view class="content-left" style="width:13%;height: 80%;float: left;position: fixed;top: 70px;">
<view class="left-box" v-for="(item, index) in indexList" :key="index"
:class="item.parentId ? 'left-box-hover':''" @tap="clickLeftBtn(index)">
<text style="width: 100%;height: 40px;line-height: 40px;display: inline-block;overflow: hidden;"
:class="item.parentId ? 'red' :''">{{item.categoryName}}</text>
3 years ago
</view>
2 months ago
</view>
<view class="content-right" style="width: 87%;background: #fff;margin-left:13%;margin-top: 70px;">
<view class="table">
<view class="table-th">
<view style="width: 5%;">#</view>
<view style="width: 10%;">商品图</view>
<view style="width: 25%;">货号</view>
<view style="width: 20%;">名称</view>
<view style="width: 20%;">批发价</view>
<view style="width: 20%;">零售价</view>
</view>
<view class="table-tr" v-for="(item,index) in goodsList" :key="index">
<view style="width: 5%;background: #fff;" @tap="checkboxChange(item)">
<checkbox-group>
<label>
<checkbox :checked="item.checked" class="checkbox" />
</label>
</checkbox-group>
</view>
<view style="width: 10%;" @tap.stop="largeImg(item)">
<img :src="item.productPicture" alt="" v-if="item.productPicture" style="border-radius:10px;width: 30px;height: 30px;margin: 0 auto;">
<view class="noPic" v-else style="width: 100%;">暂无图片</view>
</view>
<view style="width: 25%;">
{{item.productSn==null?'':item.productSn}}
3 years ago
</view>
2 months ago
<view style="width: 20%;">
{{item.productName == null?'暂无':item.productName}}
</view>
<view style="width: 20%;">
{{item.wholesalePrice}}
</view>
<view style="width: 20%;">
{{item.price}}
3 years ago
</view>
</view>
</view>
2 months ago
<u-loadmore :status="status" />
</view>
3 years ago
<view class="bottom-box">
<view class="bottom-right">
<button class="bottom-btn" @tap="clickPrint">批量打印</button>
</view>
</view>
<!-- 弹出输入框 -->
<uni-popup ref="payDialog" background-color="#fff">
<view class="popup-pay-content">
2 months ago
<uni-forms-item label="打印方式" name="type" labelWidth="170px">
<uni-data-select style="width: 100%" v-model="printingMethod" :localdata="typeList"></uni-data-select>
</uni-forms-item>
3 years ago
<view class="popup-pay-title">
<text>已选商品</text>
3 years ago
</view>
3 years ago
<view v-for="(item,index) in carList" :key="index">
3 years ago
<view class="box-right">
2 months ago
<text class="box-right-name">{{item.productName==null?'':item.productName}}</text>
3 years ago
<text class="box-right-num">({{item.productSn}})</text>
</view>
</view>
2 months ago
<view class="popup-pay-title" style="margin-top: 10px;">
3 years ago
<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>
2 years ago
</view>
2 months ago
<view v-if="list[0].checked && purchase != ''" style="display: flex;height: 80px;width: 100%;line-height: 80px;margin-top: 20px;">
<text style="display:inline-block;width:100px;">
2 years ago
供应商:
</text>
2 months ago
<input v-model="purchase.supplierName" @change="changeText" :disabled="closetanPopup" type="text" placeholder="请输入供应商名称" style="display: flex;height: 80px;width: 300px;line-height: 80px;padding-left: 20px;border: 1px solid #eee;">
3 years ago
</view>
<view class="popup-pay-container" >
<kk-printer ref="kkprinter" :bufferData="bufferData" @goPrint="goPrint" :defaultText="'确认打印'"></kk-printer>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import util from '@/components/kk-printer/utils/util.js';
import * as blesdk from '@/components/kk-printer/utils/bluetoolth.js';
3 years ago
import kkPrinter from '@/components/kk-printer/index.vue';
import base from '@/utils/ossUploadFile/base64.js';
3 years ago
export default {
data() {
return {
indexList: [],
pageNum: 1, //分页的页码
shopList: [],
goodsList: [],
categoryId: '', //分类id
searchName: '', //搜索框输入值
id: '',
carList: [],
type: '',
bufferData:[],
typeList: [{
value: '0',
text: "打印长票"
},
{
value: '1',
text: "打印短票"
},
],
printingMethod:"0",
3 years ago
checkPayData:'',
data:{},
height:0,
list:[{
type:'供应商',
checked:false,
},{
type:'货号',
checked:false,
},{
type:'零售价',
checked:false,
},{
type:'批发价',
checked:false,
}],
multipleList:[],
3 years ago
purchase:'',
shopId:''
3 years ago
}
},
components: {
kkPrinter
2 years ago
},
onHide(){
setTimeout(res=>{
uni.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success(res) {
},fail(err){
}
})
},5000)
3 years ago
},
3 years ago
onLoad(options) {
wx.openBluetoothAdapter({mode: 'central'})
3 years ago
this.height = wx.getSystemInfoSync().windowHeight
this.shopId = uni.getStorageSync('shopId')
3 years ago
if (options.khid != undefined) {
uni.redirectTo({
2 years ago
url: "/package1/index/downStearmList?khid=" + options.khid
3 years ago
})
}else{
if(options.purchase){
this.purchase = JSON.parse(options.purchase)
this.goodsList = JSON.parse(options.purchaseDetails)
}else{
this.type = uni.getStorageSync('type')
this.getGategoryList()
}
}
},
methods: {
2 months ago
backPage(){
uni.navigateBack()
},
3 years ago
//初始化获取分类列表
getGategoryList() {
2 months ago
this.tui.request("/app/productCategory/list", "get", {
// shopId: 1,
}, false, true).then((res) => {
3 years ago
if (res.code == 200) {
this.indexList = res.result;
for (var i = 0; i < this.indexList.length; i++) {
if (i == 0) {
this.indexList[i].parentId = true
} else {
this.indexList[i].parentId = false
2 months ago
}
3 years ago
}
2 months ago
this.categoryId = this.indexList[0].id
this.pageNum = 1
this.searchName = ""
this.shopList1 = []
this.shopList = []
this.getShareList();
3 years ago
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//点击分类获取商品列表
2 months ago
async getShareList(id) {
let that = this
this.goodsList = []
await this.tui.request("/app/product/getShareList", "POST", {
categoryId: this.searchName == "" ? this.categoryId : "",
3 years ago
searchStr: this.searchName,
pageNum: this.pageNum,
2 months ago
pageSize: '25'
3 years ago
}, false, false).then((res) => {
2 months ago
if (res.code == 200) {
for (var i = 0; i < res.result.records.length; i++) {
if (res.result.records != '') {
res.result.records[i].checked = false
}
3 years ago
}
2 months ago
this.$nextTick(() => {
this.status = 'nomore';
if (this.pages == 1) {
this.goodsList = res.result.records
} else {
this.goodsList = [...this.goodsList, ...res.result.records]
}
this.pages = res.result.pages
})
3 years ago
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
2 months ago
await this.getCheck()
},
getCheck() {
let that = this;
if (that.carList != '') {
for (var i = 0; i < that.carList.length; i++) {
for (var m = 0; m < that.goodsList.length; m++) {
// for (var j = 0; j < that.goodsList[m].length; j++) {
if (that.carList[i].id == that.goodsList[m].id) {
that.goodsList[m].checked = true
}
// }
}
}
}
this.$forceUpdate()
3 years ago
},
//顶部搜索框
search(res) {
this.searchName = res.value
this.getGategoryList()
},
//未入库遮罩
clickMask() {
uni.showToast({
title: '请将商品上架或入库后再操作!',
icon: 'none'
})
},
//点击左侧菜单切换
clickLeftBtn(index) {
for (var i = 0; i < this.indexList.length; i++) {
if (i == index) {
this.indexList[i].parentId = true
} else {
this.indexList[i].parentId = false
}
2 months ago
}
this.categoryId = this.indexList[index].id
this.pageNum = 1
this.searchName = ""
this.goodsList = []
this.getShareList(this.indexList[index].id)
3 years ago
},
goInvPrint(item){
item.checked = !item.checked
if(this.carList == ''){
this.carList.push(item)
}else{
for(let i=0;i<this.carList.length;i++){
3 years ago
if(this.carList[i].productName == item.productName){
3 years ago
this.carList.splice(i, 1)
return;
}else{
if(i+1 == this.carList.length){
this.carList.push(item)
return;
}
}
}
}
3 years ago
3 years ago
},
//选中商品
checkboxChange(item) {
2 months ago
console.log(this.carList)
item.checked = !item.checked
if (this.carList.indexOf(item.id) != -1) {
this.carList.splice(this.carList.indexOf(item.id), 1)
} else {
this.carList.push(item)
}
3 years ago
},
//点击批量打印按钮
clickPrint() {
this.$refs.payDialog.open('center')
},
checkPay(type){
this.data.priceType = type
this.tui.request("/app/productShare/save", "POST", this.data, false, true).then((res) => {
if (res.code == 200) {
this.khid = res.result.id
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
this.checkPayData = type
this.$refs.payDialog.close()
this.$refs.share.open()
},
//选择多个规格保存
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;
}
}
}
}
3 years ago
3 years ago
},
//点击打印按钮
goPrint(){
uni.setStorageSync('small',true)
let that = this;
for(var i=0;i<that.carList.length;i++){
let item = that.carList[i]
2 years ago
that.yNum = 10
if(this.printingMethod == "0"){ //长票打印
2 years ago
//宽5.1 高4.1
let strCmd = blesdk.CreatCPCLPage(320, 480, 1, 0);
if(this.multipleList.indexOf('供应商') != -1){
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLSETBOLD('400');
strCmd += blesdk.addCPCLText('0', that.yNum += 10, '24', '0', 0, this.purchase !=''?this.purchase.supplierName:item.supplierName)
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('0');
strCmd += blesdk.addCPCLText('20', that.yNum += 70, '24', '0', 0, '品名: '+(item.productName==null?'':item.productName))
if(this.multipleList.indexOf('货号') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 50, '24', '0', 0, '货号: '+item.productSn)
}
if(this.multipleList.indexOf('批发价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 50, '24', '0', 0, '批发价: '+item.wholesalePrice)
}
if(this.multipleList.indexOf('零售价') != -1){
strCmd += blesdk.addCPCLText('20', that.yNum += 50, '24', '0', 0, '零售价: '+(item.lsprice || item.price))
}
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLQRCode(0, that.yNum += 70, 'H', '1', 4, [this.purchase!=''?base.encode(item.productId):base.encode(item.id),base.encode(this.shopId)]) //二维码
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
}else{
//宽5.1 高4.1
let strCmd = blesdk.CreatCPCLPage(410, 320, 1, 0);
if(this.multipleList.indexOf('供应商') != -1){
2 years ago
strCmd += blesdk.addCPCLSETMAG(2, 2)
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLSETBOLD('400');
strCmd += blesdk.addCPCLText('0', that.yNum += 10, '24', '0', 0, this.purchase !=''?this.purchase.supplierName:item.supplierName)
}
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLSETBOLD('0');
strCmd += blesdk.addCPCLText('30', that.yNum += 60, '24', '0', 0, '商品名:'+(item.productName==null?'':item.productName))
strCmd += blesdk.addCPCLSETMAG(2, 2)
if(this.multipleList.indexOf('货号') != -1){
strCmd += blesdk.addCPCLText('30', that.yNum += 40, '24', '0', 0, '货号:'+item.productSn)
}
2 years ago
strCmd += blesdk.addCPCLSETMAG(1, 1)
if(this.multipleList.indexOf('批发价') != -1){
2 years ago
strCmd += blesdk.addCPCLText('30', that.yNum += 50, '24', '0', 0, '批发价:'+item.wholesalePrice)
}
if(this.multipleList.indexOf('零售价') != -1){
2 years ago
strCmd += blesdk.addCPCLText('30', that.yNum += 50, '24', '0', 0, '零售价:'+(item.lsprice || item.price))
}
2 years ago
strCmd += blesdk.addCPCLQRCode(240, 160, 'H', '1', 4, [this.purchase!=''?base.encode(item.productId):base.encode(item.id),base.encode(uni.getStorageSync('shopId').substring('10','12'))]) //二维码
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
3 years ago
}
3 years ago
}
3 years ago
that.$nextTick(()=>{
that.$refs.payDialog.close();
that.bufferData = []
uni.navigateBack({
delta: 1
})
})
3 years ago
}
}
}
</script>
<style lang="scss">
page {
2 months ago
height: 100%;
font-size: 14px;
3 years ago
}
.page1 {
display: flex;
flex-direction: column;
2 months ago
height: 92%;
font-size: 14px;
3 years ago
}
.uni-tab__dot {
2 months ago
padding: 0 8px;
line-height: 30px;
3 years ago
color: #ffffff;
text-align: center;
background-color: #ff0000;
2 months ago
border-radius: 30px;
3 years ago
}
.uni-tab__text {
color: #646566;
}
.title-box {
background: #fff;
position: fixed;
z-index: 99;
width: 100%;
top: 0;
}
.bottom-box {
width: 100%;
2 months ago
height: 50px;
3 years ago
position: fixed;
bottom: 0;
display: flex;
background: #fff;
z-index: 98;
}
.bottom-left {
width: 15%;
position: relative;
}
.bottom-right {
width: 100%;
display: flex;
.bottom-btn {
margin: 0 auto;
padding: 0;
width: 90%;
2 months ago
line-height: 40px;
height: 40px;
3 years ago
text-align: center;
2 months ago
margin-top: 5px;
3 years ago
color: #fff;
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-radius: 5px;
}
}
.bottom-left-box {
display: flex;
flex-direction: column;
text-align: center;
}
.content-box {
background: #fff;
flex: 1;
display: flex;
overflow: scroll;
}
.content-left {
2 months ago
width: 170px;
3 years ago
background: #eee;
2 months ago
height: 100%;
3 years ago
overflow: scroll;
}
.left-box {
width: 100%;
2 months ago
height: 40px;
3 years ago
text-align: center;
2 months ago
line-height: 40px;
3 years ago
border-bottom: 1px solid #fff;
}
2 months ago
3 years ago
.left-box-hover {
width: 100%;
2 months ago
height: 40px;
3 years ago
text-align: center;
2 months ago
line-height: 40px;
3 years ago
border-bottom: 1px solid #fff;
background-color: #fff;
}
.red {
border-right: 3px solid red;
}
.content-right {
flex: 1;
2 months ago
height: 100%;
3 years ago
overflow-y: scroll;
}
.right-box {
width: 100%;
2 months ago
height: 190px;
3 years ago
display: flex;
border-bottom: 1px solid #eee;
position: relative;
}
.box-left {
2 months ago
width: 60px;
height: 60px;
3 years ago
background-size: 100%;
2 months ago
margin: 25px 30px 35px 10px;
border-radius: 20px;
3 years ago
}
.box-left img {
width: 100%;
height: 100%;
}
.box-right {
2 months ago
margin-top: 17px;
3 years ago
}
.box-right-name {
font-weight: bold;
}
.box-right-num {
2 months ago
padding: 5px 0;
3 years ago
color: #777;
}
.box-right-price {
display: flex;
}
.checkbox {
2 months ago
width: 30px;
height: 30px;
3 years ago
}
.price-box {
display: flex;
flex-direction: column;
2 months ago
margin-right: 20px;
3 years ago
}
.price-box text:first-child {
color: #ffa200
}
.uni-tab__cart-button-right,
.uni-tab__cart-sub-right {
display: none;
flex: none;
}
.popup-content {
align-items: center;
justify-content: center;
2 months ago
padding: 30px;
height: 1200px;
3 years ago
background-color: #fff;
2 months ago
margin-bottom: 30px;
3 years ago
overflow: scroll;
}
.popup-title-right-box {
2 months ago
height: 50px;
line-height: 50px;
3 years ago
}
.popup-title-right {
2 months ago
width: 400px;
margin-left: 30px;
3 years ago
}
.popup-title-left {
2 months ago
width: 150px;
height: 150px;
3 years ago
}
.popup-title-left image {
2 months ago
width: 150px;
height: 150px;
3 years ago
}
.popup-title {
display: flex;
2 months ago
height: 180px;
3 years ago
border-bottom: 1px solid #eee;
2 months ago
margin-top: 20px;
3 years ago
}
.popup-bottom {
width: 95%;
2 months ago
height: 100px;
3 years ago
position: fixed;
bottom: 0;
left: 2.5%;
display: flex;
z-index: 99;
background: #fff;
}
.popup-bottom-left {
width: 50%;
2 months ago
line-height: 80px;
3 years ago
}
.popup-bottom-right {
width: 50%;
2 months ago
line-height: 100px;
3 years ago
.bottom-btn {
width: 70%;
2 months ago
line-height: 70px;
height: 70px;
3 years ago
text-align: center;
2 months ago
/* margin-top: 10px; */
3 years ago
color: #fff;
margin: 0 auto;
background: linear-gradient(90deg, #60F3FF, #088FEB);
2 months ago
border-radius: 70px;
3 years ago
}
}
.shop-mask {
width: 100%;
2 months ago
height: 190px;
3 years ago
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.1);
z-index: 99;
}
.popup-pay-content {
align-items: center;
justify-content: center;
2 months ago
padding: 30px;
width: 500px;
3 years ago
height: auto;
2 months ago
max-height: 1000px;
3 years ago
overflow: scroll;
background-color: #fff;
}
.popup-pay-title {
font-weight: bold;
text-align: center;
position: relative;
border-bottom: 1px solid #eee;
2 months ago
padding-bottom: 20px;
3 years ago
}
.popup-pay-container {
2 months ago
margin-top: 10px;
height: 40px;
border-radius: 10px;
background: #088FEB;
line-height: 40px;
text-align: center;
border-bottom: 1px solid #eee;
border-top: 1px solid #eee;
3 years ago
color: #fff;
}
.noPic{
2 months ago
width: 40px;
height: 40px;
text-align: center;
line-height: 40px;
color: #777;
3 years ago
background: #eee;
}
.checked{
background: #60F3FF;
color: #fff !important;
}
.content-fur {
2 months ago
padding-bottom: 10px;
3 years ago
}
.content-low {
width: auto;
border: 1px solid #eee;
display: inline-block;
2 months ago
min-width: 90px;
padding: 5px;
3 years ago
text-align: center;
color: #777;
2 months ago
margin: 20px 0 0 20px;
}
.table {
display: flex;
flex-direction: column;
height: auto;
overflow-x: scroll;
width: 100%;
white-space: nowrap;
overflow: scroll;
min-height: 200px;
}
.table-th {
width: 100%;
height: 30px;
line-height: 30px;
background: #088FEB;
color: #fff;
view {
width: 80px;
float: left;
text-align: center;
border-right: 1px solid #fff;
}
}
.table-tr {
flex: 0 0 auto;
width: 100%;
height: 30px;
position: relative;
line-height: 30px;
color: #000;
view {
width: 80px;
height: 30px;
line-height: 30px;
float: left;
text-align: center;
border-bottom: 1px solid #000;
border-right: 1px solid #000;
}
3 years ago
}
</style>