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

3730 lines
118 KiB

<!-- 销售商品 -->
<template>
<view class="page1">
<!-- <view class="content"> -->
<view style="position: fixed;top:0;z-index: 99;width: 100%;">
<!-- <view class="notice">
<u-notice-bar mode='horizontal' bgColor="#088FEB" color="#eee" :text="noticeData"></u-notice-bar>
</view> -->
<view class="content-box">
<view class="content-list" @tap.stop="goPopleList('khName')">
<view class="list-name">客户</view>
<view class="list-val">
<input type="text" placeholder="请选择客户" disabled :value="khName.name"
style="border-bottom: 1px solid #fff;text-align: center;">
<uni-icons type="right" size="16" style="margin-left: 80rpx;line-height: 80rpx;"></uni-icons>
</view>
</view>
<view class="shop-box" style="border-bottom: 1px solid #eee;margin-bottom: 20rpx;">
<view style="height: 80rpx;display: flex;padding: 5px 0;border-bottom: 1px solid #eee;">
<view @tap.stop="scanCodeAdd" style="width: 50%;text-align: center;line-height: 70rpx;">
<uni-icons type="scan" size="12"></uni-icons>
<text>扫一扫</text>
</view>
<view @tap.stop="goodsAdd"
style="width: 50%;text-align: center;line-height: 70rpx;border-left: 1px solid #eee;">
<uni-icons type="plusempty" size="12"></uni-icons>
<text>添加商品</text>
</view>
</view>
<view style="height: 150rpx;width: 100%;display: flex;" @tap="toggle('center',item)">
<view style="width: 70rpx;height: 70rpx;margin: 40rpx;display: block;overflow: hidden;">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/27e2655fe19f454d93970f968d91fbef.png"
alt="" style="width: 100%;height: 100%;" />
</view>
<view style="padding-left: 11rpx;">
<view style="height: 80rpx;font-size: 30rpx;font-weight: bold;line-height: 80rpx;">
AI开单
</view>
<view>
<radio :value="isInventory" @tap.stop="invenRadio" :checked="isInventory" />
未入库规格不显示
</view>
</view>
</view>
</view>
</view>
</view>
<scroll-view class="scroll-content" scroll-y="true" :scroll-into-view="currentAnchor" scroll-top="0">
<view class="content-box">
<view class="shop-box" style="border-top:5px solid #eee;" v-for="(value,key) in Array.from(carList)"
:key="key">
<view class="shop-name" style="position: relative;">
<img class="img-radius" :src="value[1].productPicture" alt=""
style="width: 140rpx;height: 140rpx;margin: 30rpx 0 0 30rpx;"
v-if="value[1].productPicture">
<view class="noPic" v-else>暂无图片</view>
<view class="shop-productName">
<view style="color:#FF5809;">{{value[1].productName}} ({{value[1].productSn}})</view>
<view>¥{{value[1].discountAmount}} * {{value[1].productCount}} 总价:{{value[1].price}}
</view>
<view v-if="value[1].supplierName !=undefined">供应商:{{value[1].supplierName}}</view>
</view>
<view @tap.stop="clickPrice(value[0])"
style="position: absolute;top: 73rpx;right: 20rpx;color: blue;height: 60rpx;width: 80rpx;text-decoration: underline;line-height: 40rpx;">
改价
</view>
<view @tap.stop="AiAddSpec(value[1])"
style="position: absolute;bottom: 0;right: 44rpx;color: blue;height: 60rpx;text-decoration: underline;line-height: 40rpx;">
添加规格
</view>
<view @tap.stop="getHistoryPrice(value[1].productId,value[0])"
v-if="khName !=''&&khName.name !='散客'"
style="position: absolute;top: 120rpx;right: 160rpx;">
<u-icon name="clock" size="20"></u-icon>
</view>
<view
style="position: absolute;top: 20rpx;height: 60rpx;width: 60rpx;line-height: 40rpx;right: 17rpx;"
@tap.stop="delShop(value[0])">
<uni-icons color="red" type="trash" size="26"></uni-icons>
</view>
</view>
<view class="shop-type">
<view class="shop-collapse-item" v-if="discountType == '0'">
<view class="collapse-1">
<text>单价</text>
<input class="input" type="text" :value='value[1].unitPrice' disabled>
</view>
<view class="collapse-1">
<text>折扣(0-10)</text>
<input class="input" type="digit" @focus="obtainPrice($event,'danzhe',value[0])" :value='value[1].discount'
@blur="changeDis($event,value[0])">
</view>
<view class="collapse-1">
<text>折后价</text>
<input class="input" type="text" :value='value[1].price' disabled>
</view>
<view class="collapse-1">
<text>数量</text>
<input class="input" type="number" :value='value[1].productCount' disabled>
</view>
</view>
<view class="shop-checkList" v-if="value[1].stockLogList !=''">
<view class="shop-checkList-box" style="width: 67%;">
<text
style="text-align:center;width: 400rpx;display: inline-block;font-size: 30rpx;font-weight: bold;padding-left: 40rpx;">
规格
</text>
<text
style="font-size: 30rpx;color: #000;font-weight: bold;width: 60rpx;display: inline-block;text-align: center;">
库存
</text>
</view>
<view
style="font-size: 30rpx;color: #000;font-weight: bold;width: 152rpx;display: inline-block;text-align: right;">
数量
</view>
</view>
<view v-for="(values,keys) in Array.from(value[1].stockLogList)" :key='keys'
:id="values[1].uuid">
<view class="shop-collapse">
<view @tap.stop="delShopSpec(value[0],values[0])">
<uni-icons color="red" type="minus" size="26"></uni-icons>
</view>
<text @tap="checkSpec('颜色',value[0],values[0],numData(values[0])[0])">
{{numData(values[0])[0]}}
</text>
<text @tap="checkSpec('尺码',value[0],values[0],numData(values[0])[1])">
{{numData(values[0])[1]}}
</text>
<text
style="width: 25%;font-size: 22rpx;">{{values[1].productNum == null ?'无库存':values[1].productNum}}</text>
<view style="text-align: left;padding-left: 5px;width:50%;display: flex;">
<uni-number-box min="-10000" max="100000" style="margin-top:9rpx;border-right:0;"
v-model="values[1].productCount"
@change="GoodsNumChange($event,value,values[0])" />
</view>
</view>
</view>
</view>
</view>
<view class="shop-box" style="border-top:5px solid #eee;">
<view class="content-list">
<view class="list-name" style="width:150rpx;padding-left:0;">选择价格</view>
<view class="list-val" style="width:560rpx;display: flex;">
<radio-group style="display: flex;">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in priceItems"
:key="item.value" style="margin-right:0">
<view>
<radio :value="item.value" @tap.stop="priceChange(item.value,index)"
:checked="index === priceCurrent" />
</view>
<view style="width: 100rpx;">{{item.name}}</view>
</label>
</radio-group>
</view>
</view>
</view>
<view class="shop-box">
<view class="content-list">
<view class="list-name" style="width:150rpx;padding-left:0;">折扣类型</view>
<view class="list-val" style="width:560rpx;display: flex;">
<radio-group @change="discountChange" style="display: flex;">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items"
:key="item.value" style="margin-right:0">
<view>
<radio :value="item.value" :checked="index === discountCurrent" />
</view>
<view style="width: 100rpx;">{{item.name}}</view>
</label>
</radio-group>
<view class="discount-num" v-if="discountType == '1'">
<input type="digit" style="width:150rpx;padding:0;text-align: center;"
v-model="discountNum" @focus="obtainPrice($event,'zhengti')" @blur="change($event)">
</view>
</view>
</view>
</view>
</view>
<view class="content-box">
<view class="price-box-list">
<view class="content-list">
<view class="list-name">支付类型</view>
<uni-data-select class="uni-data-select" :localdata="payTypeList" v-model="payType"
placeholder="请选择支付类型" @change="payTypeChange" style="width: 60%;">
</uni-data-select>
</view>
<view class="content-list">
<view class="list-name" id="idss">总金额</view>
<view class="list-val">
<input type="digit" v-model="shouldPay" disabled>
</view>
</view>
<view class="content-list">
<view class="list-name">实收金额</view>
<view class="list-val">
<input type="digit" ref="relPriceinput" placeholder="请输入实收金额" v-model="relPrice" @focus="obtainPrice($event,'relPrice')" @blur="changessPrice($event)">
</view>
</view>
<view class="content-list">
<view class="list-name">已收金额</view>
<view class="list-val">
<input type="digit" placeholder="请输入已收金额" v-model="priceOk" @focus="obtainPrice($event,'priceOk')" @blur="changePrice($event)">
</view>
</view>
<view class="content-list">
<view class="list-name">欠款</view>
<view class="list-val">
<input type="digit" v-model="noPay" disabled>
</view>
</view>
<view class="content-list">
<view class="list-name">其他费用</view>
<view class="list-val">
<input type="digit" placeholder="如无其他费用可忽略" v-model="otherExpense">
</view>
</view>
<view class="content-list">
<view class="list-name">备注</view>
<view class="">
<textarea @input='changeRemark($event)' v-model="remark" />
</view>
</view>
</view>
</view>
<view class="content-box" style="margin-bottom: 130rpx;">
<view class="content-list">
<view class="list-name">销售员</view>
<uni-data-select class="uni-data-select" :localdata="categoryList" v-model="xsyId"
placeholder="请选择销售员" @change="categoryChange"></uni-data-select>
</view>
<view class="shop-box">
<view class="" style="border-bottom: 1px solid #eee;">
<view class="list-name" style="width: 100%;">发货方式</view>
<view class="list-val" style="width: 100%;padding-left:20rpx;height:200rpx;">
<radio-group @change="radioChange">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in logisticsType"
:key="item.value">
<view>
<radio :value="item.value" :checked="index === current" />
</view>
<view>{{item.name}}</view>
</label>
</radio-group>
</view>
</view>
<view class="" v-if="radioType != '2'">
<view class="content-list" v-if="radioType == '0' || radioType == '1'"
@tap.stop="goPopleList(radioType == '0'? 'wlName' :'kdName')">
<view class="list-name" style="width:150rpx;padding-left: 0;">
{{radioType == '0'? '选择物流' :'选择快递'}}
</view>
<view class="list-val">
<input type="text" placeholder="请选择" disabled
:value="wlName.companyName || wlName.shippingMethod"
style="border-bottom: 1px solid #fff;text-align: center;padding-right: 54rpx;">
<uni-icons type="right" size="16"
style="margin-left: 80rpx;line-height: 80rpx;"></uni-icons>
</view>
</view>
<view class="content-list" v-if="radioType == '4'" @tap.stop="goPopleList('fcName')">
<view class="list-name" style="width:150rpx;padding-left:0;">选择车号</view>
<view class="list-val">
<input type="text" placeholder="请选择" disabled
:value="wlName.companyName || wlName.shippingMethod"
style="border-bottom: 1px solid #fff;text-align: center;">
<uni-icons type="right" size="16"
style="margin-left: 80rpx;line-height: 80rpx;"></uni-icons>
</view>
</view>
<view class="content-list" v-if="radioType == '5'" @tap.stop="goPopleList('dbName')">
<view class="list-name" style="width:150rpx;padding-left:0;">选择车号</view>
<view class="list-val">
<input type="text" placeholder="请选择" disabled
:value="wlName.companyName || wlName.shippingMethod"
style="border-bottom: 1px solid #fff;text-align: center;">
<uni-icons type="right" size="16"
style="margin-left: 80rpx;line-height: 80rpx;"></uni-icons>
</view>
</view>
<view class="content-list" v-if="radioType =='0' || radioType =='5' || radioType =='4'">
<view class="list-name" style="width:150rpx;padding-left:0;">配送方式</view>
<view class="list-val" style="line-height: 90rpx;">
<uni-data-select clear='true' class="uni-data-select" :localdata="sex" v-model="value"
placeholder="请选择配送方式" @change="checkBoxChange"></uni-data-select>
</view>
</view>
<view class="content-list" v-if="radioType1 == '0' && radioType !=''"
@tap.stop="goPopleList(radioType == '1'? 'kdyName' :'lbgName')">
<view class="list-name" style="width:150rpx;padding-left:0;">
{{radioType == '1'? '快递员' :'拉包工'}}
</view>
<view class="list-val">
<input type="text" placeholder="可指定人员" disabled
:value="radioType == '1'? kdyName.workerName : lbgName.workerName"
style="border-bottom: 1px solid #fff;text-align: center;">
<uni-icons type="right" size="16"
style="margin-left: 80rpx;line-height: 80rpx;"></uni-icons>
</view>
</view>
<view class="content-list" v-if="radioType == '3'">
<view class="list-name" style="padding-left:0;">拼包地址</view>
<view class="">
<textarea @input='changePbAddress($event)' :value='pbAddress' />
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<!-- </view> -->
<view class="bottom-box">
<view class="bottom-left">
<text>合计:{{totalAmount}}</text>
<text style="color: #ffa200;">¥{{shouldPay == null ?0:shouldPay}}</text>
</view>
<view class="bottom-right">
<button class="bottom-btn" @tap.stop="clearAll">清空商品</button>
<button class="bottom-btn" @tap.stop="showPrice">开单</button>
</view>
</view>
<!-- 弹出输入框 -->
<uni-popup ref="inputDialog" background-color="#fff">
<view class="popup-pay-content">
<view class="popup-pay-title">
<text>选择商品价格</text>
</view>
<view class="popup-pay-container" @tap.stop="checkPay(lsprice)">
<text style="display: inline-block">零售价:¥{{lsprice}}</text>
</view>
<view class="popup-pay-container" @tap.stop="checkPay(wholesalePrice)">
<text style="display: inline-block">批发价:¥{{wholesalePrice}}</text>
</view>
<view class="popup-pay-container" style="background: #fff;display: flex;width: 100%;">
<input type="digit" style="height: 100rpx;line-height: 100rpx;color:#000;width: 296rpx;"
placeholder="请输入价格" @input="changePay">
<view style="flex: 1;color: #fff;background: #088FEB;border-radius: 10px;width: 144rpx;"
@tap.stop="checkPay(customPrice)">确定</view>
</view>
</view>
</uni-popup>
<!-- <canvas canvas-id="myCanvas"></canvas> -->
<!-- 弹出层 -->
<view class="tanchuceng">
<uni-popup ref="shopPopup" background-color="#fff" @change="clickClose">
<view class="shop-popup-content">
<view class="shop-popup-title">
<view class="shop-popup-title-left">
<img class="img-radius" :src="goodsDetail.productPicture" alt=""
v-if="goodsDetail.productPicture">
<view class="noPic" style="margin: 0;" v-else>暂无图片</view>
</view>
<view class="shop-popup-title-right">
<view class="shop-popup-title-right-box" style="color: #088FEB;">{{goodsDetail.productName}}
</view>
<view class="shop-popup-title-right-box">{{goodsDetail.productSn}}</view>
</view>
</view>
<view class="shop-popup-container" style="position: relative;">
<view @tap="saveCheck"
style="position: absolute;top: 10rpx;right: 20rpx;color: #088FEB;text-decoration: underline;">
保存已选</view>
<ul style="border-top:20rpx;">
<li v-for="(items,index) in goodsDetail.attributeList" :key="index">
<view class="shop-title-fur">
<view class="shop-title-name">{{items.name}}</view>
</view>
<view class="shop-attrs">
<view class="suibian" v-for="(itemTag, index1) in items.value" :key="index1"
@tap.stop="attrNameChange(index,itemTag.value,index1) "
:class="itemTag.isChecked ? 'checkedText' : '' " style="position: relative;">
{{itemTag.value}}
<view class="kucun" v-if="itemTag.isKucun"></view>
</view>
</view>
</li>
</ul>
<view style="padding-bottom:100rpx;">
<view class="shop-checkList" v-if="temporaryList != ''">
<view class="shop-checkList-box" style="width: 69.5%;">
<text
style="width: 300rpx;display: inline-block;font-size: 30rpx;font-weight: bold;padding-left: 40rpx;">
规格
</text>
<text
style="font-size: 30rpx;color: #000;font-weight: bold;width: 110rpx;display: inline-block;text-align: right;">
库存
</text>
</view>
<view class="zuni-numbox">
<view @tap="minusNum" class="zuni-numbox__minus zuni-numbox-btns"
style="background: #f5f5f5;">
<text class="zuni-numbox--text">-</text>
</view>
<input v-model="allChangeNum" @blur="allChange" @focus="obtainPrice($event,'zongjishu')" class="zuni-numbox__value"
type="number" />
<view @tap="plusNum" class="zuni-numbox__plus zuni-numbox-btns"
style="background: #f5f5f5;">
<text class="zuni-numbox--text">+</text>
</view>
</view>
<!-- <uni-number-box max='1000000' @minus='minusNum' @plus="plusNum" v-model="allChangeNum" @blur="allChange" /> -->
</view>
<view class="shop-checkList" v-for="(item,index) in temporaryList" :key="index">
<view @tap.stop="delCarData(index)" style="margin-right: 20rpx;width: 7%;">
<uni-icons color="red" type="minus" size="26"></uni-icons>
</view>
<view class="shop-checkList-box">
<text style="width: 300rpx;display: inline-block;">{{item.name}}</text> <text
style="color:#777;font-size: 12px;">{{item.productNum==null?'无库存':item.productNum}}</text>
</view>
<uni-number-box max='1000000' min="-10000" v-model="item.productCount"
@change="temporaryChange($event,item)" />
</view>
</view>
</view>
</view>
<view class="shop-popup-bottom" v-for="(item,index) in temporaryList" :key="index">
<view class="shop-popup-bottom-left">
<text>{{zNum}} 件</text>
<!-- <text>¥{{zPrice}}</text> -->
</view>
<view class="shop-popup-bottom-right">
<view class="bottom-btn" @tap.stop="temporaryCheck">选好了</view>
</view>
</view>
</uni-popup>
</view>
<!-- 历史价格弹出层 -->
<uni-popup ref="historyPopup" background-color="#fff">
<view class="popup-content">
<view class="popup-title">
<text>拿货历史价格</text>
<uni-icons @tap='this.$refs.historyPopup.close()' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view class="popup-container" v-if="historyList != null && historyList.discountAmount != null">
<view style="height: 60rpx;line-height: 60rpx;">上次拿货时间:</view>
<view style="height: 60rpx;line-height: 60rpx;">{{historyList.createTime}}</view>
<view style="height: 60rpx;line-height: 60rpx;">上次拿货数:{{historyList.productCount}}</view>
<view style="height: 60rpx;line-height: 60rpx;font-size: 36rpx;font-weight: bold;">
上次拿货价:{{historyList.discountAmount}}</view>
</view>
<view class="popup-container" v-else>
<view style="height: 150rpx;line-height: 150rpx;text-align: center;">暂无拿货历史</view>
</view>
<view class="popup-bottom" v-if="historyList != null">
<view class="popup-btn" @tap="checkPay(historyList.discountAmount)">一键使用历史价格</view>
</view>
</view>
</uni-popup>
<!-- 语音识别弹出层 -->
<uni-popup ref="popup" background-color="#fff">
<view class="voice-popup-content">
<view class="voice-popup-title">
<text>语音录入</text>
<uni-icons @tap='close' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view style="text-align: center;width: 100%;line-height: 40rpx;font-size: 11px;color: #777;">
语音示例:货号02-37,白色M码,10件
</view>
<view class="voice-popup-container">
<textarea name="" id="" style="width:100%;height:300rpx;border:1px solid #eee;margin:0;"
v-model="voiceText" placeholder="等待语音识别中..."></textarea>
<view>
<text style="color:red;font-size:22rpx;">*长按“语音”按钮录入,系统将自动识别</text>
</view>
<view class="voice-popup-bottom">
<view class="voice-popup-btn" @tap="clearText">清空</view>
<view class="voice-popup-btn" @tap="setDetail">确认</view>
</view>
</view>
<view class="voice-btn" @touchstart="kaishi" @touchend="jieshu">
<img src="/static/images/maikefeng.png" style="width: 80%;height: 80%;margin: 10%;" alt="">
</view>
</view>
</uni-popup>
<view class="voice-model" v-if="recordState == true">
<img src="/static/images/maikefeng.png" alt="">
<view class="voice-text">语音识别中...</view>
</view>
<!-- 金额展示框 -->
<uni-popup ref="showPopup" background-color="#fff">
<view class="popup-pay-content" style="width: 550rpx;">
<view class="popup-pay-title">
<text>请确认开单金额</text>
<uni-icons @tap='$refs.showPopup.close()' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view>
<view class="box-right">
<text class="box-right-name" style="font-size: 24rpx;">总金额:{{shouldPay}}</text>
</view>
<view class="box-right">
<text class="box-right-name" style="font-size: 24rpx;">实收金额:{{relPrice}}</text>
</view>
<view class="box-right">
<text class="box-right-name" style="font-size: 24rpx;">已收金额:{{priceOk}}</text>
</view>
<view class="box-right">
<text class="box-right-name" style="font-size: 24rpx;">欠款:{{noPay}}</text>
</view>
</view>
<view class="popup-pay-container" style="display: flex;">
<view @tap='goSell'
style="width:50%;line-height: 100rpx;text-align: center;border-right: 1px solid #eee;">
仅开单
</view>
<view
style="position:relative;width:50%;line-height: 100rpx;text-align: center;border-right: 1px solid #eee;">
<kk-printer style="width: 100%;color:#fff;position: absolute;top: 0;left: 0;" ref="kkprinter"
:bufferData="bufferData" @onPrint="onPrint" :defaultText="'开单并打印'"></kk-printer>
</view>
</view>
</view>
</uni-popup>
<!-- AI开单选中未入库不展示的框 -->
<uni-popup ref="AiNoPopup" background-color="#fff">
<view class="popup-pay-content" style="max-height: 1000rpx;overflow: scroll;">
<view class="popup-pay-title">
<text>识别结果</text>
</view>
<view style="border-bottom: 1px solid #eee;" v-if="aiNotRecognition != ''">
<view style="margin-top:20rpx;">抱歉:小助手对“{{getMsg}}”的部分商品未识别,请检查识别信息是否正确:</view>
<view class="box-right" style="margin: 20rpx 0 20rpx;text-align: left;width: 100%;">
<text class="box-right-name"
style="font-size: 24rpx;padding: 20rpx 0;">{{aiNotRecognition}}</text>
</view>
</view>
<view style="width: 220px;background: #fff;width: 440rpx;">
<view @tap='$refs.AiNoPopup.close()'
style="width: 100%;line-height: 50px;text-align: center;background: #088FEB;margin-bottom: 10rpx;border-radius: 10px;color: #fff;">
确认
</view>
</view>
</view>
</uni-popup>
<!-- 弹出规格选择 -->
<uni-popup ref="getaPopup" background-color="#fff" :is-mask-click="true">
<view class="type-popup" style="margin-bottom: 0;border-radius: 0;">
<view style="height: 80rpx;font-size: 36rpx;font-weight: bold;line-height: 80rpx;text-align: center;">
修改当前规格
</view>
<view class="card-list">
<ul>
<li v-for="items in attrList" :key="items.id">
<view class="title-fur">
<view class="name">{{items.attributeName}}</view>
</view>
<view class="content-fur">
<view class="content-low" v-for="item in attributeValue" :key="item.id"
@tap="changeSpec(item.value)" v-if="temporary[3] != item.value">{{item.value}}
</view>
</view>
</li>
</ul>
</view>
</view>
</uni-popup>
<view class="mask-model" v-if="isVoice">貌似没有检测到您上次的语音录入信息,正在反复识别中</view>
</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 {
generateUUID
} from '@/utils/global.js'
import base from '@/utils/ossUploadFile/base64.js';
var plugin = requirePlugin("WechatSI")
let manager = plugin.getRecordRecognitionManager()
export default {
data() {
return {
attrList: [],
attributeValue: [],
evalue:[],
lsprice: 0, //临时零售价
wholesalePrice: 0, // 临时显示批发价
price: 0, //总金额
relPrice: "", //实收金额
otherExpense: "", // 其他费用
noPay: 0, //欠款
discountNum: 10, //整体折扣
priceCurrent: '',
goodsDetail: [],
noticeData: ['您每发出一个包,使用拉包工和物流公司送货时,我们将从中拿出XX元,捐入快拾帮帮公益基金中,帮助那些贫困儿童!我们的付出将让世界充满爱!'],
columns: [],
keyList: [],
index: '',
temporary: [],
temporaryList: [],
zNum: 0,
bufferData: [],
zPrice: 0,
priceOk: '', //已收金额
value: 0,
valuexsy: '',
sex: [{
text: '平台配送',
value: 0
}, {
text: '自送',
value: 1
}],
priceItems: [{
value: '0',
name: '零售价'
},
{
value: '1',
name: '批发价'
}
],
items: [{
value: '0',
name: '单品'
},
{
value: '1',
name: '整体'
}
],
logisticsType: [{
value: '0',
name: '物流'
},
{
value: '3',
name: '拼包'
},
{
value: '4',
name: '厢货'
},
{
value: '1',
name: '快递'
},
{
value: '2',
name: '自提'
},
{
value: '5',
name: '大巴'
}
],
discountType: '', //折扣类型
discountCurrent: '',
isVoice:false,
current: 4,
voiceText: ' ',
discCurrent: '', //折扣
logisticsCurrent: '', //物流
categoryList: '', //销售员
payType:1,
payTypeList:[{
value: 1,
text: "微信支付"
},{
value: 0,
text: "现金支付"
},{
value: 2,
text: "支付宝支付"
},{
value: 3,
text: "银行卡转账"
},{
value: 4,
text: "收款码支付"
}],
radioType: "2", //发货方式按钮选择
khName: [], //客户
gysName: [], //供应商
wlName: [], //物流公司/物流/发车
kdyName: [], //快递员
lbgName: [], //拉包工姓名
carList: new Map(), //添加商品页传回来的商品信息
xsyId: '',
shouldPay: 0,
totalAmount: 0,
customPrice: 0, //选择自定义金额
remark: '',
pbAddress: '',
yanseList: new Map(),
chimaList: new Map(),
carList1: [],
isPlusAndMinus: false,
radioType1: 0,
linshiPrice:0,
saleId: '',
saleDetailList: [],
yNum: 150,
clearMsg: '',
priceType: '',
multiple: 1,
productId: '',
productNum: 0,
historyList: {},
printTotal: 1040,
afterPrice: 0, //第二次选择商品的时候,先计算这个价格,实收金额= 已经存在的实收金额 + afterPrice
pageOldTemList: [],
oldTemList: [],
goodsList: [],
newTemList: [],
pecsList: [],
dataObj: new Map(),
allChangeNum: 0,
recordState: false,
currentAnchor: '',
temporaryNum: 0,
isInventory: true,
aiNotRecognition: '',
getMsg: '',
qrArr: []
}
},
components: {
kkPrinter
},
onHide(){
console.log('1加载了啊')
this.recordState = false
},
onShow() {
console.log('加载了啊')
this.recordState = false
// 初始化蓝牙模块
wx.openBluetoothAdapter({
mode: 'central'
})
uni.showLoading({
title: '加载中...'
})
let that = this;
this.khName = JSON.parse(JSON.stringify(this.khName)) || ''
this.gysName = JSON.parse(JSON.stringify(this.gysName))
this.wlName = JSON.parse(JSON.stringify(this.wlName))
this.kdyName = JSON.parse(JSON.stringify(this.kdyName))
this.lbgName = JSON.parse(JSON.stringify(this.lbgName))
if (uni.getStorageSync('hangOrder') == true) {
this.carList.clear()
this.remark = ''
this.xsyId = ''
this.khName = []
this.saleId = ''
uni.removeStorageSync('hangOrder');
}
this.sex = [{
text: '平台配送',
value: 0
}, {
text: '自送',
value: 1
}]
// if(this.wlName !='' && this.wlName.canToDoor == 1){
// let data = {
// text: '物流自取',
// value: 2
// }
// this.sex.push(data)
// }else if(this.wlName !='' && this.wlName.canToDoor == 0){
// this.sex = [{
// text: '平台配送',
// value: 0
// }, {
// text: '自送',
// value: 1
// }]
// }
if (uni.getStorageSync('carList1') != '') {
this.carList.clear()
this.carList1 = JSON.parse(uni.getStorageSync('carList1'))
this.khName = uni.getStorageSync('khName') ? JSON.parse(uni.getStorageSync('khName')) : ''
this.remark = this.carList1[0].remark || ""
this.saleId = this.carList1[0].saleId
this.xsyId = this.carList1[0].xsyId
this.createByName = this.carList1[0].createByName
} else {
this.carList1 = this.carList1
}
// const uuid = generateUUID();
this.handleData()
},
filters: {
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + '/'
}
}
return name;
}
},
onLoad(option) {
this.xsyList();
this.initRecord();
this.analysisQrCode()
},
methods: {
//正则匹配处理“2十9”等情况
convertStringCorrectly(str) {
var regexForSingleTen = /(\d+)十(?!\d)/g;
var regexForFollowedByDigit = /(\d+)十(?=\d)/g;
var step1Result = str.replace(regexForSingleTen, '$10');
var finalResult = step1Result.replace(regexForFollowedByDigit, '$1');
return finalResult;
},
//打印小票二维码,分割二维码字符串
analysisQrCode() {
let qrCode = uni.getStorageSync('shopIcon')
if(qrCode != ''){
let data = qrCode.split(',')
for(let i=0;i<data.length;i++){
var weixin = data[i].indexOf("微信");
var dianpu = data[i].indexOf("店铺");
var zifubao = data[i].indexOf("支付");
var yinlian = data[i].indexOf("收款");
if (dianpu != -1) {
var result = data[i].substring(dianpu + 2);
let obj = {
name:'店铺微信',
path:result,
level:"M"
}
this.qrArr.push(obj)
}
if (weixin != -1) {
var result = data[i].substring(weixin + 2);
let obj = {
name:'微信收款码',
path:result,
level:"M"
}
this.qrArr.push(obj)
}
if (zifubao != -1) {
var result = data[i].substring(zifubao + 2);
let obj = {
name:'支付宝收款码',
path:result,
level:"Q"
}
this.qrArr.push(obj)
}
if (yinlian != -1) {
var result = data[i].substring(yinlian + 2);
let obj = {
name:'银行收款码',
path:result,
level:"M"
}
this.qrArr.push(obj)
}
}
}
},
handleData() {
let that = this;
for (let i = 0; i < this.carList1.length; i++) {
if (this.carList1[i].saleDetailQueryDTO) {
if (this.carList.size == 0) { //当前页没有数据
let obj = {
purchasePrice: this.carList1[i].price, //采购价
price: 0, //总价
discount: 10, //折扣
categoryId: this.carList1[i].categoryId,
unitPrice: this.carList1[i].unitPrice || 0, //单价
discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].lsprice, //零售价
productCount: 0, //总数量
productId: this.carList1[i].id,
productName: this.carList1[i].productName,
productPicture: this.carList1[i].productPicture,
productSn: this.carList1[i].productSn,
stockLogList: new Map(),
stockLogList1: [],
supplierName: this.carList1[i].supplierName //供应商
}
for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) {
var data1 = {
productCount: this.carList1[i].saleDetailQueryDTO[m].productCount,
name: this.carList1[i].saleDetailQueryDTO[m].name,
productNum: this.carList1[i].saleDetailQueryDTO[m].productNum != undefined ? this
.carList1[i].saleDetailQueryDTO[m].productNum : this.carList1[i]
.saleDetailQueryDTO[m].stockCount
}
obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1)
obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
}
this.carList.set(this.carList1[i].id, obj)
} else { //当前页有数据
if (this.carList.has(this.carList1[i].id) == true) { //商品相同
for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) {
if (this.carList.get(this.carList1[i].id).stockLogList.has(this.carList1[i]
.saleDetailQueryDTO[
m].attributeList) == true) { //规格相同
var data1 = {
productCount: this.carList.get(this.carList1[i].id).stockLogList.get(this
.carList1[i].saleDetailQueryDTO[m].attributeList).productCount +
this.carList1[i].saleDetailQueryDTO[m].productCount,
name: this.carList1[i].saleDetailQueryDTO[m].name,
productNum: this.carList1[i].saleDetailQueryDTO[m].productNum !=
undefined ? this.carList1[i].saleDetailQueryDTO[m].productNum : this
.carList1[i].saleDetailQueryDTO[m].stockCount
}
this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i]
.saleDetailQueryDTO[m].attributeList, data1)
// this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i]
// .saleDetailQueryDTO[m].attributeList, this.carList.get(this.carList1[i].id).stockLogList.get(
// this.carList1[i].saleDetailQueryDTO[m].attributeList) + this.carList1[i]
// .saleDetailQueryDTO[m].productCount)
// this.carList.get(this.carList1[i].id).productCount += this.carList1[i]
// .saleDetailQueryDTO[m].productCount
} else { //规格不同
// this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i]
// .saleDetailQueryDTO[
// m].attributeList, this.carList1[i].saleDetailQueryDTO[m].productCount)
// this.carList.get(this.carList1[i].id).productCount += this.carList1[i]
// .saleDetailQueryDTO[
// m].productCount
var data1 = {
productCount: this.carList1[i].saleDetailQueryDTO[m].productCount,
name: this.carList1[i].saleDetailQueryDTO[m].name,
productNum: this.carList1[i].saleDetailQueryDTO[m].productNum !=
undefined ? this.carList1[i].saleDetailQueryDTO[m].productNum : this
.carList1[i].saleDetailQueryDTO[m].stockCount
}
this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i]
.saleDetailQueryDTO[
m].attributeList, data1)
}
this.carList.get(this.carList1[i].id).productCount += this.carList1[i]
.saleDetailQueryDTO[
m].productCount
}
} else { //商品不同
let obj = {
purchasePrice: this.carList1[i].price, //采购价
price: 0,
discount: 10,
categoryId: this.carList1[i].categoryId,
discountAmount: this.carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
unitPrice: this.carList1[i].unitPrice || 0, //单价
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].lsprice, //零售价
productCount: 0,
productId: this.carList1[i].id,
productName: this.carList1[i].productName,
productPicture: this.carList1[i].productPicture,
stockLogList: new Map(),
stockLogList1: [],
productSn: this.carList1[i].productSn,
supplierName: this.carList1[i].supplierName
}
for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) {
// obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, this.carList1[i]
// .saleDetailQueryDTO[m].productCount)
// obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
var data1 = {
productCount: this.carList1[i].saleDetailQueryDTO[m].productCount,
name: this.carList1[i].saleDetailQueryDTO[m].name,
productNum: this.carList1[i].saleDetailQueryDTO[m].productNum != undefined ?
this.carList1[i].saleDetailQueryDTO[m].productNum : this.carList1[i]
.saleDetailQueryDTO[m].stockCount
}
obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1)
obj.name = this.carList1[i].saleDetailQueryDTO[m].name
obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
}
this.carList.set(this.carList1[i].id, obj)
}
}
}
}
uni.removeStorageSync('carList1')
uni.removeStorageSync('khName')
uni.removeStorageSync('saoma')
uni.removeStorageSync('clearMsg')
this.carList1 = []
this.carList.forEach(function(value, key) {
if (that.priceType == '') {
// value.unitPrice = value.unitPrice
} else if (that.priceType == 0) { //零售
value.unitPrice = value.lsprice
} else if (that.priceType == 1) { //批发
value.unitPrice = value.wholesalePrice
}
if (that.discountType == 1) { //整体折扣
value.price = value.unitPrice * 10000 * value.productCount * that.discountNum / 10 / 10000
}
})
this.getAllPrice()
this.getAmountAndWho()
// this.noPay = this.shouldPay
if (this.xsyId == '') {
this.xsyId = uni.getStorageSync('id')
this.createByName = uni.getStorageSync('nickname')
}
if (this.carList1 != '') {
setTimeout(res => {
uni.hideLoading();
}, 2000)
} else {
setTimeout(res => {
uni.hideLoading();
}, 300)
}
},
invenRadio() {
this.isInventory = !this.isInventory
},
AiHandleData() {
let that = this;
for (let i = 0; i < this.carList1.length; i++) {
if (this.carList1[i].stockLogList1) {
if (this.carList.size == 0) { //当前页没有数据
let obj = {
purchasePrice: this.carList1[i].purchasePrice, //采购价
price: 0, //总价
discount: 10, //折扣
productId: this.carList1[i].productId,
categoryId: this.carList1[i].categoryId,
unitPrice: this.carList1[i].wholesalePrice || 0, //单价
discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].price, //零售价
productCount: 0, //总数量
id: this.carList1[i].productId,
productName: this.carList1[i].productName,
productPicture: this.carList1[i].productPicture,
productSn: this.carList1[i].productSn,
stockLogList: new Map(),
stockLogList1: [],
supplierName: this.carList1[i].supplierName //供应商
}
for (let m = 0; m < this.carList1[i].stockLogList1.length; m++) {
var data1 = {
productCount: this.carList1[i].stockLogList1[m].productCount,
name: this.sliceMsg(this.carList1[i].stockLogList1[m].attributeList),
productNum: this.carList1[i].stockLogList1[m].stockCount
}
obj.stockLogList.set(this.carList1[i].stockLogList1[m].attributeList, data1)
obj.productCount += this.carList1[i].stockLogList1[m].productCount
}
this.carList.set(this.carList1[i].productId, obj)
} else { //当前页有数据
if (this.carList.has(this.carList1[i].productId) == true) { //商品相同
for (let m = 0; m < this.carList1[i].stockLogList1.length; m++) {
if (this.carList.get(this.carList1[i].productId).stockLogList.has(this.carList1[i]
.stockLogList1[
m].attributeList) == true) { //规格相同
var data1 = {
productCount: this.carList.get(this.carList1[i].productId).stockLogList
.get(this.carList1[i].stockLogList1[m].attributeList).productCount +
this.carList1[i].stockLogList1[m].productCount,
name: this.sliceMsg(this.carList1[i].stockLogList1[m].attributeList),
productNum: this.carList1[i].stockLogList1[m].stockCount
}
this.carList.get(this.carList1[i].productId).stockLogList.set(this.carList1[i]
.stockLogList1[m].attributeList, data1)
} else { //规格不同
var data1 = {
productCount: this.carList1[i].stockLogList1[m].productCount,
name: this.sliceMsg(this.carList1[i].stockLogList1[m].attributeList),
productNum: this.carList1[i].stockLogList1[m].stockCount
}
this.carList.get(this.carList1[i].productId).stockLogList.set(this.carList1[i]
.stockLogList1[
m].attributeList, data1)
}
this.carList.get(this.carList1[i].productId).productCount += this.carList1[i]
.stockLogList1[
m].productCount
}
} else { //商品不同
let obj = {
purchasePrice: this.carList1[i].purchasePrice, //采购价
price: 0, //总价
discount: 10, //折扣
categoryId: this.carList1[i].categoryId,
productId: this.carList1[i].productId,
unitPrice: this.carList1[i].wholesalePrice || 0, //单价
discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].price, //零售价
productCount: 0, //总数量
id: this.carList1[i].productId,
productName: this.carList1[i].productName,
productPicture: this.carList1[i].productPicture,
productSn: this.carList1[i].productSn,
stockLogList: new Map(),
stockLogList1: [],
supplierName: this.carList1[i].supplierName //供应商
}
for (let m = 0; m < this.carList1[i].stockLogList1.length; m++) {
// obj.stockLogList.set(this.carList1[i].stockLogList1[m].attributeList, this.carList1[i]
// .stockLogList1[m].productCount)
// obj.productCount += this.carList1[i].stockLogList1[m].productCount
var data1 = {
productCount: this.carList1[i].stockLogList1[m].productCount,
name: this.sliceMsg(this.carList1[i].stockLogList1[m].attributeList),
productNum: this.carList1[i].stockLogList1[m].stockCount
}
obj.stockLogList.set(this.carList1[i].stockLogList1[m].attributeList, data1)
obj.name = this.sliceMsg(this.carList1[i].stockLogList1[m].attributeList)
obj.productCount += this.carList1[i].stockLogList1[m].productCount
}
this.carList.set(this.carList1[i].productId, obj)
}
}
}
}
console.log(that.priceType)
this.$nextTick(() => {
this.carList1 = []
this.carList.forEach(function(value, key) {
if (that.priceType == '') {
// value.unitPrice = value.unitPrice
} else if (that.priceType == 0) { //零售
value.unitPrice = value.lsprice
} else if (that.priceType == 1) { //批发
value.unitPrice = value.wholesalePrice
}
if (that.discountType == 1) { //整体折扣
value.price = value.unitPrice * 10000 * value.productCount * that.discountNum /
10 / 10000
}
})
this.getAllPrice()
this.getAmountAndWho()
})
// 2019002均色M码1件2019005黑色S码一件
},
//保存已选
saveCheck() {
this.pageOldTemList = this.temporaryList
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) {
this.goodsList[i].specs = []
for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
},
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + '/'
}
}
return name;
},
combination(arr) {
let result = [
[]
]
arr.map(x => {
var res = []
result.map(y => {
x.specs.map(z => {
res.push([...y, z])
})
})
result = res
})
return result;
},
numData(val) {
var name = []
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name.push(newObj[as])
}
}
return name;
},
checkSpec(type, id, attr, value) {
this.temporary = [id, attr, type, value]
let num = type == '颜色' ? 0 : 1
this.getGategoryLowList()
},
//初始化获取子分类列表
getGategoryLowList() {
this.attrList = []
let num = this.temporary[2] == '颜色' ? 0 : 1
this.tui.request("/app/productAttribute/selectByCategoryId", "POST", {
categoryId: this.carList.get(this.temporary[0]).categoryId
}, false, true).then((res1) => {
if (res1.code == 200) {
this.attrList.push(res1.result[num])
if (res1.result.length > 0) {
this.attributeValue = []
this.tui.request(
"/app/productAttributeValue/selectByAttributeId",
"get", {
id: this.attrList[0].id
}, false, true).then((res2) => {
if (res2.code == 200) {
this.attributeValue = res2.result;
this.$forceUpdate()
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
}
setTimeout(() => {
this.showList = this.attrList;
}, 1000)
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
this.$forceUpdate()
this.$refs.getaPopup.open()
},
//点击某一个规格,可修改
async changeSpec(item) {
let that = this;
if (item == '') {
this.tui.toast('请输入要修改的规格值')
return;
}
let data = this.temporary
let specMap = new Map() //新的临时存放值那个更改过的值的map
await this.carList.get(data[0]).stockLogList.forEach(function(value, key) {
if (key == data[1]) {
let stringKey = key.replace(data[3], item) //拿到了更改过的key
if (specMap.has(stringKey) == true) {
data[1] = stringKey
specMap.get(stringKey).name = that.sliceMsg(stringKey)
specMap.get(stringKey).productCount += value.productCount
} else {
data[1] = stringKey
specMap.set(stringKey, value)
specMap.get(stringKey).name = that.sliceMsg(stringKey)
}
that.tui.request("/app/stock/productCount", "post", {
productId: that.carList.get(data[0]).productId,
attributeList: stringKey
}, false, true).then((res) => {
if (res.code == 200) {
value.productNum = res.result
that.$forceUpdate()
} else {
that.tui.toast(res.message)
}
}).catch((res) => {})
} else {
specMap.set(key, value)
}
})
await that.$nextTick(() => {
this.carList.get(data[0]).stockLogList = specMap
this.$forceUpdate()
this.$refs.getaPopup.close()
})
},
//销售员列表
xsyList() {
this.tui.request('/app/common/user/findAllUserByShopId', 'get', {
}, false, false, true).then((res) => {
if (res.code !== 200) return
this.categoryList = res.result.map(item => {
return {
value: item.id,
text: item.nickname
}
})
})
},
allChange(e) {
console.log(this.linshiPrice)
if(this.linshiPrice == e.target.value){
this.allChangeNum = e.target.value
}else{
if(e.target.value == ''){
this.allChangeNum = this.linshiPrice
}else{
this.allChangeNum = e.target.value
}
}
//监听到输入框改变,给所有的都赋值
if (this.isPlusAndMinus == false) {
for (var i = 0; i < this.temporaryList.length; i++) {
if(this.evalue.length == 0){
this.temporaryList[i].productCount = Number(this.allChangeNum)
}else{
for(var j=0;j<this.evalue.length;j++){
if(this.evalue[j] == this.temporaryList[i].name){
this.temporaryList[i].productCount = Number(this.allChangeNum)
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (this.temporaryList[i].attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = this.temporaryList[i].productCount
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (this.temporaryList[i].attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = this.temporaryList[i].productCount
}
}
}
}
this.isPlusAndMinus == false
this.temporaryChange()
},
plusNum() {
this.isPlusAndMinus == true
//监听到点击+的操作,给所有的都+1
for (var i = 0; i < this.temporaryList.length; i++) {
if(this.evalue.length == 0){
if (this.temporaryList[i].productCount == undefined) {
this.temporaryList[i].productCount = 1
} else {
this.temporaryList[i].productCount++
}
}else{
for(var j=0;j<this.evalue.length;j++){
if(this.evalue[j] == this.temporaryList[i].name){
if (this.temporaryList[i].productCount == undefined) {
this.temporaryList[i].productCount = 1
} else {
this.temporaryList[i].productCount++
}
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (this.temporaryList[i].attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = this.temporaryList[i].productCount
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (this.temporaryList[i].attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = this.temporaryList[i].productCount
}
}
}
this.temporaryChange()
},
minusNum() {
this.isPlusAndMinus == true
//监听到点击-的操作,给所有的都-1
for (var i = 0; i < this.temporaryList.length; i++) {
if(this.evalue.length == 0){
this.temporaryList[i].productCount--
}else{
for(var j=0;j<this.evalue.length;j++){
if(this.evalue[j] == this.temporaryList[i].name){
this.temporaryList[i].productCount--
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (this.temporaryList[i].attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = this.temporaryList[i].productCount
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (this.temporaryList[i].attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = this.temporaryList[i].productCount
}
}
}
this.temporaryChange()
},
attrNameChange(index, data1, index1) {
uni.showLoading({
title: '加载中...'
})
this.goodsDetail.attributeList[index].isChecked = !this.goodsDetail.attributeList[index].isChecked;
this.goodsDetail.attributeList[index].value[index1].isChecked = !this.goodsDetail.attributeList[index]
.value[index1].isChecked;
if (this.goodsList[index].specs.indexOf(data1) != -1) {
this.goodsList[index].specs.splice(this.goodsList[index].specs.indexOf(data1), 1)
} else {
this.goodsList[index].specs.push(data1)
}
let jishuqi = 0
for (var i = 0; i < this.goodsList.length; i++) {
if (this.goodsList[i].specs.length > 0) {
jishuqi++
}
}
var resultList = []
if (jishuqi == this.goodsList.length) {
resultList = this.combination(this.goodsList);
}
this.evalue = []
var value = []
for (var m = 0; m < resultList.length; m++) {
var name = ''
let value1 = "{"
for (var j = 0; j < resultList[m].length; j++) {
if (j != resultList[m].length - 1) {
name += resultList[m][j] + '/'
value1 += '"' + this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '",'
} else {
name += resultList[m][j]
value1 += '"' + this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '"'
}
}
value1 += "}"
value.push(value1)
this.evalue.push(name)
}
if (jishuqi == 0) {
this.oldTemList = []
}
if (this.temporaryList.length == 0) {
if (jishuqi == this.goodsList.length) {
for (var i = 0; i < value.length; i++) {
this.attributeList = {
attributeList: value[i],
productCount: this.temporaryNum,
productNum: null,
name: this.evalue[i],
price: this.purchasePrice
}
this.temporaryList.push(this.attributeList);
}
}
} else {
let newProductCount = 0;
for (var i = 0; i < value.length; i++) {
for (var m = 0; m < this.temporaryList.length; m++) {
if (this.temporaryList[m].attributeList == value[i]) {
newProductCount = this.temporaryList[m].productCount
}
}
this.attributeList = {
attributeList: value[i],
productCount: newProductCount,
productNum: null,
name: this.evalue[i],
price: this.purchasePrice
}
this.newTemList.push(this.attributeList);
newProductCount = 0;
}
for (var i = 0; i < this.oldTemList.length; i++) {
let oldAttributeList = '';
let oldProductCount = '';
let notChcek = true;
for (var m = 0; m < this.newTemList.length; m++) {
if (this.oldTemList[i].attributeList == this.newTemList[m].attributeList) {
this.newTemList[m].productCount = this.oldTemList[i].productCount
notChcek = false;
}
}
if (this.newTemList.length > 0 && notChcek) {
this.newTemList.push(this.oldTemList[i]);
}
}
for (var i = 0; i < this.pageOldTemList.length; i++) {
let oldAttributeList = '';
let oldProductCount = '';
let notChcek = true;
for (var m = 0; m < this.newTemList.length; m++) {
if (this.pageOldTemList[i].attributeList == this.newTemList[m].attributeList) {
this.newTemList[m].productCount = this.pageOldTemList[i].productCount
notChcek = false;
}
}
if (this.newTemList.length > 0 && notChcek) {
this.newTemList.push(this.pageOldTemList[i]);
}
}
}
this.$nextTick(() => {
for (var i = 0; i < this.temporaryList.length; i++) {
for (var m = 0; m < this.pecsList.length; m++) {
if (this.temporaryList[i].attributeList == this.pecsList[m].attributeList) {
this.temporaryList[i].productNum = this.pecsList[m].stockCount
}
}
}
})
if (jishuqi != this.goodsList.length) {
if (this.oldTemList.length == 0 && this.pageOldTemList.length == 0) {
this.newTemList = []
this.temporaryList = []
}
}
if (this.newTemList.length != 0 && jishuqi == this.goodsList.length) {
this.temporaryList = this.newTemList;
this.oldTemList = []
this.newTemList = []
}
setTimeout(res => {
uni.hideLoading();
}, 200)
},
obtainPrice(e,type,num){
console.log("获得焦点")
this.linshiPrice = e.target.value
if(type=='relPrice'){
this.relPrice = ''
}else if(type=='zhengti'){
this.discountNum = ''
}else if(type=='danzhe'){
console.log(this.carList)
console.log(num)
this.carList.get(num).discount = ''
this.$forceUpdate()
}else if(type=='zongjishu'){
this.allChangeNum = ''
}else{
this.priceOk = ''
}
},
//实收金额失去焦点
changessPrice(e) {
if(this.linshiPrice == e.target.value){
this.relPrice = e.target.value
}else{
if(e.target.value == ''){
this.relPrice = this.linshiPrice
}else{
this.relPrice = e.target.value
}
}
// this.relPrice = e.target.value
this.priceOk = this.relPrice
this.noPay = this.relPrice - this.priceOk;
},
changePrice(e) {
if(this.linshiPrice == e.target.value){
this.priceOk = e.target.value
}else if(Number(e.detail.value) > Number(this.relPrice)){
this.priceOk = this.relPrice
}else{
if(e.target.value == ''){
this.priceOk = this.linshiPrice
}else{
this.priceOk = e.target.value
}
}
// if (Number(e.detail.value) > Number(this.relPrice)) {
// } else {
// this.priceOk = e.detail.value
// }
this.$forceUpdate()
this.noPay = this.relPrice - this.priceOk;
this.noPay = this.noPay.toFixed(2)
},
getImg(key) {
return this.carList.get(key).productPicture
},
//获取客户拿货历史
getHistoryPrice(id, index) {
this.index = index
this.tui.request("/app/product/getByUserIdAndProductId", "POST", {
userId: this.khName.id,
productId: id
}, false, true).then((res1) => {
if (res1.code == 200) {
this.historyList = res1.result
this.$refs.historyPopup.open()
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//切换销售员
categoryChange(e) {
for (let i = 0; i < this.categoryList.length; i++) {
if (this.categoryList[i].value == e) {
this.xsyId = e;
this.createByName = this.categoryList[i].text
}
}
},
//切换销售员
payTypeChange(e) {
for (let i = 0; i < this.payTypeList.length; i++) {
if (this.payTypeList[i].value == e) {
this.payType = e;
}
}
},
//清空语音输入的文字
clearText() {
this.voiceText = ''
},
spliceMsg(res) {
let regex = /嗯|啊|儿|阿|恩/g;
return res.replace(regex, '')
},
convertChineseToArabic(str) {
const chineseNumToArabic = {
'零': 0,
'一': 1,
'二': 2,
'两': 2,
'三': 3,
'四': 4,
'五': 5,
'六': 6,
'七': 7,
'八': 8,
'九': 9,
'杠': '-',
'刚': '-',
'军色': '均色',
'叉': 'X',
'金色': '均色',
'井': '#',
'时间': '10件',
'事件': '10件',
'世间': '10件',
'实践': '10件',
'实件': '10件',
'景': '#',
'警': '#',
'颈': '#',
};
const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|金色|井|时间|事件|世间|实践|实件|景|警|颈)/g;
return str.replace(regex, match => chineseNumToArabic[match]);
},
//编辑挂单信息
setDetail(e) {
if(this.voiceText ==''){
this.tui.toast('识别内容不能为空')
return
}
let convertedStr = this.convertChineseToArabic(this.voiceText);
if (convertedStr.indexOf('点') != -1) {
convertedStr = this.replaceCharAfterNumber(convertedStr, '点', '.')
}
if (convertedStr.indexOf('货号,') != -1) {
convertedStr = convertedStr.replace(/货号,/g, '货号')
}
if (convertedStr.indexOf('货号') != -1) {
convertedStr = convertedStr.replace(/货号/g, '货号:')
}
if (convertedStr.indexOf(',数量') != -1) {
convertedStr = convertedStr.replace(/,数量/g, '数量')
}
if (convertedStr.indexOf('数量,') != -1) {
convertedStr = convertedStr.replace(/数量,/g, '数量')
}
if (convertedStr.indexOf('数量') != -1) {
convertedStr = convertedStr.replace(/数量/g, ',数量:')
}
convertedStr = this.convertStringCorrectly(convertedStr)
convertedStr = this.spliceMsg(convertedStr)
if(convertedStr.indexOf(',') == 0){
console.log('位置',convertedStr.indexOf(','))
convertedStr = convertedStr.substr(1)
}
this.getMsg = convertedStr
this.tui.request("/app/sale/buyAi", "POST", {
aiMsg: this.getMsg
}, false, true).then((res) => {
if (res.code == 200) {
this.voiceText = ''
this.$refs.popup.close()
this.aiNotRecognition = res.result.aiNotRecognition
if (this.isInventory == true) {
let newData = []
for (let i = 0; i < res.result.data.length; i++) {
let newList = []
// res.result.data[i].productCount = 0
for (let m = 0; m < res.result.data[i].stockLogList1.length; m++) {
if (res.result.data[i].stockLogList1[m].stockCount != null) {
newList.push(res.result.data[i].stockLogList1[m])
}
}
res.result.data[i].stockLogList1 = newList
if (newList.length > 0) {
newData.push(res.result.data[i])
}
}
this.carList1 = newData
} else {
this.carList1 = res.result.data
}
if (res.result.aiNotRecognition != '') {
this.$refs.AiNoPopup.open()
}
this.AiHandleData()
} else {
this.tui.toast("抱歉:小助手对" + this.getMsg + "的部分商品未识别,请检查识别信息是否正确")
}
}).catch((res) => {
this.tui.toast(res)
})
},
//扫一扫功能
scanCodeAdd() {
let that = this;
uni.setStorageSync('saoma', '1')
uni.scanCode({
success: (res) => {
if (res.scanType == "QR_CODE") { //二维码
let shopId = base.decode(res.result.split(',')[1])
if (shopId == uni.getStorageSync('shopId')) {
that.productId = base.decode(res.result.split(',')[0])
that.toggle('bottom', base.decode(res.result.split(',')[0]));
// if (item.saleDetailDTOList) {
// for (let i = 0; i < item.saleDetailDTOList.length; i++) {
// that.carList.push(item.saleDetailDTOList[i])
// }
// }
} else {
setTimeout(res => {
that.tui.toast('您的店铺中暂无该商品!')
}, 1000)
}
} else {
that.tui.request("/app/product/getByBarcode", "POST", {
barcode: base.decode(res.result)
}, false, true).then((res1) => {
if (res1.code == 200) {
if (res1.result == '') {
// setTimeout(res => {
that.tui.toast('您的店铺中暂无该商品!')
// }, 1000)
} else {
that.productId = res1.result[0].id
that.toggle('bottom', res1.result[0].id);
if (item.saleDetailDTOList) {
for (let i = 0; i < item.saleDetailDTOList.length; i++) {
that.carList.push(item.saleDetailDTOList[i])
}
}
}
} else {
that.tui.toast(res.message)
}
}).catch((res) => {
that.tui.toast(res)
})
}
},
fail: (res) => {
uni.showToast({
title: '扫描失败',
icon: 'none'
})
}
})
},
//弹出商品规格选择
toggle(type, id) {
this.type = type
if (type == 'bottom') {
this.allChangeNum = 0
this.getById(id);
uni.showLoading({
title: '加载中...'
})
} else {
this.initRecord();
this.voiceText = ''
this.$refs.popup.open(type)
}
},
//整体选择是批发价还是零售价
async priceChange(e, index) {
uni.showLoading({
title: '加载中...',
mask: true
})
let that = this;
this.priceType = e
that.priceCurrent = index
await this.carList.forEach(function(value, key) {
that.index = value.productId || value.id
if (e == '0') { //零售
value.discountAmount = value.lsprice
} else { //批发
value.discountAmount = value.wholesalePrice
}
})
await this.getAllPrice()
await this.getAmountAndWho()
await setTimeout(res => {
uni.hideLoading();
}, 500)
this.$forceUpdate()
},
//商品上选择是零售价还是批发价
checkPay(price) {
if (price == undefined || price == null) {
this.tui.toast("暂无拿货记录")
return
}
let that = this;
let num = this.carList.get(this.index)
num.discountAmount = price
num.unitPrice = price;
num.price = price * num.productCount;
this.$refs.inputDialog.close()
this.$refs.historyPopup.close()
// num.discountAmount = num.unitPrice * num.discount / 10
num.disNoAmount = num.discountAmount
num.price = num.unitPrice * num.discount / 10 * num.productCount
that.relPrice = that.shouldPay
that.priceOk = that.shouldPay
this.getAllPrice()
this.getAmountAndWho()
},
//整体选择时使用批发价、零售价,选择整体折扣的方法
getAmountAndWho() {
let that = this;
let price = 0
this.carList.forEach(function(value, key) {
if (value.disNoAmount > 0) {
price = value.disNoAmount
} else {
if (that.priceType == '') {
price = value.wholesalePrice
} else if (that.priceType == 0) { //零售
price = value.lsprice
} else if (that.priceType == 1) { //批发
price = value.wholesalePrice
}
}
value.unitPrice = price;
if (that.discountType == 1) { //整体折扣
value.discountAmount = value.unitPrice * (that.discountNum / 10)
value.discountAmount = value.discountAmount.toFixed(2)
value.price = value.discountAmount * value.productCount
value.price = value.price.toFixed(2)
} else if (that.discountType == 0) { //单品折扣
value.discountAmount = value.unitPrice * (value.discount / 10)
value.discountAmount = value.discountAmount.toFixed(2)
value.price = (value.unitPrice * (value.discount / 10)) * value.productCount
value.price = value.price.toFixed(2)
}
})
this.getAllPrice();
// if (this.relPrice == '' || this.relPrice == 0) {
// that.noPay = that.shouldPay
// } else if (this.relPrice != '' && this.priceOk != '') {
// that.noPay = this.relPrice - this.priceOk
// }
},
AiAddSpec(value) {
this.getById(value.productId || value.id);
},
//通过商品id查询商品详细信息
async getById(id) {
let that = this;
this.pageOldTemList = []
await this.tui.request("/app/product/getById/" + id, "POST", {}, false, true).then((res) => {
if (res.code == 200) {
if (res.result.delFlag == 0) {
that.tui.toast("请将商品上架后再操作!")
return
}
that.goodsDetail = res.result;
that.temporaryList = []
if (that.carList.size > 0) {
that.carList.forEach(function(value, key) {
value.stockLogList.forEach(function(values, keys) {
if (value.stockLogList1.length == 0) {
let obj = {
productCount: values.productCount,
name: values.name,
attributeList: keys,
productNum: values.productNum
}
value.stockLogList1.push(obj)
} else {
for (var i = 0; i < value.stockLogList1.length; i++) {
if (value.stockLogList1[i].attributeList != keys) {
if (value.stockLogList1.length == (i + 1)) {
let obj = {
productCount: values.productCount,
name: values.name,
attributeList: keys,
productNum: values.productNum
}
value.stockLogList1.push(obj)
}
}
}
}
})
})
that.zNum = 0
that.$nextTick(() => {
that.carList.forEach(function(value, key) {
if (value.productId == id) {
that.zNum = value.productCount
that.temporaryList = value.stockLogList1
that.pageOldTemList = value.stockLogList1
that.oldTemList = value.stockLogList1
}
value.stockLogList1 = []
})
})
}
that.$nextTick(() => {
console.log('temporaryList', that.temporaryList)
console.log('pageOldTemList', that.pageOldTemList)
})
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", {
categoryId: this.goodsDetail.categoryId
}, false, true).then((res1) => {
if (res1.code == 200) {
this.goodsList = []
this.$refs.shopPopup.open('bottom')
if (typeof(res1.result) == 'string') {
let newObj = JSON.parse(res1.result)
let newArr = []
let dataArr = []
for (let val in newObj) {
let valueObj = [];
for (var i = 0; i < newObj[val].length; i++) {
valueObj.push({
value: newObj[val][i],
isChecked: false
})
this.dataObj.set(newObj[val][i], val)
}
newArr.push({
name: val,
value: valueObj
})
}
this.goodsDetail.attributeList = newArr;
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) {
let oldCheck = false
let oldValue = []
for (var m = 0; m < this.goodsDetail.attributeList[i].value
.length; m++) {
if (this.goodsDetail.attributeList[i].value[m].isChecked ==
true) {
oldCheck = true
oldValue.push(this.goodsDetail.attributeList[i].value[
m].value)
}
}
let specs1 = {
specs: []
}
this.goodsList.push(specs1)
oldCheck = false
oldValue = []
}
} else {
this.tui.toast('失败了')
}
} else {
this.tui.toast(res1.message)
}
}).catch((res) => {})
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
this.getKCList(id);
},
//库存商品详情
getKCList(id) {
this.yanseList = new Map()
this.chimaList = new Map()
this.tui.request("/app/stock/productCount", "GET", {
productId: id
}, false, true).then((res) => {
if (res.code == 200) {
this.pecsList = res.result
for (let i = 0; i < res.result.length; i++) {
let attributeList = JSON.parse(res.result[i].attributeList)
Object.keys(attributeList).forEach(key => {
if (key == '颜色') {
if (this.yanseList.has(attributeList[key]) != true) {
this.yanseList.set(attributeList[key], attributeList[key])
}
} else {
if (this.chimaList.has(attributeList[key]) != true) {
this.chimaList.set(attributeList[key], attributeList[key])
}
}
})
}
for (let i = 0; i < this.goodsDetail.attributeList[0].value.length; i++) { //颜色
if (this.yanseList.has(this.goodsDetail.attributeList[0].value[i].value) == true) {
this.goodsDetail.attributeList[0].value[i].isKucun = true
}
}
for (let i = 0; i < this.goodsDetail.attributeList[1].value.length; i++) { //尺码
if (this.chimaList.has(this.goodsDetail.attributeList[1].value[i].value) == true) {
this.goodsDetail.attributeList[1].value[i].isKucun = true
}
}
console.log('颜色', this.yanseList)
console.log('尺码', this.chimaList)
console.log('颜色', this.goodsDetail)
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
setTimeout(res => {
uni.hideLoading();
}, 200)
},
temporaryChange(val, item) {
if (item != '' && item != undefined) {
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (item.attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = item.productCount
break;
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (item.attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = item.productCount
break;
}
}
}
this.zNum = 0
for (var i = 0; i < this.temporaryList.length; i++) {
this.zNum += this.temporaryList[i].productCount
}
},
//折扣种类选择
discountChange(e) {
let that = this;
that.shouldPay = 0
this.discountType = e.detail.value;
this.carList.forEach(function(value, key) {
value.price = value.productCount * value.unitPrice //总价
value.discount = 10 //折扣
value.discountAmount = value.unitPrice
that.shouldPay += value.price
})
this.price = this.shouldPay
this.relPrice = this.shouldPay
this.priceOk = this.shouldPay
// if(this.priceOk != ''){
// this.priceOk = this.relPrice
// }
this.$forceUpdate()
this.discountNum = 10
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
this.discountCurrent = i;
break;
}
}
this.getAllPrice()
this.getAmountAndWho()
},
changeRemark(e) {
this.remark = e.detail.value
},
changePbAddress(e) {
this.pbAddress = e.detail.value
},
//整体折扣数字框改变
change(e) {
uni.showLoading({
title: '加载中...'
})
if(this.linshiPrice == e.target.value){
this.relPrice = e.target.value
}else{
if (e.detail.value > 10) {
this.discountNum = 10
} else if (e.detail.value < 0) {
this.discountNum = 0
} else if(e.target.value == ''){
this.discountNum = this.linshiPrice
}else{
this.discountNum = e.target.value
}
}
this.getAmountAndWho()
setTimeout(res => {
uni.hideLoading();
}, 200)
},
//点击发货方式按钮
radioChange(e) {
this.gysName = ''
this.wlName = ''
this.kdyName = ''
this.lbgName = ''
this.radioType = e.detail.value;
for (let i = 0; i < this.logisticsType.length; i++) {
if (this.logisticsType[i].value === e.detail.value) {
this.current = i;
break;
}
}
},
//发货方式选择
goPopleList(popleType) {
if (popleType == 'kdyName' && this.wlName == '') {
uni.showToast({
title: "先选择快递公司",
icon: 'error'
})
return
}
if ((popleType == 'wlName' || popleType == 'fcName') && this.khName == '') {
uni.showToast({
title: "先选择客户",
icon: 'error'
})
return
}
let companyType = this.radioType == 1 ? this.wlName.id : ''
console.log(this.khName)
uni.navigateTo({
url: '/package1/index/peopleList?popleType=' + popleType + '&companyType=' + companyType +
'&khName=' + JSON.stringify(this.khName)
})
},
clickClose(){
this.evalue = []
this.allChangeNum = 0
},
//弹窗选择规格后,点击弹窗中选好了按钮
temporaryCheck() {
uni.showLoading({
title: '加载中...'
})
this.evalue = []
let that = this,
carList1 = []
let data = {
id: this.goodsDetail.id,
price: this.zPrice,
num: this.zNum,
categoryId: this.goodsDetail.categoryId,
productName: this.goodsDetail.productName,
productSn: this.goodsDetail.productSn,
productPicture: this.goodsDetail.productPicture,
supplierName: this.goodsDetail.supplierName,
saleDetailQueryDTO: this.temporaryList,
wholesalePrice: this.goodsDetail.wholesalePrice,
lsprice: this.goodsDetail.price
}
carList1.push(data)
this.temporaryList = []
this.purchasePrice = ''
this.zPrice = ''
this.zNum = ''
for (let i = 0; i < this.goodsDetail.attributeList.length; i++) {
this.goodsDetail.attributeList[i].isChecked = false;
for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
if (this.carList.size == 0) { //当前页没有数据
for (let i = 0; i < carList1.length; i++) {
let obj = {
purchasePrice: carList1[i].price, //采购价
price: 0, //总价
discount: 10, //折扣
unitPrice: 0, //单价
categoryId: carList1[i].categoryId,
discountAmount: carList1[i].wholesalePrice || 0, //折后价
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: carList1[i].wholesalePrice, //批发价
lsprice: carList1[i].lsprice, //零售价
productCount: 0, //总数量
productId: carList1[i].id,
productName: carList1[i].productName,
productPicture: carList1[i].productPicture,
productSn: carList1[i].productSn,
stockLogList: new Map(),
stockLogList1: [],
supplierName: carList1[i].supplierName //供应商
}
for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) {
var data1 = {
productCount: carList1[i].saleDetailQueryDTO[m].productCount,
name: carList1[i].saleDetailQueryDTO[m].name,
productNum: carList1[i].saleDetailQueryDTO[m].productNum
}
obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1)
obj.productCount += carList1[i].saleDetailQueryDTO[m].productCount
}
this.carList.set(carList1[i].id, obj)
}
carList1 = []
} else { //当前页有数据
for (let i = 0; i < carList1.length; i++) {
if (this.carList.has(carList1[i].id) == true) {
this.carList.get(carList1[i].id).stockLogList = new Map()
}
if (this.carList.has(carList1[i].id) == true) { //商品相同
this.carList.get(carList1[i].id).productCount = 0
for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) {
if (this.carList.get(carList1[i].id).stockLogList.has(carList1[i]
.saleDetailQueryDTO[
m].attributeList) == true) { //规格相同
var data1 = {
productCount: carList1[i].saleDetailQueryDTO[m].productCount,
name: carList1[i].saleDetailQueryDTO[m].name,
productNum: carList1[i].saleDetailQueryDTO[m].productNum
}
this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[
m].attributeList, data1)
} else { //规格不同
var data1 = {
productCount: carList1[i].saleDetailQueryDTO[m].productCount,
name: carList1[i].saleDetailQueryDTO[m].name,
productNum: carList1[i].saleDetailQueryDTO[m].productNum
}
this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[
m].attributeList, data1)
}
this.carList.get(carList1[i].id).productCount += carList1[i].saleDetailQueryDTO[
m].productCount
that.carList.get(carList1[i].id).price = that.carList.get(carList1[i].id).productCount *
that.carList.get(carList1[i].id).purchasePrice
}
} else { //商品不同
let obj = {
purchasePrice: carList1[i].price, //采购价
price: 0,
discount: 10,
discountAmount: carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
unitPrice: 0, //单价
categoryId: carList1[i].categoryId,
wholesalePrice: carList1[i].wholesalePrice, //批发价
lsprice: carList1[i].lsprice, //零售价
productCount: 0,
productId: carList1[i].id,
productName: carList1[i].productName,
productPicture: carList1[i].productPicture,
stockLogList: new Map(),
stockLogList1: [],
productSn: carList1[i].productSn,
supplierName: carList1[i].supplierName
}
for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) {
var data1 = {
productCount: carList1[i].saleDetailQueryDTO[m].productCount,
name: carList1[i].saleDetailQueryDTO[m].name,
productNum: carList1[i].saleDetailQueryDTO[m].productNum
}
obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1)
obj.productCount += carList1[i].saleDetailQueryDTO[m].productCount
}
this.carList.set(carList1[i].id, obj)
}
}
carList1 = []
}
this.carList.forEach(function(value, key) {
if (that.priceType == 0) { //零售
value.unitPrice = value.lsprice
} else if (that.priceType == 1) { //批发
value.unitPrice = value.wholesalePrice
}
if (that.discountType == 1) { //整体折扣
value.price = value.unitPrice * 10000 * value.productCount * that.discountNum / 10 / 10000
}
})
this.getAllPrice()
this.getAmountAndWho();
this.noPay = this.shouldPay
this.$refs.shopPopup.close()
setTimeout(res => {
uni.hideLoading();
}, 1000)
},
//是否平台取货
checkBoxChange(e) {
this.radioType1 = e
},
//点击加号手动添加商品
goodsAdd() {
uni.navigateTo({
url: '/pages/billing/changeGoods1'
})
},
//关闭弹出层
close() {
this.$refs.popup.close()
},
//按住语音识别,开始
kaishi() {
// manager.stop()
if(this.isVoice == false){
this.recordState = true
uni.vibrateShort();
manager.start({
duration: 60000,
lang: "zh_CN"
});
}
},
//松开语音识别,结束
jieshu() {
// uni.showLoading({
// title: '识别中...',
// mask:true
// })
manager.stop()
this.recordState = false
},
replaceCharAfterNumber(str, charToFind, charToReplace) {
// 正则表达式匹配字符前是否有数字,并且该字符与charToFind相同
const regex = new RegExp(`\\d${charToFind}`, 'g');
// 使用replace方法进行替换
return str.replace(regex, (match) => {
// 将匹配到的字符中的指定字符替换为charToReplace
return match.replace(charToFind, charToReplace);
});
},
//语音识别功能初始化
initRecord() {
let that = this;
// 识别结束事件
manager.onStop = (res) => {
let convertedStr = this.spliceMsg(this.convertChineseToArabic(res.result));
convertedStr = this.convertStringCorrectly(convertedStr)
if (convertedStr.indexOf('点') != -1) {
convertedStr = that.replaceCharAfterNumber(convertedStr, '点', '.')
}
if (convertedStr.indexOf('货号,') != -1) {
convertedStr = convertedStr.replace(/货号,/g, '货号')
}
if (convertedStr.indexOf('货号') != -1) {
convertedStr = convertedStr.replace(/货号/g, '货号:')
}
if (convertedStr.indexOf(',数量') != -1) {
convertedStr = convertedStr.replace(/,数量/g, '数量')
}
if (convertedStr.indexOf('数量,') != -1) {
convertedStr = convertedStr.replace(/数量,/g, '数量')
}
if (convertedStr.indexOf('数量') != -1) {
convertedStr = convertedStr.replace(/数量/g, ',数量:')
}
if(convertedStr.indexOf(',') == 0){
convertedStr = convertedStr.substr(1)
}
if (that.voiceText == '' || that.voiceText == null) {
that.voiceText = convertedStr
} else {
that.voiceText += '\n' + convertedStr
}
// uni.hideLoading()
}
// 识别错误事件
manager.onError = (res) => {
console.log('报错',res)
if(res.retcode == '-30011'){
that.isVoice = true
}
if(res.retcode == '-30004'){
// uni.hideLoading()
that.isVoice = false
uni.hideToast()
uni.showToast({
title: "未识别到声音信息,请重新录入",
icon: 'none'
})
}
if (res.retcode == '-40001') {
uni.showToast({
title: '使用次数超限制,请联系管理员!',
icon: 'none'
})
}
}
},
showPrice() {
if (this.khName == '') {
this.tui.toast('请选择客户!')
return
}
if (this.xsyId == '') {
this.tui.toast('请选择销售员!')
return
}
// if (this.shouldPay == 0) {
// this.tui.toast('请维护商品金额!')
// return
// }
// if (this.relPrice == (0 || '')) {
// this.tui.toast('请输入实收金额!')
// return
// } else if (this.priceOk == (0 || '')) {
// this.tui.toast('请输入已收金额!')
// return
// }
if (this.carList.size == 0) {
this.tui.toast('请添加商品!')
return
}
if (this.radioType != '') {
if (this.radioType == 0 || this.radioType == 1 || this.radioType == 4 || this.radioType == 5) {
if (this.wlName == '') {
this.tui.toast('请选择配送公司!')
return
}
} else if (this.radioType == 3) {
if (this.pbAddress == '') {
this.tui.toast('请输入拼包地址!')
return
}
}
} else {
this.tui.toast('请选择发货方式!')
return
}
this.$refs.showPopup.open()
},
//点击底部开单按钮
goSell(print) {
let that = this;
uni.showLoading({
title: '加载中...'
})
this.$refs.showPopup.close()
let obj = {
orderByWorker: this.lbgName.workerId || this.kdyName.workerId,
oldSaleId: this.saleId || '',
sale: {
// relPrice:,
alreadyEarn: this.priceOk, //已付金额
realAmount: this.relPrice, //实收金额
noEarn: this.relPrice - this.priceOk, //欠款
totalAmount: this.shouldPay, //总金额
area: this.khName.area,
city: this.khName.city,
province: this.khName.province,
payStatus: 1,
payType:this.payType,
receiveAddress: this.khName.address || this.khName.receiveAddress,
userId: this.khName.id,
userName: this.khName.name,
transportType: this.radioType1 == 1 ? 2 : this.radioType, //this.radioType
modeOfService: this.radioType1,
discount: this.discountNum,
createBy: this.xsyId,
createByName: this.createByName,
remark: this.remark,
otherExpense: this.otherExpense == '' ? 0 : this.otherExpense, //其他费用
shareAddress: this.pbAddress,
transCompany: this.wlName.shippingMethodId || this.wlName.id,
companyName: this.wlName.shippingMethod || this.wlName.companyName,
companyPhone: this.wlName.mobile
},
saleDetailList: []
}
let purchaseDetails = [];
this.carList.forEach(function(value, key) {
value.stockLogList.forEach(function(values, keys) {
if (values <= 0) {
that.tui.toast("商品数量不能为零!")
return;
}
let obj = {
productCount: values.productCount,
attributeList: keys
}
value.stockLogList1.push(obj)
})
purchaseDetails.push(value)
})
this.saleDetailList = purchaseDetails;
obj.saleDetailList = purchaseDetails;
let url = ''
if (this.saleId != '') {
url = '/app/sale/shareToBuyNew'
} else {
url = '/app/sale/buyNew'
}
this.tui.request(url, "post", obj, false, false).then((res) => {
if (res.code == 200) {
uni.showToast({
title: "开单成功",
icon: 'none'
})
if (print != 'print') {
setTimeout(res => {
this.$refs.showPopup.close()
that.clearAll1()
uni.switchTab({
url: '/pages/index/index'
});
}, 1000)
}
} else {
this.tui.toast(res.message)
}
})
setTimeout(res => {
uni.hideLoading();
}, 1000)
},
//打印取消按钮
// printChenel() {
// that.clearAll()
// uni.switchTab({
// url: '/pages/index/index'
// });
// },
//打印小票
onPrint(opt) {
let that = this;
this.goSell('print')
let strCmd = ''
that.yNum = 150
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLSETMAG(2, 2)
blesdk.addCPCLSETBOLD('bold')
strCmd += blesdk.addCPCLLocation(2);
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, uni.getStorageSync('shopName'))
strCmd += blesdk.addCPCLSETMAG(1, 1)
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', '100', '24', '0', 0, '客户:' + this.khName.name)
// strCmd += blesdk.addCPCLText('280', '100', '24', '0', 0, this.sales.id)
strCmd += blesdk.addCPCLText('0', '130', '24', '0', 0, '销售:' + this.createByName)
strCmd += blesdk.addCPCLText('280', '130', '24', '0', 0, '日期:' + this.formatDate(new Date(),
'YYYY-MM-DD')) //+
strCmd += blesdk.addCPCLText('0', '150', '24', '0', 0,
'=========================================================')
this.carList.forEach(function(value, key) {
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, value.productName + '(' +
value.productSn + ')')
} else {
that.yNum = 0
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, value.productName +
'(' +
value.productSn + ')')
}
value.stockLogList.forEach(function(value1, key1) {
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, '□ ' + (that
.slicePrint(
key1)) + '*' + value1.productCount)
strCmd += blesdk.addCPCLText('240', that.yNum, '24', '0', 0, '单价:' + value
.discountAmount)
strCmd += blesdk.addCPCLText('400', that.yNum, '24', '0', 0, '总价:' + (value
.discountAmount * value1.productCount))
} else {
that.yNum = 0
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '□ ' + (that
.slicePrint(key1)) + '*' + value1.productCount)
strCmd += blesdk.addCPCLText('240', that.yNum, '24', '0', 0, '单价:' + value
.discountAmount)
strCmd += blesdk.addCPCLText('400', that.yNum, '24', '0', 0, '总价:' + (value
.discountAmount * value1.productCount))
}
})
})
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0,
'===============================================================')
} else {
this.yNum = 0
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0,
'===============================================================')
}
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '总数量:' + this.totalAmount)
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '总金额:' + this.shouldPay)
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '应收:' + this.relPrice)
} else {
this.yNum = 0
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', (this.yNum += 30), '24', '0', 0, '总数量:' + this.totalAmount)
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '总金额:' + this.shouldPay)
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '应收:' + this.relPrice)
}
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '实收:' + this.priceOk)
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '欠款:' + (this.relPrice - this.priceOk)
.toFixed(2))
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '其他费用:' + (this.otherExpense == '' ? 0 :
this.otherExpense))
} else {
this.yNum = 0
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', (this.yNum += 30), '24', '0', 0, '实收:' + this.priceOk)
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '欠款:' + (this.relPrice - this.priceOk)
.toFixed(2))
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '其他费用:' + (this.otherExpense == '' ? 0 :
this.otherExpense))
}
if (Math.ceil(Number(this.remark.length) / 20) * 30 + this.yNum < that.printTotal) {
if (this.remark.length > 20) {
let position = 20;
let part1 = this.remark.substring(0, position);
let part2 = this.remark.substring(position);
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + part1)
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, part2)
} else {
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + this.remark)
}
} else {
this.yNum = 0
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
strCmd = ''
if (this.remark.length > 20) {
let position = 20;
let part1 = this.remark.substring(0, position);
let part2 = this.remark.substring(position);
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + part1)
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, part2)
} else {
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + this.remark)
}
}
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0,
'===============================================================')
} else {
this.yNum = 0
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0,
'===============================================================')
}
//店铺地址
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '店铺地址:' + uni.getStorageSync(
'shopAddress'))
} else {
this.yNum = 0
strCmd += blesdk.addCPCLPrint();
this.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '店铺地址:' + uni.getStorageSync(
'shopAddress'))
}
//店铺电话
if (that.countPrint() < that.printTotal) {
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + uni.getStorageSync(
'username'))
} else {
that.yNum = 0
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '店铺电话:' + uni.getStorageSync(
'username'))
}
if(this.qrArr.length != 0){
//店铺微信/微信收款/支付宝收款/收款码收款(店铺,微信,支付,收款)
for (let i = 0; i < this.qrArr.length; i++) {
//店铺二维码
console.log(that.qrArr[i])
console.log(that.yNum)
console.log(that.countWidth(i,600/that.qrArr.length))
if ((that.yNum + 200) < that.printTotal) {
console.log('11111')
strCmd += blesdk.addCPCLQRCode(that.countWidth(i,600/that.qrArr.length), (that.yNum + 50), that.qrArr[i].level, '2', 3, that.qrArr[i].path) //二维码
strCmd += blesdk.addCPCLText(that.countWidth(i,600/that.qrArr.length), (that.yNum + 180), '24', '0', 0, that.qrArr[i].name)
strCmd += blesdk.addCPCLLocation(0);
if(this.qrArr.length == (i+1)){
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
} else {
console.log('2222')
// that.yNum = 0
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
strCmd = ''
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0);
strCmd += blesdk.addCPCLLocation(0);
strCmd += blesdk.addCPCLQRCode(that.countWidth(i,600/that.qrArr.length) , 30, that.qrArr[i].level, '2', 3, that.qrArr[i].path) //二维码
strCmd += blesdk.addCPCLText(that.countWidth(i,600/that.qrArr.length), 180, '24', '0', 0, that.qrArr[i].name)
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
}
}else{
strCmd += blesdk.addCPCLPrint();
that.bufferData.push(strCmd);
}
uni.hideLoading();
this.$nextTick(() => {
console.log('bufferData',that.bufferData)
that.$refs.showPopup.close()
that.bufferData = []
that.clearAll1()
uni.switchTab({
url: '/pages/index/index'
});
})
},
countWidth(num,len){
// if(num == 0){
// return num*len + 50
// }else{
return num*len + 20
// }
},
//计算打印机当前行高度
countPrint() {
if ((this.yNum + 50) >= 1040) {
return this.yNum += 50
} else {
return this.yNum += 30
}
},
//截取
slicePrint(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + '/'
}
}
return name;
},
formatDate(date, fmt) {
var o = {
'M+': date.getMonth() + 1, //月份
'D+': date.getDate(), //日
'H+': date.getHours(), //小时
'm+': date.getMinutes(), //分
's+': date.getSeconds(), //秒
'q+': Math.floor((date.getMonth() + 3) / 3), //季度
'S': date.getMilliseconds() //毫秒
};
if (/(Y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp('(' + k + ')').test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k])
.length)));
return fmt;
},
//编辑每一个的单价
clickPrice(index) {
this.index = index
this.wholesalePrice = this.carList.get(this.index).wholesalePrice
this.lsprice = this.carList.get(this.index).lsprice
this.$refs.inputDialog.open()
},
//输入商品自定义金额
changePay(e) {
this.customPrice = e.detail.value
},
//更改单品折扣
changeDis(e, id) {
let that = this;
let carlist = this.carList.get(id)
if(this.linshiPrice == e.target.value){
carlist.discount = e.target.value
}else{
if (e.detail.value > 10) {
carlist.discount = 10;
} else if (e.detail.value < 0) {
carlist.discount = 0;
} else if(e.detail.value == ''){
carlist.discount = this.linshiPrice
}else{
carlist.discount = e.detail.value;
}
}
carlist.discountAmount = carlist.unitPrice * carlist.discount / 10
carlist.discountAmount = carlist.discountAmount.toFixed(2)
carlist.price = carlist.unitPrice * (carlist.discount / 10) * carlist.productCount
carlist.price = carlist.price.toFixed(2)
this.getAllPrice()
},
//选商品的时候能删除规格
delCarData(index) {
this.temporaryList.splice(index, 1);
this.temporaryChange()
},
//删除整条商品
delShop(id) {
var that = this;
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
uni.showLoading({
title: '加载中...'
})
if (res.confirm) {
if (that.carList.has(id) == true) {
that.carList.delete(id)
}
that.$forceUpdate()
that.getAllPrice()
that.getAmountAndWho()
}
setTimeout(res => {
uni.hideLoading();
}, 500)
}
})
},
//删除商品下的某一个规格
delShopSpec(id, name) {
var that = this;
uni.showModal({
title: "提示",
content: "确定删除此条规格吗?",
success: function(res) {
if (res.confirm) {
that.carList.get(id).productCount -= that.carList.get(id).stockLogList.get(name)
.productCount;
that.carList.get(id).stockLogList.delete(name);
that.carList.get(id).price = that.carList.get(id).productCount * that.carList.get(
id).unitPrice
if (that.carList.get(id).stockLogList.size == 0) {
that.carList.delete(id)
}
that.getAllPrice()
that.getAmountAndWho()
}
that.$forceUpdate()
}
})
},
//计算总金额和总数量
getAllPrice() {
let that = this;
this.shouldPay = 0
this.totalAmount = 0
this.carList.forEach(function(value, key) {
that.shouldPay = Number(that.shouldPay) + Number(value.price)
that.totalAmount = that.totalAmount + value.productCount
})
that.shouldPay = that.shouldPay.toFixed(2)
this.relPrice = this.shouldPay
this.priceOk = this.shouldPay
this.$forceUpdate()
that.noPay = this.relPrice - (this.priceOk == '' ? 0 : this.priceOk)
that.noPay = that.noPay.toFixed(2)
},
//修改已选规格的数量
GoodsNumChange(e, index, index1) {
let that = this;
this.carList.get(index[0]).stockLogList.get(index1).productCount = e
this.carList.get(index[0]).productCount = 0
this.carList.get(index[0]).stockLogList.forEach(function(value, key) {
that.carList.get(index[0]).productCount = that.carList.get(index[0]).productCount + value
.productCount
if (that.discountType == 0) { //单品折扣
// that.carList.get(index[0]).price = that.carList.get(index[0]).productCount * (that.carList.get(
// index[0]).discountAmount * (that.carList.get(index[0]).discount / 10))
// that.carList.get(index[0]).price = that.carList.get(index[0]).price.toFixed(2)
// console.log(that.carList.get(index[0]).price)
} else {
that.carList.get(index[0]).price = that.carList.get(index[0]).productCount * that.carList
.get(index[0]).unitPrice
}
})
that.getAllPrice()
that.getAmountAndWho();
},
clearAll1() {
let that = this;
that.carList.clear()
that.remark = ''
that.index = ''
that.priceCurrent = ''
that.current = 4
that.radioType = '2'
that.discountType = ''
that.pbAddress = ''
that.discountCurrent = ''
that.temporaryList = []
that.purchasePrice = 0
that.zPrice = 0
that.zNum = 0
that.shouldPay = 0
that.khName = []
that.gysName = []
that.wlName = []
that.kdyName = []
that.lbgName = []
that.relPrice = 0
that.priceOk = 0
that.noPay = 0
that.otherExpense = 0
that.totalAmount = 0
that.saleId = ''
that.$forceUpdate()
},
//清空全部数据
clearAll() {
let that = this;
uni.showModal({
title: "提示",
content: "确定清空全部已选商品吗?",
success: function(res) {
uni.showLoading({
title: '加载中...'
})
if (res.confirm) {
console.log(that.priceCurrent)
that.carList.clear()
that.remark = ''
that.index = ''
that.pbAddress = ''
that.priceType = ''
that.current = null
that.discountType = ''
that.discountCurrent = null
that.temporaryList = []
that.purchasePrice = 0
that.zPrice = 0
that.zNum = 0
that.shouldPay = 0
that.khName = []
that.gysName = []
that.wlName = []
that.kdyName = []
that.lbgName = []
that.relPrice = 0
that.priceOk = 0
that.noPay = 0
that.otherExpense = 0
that.totalAmount = 0
that.saleId = ''
that.priceCurrent = null
that.$forceUpdate()
}
setTimeout(res => {
uni.hideLoading();
}, 500)
}
})
}
}
}
</script>
<style lang="scss">
page,
.page1 {
height: 1280rpx;
overflow-y: scroll;
min-height: 100vh;
}
.popup-pay-content {
align-items: center;
justify-content: center;
padding: 15px;
width: 500rpx;
height: auto;
background-color: #fff;
}
.content {
border-top: 1px solid #eee;
}
.content-box {
width: 100%;
height: auto;
background: #fff;
margin-bottom: 20rpx;
}
.popup-pay-title {
font-size: 36rpx;
font-weight: bold;
text-align: center;
position: relative;
}
.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;
}
.content-list {
width: 95%;
margin: 0 auto;
display: flex;
height: 80rpx;
border-bottom: 1px solid #eee;
}
.content-list:last-child {
border-bottom: none;
height: auto;
}
.list-name {
width: 200rpx;
text-align: left;
line-height: 40px;
height: 80rpx;
padding-left: 20rpx;
}
.list-val {
width: 560rpx;
height: 80rpx;
line-height: 80rpx;
}
.list-val input {
width: 400rpx;
height: 60rpx;
display: inline-block;
line-height: 60rpx;
float: left;
margin-top: 10rpx;
padding-left: 20rpx;
border-bottom: 1px solid #088FEB;
}
.uni-data-select {
width: 80%;
text-align: center;
}
.uni-select {
border: none !important;
border-radius: 0 !important;
}
.uni-select__input-placeholder {
color: #6a6a6a;
font-size: 28rpx !important;
width: 400rpx;
}
.uni-select__input-box {
.uni-icons {
margin-left: 50rpx;
margin-right: 5px;
}
}
.shop-box {
width: 95%;
margin: 0 auto;
}
.shop-name {
width: 100%;
height: 200rpx;
line-height: 80rpx;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
font-size: 28rpx;
font-weight: bold;
display: flex;
}
.discount-num {
width: 160rpx;
}
.shop-productName {
flex: 1;
display: flex;
flex-direction: column;
padding-left: 20rpx;
}
.shop-productName view {
height: 55rpx;
}
.checklist-group {
height: 80rpx !important;
}
.shop-collapse {
display: flex;
height: 80rpx;
font-size: 26rpx;
line-height: 80rpx;
}
.shop-collapse text {
width: 60%;
text-align: center;
border-right: 1px solid #eee;
}
.shop-collapse-item {
display: flex;
text-align: center;
background: #eee;
height: 110rpx;
.input {
border: 1px solid #eee;
background: #fff;
height: 60rpx;
}
}
.price-box-title {
width: 95%;
height: 80rpx;
line-height: 80rpx;
margin: 0 auto;
display: flex;
text-align: center;
border-bottom: 1px solid #eee;
}
.price-box-title text {
flex: 1;
}
.uni-list-cell {
margin-right: 110rpx;
display: flex;
float: left;
}
.bottom-box {
width: 100%;
position: fixed;
bottom: 0rpx;
display: flex;
background: #fff;
border-top: 1px solid #eee;
height: 110rpx;
z-index: 98;
}
.bottom-left {
flex: 1;
height: 110rpx;
line-height: 110rpx;
font-size: 26rpx;
}
.notice {
width: 100%;
height: 56rpx;
}
.bottom-right {
width: 50%;
display: flex;
.bottom-btn {
margin: 0;
padding: 0;
width: 45%;
line-height: 35px;
height: 70rpx;
text-align: center;
margin-top: 10rpx;
color: #fff;
font-size: 28rpx;
border-radius: 0;
}
.bottom-btn:first-child {
background: linear-gradient(90deg, #FF9797, #FFC1E0);
border-top-left-radius: 70rpx;
border-bottom-left-radius: 70rpx;
margin-left: 20rpx;
}
.bottom-btn:last-child {
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-top-right-radius: 70rpx;
border-bottom-right-radius: 70rpx;
}
}
.bottom-left text {
line-height: 84rpx;
display: inline-block;
padding-left: 20rpx;
}
.bottom-btn {
width: 320rpx;
background: linear-gradient(90deg, #60F3FF, #088FEB);
color: #fff;
border-radius: 50rpx;
height: 85rpx;
margin-top: 15rpx;
}
textarea {
margin: 20rpx;
border: 1px solid #eee;
height: 150rpx;
width: 500rpx;
}
.shop-popup-content {
align-items: center;
justify-content: center;
padding: 15px;
height: 1100rpx;
background-color: #fff;
margin-bottom: 30rpx;
overflow: scroll;
}
.shop-popup-title {
display: flex;
height: 180rpx;
border-bottom: 1px solid #eee;
margin-top: 20rpx;
}
.shop-popup-title-left {
width: 150rpx;
height: 150rpx;
}
.shop-popup-title-left img {
width: 150rpx;
height: 150rpx;
}
.shop-popup-title-right {
width: 400rpx;
margin-left: 30rpx;
}
.shop-popup-title-right-box {
height: 50rpx;
line-height: 50rpx;
}
.shop-popup-container {
width: 100%;
background: #fff;
height: 50rpx;
}
.shop-title-fur {
width: 95%;
height: 50rpx;
margin: 0 auto;
}
.shop-title-name {
font-size: 30rpx;
width: 50%;
float: left;
height: 50rpx;
line-height: 70rpx;
}
.shop-attrs {
.suibian {
display: inline-block;
border: 1px solid #5fd9ee;
margin: 20rpx;
margin-bottom: 0;
margin-left: 0;
background-color: #fff;
color: #5fd9ee;
padding: 0 10px;
min-width: 100rpx;
line-height: 35px;
height: 70rpx;
text-align: center;
border-radius: 20rpx;
}
.checkedText {
background-color: #5fd9ee;
color: #fff;
border-radius: 20rpx;
}
}
.shop-checkList {
display: flex;
height: 50rpx;
font-size: 28rpx;
line-height: 50rpx;
margin: 20rpx 0;
}
.shop-checkList-box {
height: 50rpx;
width: 60%;
}
.popup-content {
align-items: center;
justify-content: center;
padding: 15px;
width: 500rpx;
height: 500rpx;
background-color: #fff;
}
.popup-title {
font-size: 36rpx;
font-weight: bold;
text-align: center;
position: relative;
}
.popup-container {
margin-top: 20rpx;
margin-top: 20rpx;
font-size: 32rpx;
}
.popup-bottom {
height: 80rpx;
color: #fff;
line-height: 80rpx;
margin-top: 50rpx;
}
.popup-btn {
text-align: center;
background: linear-gradient(90deg, #60F3FF, #088FEB);
}
.shop-popup-bottom {
width: 95%;
height: 100rpx;
position: fixed;
bottom: 0;
left: 2.5%;
display: flex;
z-index: 99;
background: #fff;
}
.shop-popup-bottom-left {
width: 50%;
line-height: 80rpx;
}
.shop-popup-bottom-right {
width: 50%;
line-height: 100rpx;
.bottom-btn {
width: 70%;
line-height: 35px;
height: 70rpx;
text-align: center;
color: #fff;
font-size: 28rpx;
margin: 0 auto;
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-radius: 70rpx;
}
}
.uni-numbox {
input {
padding-left: 0;
}
}
.noPic {
border-radius: 10px;
width: 140rpx;
height: 140rpx;
margin: 30rpx 0 0 30rpx;
text-align: center;
line-height: 140rpx;
color: #777;
background: #eee;
}
.list-val {
.uni-data-select {
text-align: left;
}
.uni-select__input-text {
padding-left: 120rpx;
}
.uni-select__selector {
position: absolute;
left: 0;
top: -240rpx
}
.uni-popper__arrow {
display: none;
}
.uni-select__selector-item text {
display: inline-block;
text-align: center;
}
}
.voice-popup-content {
align-items: center;
justify-content: center;
padding: 15px;
width: 500rpx;
border-radius: 10px;
height: 600rpx;
background-color: #fff;
}
.voice-popup-title {
font-size: 36rpx;
font-weight: bold;
text-align: center;
position: relative;
}
.voice-popup-container {
margin-top: 20rpx;
}
.voice-popup-bottom {
display: flex;
height: 80rpx;
color: #fff;
line-height: 80rpx;
margin-top: 30rpx;
}
.voice-popup-btn {
flex: 1;
text-align: center;
background: linear-gradient(90deg, #FF9797, #FFC1E0);
}
.voice-popup-btn:last-child {
background: linear-gradient(90deg, #60F3FF, #088FEB);
}
.voice-model {
width: 300rpx;
height: 300rpx;
display: flex;
justify-content: center;
flex-flow: column;
position: fixed;
top: 50%;
left: 50%;
background: rgba(0, 0, 0, 0.5);
border-radius: 20rpx;
color: #fff;
text-align: center;
margin-left: -150rpx;
z-index: 999;
}
.voice-model img {
width: 200rpx;
height: 200rpx;
margin: 0 auto;
}
.voice-btn {
position: absolute;
bottom: -250rpx;
left: 30%;
width: 180rpx;
height: 180rpx;
background: #eee;
border-radius: 50%;
}
.type-popup {
width: 500rpx;
height: auto;
background: #fff;
border-radius: 10px;
position: relative;
margin-bottom: 40rpx;
}
.card-list {
width: 95%;
border-radius: 10upx;
background: #fff;
height: auto;
margin: 40rpx auto 0;
}
.title-fur {
width: 95%;
height: 70rpx;
margin: 0 auto;
border-bottom: 1px solid #eee;
}
.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;
}
.scroll-content {
padding-top: 315rpx;
height: 90%;
}
.kucun {
background: url(https://jewel-shop.oss-cn-beijing.aliyuncs.com/9428d632981647728829da336a1d24b3.png) no-repeat;
width: 50rpx;
height: 25rpx;
position: absolute;
top: -14rpx;
right: -15rpx;
background-size: 100%;
}
.zuni-numbox {
height: 60rpx;
display: flex;
flex-direction: row;
}
.zuni-numbox-btns {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 0 8px;
cursor: pointer;
}
.zuni-numbox__value {
margin: 0 2px;
width: 40px;
text-align: center;
font-size: 20px;
line-height: 30px;
height: 60rpx;
border-left-width: 0;
border-right-width: 0;
}
.zuni-numbox--text {
line-height: 20px;
font-size: 32px;
font-weight: 300;
}
.zuni-numbox .zuni-numbox--disabled {
color: #c0c0c0 !important;
cursor: not-allowed;
}
.mask-model{
width: 60%;
height: 100rpx;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
text-align: center;
background: rgba(0,0,0,0.7);
color: #eee;
padding: 5px;
border-radius: 5px;
z-index: 99;
}
</style>