|
|
@@ -90,30 +90,33 @@
|
|
|
<template v-if="form.flower == 1">
|
|
|
<view class="module-com content-box proInfo">
|
|
|
<view class="commodity-view">
|
|
|
- <view class="infoAEdit">
|
|
|
- <text>使用花材</text>
|
|
|
- </view>
|
|
|
+ <view class="infoAEdit">
|
|
|
+ <text>使用花材</text>
|
|
|
+ </view>
|
|
|
+ <template v-if="!$util.isEmpty(selectList)">
|
|
|
<view class="commodity-list">
|
|
|
- <view v-for="(s, idx) in goodsInfo.goodsItem" :key="idx" class="commodity-item" >
|
|
|
- <image class="item-icon" :src="s.smallCover" @click="pageTo({url:'/admin/item/detail',query:{id: s.itemId}})" />
|
|
|
+ <view v-for="(s, idx) in selectList" :key="idx" class="commodity-item" >
|
|
|
+ <image class="item-icon" :src="s.cover" @click="pageTo({url:'/admin/item/detail',query:{id: s.id}})" />
|
|
|
<view class="item-info">
|
|
|
<view class="info-line">
|
|
|
<text class="item-name">{{ s.name }}</text>
|
|
|
<text class="item-price">
|
|
|
<text class="unit"></text>
|
|
|
<text class="price">
|
|
|
- <text>{{s.num}}{{s.unitName}}</text>
|
|
|
+ <text v-if="Number(s.bigCount)>0">{{s.bigCount}}{{s.bigUnit}}</text>
|
|
|
+ <text v-if="Number(s.smallCount)>0">{{s.smallCount}}{{s.smallUnit}}</text>
|
|
|
</text>
|
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ </template>
|
|
|
</view>
|
|
|
|
|
|
<template>
|
|
|
<view style="text-align:center;">
|
|
|
- <button class="admin-button-com middle blue" v-if="goodsInfo.setItemNum == 0" style="margin:0 auto;margin-top:10upx;margin-bottom:10upx;" @click="selectItem()">修改花材</button>
|
|
|
+ <button class="admin-button-com middle blue" v-if="goodsInfo.setItemNum == 0" style="margin:0 auto;margin-top:10upx;margin-bottom:10upx;" @click="selectItem(goodsInfo)">修改花材</button>
|
|
|
<button class="admin-button-com middle default" v-else style="margin:0 auto;margin-top:10upx;margin-bottom:10upx;">修改花材</button>
|
|
|
</view>
|
|
|
</template>
|
|
|
@@ -173,6 +176,7 @@ import { getDetailB, addB, updateB } from "@/api/goods";
|
|
|
//图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
|
|
|
import htzImageUpload from './components/htz-image-upload/htz-image-upload.vue'
|
|
|
import {currentShop} from "@/api/shop"
|
|
|
+import productMins from "@/mixins/product";
|
|
|
export default {
|
|
|
name: "add",
|
|
|
components: {
|
|
|
@@ -180,8 +184,10 @@ export default {
|
|
|
AppUploader,
|
|
|
htzImageUpload
|
|
|
},
|
|
|
+ mixins: [productMins],
|
|
|
data() {
|
|
|
return {
|
|
|
+ selectJobType: "addGoodsSelectItem",
|
|
|
headers:{token:''},
|
|
|
currentImgData: [],
|
|
|
status: 1,
|
|
|
@@ -206,26 +212,31 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
onLoad() {
|
|
|
+
|
|
|
+ if(this.option.id){
|
|
|
+ this.selectJobId = this.option.id
|
|
|
+ }
|
|
|
+
|
|
|
const token = uni.getStorageSync('token')
|
|
|
this.headers.token = token
|
|
|
this.getDetail()
|
|
|
|
|
|
- currentShop().then(res=>{
|
|
|
- let that = this
|
|
|
- if(res.code == 1){
|
|
|
- if(res.data && res.data.stockModel){
|
|
|
- that.stockModel = res.data.stockModel
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ currentShop().then(res=>{
|
|
|
+ let that = this
|
|
|
+ if(res.code == 1){
|
|
|
+ if(res.data && res.data.stockModel){
|
|
|
+ that.stockModel = res.data.stockModel
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
setItemNumChange(e){
|
|
|
this.form.setItemNum = e.detail.value;
|
|
|
},
|
|
|
- selectItem(){
|
|
|
- this.pageTo({url:'/admin/goods/selectItem'})
|
|
|
+ selectItem(goods){
|
|
|
+ this.pageTo({url:'/admin/goods/selectItem?id='+goods.id})
|
|
|
},
|
|
|
imgDeleteFn(res){
|
|
|
const index = res.index
|
|
|
@@ -246,7 +257,26 @@ export default {
|
|
|
if (this.$util.isEmpty(res.data)) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
this.goodsInfo = res.data
|
|
|
+
|
|
|
+ if(this.goodsInfo.goodsItem && !this.$util.isEmpty(this.goodsInfo.goodsItem)){
|
|
|
+ const newItem = this.goodsInfo.goodsItem.map(ele=>{
|
|
|
+ let unitType = ele.unitType
|
|
|
+ let bigCount = 0
|
|
|
+ let smallCount = 0
|
|
|
+ let num = ele.num
|
|
|
+ if(unitType == 0){
|
|
|
+ bigCount = num
|
|
|
+ }else{
|
|
|
+ smallCount = num
|
|
|
+ }
|
|
|
+ return {name:ele.name,cover:ele.smallCover,itemId:ele.ptItemId,id:ele.itemId,ratio:ele.ratio,
|
|
|
+ bigCount:bigCount,smallCount:smallCount,bigUnit:ele.bigName,smallUnit:ele.smallName,shortCover:ele.shortCover}
|
|
|
+ })
|
|
|
+ this.pushToSave(newItem)
|
|
|
+ }
|
|
|
+
|
|
|
Object.keys(this.form).forEach((i) => {
|
|
|
this.form[i] = res.data[i];
|
|
|
});
|
|
|
@@ -292,8 +322,25 @@ export default {
|
|
|
this.$msg("请上传图片")
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+ const product = this.selectList.map(ele => {
|
|
|
+ let unitName = ele.bigUnit
|
|
|
+ let unitType = 0
|
|
|
+ let num = ele.bigCount||0
|
|
|
+ let count = ele.bigCount||0
|
|
|
+ if(Number(ele.smallCount)>0){
|
|
|
+ unitType = 1
|
|
|
+ unitName = ele.smallUnit
|
|
|
+ num=Number(ele.smallCount)
|
|
|
+ count = (ele.smallCount/ele.ratio).toFixed(2)
|
|
|
+ }
|
|
|
+ return { id: ele.id, unitType:unitType,ptItemId:ele.itemId,name:ele.name,
|
|
|
+ bigName:ele.bigUnit,smallName:ele.smallUnit,unitName:unitName,cover:ele.shortCover,ratio:ele.ratio,num:num,count:count}
|
|
|
+ })
|
|
|
+
|
|
|
let form = JSON.parse(JSON.stringify(this.form))
|
|
|
- updateB({ ...form }).then(res => {
|
|
|
+ updateB({ ...form,itemList:JSON.stringify(product) }).then(res => {
|
|
|
+ this.removeFromSaveDirect()
|
|
|
uni.navigateBack({})
|
|
|
this.$msg("操作成功")
|
|
|
});
|