更新商品管理模块
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
<template>
|
||||
<view class="u-p-30 safe-page">
|
||||
<up-sticky v-if="option.type==='edit'" offset-top="20" zIndex="99">
|
||||
<myTabs :list="tabsList" v-model="tabsCurrent"></myTabs>
|
||||
<myTabs :list="tabsList" v-model="tabsCurrent"></myTabs>
|
||||
</up-sticky>
|
||||
|
||||
<view class="box">
|
||||
<template v-if="tabsCurrent===0">
|
||||
<view class="basic">
|
||||
@@ -11,20 +10,13 @@
|
||||
err-show-type="toast" validateTrigger="submit" label-width="350" ref="Forms">
|
||||
<view class="block">
|
||||
<uni-forms-item label="商品类型" required showRequired>
|
||||
<up-radio-group
|
||||
:disabled="option.type=='edit'"
|
||||
v-model="FormData.typeEnum"
|
||||
placement="row"
|
||||
>
|
||||
<up-radio
|
||||
:customStyle="{marginRight: '30px'}"
|
||||
v-for="(item, index) in pageData.types"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:name="item.value"
|
||||
>
|
||||
</up-radio>
|
||||
</up-radio-group>
|
||||
<up-radio-group :disabled="option.type=='edit'" v-model="FormData.typeEnum"
|
||||
placement="row">
|
||||
<up-radio :customStyle="{marginRight: '30px'}"
|
||||
v-for="(item, index) in pageData.types" :key="index" :label="item.name"
|
||||
:name="item.value">
|
||||
</up-radio>
|
||||
</up-radio-group>
|
||||
<!-- <view class="u-flex u-flex-wrap types " :class="{disabled:option.productId!==''}">
|
||||
<view class="item" @tap="changeFormData('typeEnum',item.value)"
|
||||
:class="{active:FormData.typeEnum===item.value}"
|
||||
@@ -37,7 +29,7 @@
|
||||
</view> -->
|
||||
|
||||
</uni-forms-item>
|
||||
<uni-forms-item ref="fileItem" label="图片">
|
||||
<uni-forms-item ref="fileItem" label="图片" required showRequired>
|
||||
<my-upload-file ref="refFile" :images="FormData.images"></my-upload-file>
|
||||
<view class="u-m-t-16 color-999 u-font-24">
|
||||
注:第一张图为商品封面图,图片尺寸为750x750
|
||||
@@ -63,17 +55,6 @@
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
|
||||
<!-- <uni-forms-item label="商品详情" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
type="textarea" v-model="FormData.goodsDetail" placeholder="请填写商品详情" />
|
||||
</uni-forms-item> -->
|
||||
|
||||
<!-- <view class="">
|
||||
<uni-forms-item label="规格模式" required>
|
||||
<uni-data-checkbox v-model="FormData.specificationsPattern"
|
||||
:localdata="specificationMode" />
|
||||
</uni-forms-item>
|
||||
</view> -->
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="单位" required showRequired name="categoryId">
|
||||
|
||||
@@ -84,7 +65,7 @@
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
|
||||
<template v-if="FormData.typeEnum==='group'">
|
||||
<template v-if="FormData.typeEnum==='group'">
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="团购券分类" required showRequired name="categoryId">
|
||||
<view class="u-p-30 bg-gray u-m-b-20" v-if="FormData.groupCategoryId.length">
|
||||
@@ -118,179 +99,29 @@
|
||||
<choose-group-category @confirm="refChooseCouponCategoryConfirm"
|
||||
ref="refChooseGroupCategory"></choose-group-category>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- <view class="">
|
||||
<uni-forms-item label=" " required>
|
||||
<view class="u-flex u-row-between zuofa" @tap="toGuige ">
|
||||
<view class="color-333">{{returnSpecificationsGroup }}</view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view> -->
|
||||
|
||||
|
||||
<!-- <uni-forms-item label="底价(元)" name="floorPrice" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.floorPrice" placeholder="请输入底价(元)" />
|
||||
</uni-forms-item> -->
|
||||
<!-- <uni-forms-item label="售卖方式" required>
|
||||
<view style="display: none;"><uni-easyinput :paddingNone="inputPaddingNone"
|
||||
:inputBorder="inputBorder" v-model="FormData.salesMethod"
|
||||
placeholder="请选择售卖方式" />
|
||||
</view>
|
||||
<picker @change="salesMethodChange" :value="salesMethod.defaultIndex"
|
||||
:range="salesMethod.list">
|
||||
<view class="u-flex u-row-between lh40" v-if="FormData.salesMethod===0">
|
||||
<view class="color-333">{{salesMethod.list[FormData.salesMethod]||'售卖方式'}}
|
||||
</view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
<view class="u-flex u-row-between lh40" v-if="FormData.salesMethod===1">
|
||||
<view class="u-flex">
|
||||
<text
|
||||
class="color-333">{{salesMethod.list[FormData.salesMethod]||'售卖方式'}}</text>
|
||||
<view class="u-flex color-999">
|
||||
<text>(</text>
|
||||
<text class="color-red">*</text>
|
||||
<text class="u-font-24">注意:预售商品不支持堂食</text>
|
||||
<text>)</text>
|
||||
</view>
|
||||
</view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
<view class="u-flex u-row-between lh40" v-if="FormData.salesMethod===2">
|
||||
<view class="u-flex">
|
||||
<text
|
||||
class="color-333">{{salesMethod.list[FormData.salesMethod]||'售卖方式'}}</text>
|
||||
<view class="u-flex color-999">
|
||||
<text>(</text>
|
||||
<text class="color-red">*</text>
|
||||
<text class="u-font-24">注意:该商品仅作展示,无法进行下单</text>
|
||||
<text>)</text>
|
||||
</view>
|
||||
</view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
</uni-forms-item> -->
|
||||
<!-- <template v-if="FormData.salesMethod==1">
|
||||
<view class="bg-gray border-top-0">
|
||||
<uni-forms-item label="交货时间" required>
|
||||
<radio-group @change="DeliveryTimeChange">
|
||||
<label class="u-flex " :class="{
|
||||
'u-m-b-40':index===0
|
||||
}" v-for="(item, index) in DeliveryTime" :key="item.value">
|
||||
<view>
|
||||
<radio :color="ColorMain" :value="item.value"
|
||||
:checked="index === DeliveryTimeCurrent" />
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<template v-if="index===0">
|
||||
<uni-datetime-picker v-model="FormData.startTime"
|
||||
:hide-second="true" :end="limitDayTime">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>
|
||||
<text></text>
|
||||
<text
|
||||
class="color-999">{{FormData.startTime||'选择开始时间'}}</text>
|
||||
</view>
|
||||
<uni-icons type="right" color="#999"></uni-icons>
|
||||
</view>
|
||||
</uni-datetime-picker>
|
||||
|
||||
</template>
|
||||
<template v-if="index===1">
|
||||
<view class="u-flex ">
|
||||
<view>
|
||||
付款成功
|
||||
</view>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone"
|
||||
:placeholderStyle="placeholderStyle"
|
||||
:inputBorder="false"
|
||||
v-model="FormData.paySuccessAfterDay" type="number"
|
||||
placeholder="请填写天数" />
|
||||
|
||||
|
||||
<view>
|
||||
天后交货
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
</label>
|
||||
</radio-group>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class="color-999 u-font-24 u-m-t-20 u-p-b-30">
|
||||
<text class="color-red">*</text> 注意: 只允许设置{{limitDay}}天内的发货时间,请务必按照约定时间发货以免引起客户投诉
|
||||
</view>
|
||||
<view class="">
|
||||
<uni-forms-item label="" required>
|
||||
<slot name="label">
|
||||
<view class="class">
|
||||
<text class="label-title u-m-r-6">预售可预约天数</text>
|
||||
<uni-icons @click="showModel('help')" color="#999"
|
||||
type="help"></uni-icons>
|
||||
</view>
|
||||
</slot>
|
||||
<view class="u-flex">
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :min="1" :max="15"
|
||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="FormData.discountPrice" type="number" placeholder="填写天数" />
|
||||
<text>天</text>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
</template> -->
|
||||
<!-- <uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">库存</view>
|
||||
<my-switch v-model="FormData.isStock"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<view class="border-top-0 none-label" v-if="FormData.isStock">
|
||||
<uni-forms-item label="" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.stockNumber" type="number"
|
||||
placeholder="请填写库存" />
|
||||
</uni-forms-item>
|
||||
</view> -->
|
||||
|
||||
</view>
|
||||
|
||||
<template v-if="FormData.typeEnum==='sku' ">
|
||||
<!-- <view class="block border-top-0">
|
||||
<uni-forms-item label="选择规格" required name="categoryId">
|
||||
|
||||
<uni-data-picker :clear-icon="false" @change="specIdChange"
|
||||
:map="{text:'name',value:'id'}" placeholder="请选择规格" popup-title="请选择规格"
|
||||
:localdata="pageData.specList" v-model="FormData.specId">
|
||||
</uni-data-picker>
|
||||
</uni-forms-item>
|
||||
</view> -->
|
||||
<template v-if="FormData.typeEnum=='sku' ">
|
||||
<view class="block border-top-0">
|
||||
<uni-forms-item label=" ">
|
||||
<view class="u-flex u-row-between " @tap="toGuige">
|
||||
<view class="color-333 font-bold">
|
||||
<text v-if="!skuList.length">选择规格</text>
|
||||
<text v-if="!skuList.list.length">选择规格</text>
|
||||
<text v-else>编辑规格</text>
|
||||
</view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<template v-if="skuList.length">
|
||||
<template v-if="skuList.list.length">
|
||||
<view class="u-text-center">
|
||||
<view class="u-flex font-bold u-m-b-12">
|
||||
<view class="u-flex-1">组合名称</view>
|
||||
<view class="u-flex-1">售价</view>
|
||||
<view class="u-flex-1">库存数量</view>
|
||||
</view>
|
||||
<view class="u-flex u-p-b-12 u-p-t-12" v-for="(item,index) in skuList"
|
||||
<view class="u-flex u-p-b-12 u-p-t-12" v-for="(item,index) in skuList.list"
|
||||
:key="index">
|
||||
<view class="u-flex-1">{{item.specSnap}}</view>
|
||||
<view class="u-flex-1">{{item.salePrice}}</view>
|
||||
<view class="u-flex-1">¥{{item.salePrice}}</view>
|
||||
<view class="u-flex-1">{{item.stockNumber}}</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -374,9 +205,9 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-if="FormData.typeEnum!=='sku'">
|
||||
<template v-if="FormData.typeEnum!='sku'">
|
||||
<view class="u-m-t-32 u-font-32 u-m-l-10 u-m-b-32">规格属性</view>
|
||||
<view class="block" v-for="(sku,index) in skuList" :key="index">
|
||||
<view class="block" v-for="(sku,index) in skuList.list" :key="index">
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="售价">
|
||||
<uni-easyinput :paddingNone="inputPaddingNone"
|
||||
@@ -392,7 +223,7 @@
|
||||
:inputBorder="inputBorder" v-model="sku.memberPrice" type="digit"
|
||||
placeholder="请输入会员价(元)" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="成本价(元)">
|
||||
<!-- <uni-forms-item label="成本价(元)">
|
||||
<uni-easyinput @blur="priceFormat(sku,'costPrice')" :paddingNone="inputPaddingNone"
|
||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="sku.costPrice" type="digit" placeholder="请输入成本价(元)" />
|
||||
@@ -402,7 +233,7 @@
|
||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="sku.originPrice" type="digit"
|
||||
placeholder="请输入原价(元)" />
|
||||
</uni-forms-item>
|
||||
</uni-forms-item> -->
|
||||
<uni-forms-item label="起售数量">
|
||||
<uni-easyinput @blur="priceFormat(sku,'suit')" :paddingNone="inputPaddingNone"
|
||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
@@ -598,138 +429,11 @@
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <view class="block">
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">打折设置</view>
|
||||
<my-switch v-model="FormData.openDiscount"
|
||||
@change="openDiscountChange"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class="border-top-0 none-label" v-if="FormData.openDiscount">
|
||||
<uni-forms-item label="" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.discountPrice" type="digit"
|
||||
placeholder="请填写折后价" />
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">不参与会员折扣</view>
|
||||
<my-switch v-model="FormData.isVipDiscount"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="会员价(元)" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.vipPrice" type="digit"
|
||||
placeholder="请输入会员价(元)" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="包装费(元)" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.packagingFee" type="digit"
|
||||
placeholder="请输入包装费(元)" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="重量(千克)" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.weight" type="digit"
|
||||
placeholder="请输入重量(千克)" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="赠送积分" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.integral" type="digit"
|
||||
placeholder="请输入赠送积分" />
|
||||
</uni-forms-item>
|
||||
|
||||
</view> -->
|
||||
|
||||
<!-- <view class="block">
|
||||
<view class="border-top-0 ">
|
||||
<uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">每日销量上限</view>
|
||||
<my-switch v-model="FormData.openDailySalesLimit"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class="border-top-0 none-label" v-if="FormData.openDailySalesLimit">
|
||||
<uni-forms-item label="" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.dailySalesLimit" type="digit"
|
||||
placeholder="请填写每日销量上限" />
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">每单限购</view>
|
||||
<my-switch v-model="FormData.openOrderBuyLimit"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<view class="border-top-0 none-label" v-if="FormData.openOrderBuyLimit">
|
||||
<uni-forms-item label="" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.orderBuyLimit" type="digit"
|
||||
placeholder="请填写每单限购" />
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">每人限购</view>
|
||||
<my-switch v-model="FormData.openEveryoneBuyLimit"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<view class="border-top-0 none-label" v-if="FormData.openEveryoneBuyLimit">
|
||||
<uni-forms-item label="" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.everyoneBuyLimit" type="digit"
|
||||
placeholder="请填写每人限购" />
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<uni-forms-item label="最低起售(件)" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.minBuyLimit" type="number"
|
||||
placeholder="请输入最低起售(件)" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="包装费(元)" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.packagingFee" type="digit"
|
||||
placeholder="请输入包装费(元)" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="">
|
||||
<view class="u-flex u-row-between" @tap="toTimerPage">
|
||||
<view>
|
||||
<view class="label-title">定时上下架</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="color-666">{{returnTimerText()}}</view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
|
||||
<uni-forms-item label="虚拟销量" required>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.virtualSales" type="number"
|
||||
placeholder="虚拟销量" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="" required>
|
||||
<view class="u-flex u-row-between lh40">
|
||||
<view class="label-title">设为推荐</view>
|
||||
<my-switch v-model="FormData.isRecommend"></my-switch>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
|
||||
</view> -->
|
||||
|
||||
</uni-forms>
|
||||
<view style="height: 200rpx;"></view>
|
||||
<view style="padding-left: 110rpx;padding-right: 110rpx;" class="u-m-t-20" v-if="option.type==='edit'" @click="delModelShow">
|
||||
<my-button bgColor="#F9F9F9" shape="circle" type="cancel" >
|
||||
<view style="padding-left: 110rpx;padding-right: 110rpx;" class="u-m-t-20"
|
||||
v-if="option.type==='edit'" @click="delModelShow">
|
||||
<my-button bgColor="#F9F9F9" shape="circle" type="cancel">
|
||||
<view class="color-red">删除该商品</view>
|
||||
</my-button>
|
||||
</view>
|
||||
@@ -737,18 +441,13 @@
|
||||
<view class="save-btn-box">
|
||||
<my-button shape="circle" @tap="save">保存</my-button>
|
||||
</view>
|
||||
<!-- <view class="u-m-t-20" v-if="option.type==='edit'" @click="delModelShow">
|
||||
<my-button bgColor="#fff" shape="circle" type="cancel" >
|
||||
<view class="color-red">删除该商品</view>
|
||||
</my-button>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-if="tabsCurrent===1">
|
||||
<edit-haocai :goods="FormData" @cancel="changeTabsCurrent(0)"></edit-haocai>
|
||||
<edit-haocai @updateGoods="updateGoodsDetail" :goods="FormData" @cancel="changeTabsCurrent(0)"></edit-haocai>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
@@ -762,15 +461,16 @@
|
||||
</template>
|
||||
</my-model>
|
||||
|
||||
|
||||
|
||||
<!-- 删除弹窗 -->
|
||||
<my-model @confirm="delmodelConfirm" ref="delModel" desc="确认删除">
|
||||
</my-model>
|
||||
<!-- 选择商品 -->
|
||||
<choose-goods ref="refChooseGoods" @confirm="refChooseGoodsConfirm" :category="pageData.category"></choose-goods>
|
||||
<!-- 更多操作 -->
|
||||
<my-action-sheet @itemClick="actionSheetClick" ref="refMoreSheet" :list="actionSheet.list"></my-action-sheet>
|
||||
|
||||
|
||||
<!-- 删除弹窗 -->
|
||||
<my-model @confirm="delmodelConfirm" ref="delModel" desc="确认删除">
|
||||
</my-model>
|
||||
<!-- 选择商品 -->
|
||||
<choose-goods ref="refChooseGoods" @confirm="refChooseGoodsConfirm"
|
||||
:category="pageData.category"></choose-goods>
|
||||
<!-- 更多操作 -->
|
||||
<my-action-sheet @itemClick="actionSheetClick" ref="refMoreSheet" :list="actionSheet.list"></my-action-sheet>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -798,7 +498,7 @@
|
||||
import myButton from '@/components/my-components/my-button'
|
||||
import mySwitch from '@/components/my-components/my-switch.vue'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
|
||||
|
||||
import {
|
||||
$types,
|
||||
$defaultSku
|
||||
@@ -1146,11 +846,12 @@
|
||||
|
||||
const tabsList = ['基础设置', '耗材绑定']
|
||||
let tabsCurrent = ref(0)
|
||||
function changeTabsCurrent(newval){
|
||||
tabsCurrent.value=newval
|
||||
|
||||
function changeTabsCurrent(newval) {
|
||||
tabsCurrent.value = newval
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const Forms = ref(null)
|
||||
|
||||
|
||||
@@ -1253,10 +954,15 @@
|
||||
usageRules: ""
|
||||
}
|
||||
})
|
||||
const skuList = reactive([{
|
||||
...$defaultSku,
|
||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||
}])
|
||||
const skuList = reactive({
|
||||
list: [{
|
||||
...$defaultSku,
|
||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||
}]
|
||||
})
|
||||
watch(() => skuList.list, (newval) => {
|
||||
console.log(newval);
|
||||
})
|
||||
//库存表单数据
|
||||
const stockData = reactive({
|
||||
inventoryMode: 0,
|
||||
@@ -1294,13 +1000,21 @@
|
||||
url: v
|
||||
}
|
||||
})
|
||||
$goodsData = res
|
||||
Object.assign(FormData, res)
|
||||
if (res.skuList.length) {
|
||||
for (let i in res.skuList) {
|
||||
skuList[i] = res.skuList[i]
|
||||
for(let i in res.conInfos){
|
||||
const con=res.conInfos[i]
|
||||
const item=res.skuList.find(v=>v.id==con.productSkuId)
|
||||
if(item){
|
||||
if(item.hasOwnProperty('haoCaiList')){
|
||||
item.haoCaiList.push(con)
|
||||
}else{
|
||||
item.haoCaiList=[con]
|
||||
}
|
||||
}
|
||||
}
|
||||
$goodsData = res
|
||||
console.log(res);
|
||||
Object.assign(FormData, res)
|
||||
skuList.list = res.skuList || []
|
||||
//多规格
|
||||
if (res.typeEnum === 'sku') {
|
||||
const selectSpec = JSON.parse(res.selectSpec)
|
||||
@@ -1319,13 +1033,12 @@
|
||||
selectSpec: selectSpec.map(s => {
|
||||
return {
|
||||
...s,
|
||||
// value: s.value.map(v => {
|
||||
// return {
|
||||
// text: v,
|
||||
// value: v
|
||||
// }
|
||||
// })
|
||||
|
||||
value: s.value.map(v => {
|
||||
return typeof v === 'string' ? {
|
||||
text: v,
|
||||
value: v
|
||||
} : v
|
||||
})
|
||||
}
|
||||
}),
|
||||
result: res.skuList.map(v => {
|
||||
@@ -1339,7 +1052,8 @@
|
||||
...v
|
||||
},
|
||||
names,
|
||||
specSnap: v.specSnap
|
||||
specSnap: v.specSnap,
|
||||
coverImg:v.coverImg
|
||||
}
|
||||
}),
|
||||
specList: [],
|
||||
@@ -1422,9 +1136,14 @@
|
||||
const pageData = reactive({
|
||||
// 商品类型
|
||||
// types: $types,
|
||||
types: [
|
||||
{name:'单规格',value:'normal'},
|
||||
{name:'多规格',value:'sku'}
|
||||
types: [{
|
||||
name: '单规格',
|
||||
value: 'normal'
|
||||
},
|
||||
{
|
||||
name: '多规格',
|
||||
value: 'sku'
|
||||
}
|
||||
],
|
||||
// 单位
|
||||
units: [],
|
||||
@@ -1441,6 +1160,10 @@
|
||||
pageData.skuList = res
|
||||
})
|
||||
}
|
||||
function updateGoodsDetail(){
|
||||
getGoodsDetail()
|
||||
getProductSku()
|
||||
}
|
||||
onLoad((params) => {
|
||||
if (isEmpty(params)) {
|
||||
option.type = params.type ? params.type : 'add'
|
||||
@@ -1454,6 +1177,10 @@
|
||||
uni.setNavigationBarTitle({
|
||||
title: option.type === 'add' ? '添加商品' : '编辑商品'
|
||||
})
|
||||
if (option.type === 'edit') {
|
||||
getGoodsDetail()
|
||||
getProductSku()
|
||||
}
|
||||
defaultValueInit()
|
||||
getCategory()
|
||||
getTbShopUnit()
|
||||
@@ -1461,10 +1188,10 @@
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (option.type === 'edit') {
|
||||
getGoodsDetail()
|
||||
getProductSku()
|
||||
}
|
||||
// if (option.type === 'edit') {
|
||||
// getGoodsDetail()
|
||||
// getProductSku()
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
@@ -1498,15 +1225,23 @@
|
||||
if (typeEnum === 'group' && !groupCategoryId.length) {
|
||||
return infoBox.showToast('请选择团购券分类')
|
||||
}
|
||||
|
||||
// if(typeEnum==='sku'){
|
||||
// return infoBox.showErrorToast('请选择规格')
|
||||
// }
|
||||
const images = refFile.value.getFileList()
|
||||
if(images.length<=0){
|
||||
return infoBox.showToast('请上传商品图片')
|
||||
}
|
||||
const skuSnap = []
|
||||
const submitSkuList = FormData.specificationsGroup ? skuList : [{
|
||||
let submitSkuList = FormData.specificationsGroup ? skuList.list : [{
|
||||
...$defaultSku,
|
||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||
}]
|
||||
}];
|
||||
if(typeEnum=='normal'){
|
||||
submitSkuList=skuList.list ;
|
||||
}
|
||||
console.log(submitSkuList);
|
||||
if (FormData.specificationsGroup) {
|
||||
for (let i of FormData.specificationsGroup.selectSpec) {
|
||||
if (i.selectSpecResult.length) {
|
||||
@@ -1517,7 +1252,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const submitData = {
|
||||
...FormData,
|
||||
images: images,
|
||||
@@ -1526,7 +1260,13 @@
|
||||
specInfo: JSON.stringify(submitSkuList),
|
||||
lowPrice: submitSkuList[0].salePrice,
|
||||
specificationsGroup: undefined,
|
||||
selectSpec: JSON.stringify(FormData.specificationsGroup.selectSpec),
|
||||
selectSpec: JSON.stringify(FormData.specificationsGroup.selectSpec.map(spe=>{
|
||||
return {
|
||||
...spe,value:spe.value.map(v=>{
|
||||
return typeof v==='string'?v:v.text||v.value
|
||||
})
|
||||
}
|
||||
})),
|
||||
skuSnap: JSON.stringify(skuSnap)
|
||||
}
|
||||
//编辑
|
||||
@@ -1562,29 +1302,33 @@
|
||||
|
||||
/**
|
||||
* 监听规格保存,拿到数据
|
||||
* @param {Boolean} open //控制开启或关闭监听
|
||||
*/
|
||||
function watchSpecificationsSave(open = true) {
|
||||
if (open) {
|
||||
uni.$on('emitspecificationsSave', function(data) {
|
||||
FormData.specificationsGroup = data
|
||||
skuList.length = data.result.length
|
||||
for (let i in data.result) {
|
||||
const v = data.result[i]
|
||||
skuList[i] = {
|
||||
...v.skus,
|
||||
...v.names,
|
||||
specSnap: v.specSnap,
|
||||
}
|
||||
}
|
||||
console.log(skuList);
|
||||
})
|
||||
} else {
|
||||
uni.$off('emitspecificationsSave', function(data) {
|
||||
console.log('emitspecificationsSave remove');
|
||||
})
|
||||
}
|
||||
const newSkuList = reactive({
|
||||
list: []
|
||||
})
|
||||
|
||||
function watchSpecificationsSave() {
|
||||
uni.$off('emitspecificationsSave')
|
||||
uni.$on('emitspecificationsSave', function(data) {
|
||||
FormData.specificationsGroup = data
|
||||
skuList.list = data.result.map(v => {
|
||||
return {
|
||||
...v.skus,
|
||||
...v.names,
|
||||
specSnap: v.specSnap,
|
||||
coverImg: v.coverImg || ''
|
||||
}
|
||||
})
|
||||
newSkuList.list = data.result.map(v => {
|
||||
return {
|
||||
...v.skus,
|
||||
...v.names,
|
||||
specSnap: v.specSnap,
|
||||
coverImg: v.coverImg || ''
|
||||
}
|
||||
})
|
||||
console.log(skuList.list);
|
||||
})
|
||||
}
|
||||
|
||||
function toGroup() {
|
||||
@@ -1666,23 +1410,20 @@
|
||||
watch(() => FormData.typeEnum, (newval) => {
|
||||
if (option.type === 'add') {
|
||||
if (newval === 'sku') {
|
||||
skuList.length = 0
|
||||
skuList.list = []
|
||||
} else {
|
||||
skuList[0] = {
|
||||
skuList.list[0] = {
|
||||
...$defaultSku,
|
||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
watchSpecificationsSave()
|
||||
watchTimerSave()
|
||||
onBeforeUnmount(() => {
|
||||
watchSpecificationsSave(false)
|
||||
watchTimerSave(false)
|
||||
onShow(() => {
|
||||
watchSpecificationsSave()
|
||||
})
|
||||
onReady(() => {
|
||||
Forms.value&&Forms.value.setRules(rules)
|
||||
Forms.value && Forms.value.setRules(rules)
|
||||
})
|
||||
watch(() => pageData.types, (newval) => {
|
||||
Forms.value.setRules(rules)
|
||||
@@ -1764,6 +1505,7 @@
|
||||
.box {
|
||||
margin-top: 36rpx;
|
||||
font-size: 28rpx;
|
||||
|
||||
.block {
|
||||
background: #FFFFFF;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
|
||||
@@ -91,8 +91,8 @@
|
||||
|
||||
function haocaiClick(item, index) {
|
||||
console.log(item);
|
||||
if (item.consId != props.modelValue) {
|
||||
emits('update:modelValue', item.consId)
|
||||
if (item.id != props.modelValue) {
|
||||
emits('update:modelValue', item.id)
|
||||
emits('change', item)
|
||||
}
|
||||
popShow.value = false
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<view class="">
|
||||
<template v-if="isBindGuige&&isSku">
|
||||
<view class="list">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(item,index) in skuList" :key="index">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(sku,index) in skuList" :key="index">
|
||||
<view>规格名称</view>
|
||||
<view class="u-m-t-16">{{item.specSnap}}</view>
|
||||
<view class="u-m-t-16">{{sku.specSnap}}</view>
|
||||
<view class="color-666 u-m-t-24 u-flex">
|
||||
<view class="xuhao">序号</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
@@ -26,29 +26,24 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 color-666">
|
||||
<view class="u-m-t-24" v-for="(haocai,haocaiIndex) in item.haoaiList"
|
||||
<view class="u-m-t-24" v-for="(item,haocaiIndex) in sku.haoCaiList"
|
||||
:key="haocaiIndex">
|
||||
<view class=" u-flex">
|
||||
<view class="xuhao">{{haocaiIndex+1}}</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1 ">
|
||||
<view class="u-flex input">
|
||||
<view>{{item.name}}</view>
|
||||
<up-icon :size="10" name="arrow-down-fill"></up-icon>
|
||||
</view>
|
||||
<choose-haocai @change="conInfosChange($event,item)"
|
||||
:listMap="$haocaiMap" :list="haoCaiList"
|
||||
v-model="item.conInfoId"></choose-haocai>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<view class="u-flex input">
|
||||
<view>{{item.unit}}</view>
|
||||
<up-icon :size="10" name="arrow-down-fill"></up-icon>
|
||||
</view>
|
||||
<choose-danwei :listMap="$danweiMap" :list="danweiList"
|
||||
v-model="item.conUnit"></choose-danwei>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<view class="u-flex input">
|
||||
<up-input border="none"></up-input>
|
||||
<up-icon color="#EB4F4F" @click="delGuigeHaocao(index,haocaiIndex)"
|
||||
:size="16" name="minus-circle-fill"></up-icon>
|
||||
</view>
|
||||
<view class="u-flex input">
|
||||
<up-input border="none" v-model="item.surplusStock"></up-input>
|
||||
<up-icon @click="delGuigeHaocao(index,haocaiIndex)" color="#EB4F4F" :size="16"
|
||||
name="minus-circle-fill"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -173,16 +168,20 @@
|
||||
deletetbProskuCon,
|
||||
} from "@/http/yskApi/consumable.js";
|
||||
import {
|
||||
tbShopCurrencyGet,$hasPermission
|
||||
tbShopCurrencyGet,
|
||||
$hasPermission
|
||||
} from '@/http/yskApi/shop.js'
|
||||
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import chooseHaocai from './choose-haocai.vue';
|
||||
import chooseDanwei from './choose-danwei.vue';
|
||||
import {
|
||||
$tbProskuConV2
|
||||
} from '@/http/yskApi/goods.js'
|
||||
const emits=defineEmits(['cancel'])
|
||||
function cancel(){
|
||||
import { cloneWith } from 'lodash';
|
||||
const emits = defineEmits(['cancel', 'updateGoods'])
|
||||
|
||||
function cancel() {
|
||||
emits('cancel')
|
||||
}
|
||||
const props = defineProps({
|
||||
@@ -203,27 +202,29 @@
|
||||
console.log(newval);
|
||||
conInfos.value = newval
|
||||
})
|
||||
|
||||
function conInfosChange(newval, item) {
|
||||
console.log(newval);
|
||||
item.stockNumber = newval.balance
|
||||
item.conUnit = newval.conUnit
|
||||
}
|
||||
|
||||
|
||||
const skuList = ref(props.goods.skuList)
|
||||
watch(() => props.goods.skuList, (newval) => {
|
||||
console.log(newval);
|
||||
skuList.value = newval
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const $baseicHaocaiData = {
|
||||
conInfoId: '',
|
||||
conUnit: '',
|
||||
surplusStock: ''
|
||||
}
|
||||
|
||||
function addHaocai() {
|
||||
conInfos.value.push({
|
||||
conInfoId: '',
|
||||
conUnit: '',
|
||||
surplusStock: ''
|
||||
...$baseicHaocaiData
|
||||
})
|
||||
}
|
||||
const popup = reactive({
|
||||
@@ -233,11 +234,21 @@
|
||||
})
|
||||
|
||||
function addGuigeHaocai(index) {
|
||||
console.log(index);
|
||||
if (skuList.value[index].haoCaiList) {
|
||||
skuList.value[index].haoCaiList.push({
|
||||
...$baseicHaocaiData
|
||||
})
|
||||
} else {
|
||||
skuList.value[index].haoCaiList = [{
|
||||
...$baseicHaocaiData
|
||||
}]
|
||||
}
|
||||
console.log(skuList.value[index]);
|
||||
}
|
||||
|
||||
function delHaocai(index) {
|
||||
const item = conInfos.value[index]
|
||||
console.log(item);
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除该耗材',
|
||||
@@ -258,7 +269,24 @@
|
||||
}
|
||||
|
||||
function delGuigeHaocao(guigeIndex, haocaiIndex) {
|
||||
skuList.value[guigeIndex].haoaiList.splice(haocaiIndex, 1)
|
||||
const item = skuList.value[guigeIndex].haoCaiList[haocaiIndex]
|
||||
console.log(item);
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除该耗材',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
if (item&&item.id) {
|
||||
deletetbProskuCon([item.id]).then(res1 => {
|
||||
skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
|
||||
})
|
||||
} else {
|
||||
skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 是否是多规格商品
|
||||
@@ -270,30 +298,66 @@
|
||||
isBindGuige.value = isSku.value
|
||||
})
|
||||
|
||||
function save() {
|
||||
async function save() {
|
||||
console.log('save');
|
||||
const isPas= conInfos.value.every(v=>{
|
||||
return v.conInfoId&&v.conUnit&&v.surplusStock>0
|
||||
})
|
||||
console.log(isPas);
|
||||
return
|
||||
let ajaxData = ''
|
||||
let isPas=false
|
||||
if(!isBindGuige.value){
|
||||
//绑定至商品
|
||||
isPas = conInfos.value.every(v => {
|
||||
return v.conInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
}else{
|
||||
//绑定至规格
|
||||
isPas = skuList.value.filter(v=>v.haoCaiList&&v.haoCaiList.length).every(sku => {
|
||||
console.log(sku.haoCaiList);
|
||||
return sku.haoCaiList.every(v=>{
|
||||
return v.conInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (!isPas) {
|
||||
return infoBox.showToast('请填写全部耗材选项值')
|
||||
}
|
||||
let ajaxData = {
|
||||
productId: props.goods.id,
|
||||
cons: []
|
||||
}
|
||||
if (!isBindGuige.value) {
|
||||
//绑定至商品
|
||||
ajaxData = conInfos.value.map(v => {
|
||||
ajaxData.cons = conInfos.value.map(v => {
|
||||
return {
|
||||
id: v.id || '',
|
||||
conInfoId: v.conInfoId,
|
||||
productId: props.goods.id,
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
productSkuId: 0,
|
||||
surplusStock: v.surplusStock
|
||||
surplusStock: v.surplusStock * 1,
|
||||
status: 1
|
||||
}
|
||||
})
|
||||
} else {
|
||||
for(let i in skuList.value){
|
||||
const haocaiList=skuList.value[i].haoCaiList||[]
|
||||
for(let k in haocaiList){
|
||||
const v=haocaiList[k]
|
||||
ajaxData.cons.push({
|
||||
id: v.id || '',
|
||||
conInfoId: v.conInfoId,
|
||||
productId: props.goods.id,
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
productSkuId: skuList.value[i].id,
|
||||
surplusStock: v.surplusStock * 1,
|
||||
status: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
console.log(ajaxData);
|
||||
$tbProskuConV2(ajaxData)
|
||||
await $tbProskuConV2(ajaxData)
|
||||
emits('updateGoods')
|
||||
infoBox.showToast('修改成功')
|
||||
}
|
||||
|
||||
let haoCaiList = ref([])
|
||||
@@ -303,12 +367,11 @@
|
||||
|
||||
function init() {
|
||||
gettbConsInfo({
|
||||
page: 0,
|
||||
size: 200
|
||||
"status": 1,
|
||||
}).then(res => {
|
||||
for (let i in res.content) {
|
||||
const item = res.content[i]
|
||||
$haocaiMap[item.consId] = item
|
||||
$haocaiMap[item.id] = item
|
||||
}
|
||||
haoCaiList.value = res.content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user