|
|
@@ -9,7 +9,7 @@
|
|
|
<view class="commodity-list">
|
|
|
<view class="commodity-item" v-for="(item, index) in selectList" :key="index">
|
|
|
<image class="item-icon" :src="item.cover" alt="" />
|
|
|
- <view class="item-info" @click="showAddModel(item)">
|
|
|
+ <view class="item-info" @click="showAddModelFn(item)">
|
|
|
<view class="info-line">
|
|
|
<text class="item-name">{{ item.itemName }}</text>
|
|
|
<text class="item-price">
|
|
|
@@ -20,13 +20,13 @@
|
|
|
|
|
|
<view style="text-align:right;">
|
|
|
<view class="open-bx" >
|
|
|
- <i class="iconfont iconjian" @click.stop="delItem(item)" v-if="item.bigCount > 0 || item.smallCount > 0"></i>
|
|
|
+ <i class="iconfont iconjian" @click.stop="reduceItemFn(item)" v-if="item.bigCount > 0 || item.smallCount > 0"></i>
|
|
|
<text class="num" >
|
|
|
<text v-if="item.bigCount > 0 || item.smallCount > 0">{{ `${item.bigCount}` }}</text>
|
|
|
<text v-if="item.smallCount > 0">/</text>
|
|
|
<text v-if="item.smallCount > 0">{{ `${item.smallCount}` }}</text>
|
|
|
</text>
|
|
|
- <i class="iconfont iconzeng" @click.stop="addItem(item)"></i>
|
|
|
+ <i class="iconfont iconzeng" @click.stop="addItemFn(item)"></i>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -41,16 +41,16 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <modal-module :show="currentModelShow" @cancel="addModelCancel" @click="confirmAddModel" :title="currentItemData.itemName" color="#333" :size="32" padding="30upx 30upx" >
|
|
|
+ <modal-module :show="isAddModel" @cancel="addItemModelHidden" @click="confirmAddItemModel" :title="customData.itemName" color="#333" :size="32" padding="30rpx 30rpx" >
|
|
|
<template slot="customContent">
|
|
|
- <view class="select-cmd_bx" v-if="currentItemData">
|
|
|
- <view class="kc"><text class="unit_price">库存 {{ parseFloat(currentItemData.stock) }}</text><text class="unit_price"> 单价 {{ parseFloat(currentItemData.price) }}</text>1扎={{currentItemData.ratio}}支</view>
|
|
|
+ <view class="select-cmd_bx" v-if="customData">
|
|
|
+ <view class="kc"><text class="unit_price">库存 {{ parseFloat(customData.stock) }}</text><text class="unit_price"> 单价 {{ parseFloat(customData.price) }}</text>1扎={{customData.ratio}}支</view>
|
|
|
<view class="num_bx">
|
|
|
- <input v-model="currentItemData.bigCount" :focus="currentItemFocus" type="number" />扎
|
|
|
- <input v-model="currentItemData.smallCount" type="number" style="margin-left:24upx" />支
|
|
|
+ <input v-model="customData.bigCount" :focus="isAddInputFocus" type="number" />扎
|
|
|
+ <input v-model="customData.smallCount" type="number" style="margin-left:24upx" />支
|
|
|
</view>
|
|
|
<view class="num_bx">
|
|
|
- <input style="width: 495upx" v-model="currentItemData.userPrice" @focus="currentItemData.userPrice = null" type="number" placeholder="每扎单价" />
|
|
|
+ <input style="width: 495upx" v-model="customData.userPrice" @focus="customData.userPrice = null" type="number" placeholder="每扎单价" />
|
|
|
<text>元</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -195,9 +195,8 @@ export default {
|
|
|
money: "",
|
|
|
showCustomer: false,
|
|
|
customInfo:{discount:1},
|
|
|
- currentItemData: { bigCount: 0, smallCount: 0, userPrice: 0 },
|
|
|
- currentItemFocus:false,
|
|
|
- currentModelShow:false,
|
|
|
+ customData: { bigCount: 0, smallCount: 0, userPrice: 0 },
|
|
|
+ isAddModel:false,
|
|
|
checkStock:true,
|
|
|
xjData:{},
|
|
|
xjDataInfo:{}
|
|
|
@@ -237,58 +236,6 @@ export default {
|
|
|
if(!this.$util.isEmpty(uni.getStorageSync("newClient"))){
|
|
|
this.showCustomer = true;
|
|
|
}
|
|
|
-
|
|
|
- //小菊的添加和修改,同样代码有多个地方,请搜索关键词 xj_change_code
|
|
|
- if(this.xjData.hasUpdate == 1){
|
|
|
- console.log('this.xjData',this.xjData)
|
|
|
- console.log('this.xjDataInfo',this.xjDataInfo)
|
|
|
-
|
|
|
- const list = this.selectList;
|
|
|
-
|
|
|
- this.currentItemData = this.xjDataInfo
|
|
|
-
|
|
|
- if(this.xjData.cancel == 1){
|
|
|
- this.currentItemData.bigCount = 0
|
|
|
- this.currentItemData.smallCount = 0
|
|
|
- console.log('this.currentItemData',this.currentItemData)
|
|
|
- this.confirmAddModel({index:0})
|
|
|
- }else{
|
|
|
-
|
|
|
- //判断list有没有数据,没有需要初始化
|
|
|
- const list = this.selectList;
|
|
|
- let has = false
|
|
|
- for (let index = 0; index < list.length; index++) {
|
|
|
- const element = list[index];
|
|
|
- if (element.id == this.xjDataInfo.id && element.classId == this.xjDataInfo.classId) {
|
|
|
- has = true
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(has == false){
|
|
|
- let params = {
|
|
|
- ...this.xjDataInfo,
|
|
|
- bigCount: null, //扎数
|
|
|
- smallCount: null, //支数
|
|
|
- autoPrice: null, //调价价格
|
|
|
- userPrice: null, //调价价格
|
|
|
- };
|
|
|
- list.push(params);
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- }
|
|
|
-
|
|
|
- this.currentItemData.bigCount = this.xjData.stock
|
|
|
- this.currentItemData.smallCount = 0
|
|
|
- this.currentItemData.bigPrice = this.xjData.price
|
|
|
- this.currentItemData.price = this.xjData.price
|
|
|
- this.currentItemData.itemPrice = this.xjData.price
|
|
|
- this.currentItemData.userPrice = this.xjData.price
|
|
|
-
|
|
|
- this.confirmAddModel({index:1})
|
|
|
- }
|
|
|
- }
|
|
|
- this.xjData = {}
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
onUnload(){
|
|
|
uni.removeStorageSync('newClient');
|
|
|
@@ -303,138 +250,13 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(["initMerchantInfo"]),
|
|
|
- //通过弹框来修改花材数据(区别于点+-号修改花材)
|
|
|
- showAddModel(item) {
|
|
|
- let variety = item.variety
|
|
|
- //不是小菊或者是小菊但不是在开单
|
|
|
- if(variety == 0 || this.pageType != 'bill'){
|
|
|
- if(this.checkStock){
|
|
|
- if(item.stock<=0){
|
|
|
- this.$util.noStockRemind()
|
|
|
- uni.showToast({title:'库存不足',icon:'none'})
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if(!item.bigCount && !item.smallCount){
|
|
|
- let params = { ...item, bigCount: item.bigCount, smallCount: item.smallCount, userPrice: item.userPrice}
|
|
|
- this.$emit("groupInfoBeforeShowModel", item,params);
|
|
|
- }else{
|
|
|
- this.showAddModel({ ...item, bigCount: item.bigCount, smallCount: item.smallCount, userPrice: item.userPrice })
|
|
|
- }
|
|
|
- }else{
|
|
|
- //去特殊品种页
|
|
|
- this.goToSpecialVariety(item)
|
|
|
- }
|
|
|
- },
|
|
|
- addModelCancel() {
|
|
|
- this.currentModelShow = false;
|
|
|
- this.currentItemData = {};
|
|
|
- },
|
|
|
- confirmAddModel(val) {
|
|
|
- if (val.index === 0) {
|
|
|
- if(this.currentItemData.bigCount<=0 && this.currentItemData.smallCount<=0){
|
|
|
- this.delCurrentItem(this.currentItemData)
|
|
|
- }
|
|
|
- this.addModelCancel();
|
|
|
- return false
|
|
|
- }
|
|
|
- //二个都不是数值
|
|
|
- if(/(^[1-9]\d*$)/.test(this.currentItemData.bigCount) == false && /(^[1-9]\d*$)/.test(this.currentItemData.smallCount) == false){
|
|
|
- this.delCurrentItem(this.currentItemData)
|
|
|
- this.addModelCancel();
|
|
|
- return;
|
|
|
- }
|
|
|
- if(/(^[1-9]\d*$)/.test(this.currentItemData.bigCount)){
|
|
|
- if(this.currentItemData.bigCount<=0){
|
|
|
- uni.showToast({title:"数量要大于0",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(/(^[1-9]\d*$)/.test(this.currentItemData.smallCount)){
|
|
|
- if(this.currentItemData.smallCount<=0){
|
|
|
- uni.showToast({title:"数量要大于0",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.currentItemData.userPrice) == false){
|
|
|
- uni.showToast({title:"金额错误",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
- if(this.currentItemData.userPrice <=0){
|
|
|
- uni.showToast({title:"金额要大于0",icon:"none"})
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const { bigCount,smallCount,bigNum,bigUnit,smallNum,smallUnit,ratio} = this.currentItemData;
|
|
|
- const ratioNum = Number(ratio);
|
|
|
- if (Number(bigCount) * ratioNum + Number(smallCount) > Number(bigNum) * ratioNum + Number(smallNum)) {
|
|
|
- uni.showToast({ title: '还剩'+bigNum, icon: "none" })
|
|
|
- this.$util.noStockRemind()
|
|
|
- } else {
|
|
|
- this.updateItemEvent(this.currentItemData);
|
|
|
- this.addModelCancel();
|
|
|
- }
|
|
|
+ reduceItemFn(item) {
|
|
|
+ item.bigCount--
|
|
|
+ this.replaceItemFn(item)
|
|
|
},
|
|
|
- //显示可以修改花材的弹框
|
|
|
- showAddModel(info) {
|
|
|
- this.currentModelShow = true
|
|
|
- this.currentItemData = info;
|
|
|
- this.currentItemFocus = false;
|
|
|
- this.$nextTick(()=>{
|
|
|
- this.currentItemData.smallCount = this.currentItemData.smallCount==0?null:this.currentItemData.smallCount;
|
|
|
- this.currentItemData.bigCount = this.currentItemData.bigCount==0?null:this.currentItemData.bigCount;
|
|
|
- if(this.currentItemData.userPrice == null || this.currentItemData.userPrice == 0){
|
|
|
- this.currentItemData.userPrice = this.currentItemData.bigPrice;
|
|
|
- }else{
|
|
|
- this.currentItemData.userPrice = this.currentItemData.userPrice;
|
|
|
- }
|
|
|
- this.currentItemFocus = true;
|
|
|
- })
|
|
|
- },
|
|
|
- //删除花材
|
|
|
- delItem(item) {
|
|
|
- let variety = item.variety
|
|
|
- if(variety == 0){
|
|
|
- this.delEvent(item)
|
|
|
- }else{
|
|
|
- //去特殊品种页
|
|
|
- this.goToSpecialVariety(item)
|
|
|
- }
|
|
|
- },
|
|
|
- //添加花材
|
|
|
- addItem(item) {
|
|
|
- let variety = item.variety
|
|
|
- if(variety == 0){
|
|
|
- const ratio = Number(item.ratio);
|
|
|
- if(this.checkStock){
|
|
|
- if(item.stock<=0){
|
|
|
- this.$msg("库存不足")
|
|
|
- this.$util.noStockRemind()
|
|
|
- return
|
|
|
- }
|
|
|
- if (Number(item.bigCount) * ratio + Number(item.smallCount) >= Number(item.bigNum) * ratio + Number(item.smallNum)) {
|
|
|
- this.$msg("库存不足")
|
|
|
- this.$util.noStockRemind()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- this.addEvent(item)
|
|
|
- }else{
|
|
|
- //去特殊品种页
|
|
|
- this.goToSpecialVariety(item)
|
|
|
- }
|
|
|
- },
|
|
|
- //去特殊品种页,如小菊等
|
|
|
- goToSpecialVariety(info){
|
|
|
- this.xjDataInfo = info
|
|
|
- if(info.stock <= 0){
|
|
|
- this.$util.noStockRemind()
|
|
|
- uni.showToast({title:"没有库存",icon:"none"})
|
|
|
- }else{
|
|
|
- this.$util.pageTo({url: "/admin/item/xj",query: {stock:info.stock,price: info.price,customId:this.option.customId,userPrice:info.userPrice}})
|
|
|
- }
|
|
|
+ addItemFn (item) {
|
|
|
+ item.bigCount++
|
|
|
+ this.replaceItemFn(item)
|
|
|
},
|
|
|
init () {
|
|
|
this._getDet();
|