更新订单列表详情,更新商品管理,更新代客下单

This commit is contained in:
2024-09-23 17:39:38 +08:00
parent 90e3866524
commit edcf844adb
36 changed files with 5301 additions and 949 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
<template>
<view class="u-p-30 safe-page">
<up-sticky v-if="option.type==='edit'" offset-top="20" zIndex="99">
<myTabs :list="tabsList" @change="tabsChange"></myTabs>
<myTabs :list="tabsList" v-model="tabsCurrent"></myTabs>
</up-sticky>
<view class="box">
@@ -11,19 +11,30 @@
err-show-type="toast" validateTrigger="submit" label-width="350" ref="Forms">
<view class="block">
<uni-forms-item label="商品类型" required showRequired>
<view class="u-flex u-flex-wrap types " :class="{disabled:option.productId!==''}">
<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}"
v-for="(item,index) in pageData.types" :key="index">
<!-- <view class="gou u-flex u-row-right u-col-top u-p-t-4 u-p-r-4">
<uni-icons type="checkmarkempty" :size="8" color="#fff"></uni-icons>
</view> -->
<view class="title">{{item.title}}</view>
<view class="u-font-24 color-999 u-m-t-10">
{{item.desc}}
</view>
</view>
</view>
</view> -->
</uni-forms-item>
<uni-forms-item ref="fileItem" label="图片">
@@ -38,11 +49,6 @@
</uni-forms-item>
<template v-if="FormData.typeEnum!='group'">
<uni-forms-item label="所属分类" required showRequired name="categoryId">
<!-- <picker @change="bindPickerChange"
range-key="name"
:value="pageData.category" :range="pageData.category">
<view class="uni-input">请选择分类</view>
</picker> -->
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
placeholder="请选择分类" popup-title="请选择分类" :localdata="pageData.category"
v-model="FormData.categoryId">
@@ -50,10 +56,6 @@
</uni-forms-item>
</template>
<!-- <uni-forms-item label="产品编码">
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
:inputBorder="inputBorder" v-model="FormData.goodsCode" placeholder="请输入商品编码" />
</uni-forms-item> -->
<view class="border-top-0">
<uni-forms-item label="商品描述">
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
@@ -726,161 +728,27 @@
</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 class="color-red">删除该商品</view>
</my-button>
</view>
<view class="bootom">
<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 shape="circle" type="cancel" bgColor="#fff">
<!-- <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>
<!-- <text>删除该商品</text> -->
</view>
</view> -->
</view>
</view>
</template>
<template v-if="tabsCurrent===1">
<view class="stock">
<uni-forms :border="false" err-show-type="toast" validateTrigger="submit" ref="Forms1">
<!-- <view class="block ">
<uni-forms-item label="" required>
<view class="u-flex">
<view class="label-title">库存模式</view>
<view class="u-flex-1 u-p-l-100">
<uni-data-checkbox v-model="stockData.inventoryMode"
:localdata="InventoryModeData"></uni-data-checkbox>
</view>
</view>
</uni-forms-item>
</view> -->
<view class="block ">
<uni-forms-item label="">
<view class="u-flex u-row-between">
<view class="label-title">库存开关</view>
<my-switch v-model="FormData.isStock"
@change="updateProductStatus(FormData.id,'isStock')"></my-switch>
</view>
</uni-forms-item>
</view>
<view class="block ">
<uni-forms-item label="">
<view class="u-flex u-row-between">
<view class="label-title">共享库存</view>
<my-switch v-model="FormData.isDistribute"
@change="updateProductStatus(FormData.id,'isDistribute')"></my-switch>
</view>
</uni-forms-item>
</view>
<view class="block ">
<uni-forms-item label="">
<view class="u-flex u-row-between">
<view class="label-title">售罄</view>
<my-switch v-model="FormData.isPauseSale"
@change="updateProductStatus(FormData.id,'isPauseSale')"></my-switch>
</view>
</uni-forms-item>
</view>
<template v-if="FormData.typeEnum!=='sku'">
<view class="block ">
<uni-forms-item label="">
<view class="u-flex u-row-between">
<view class="label-title">上架</view>
<my-switch v-model="FormData.isGrounding"
@change="updateProductStatus(FormData.id,'isGrounding')"></my-switch>
</view>
</uni-forms-item>
</view>
<view class="block default-box-padding">
<view class="u-flex">
<view class="">
<my-button @tap="toRecoders" :height="60">库存记录</my-button>
</view>
<view class="u-m-l-40">
<my-button :height="60" @tap="toCheck">库存盘点</my-button>
</view>
</view>
</view>
</template>
<template v-else>
<view class="block default-box-padding">
<view class="u-flex">
<view class="">
<my-button @tap="toRecoders" :height="60">库存记录</my-button>
</view>
</view>
</view>
<view class="u-text-center block">
<view class="u-flex font-bold u-m-t-30 u-m-b-20">
<!-- <view class="u-flex-1">商品信息</view> -->
<view class="u-flex-1">规格</view>
<view class="u-flex-1">库存</view>
<view class="u-flex-1">售罄</view>
<view class="u-flex-1">上架</view>
<view class="u-flex-1">操作</view>
</view>
<view class="" v-for="(item,index) in pageData.skuList" :key="index">
<view class="u-flex u-p-b-12 u-p-t-12 ">
<view class="u-flex-1">{{item.specSnap}}</view>
<!-- <view class="u-flex-1">{{item.salePrice}}</view> -->
<view class="u-flex-1">{{item.stockNumber}}{{item.unitName}}</view>
<view class="u-flex-1 u-flex u-row-center"><my-switch v-model="item.isPauseSale"
@change="updateProductStatus(item.skuId,'isPauseSale')"></my-switch>
</view>
<view class="u-flex-1 u-flex u-row-center"><my-switch v-model="item.isGrounding"
@change="updateProductStatus(item.skuId,'isGrounding')"></my-switch>
</view>
<view class="u-flex u-row-center">
<my-button @tap="skuToCheck(item)" :width="120" :height="40">
<view class="u-font-24 no-wrap">库存盘点</view>
</my-button>
<!-- <my-button @tap="moreShow(item,index)" :width="100" :height="40">
<view class="u-font-24 no-wrap">更多</view>
</my-button> -->
</view>
</view>
</view>
</view>
</template>
<!-- <view class="block ">
<uni-forms-item label="" required>
<view class="u-flex">
<view class="label-title">剩余库存数量</view>
<view class="u-flex-1 u-p-l-40">
<uni-easyinput :paddingNone="inputPaddingNone"
:placeholderStyle="placeholderStyle" type="number"
:inputBorder="inputBorder" v-model="FormData.stockNumber"
placeholder="填写库存" />
</view>
</view>
</uni-forms-item>
</view> -->
<!-- <view class="block ">
<uni-forms-item label="" required>
<view class="u-flex">
<view class="label-title">库存模式</view>
<view class="u-flex-1 u-p-l-100">
<uni-data-checkbox v-model="stockData.inventoryReset"
:localdata="InventoryReset"></uni-data-checkbox>
</view>
</view>
</uni-forms-item>
</view> -->
</uni-forms>
<view class="btns">
<my-button shape="circle">保存</my-button>
<my-button shape="circle" type="default" @tap="back">取消</my-button>
</view>
</view>
<edit-haocai :goods="FormData" @cancel="changeTabsCurrent(0)"></edit-haocai>
</template>
</view>
@@ -894,11 +762,8 @@
</template>
</my-model>
</view>
<!-- 删除弹窗 -->
<my-model @confirm="delmodelConfirm" ref="delModel" desc="确认删除">
</my-model>
@@ -906,6 +771,9 @@
<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>
</template>
<script setup>
@@ -922,6 +790,7 @@
import myModel from '@/components/my-components/my-model'
import chooseGoods from './components/choose-goods'
import editHaocai from './components/edit-haocai.vue'
import chooseGroupCategory from './components/choose-coupon-category'
import myRadio from '@/components/my-components/my-radio'
import myUploadFile from '@/components/my-components/my-upload-file'
@@ -929,6 +798,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
@@ -1274,7 +1144,13 @@
}
const tabsList = ['基础设置', '库存设置']
const tabsList = ['基础设置', '耗材绑定']
let tabsCurrent = ref(0)
function changeTabsCurrent(newval){
tabsCurrent.value=newval
}
const Forms = ref(null)
@@ -1545,7 +1421,11 @@
//页面全部数据
const pageData = reactive({
// 商品类型
types: $types,
// types: $types,
types: [
{name:'单规格',value:'normal'},
{name:'多规格',value:'sku'}
],
// 单位
units: [],
// 分类
@@ -1597,14 +1477,7 @@
let tabsCurrent = ref(0)
function tabsChange(i) {
tabsCurrent.value = i
// if (tabsCurrent.value === 1 && option.type === 'add') {
// showModel('stockTips')
// }
}
let timer = null
@@ -1809,7 +1682,7 @@
watchTimerSave(false)
})
onReady(() => {
Forms.value.setRules(rules)
Forms.value&&Forms.value.setRules(rules)
})
watch(() => pageData.types, (newval) => {
Forms.value.setRules(rules)
@@ -1884,13 +1757,13 @@
position: fixed;
left: 110rpx;
right: 110rpx;
bottom: 110rpx;
bottom: 140rpx;
padding-bottom: env(safe-area-inset-bottom);
}
.box {
margin-top: 70rpx;
margin-top: 36rpx;
font-size: 28rpx;
.block {
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;

View File

@@ -0,0 +1,159 @@
<template>
<view class="u-relative choose-haocai">
<view class="input u-flex" @click="toggle" >
<up-input @blur="blur" @change="filterHaocaiList" border="none" v-model="text" placeholder="请选择"></up-input>
<up-icon :size="10" name="arrow-down-fill"></up-icon>
</view>
<view class="u-absolute" v-if="popShow">
<scroll-view scroll-y="true" class="scroll">
<view class="item" v-for="(item,index) in $haocaiList" :key="index" @click="haocaiClick(item,index)">
{{item.name}}
</view>
<view class="item no-wrap" @click="toggle" v-if="text&&!$haocaiList.length">没有该单位</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted
} from 'vue';
const props = defineProps({
listMap: {
type: Object,
default: () => {}
},
list: {
type: Array,
default: () => []
},
modelValue: {
type: [String, Number],
default: ''
},
show: {
type: Boolean,
default: false
},
})
let text = ref('')
let popShow = ref(props.show)
const emits = defineEmits(['update:show', 'close', 'confirm', 'update:modelValue'])
function close() {
popShow.value = false
}
function confirm() {
popShow.value = false
}
watch(() => props.show, (newval) => {
popShow.value = newval
})
watch(() => popShow.value, (newval) => {
console.log(newval);
emits('update:show', newval)
})
let $haocaiList = ref(props.list)
watch(() => props.list, (newval) => {
$haocaiList.value = newval
setText()
})
watch(() => props.modelValue, (newval) => {
console.log(newval);
setText()
})
function setText() {
// const item = props.listMap[props.modelValue]
// text.value = item ? item.name : ''
text.value=props.modelValue
}
function toggle(e) {
popShow.value = !popShow.value
}
function filterHaocaiList(e) {
if (e === '') {
return $haocaiList.value = props.list
}
const arr = props.list.filter(v => v.name.match(e))
$haocaiList.value = arr
}
function haocaiClick(item, index) {
console.log(item);
// if (item.id != props.modelValue) {
// emits('update:modelValue', item.id)
// }
if(item.name!=props.modelValue){
emits('update:modelValue', item.name)
}
popShow.value = false
}
function focus(){
console.log('focus');
popShow.value = true
}
function blur() {
console.log('blur');
setTimeout(()=>{
popShow.value = false
},100)
}
onMounted(() => {
setText()
})
</script>
<style lang="scss" scoped>
.choose-haocai {
.input {
width: 172rpx;
padding: 10rpx 16rpx;
height: 60rpx;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
display: flex;
align-items: center;
justify-content: space-between;
border: 2rpx solid #E5E5E5;
overflow: hidden;
}
.u-absolute {
top: calc(100% + 10rpx);
border: 1px solid #E5E5E5;
left: 0;
background-color: #fff;
z-index: 10;
right: 0;
border-radius: 8rpx;
.scroll {
$line-h: 60rpx;
max-height: calc($line-h * 4);
.item {
line-height: $line-h;
padding: 0 20rpx;
}
}
}
}
</style>

View File

@@ -0,0 +1,57 @@
<template>
<up-popup :round="10" :show="popShow" :closeable="true" @close="close">
<view class="u-text-center font-bold u-font-32 u-p-t-30">选择状态</view>
<view style="height: 20rpx;"></view>
<view class="u-p-30 all-list u-flex u-flex-wrap gap-20">
<view class="all-list-item" :class="{active:statusItemIndex==statusData.allListSel}" @click="changeAllListSel(statusItemIndex)" v-for="(statusItem,statusItemIndex) in statusData.allList" :key="statusItemIndex">
{{statusItem.label}}
</view>
</view>
<view class="u-flex u-p-t-30 u-p-b-30 u-p-l-20 u-p-r-20 gap-20">
<up-button @click="close">取消</up-button>
<up-button type="primary" @click="confirm">确定</up-button>
</view>
</up-popup>
</template>
<script setup>
import { ref, watch } from 'vue';
const props=defineProps({
show:{
type:Boolean,
default:false
}
})
let popShow=ref(props.show)
const emits=defineEmits(['update:show','close','confirm'])
function close(){
popShow.value=false
}
function confirm(){
popShow.value=false
}
watch(()=>props.show,(newval)=>{
popShow.value=newval
})
watch(()=>popShow.value,(newval)=>{
emits('update:show',newval)
})
</script>
<style lang="scss" scoped>
.all-list-item{
text-align: center;
width: 156rpx;
white-space: nowrap;
color: #666;
padding: 10rpx 20rpx;
border-radius: 8rpx;
transition: all .2s ease-in-out;
border: 1px solid #eee;
&.active {
color: $my-main-color;
border-color: $my-main-color;
}
}
</style>

View File

@@ -0,0 +1,149 @@
<template>
<view class="u-relative choose-haocai">
<view class="input u-flex" @click="toggle">
<!-- <view>
<text v-if="modelValue">{{modelValue}}</text>
<text v-else class="color-666">请选择</text>
</view> -->
<up-input @blur="blur" @change="filterHaocaiList" border="none" v-model="text" placeholder="请选择"></up-input>
<up-icon :size="10" name="arrow-down-fill"></up-icon>
</view>
<view class="u-absolute" v-if="popShow">
<scroll-view scroll-y="true" class="scroll">
<view class="item" v-for="(item,index) in $haocaiList" :key="index" @click="haocaiClick(item,index)">
{{item.conName}}
</view>
<view class="item no-wrap" @click="toggle" v-if="text&&!$haocaiList.length">没有该耗材</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted
} from 'vue';
const props = defineProps({
listMap: {
type: Object,
default: () => {}
},
list: {
type: Array,
default: () => []
},
modelValue: {
type: [String, Number],
default: ''
},
show: {
type: Boolean,
default: false
},
})
let text = ref('')
let popShow = ref(props.show)
const emits = defineEmits(['update:show', 'close', 'confirm', 'update:modelValue','change'])
function close() {
popShow.value = false
}
function confirm() {
popShow.value = false
}
watch(() => props.show, (newval) => {
popShow.value = newval
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
let $haocaiList = ref(props.list)
watch(() => props.list, (newval) => {
$haocaiList.value = newval
setText()
})
watch(() => props.modelValue, (newval) => {
setText()
})
function setText() {
const item = props.listMap[props.modelValue]
text.value = item ? item.conName : ''
}
function toggle(e) {
popShow.value = !popShow.value
}
function filterHaocaiList(e) {
if (e === '') {
return $haocaiList.value = props.list
}
const arr = props.list.filter(v => v.conName.match(e))
$haocaiList.value = arr
}
function haocaiClick(item, index) {
console.log(item);
if (item.consId != props.modelValue) {
emits('update:modelValue', item.consId)
emits('change', item)
}
popShow.value = false
}
function blur() {
setTimeout(()=>{
popShow.value = false
},100)
}
onMounted(() => {
setText()
})
</script>
<style lang="scss" scoped>
.choose-haocai {
.input {
width: 172rpx;
padding: 10rpx 16rpx;
height: 60rpx;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
display: flex;
align-items: center;
justify-content: space-between;
border: 2rpx solid #E5E5E5;
overflow: hidden;
}
.u-absolute {
top: calc(100% + 10rpx);
border: 1px solid #E5E5E5;
left: 0;
background-color: #fff;
z-index: 10;
right: 0;
border-radius: 8rpx;
.scroll {
$line-h: 60rpx;
max-height: calc($line-h * 4);
.item {
line-height: $line-h;
padding: 0 20rpx;
}
}
}
}
</style>

View File

@@ -0,0 +1,359 @@
<template>
<view>
<view class="default-box-padding bg-fff border-r-18">
<view class="u-flex u-row-between">
<view>商品名称</view>
<template v-if="isSku">
<view class="u-flex u-font-24 color-666">
<view class="u-m-r-20">绑定至规格</view>
<up-switch :size="18" v-model="isBindGuige" :disabled="!isSku">绑定至规格</up-switch>
</view>
</template>
</view>
<view class="border-bottom u-m-t-16 u-p-b-32">{{goods.name}}</view>
<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>规格名称</view>
<view class="u-m-t-16">{{item.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">
<view class="u-flex-1">耗材名称</view>
<view class="u-flex-1">单位</view>
<view class="u-flex-1">用量</view>
</view>
</view>
<view class="u-m-t-32 color-666">
<view class="u-m-t-24" v-for="(haocai,haocaiIndex) in item.haoaiList"
: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>
</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>
</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>
</view>
</view>
<view class="u-flex u-m-t-16 color-666 u-font-24">
<view class="xuhao">
</view>
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存{{item.stockNumber}}
</view>
</view>
</view>
</view>
<view class="u-flex">
<view class=" u-p-t-32 u-flex" @click="addGuigeHaocai(index)">
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
<view class="u-m-l-16">添加耗材</view>
</view>
</view>
</view>
</view>
</template>
<template v-else>
<view class="list">
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(item,index) in conInfos" :key="index">
<view class="color-666 u-flex">
<view class="xuhao">序号</view>
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
<view class="u-flex-1">耗材名称</view>
<view class="u-flex-1">单位</view>
<view class="u-flex-1">用量</view>
</view>
</view>
<view class="u-m-t-32 color-666">
<view class=" u-m-t-24 u-flex">
<view class="xuhao">{{index+1}}</view>
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
<view class="u-flex-1 ">
<choose-haocai @change="conInfosChange($event,item)" :listMap="$haocaiMap"
:list="haoCaiList" v-model="item.conInfoId"></choose-haocai>
<!-- <view class="u-flex input">
<view>{{item.conName}}</view>
<up-icon :size="10" name="arrow-down-fill"></up-icon>
</view> -->
</view>
<view class="u-flex-1 ">
<choose-danwei :listMap="$danweiMap" :list="danweiList"
v-model="item.conUnit"></choose-danwei>
<!-- <view class="u-flex input">
<view>{{item.conUnit}}</view>
<up-icon :size="10" name="arrow-down-fill"></up-icon>
</view> -->
</view>
<view class="u-flex-1 ">
<view class="u-flex input">
<up-input border="none" v-model="item.surplusStock"></up-input>
<up-icon @click="delHaocai(index)" color="#EB4F4F" :size="16"
name="minus-circle-fill"></up-icon>
</view>
</view>
</view>
</view>
<view class="u-flex u-m-t-16 u-font-24" v-if="item.stockNumber">
<view class="xuhao">
</view>
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存{{item.stockNumber}}
{{item.conUnit}}
</view>
</view>
</view>
</view>
</view>
</template>
<template v-if="!isBindGuige">
<view class="u-flex">
<view class=" u-p-t-32 u-flex" @click="addHaocai">
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
<view class="u-m-l-16">添加耗材</view>
</view>
</view>
</template>
</view>
</view>
<view class="default-box-padding bg-fff border-r-18 u-flex u-row-between u-m-t-32">
<view>当某个耗材的使用库存不足时商品自动
售罄</view>
<view class="u-flex u-p-l-32">
<up-switch :size="20"></up-switch>
</view>
</view>
<view class="bottom">
<my-button type="primary" shape="circle" @click="save">保存</my-button>
<my-button bgColor="#F9F9F9" shape="circle" color="#999" @click="cancel">取消</my-button>
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
toRefs,
watch,
computed,
onMounted
}
from 'vue';
import {
getviewConSku,
gettbProductSpec,
gettbConsInfo,
posttbProskuCons,
puttbProskuCon,
deletetbProskuCon,
} from "@/http/yskApi/consumable.js";
import {
tbShopCurrencyGet,$hasPermission
} from '@/http/yskApi/shop.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(){
emits('cancel')
}
const props = defineProps({
goods: {
type: Object,
default: () => {
return {
conInfos: [],
skuList: [],
typeEnum: ''
}
}
}
})
const conInfos = ref(props.goods.conInfos)
watch(() => props.goods.conInfos, (newval) => {
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
})
function addHaocai() {
conInfos.value.push({
conInfoId: '',
conUnit: '',
surplusStock: ''
})
}
const popup = reactive({
haocai: {
show: true
}
})
function addGuigeHaocai(index) {
console.log(index);
}
function delHaocai(index) {
const item = conInfos.value[index]
uni.showModal({
title: '提示',
content: '是否删除该耗材',
success(res) {
if (res.confirm) {
if (item.id) {
deletetbProskuCon([item.id]).then(res1 => {
conInfos.value.splice(index, 1)
})
} else {
conInfos.value.splice(index, 1)
}
}
}
})
}
function delGuigeHaocao(guigeIndex, haocaiIndex) {
skuList.value[guigeIndex].haoaiList.splice(haocaiIndex, 1)
}
// 是否是多规格商品
const isSku = computed(() => {
return props.goods.typeEnum == 'sku'
})
let isBindGuige = ref(isSku.value)
watch(() => props.goods.typeEnum, (newval) => {
isBindGuige.value = isSku.value
})
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 = ''
if (!isBindGuige.value) {
//绑定至商品
ajaxData = conInfos.value.map(v => {
return {
conInfoId: v.conInfoId,
productId: props.goods.id,
shopId: uni.getStorageSync('shopId'),
productSkuId: 0,
surplusStock: v.surplusStock
}
})
} else {
}
console.log(ajaxData);
$tbProskuConV2(ajaxData)
}
let haoCaiList = ref([])
let $haocaiMap = reactive({})
let danweiList = ref([])
let $danweiMap = reactive({})
function init() {
gettbConsInfo({
page: 0,
size: 200
}).then(res => {
for (let i in res.content) {
const item = res.content[i]
$haocaiMap[item.consId] = item
}
haoCaiList.value = res.content
})
tbShopCurrencyGet({
page: 0,
size: 200
}).then(res => {
for (let i in res.content) {
const item = res.content[i]
$danweiMap[item.id] = item
}
danweiList.value = res.content
})
}
onMounted(() => {
init()
})
</script>
<style lang="scss" scoped>
.bottom {
padding: 84rpx 82rpx;
}
.xuhao {
width: 52rpx;
white-space: nowrap;
}
.input {
width: 172rpx;
padding: 10rpx 16rpx;
height: 60rpx;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
display: flex;
align-items: center;
justify-content: space-between;
border: 2rpx solid #E5E5E5;
overflow: hidden;
}
.list .border-bottom:last-child {
border: none;
}
</style>

View File

@@ -0,0 +1,499 @@
<template>
<view class="page">
<view class="box">
<view class="block border-top-0">
<uni-forms ref="nameFormRef" :model="specifications" :rules="rules" :label-width="350"
label-position="top" validateTrigger="blur">
<uni-forms-item label="模版名称" required name="name">
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="specifications.name" placeholder="模版名称,如:衣服" />
</uni-forms-item>
</uni-forms>
</view>
<view v-for="(item,index) in specifications.list" :key="index">
<uni-forms :model="item" :rules="rules" err-show-type="undertext" validateTrigger="blur"
:ref="setFormRef(index)" :border="true" label-position="top" label-width="350">
<view class="block">
<view class="border-top-0">
<uni-forms-item label="规格组名" required name="name">
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.name" placeholder="规格组名,如:尺码" />
</uni-forms-item>
</view>
<uni-forms-item label="规格值">
<view class="option">
<view class="">
<view class="u-flex option-item" v-for="(option,optionIndex) in item.options"
:key="optionIndex">
<view class="u-flex-1">
<uni-forms-item :key="optionIndex" :name="['options',optionIndex,'name']"
:ref="setFormInputRef(index,optionIndex)"
:rules="[{'required': true,errorMessage: '必填'}]" label-width="0"
label="" required :showRequired="false">
<uni-easyinput
v-model="specifications.list[index].options[optionIndex].name"
@input="inpuChange(index,optionIndex)"
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
placeholder="请输入规格值,如:S、M" />
</uni-forms-item>
</view>
<view class=" u-flex">
<uni-forms-item :key="optionIndex" label-width="0" label=""
:showRequired="false">
<view class="u-flex">
<!-- <uni-easyinput v-model="specifications.list[index].options[optionIndex].optionPrice"
@input="inpuChange(index,optionIndex)"
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
type="digit" placeholder="填写价格" /> -->
<view class="icon icon-reduce u-m-l-38"
@click="delOption(index,optionIndex)">
</view>
</view>
</uni-forms-item>
</view>
</view>
</view>
<view class="u-flex" @click="addOptions(index)">
<view class="icon icon-add u-m-r-22 ">
</view>
<view class="color-main">添加规格</view>
</view>
</view>
</uni-forms-item>
<view class="u-flex u-m-t-48 u-m-b-24" @click="delSpecificationsGroup(index)">
<view class="icon icon-reduce u-m-r-22 ">
</view>
<view class="color-red">删除规格组</view>
</view>
</view>
</uni-forms>
</view>
<view class="u-flex block u-p-l-20 u-p-r-20 u-p-t-28 u-p-b-28" @click="addSpecificationsGroup">
<view class="icon icon-add u-m-r-22 ">
</view>
<view class="color-main">添加规格组</view>
</view>
<view class="save-btn-box">
<button class="save-btn" hover-class="btn-hover-class" @click="save">保存</button>
</view>
</view>
<view class="bottom" ref="bottom"></view>
</view>
</template>
<script setup>
import go from '@/commons/utils/go.js';
import {
$productSpec
} from '@/http/yskApi/goods.js'
import {
onLoad,
onReady,
} from '@dcloudio/uni-app';
import infoBox from '@/commons/utils/infoBox.js'
import {
onMounted,
reactive,
nextTick,
ref,
onBeforeMount
} from 'vue';
const nameFormRef = ref(null)
// 表单样式
const placeholderStyle = ref('font-size:28rpx;')
//表单边框
const inputBorder = ref(false)
const form = ref(null)
const bottom = ref(null)
//表单验证
const rules = {
name: {
rules: [{
required: true,
errorMessage: '必填'
}]
},
MinOptional: {
rules: [{
required: true,
errorMessage: '必填'
}]
},
MaxOptional: {
rules: [{
required: true,
errorMessage: '必填'
}]
},
optionPrice: {
rules: [{
required: true,
errorMessage: '必填'
}]
}
}
// 构造规格的选项值的基础数据
const specificationsOptionsBasicData = {
name: '',
optionPrice: '0.00'
}
function returnOptionsBasicData() {
return {
...specificationsOptionsBasicData
}
}
// 构造规格的基础数据
const specificationsBasicData = {
name: '',
// MinOptional: 1,
// MaxOptional: 1,
options: []
}
function returnSpecificationsOptionsBasicData() {
return {
...specificationsBasicData,
options: [returnOptionsBasicData()]
}
}
function onFieldChange(e) {
console.log(e);
}
// 规格列表
const specifications = reactive({
name: '',
list: [returnSpecificationsOptionsBasicData()]
})
//添加规格组
function addSpecificationsGroup() {
specifications.list.push(returnSpecificationsOptionsBasicData())
scrollPageBottom()
}
//删除规格组
function delSpecificationsGroup(index) {
specifications.list.splice(index, 1)
}
// 向指定索引的规格组添加规格项
function addOptions(index) {
specifications.list[index].options.push(returnOptionsBasicData())
}
// 删除指定索引的规格组添加规格项
function delOption(index, optionIndex) {
specifications.list[index].options.splice(optionIndex, 1)
}
//页面滚动到最底部
function scrollPageBottom() {
nextTick(() => {
uni.pageScrollTo({
duration: 100, // 过渡时间
scrollTop: 100000, // 滚动的实际距离
})
})
}
//设置表单验证规则
function setFormRules() {
form.value.setRules(rules)
}
const formRefs = ref([]);
//绑定表单元素
function setFormRef(index) {
formRefs.value[index] = null;
return (el) => {
if (el) {
formRefs.value[index] = el;
}
};
}
// 绑定option input元素
const refFormInput = ref([])
function setFormInputRef(index, index1) {
const newIndex = index * 10000 + index1
return (el) => {
if (el) {
if (!refFormInput.value[newIndex]) {
refFormInput.value[newIndex] = el;
}
}
}
}
// 当表单内容输入变化根据配置的rules进行验证
function inpuChange(index, index1) {
const newIndex = index * 10000 + index1
console.log(refFormInput.value[newIndex]);
refFormInput.value[newIndex].onFieldChange()
}
const option = {
type: 'add',
id: undefined
}
onLoad(opt => {
console.log(opt);
if (opt && JSON.stringify(opt) !== '{}' && opt.type) {
option.type = opt.type
const data = uni.getStorageSync('spec')
uni.removeStorageSync('spec')
if(data){
specifications.name = data.name
specifications.id = data.id
specifications.list = data.specList.map(v => {
return {
...v,
options: v.value.map(v => {
return {
name: v
}
})
}
})
}
}
uni.setNavigationBarTitle({
title: option.type === 'edit' ? '编辑规格模版' : '添加规格模版'
})
})
function returnPromise(prosise, index) {
return new Promise((resolve, reject) => {
prosise.then(res => {
console.log(res);
resolve({
sucees: true
})
}).catch(err => {
console.log(err);
resolve({
sucees: false
})
})
})
}
let timer = null
function settimeoutBack(time) {
clearTimeout(timer)
timer = setTimeout(() => {
uni.navigateBack()
}, time)
}
async function save() {
let isAllPassForm = 0
const nameFormRes = await returnPromise(nameFormRef.value.validate())
console.log(nameFormRes);
if (!nameFormRes.sucees) {
isAllPassForm -= 1
}
for (let i in specifications.list) {
const res = await returnPromise(formRefs.value[i].validate(), i)
isAllPassForm += res.sucees ? 1 : 0
}
//判断验证是否通过
if (isAllPassForm === specifications.list.length) {
console.log('pass');
const data = {
name: specifications.name,
id:specifications.id,
specList: specifications.list.map(v => {
return {
...v,
value: v.options.map(v => v.name),
options: undefined
}
})
}
if (option.type === 'add') {
return $productSpec.add(data).then(res => {
infoBox.showSuccessToast('添加成功')
settimeoutBack(1500)
})
}
$productSpec.update(data).then(res => {
infoBox.showSuccessToast('修改成功')
settimeoutBack(1500)
})
}
}
</script>
<style scoped>
page {
background: #F9F9F9;
}
</style>
<style lang="scss" scoped>
$icon-size: 34rpx;
$icon-line-width: 20rpx;
$icon-line-height: 4rpx;
.page {
background: #F9F9F9;
padding: 30rpx;
padding-bottom: 200rpx;
}
.my-switch {
transform: scale(0.7);
}
::v-deep .uni-forms-item__error {
display: none !important;
}
::v-deep .option .uni-forms-item {
padding: 0;
min-height: inherit;
background-color: transparent;
border-top: none;
}
.icon {
width: $icon-size;
height: $icon-size;
position: relative;
border-radius: 50%;
&:before,
&::after {
position: absolute;
display: block;
content: '';
background-color: #fff;
}
}
.icon-add {
background-color: $my-main-color;
&::before {
width: $icon-line-height;
height: $icon-line-width;
top: calc(($icon-size /2) - ($icon-line-width / 2));
left: calc(($icon-size /2) - ($icon-line-height / 2));
}
&::after {
width: $icon-line-width;
height: 4rpx;
top: calc(($icon-size /2) - ($icon-line-height / 2));
left: calc(($icon-size /2) - ($icon-line-width / 2));
}
}
.icon-reduce {
background-color: $my-red-color;
&::after {
width: $icon-line-width;
height: $icon-line-height;
top: calc(($icon-size /2) - ($icon-line-height / 2));
left: calc(($icon-size /2) - ($icon-line-width / 2));
}
}
.label-title {
font-size: 28rpx;
font-weight: bold;
font-family: Source Han Sans CN, Source Han Sans CN;
}
.lh40 {
line-height: 40rpx;
}
.box {
margin-top: 70rpx;
font-size: 28rpx;
.block {
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
padding: 12rpx 24rpx;
margin-bottom: 32rpx;
}
}
.save-btn-box {
position: fixed;
left: 30rpx;
right: 30rpx;
bottom: 60rpx;
}
::v-deep.uni-forms-item {
align-items: inherit;
}
::v-deep .uni-forms-item .uni-forms-item__label {
text-indent: 0;
font-size: 28rpx !important;
font-weight: bold;
color: #333;
}
::v-deep .border-top-0 .uni-forms-item.is-direction-top {
border-color: transparent !important;
}
.save-btn {
background-color: $my-main-color;
color: #fff;
border-radius: 12rpx;
font-size: 28rpx;
}
.btn-hover-class {
opacity: .6;
}
.zuofa {
padding: 28rpx 0;
background: #F9F9F9;
padding-left: 42rpx;
border-radius: 14rpx 14rpx 14rpx 14rpx;
}
::v-deep .uni-input-placeholder {
font-size: 28rpx;
}
.option {
padding: 26rpx 30rpx 24rpx 24rpx;
background: #F9F9F9;
}
.option-item {
margin-bottom: 34rpx;
}
</style>

View File

@@ -1,53 +1,62 @@
<template>
<view class="page">
<view class="box">
<view class="block border-top-0">
<uni-forms ref="nameFormRef" :model="specifications" :rules="rules" :label-width="350"
label-position="top" validateTrigger="blur">
<uni-forms-item label="模版名称" required name="name">
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="specifications.name" placeholder="模版名称,如:衣服" />
</uni-forms-item>
</uni-forms>
</view>
<view v-for="(item,index) in specifications.list" :key="index">
<uni-forms :model="item" :rules="rules" err-show-type="undertext" validateTrigger="blur"
:ref="setFormRef(index)" :border="true" label-position="top" label-width="350">
<view class="block">
<view class="border-top-0">
<uni-forms-item label="规格组名" required name="name">
<uni-forms-item label="规格组名" required name="name" >
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.name" placeholder="规格组名,如:尺码" />
v-model="item.name" placeholder="规格组名" />
</uni-forms-item>
</view>
<uni-forms-item label="规格值">
<!-- <uni-forms-item label="最少可选" required name="MinOptional" >
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.MinOptional" type="number" placeholder="填写最小数量" />
</uni-forms-item>
<uni-forms-item label="最大可选" required name="MaxOptional" >
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.MaxOptional" type="number" placeholder="填写最大数量" />
</uni-forms-item> -->
<uni-forms-item label="选项值">
<view class="option">
<view class="">
<view class="u-flex option-item" v-for="(option,optionIndex) in item.options"
:key="optionIndex">
<view class="u-flex">
<view class="u-flex-1">名称</view>
<view class="u-flex-1 u-p-l-60">加价</view>
</view>
<view class="u-m-t-32">
<view class="u-flex option-item"
v-for="(option,optionIndex) in item.options"
:key="optionIndex"
>
<view class="u-flex-1">
<uni-forms-item :key="optionIndex" :name="['options',optionIndex,'name']"
:ref="setFormInputRef(index,optionIndex)"
:rules="[{'required': true,errorMessage: '必填'}]" label-width="0"
label="" required :showRequired="false">
<uni-easyinput
v-model="specifications.list[index].options[optionIndex].name"
@input="inpuChange(index,optionIndex)"
<uni-forms-item :key="optionIndex" :name="['options',optionIndex,'optionName']"
:ref="setFormInputRef(index,optionIndex)"
:rules="[{'required': true,errorMessage: '必填'}]"
label-width="0" label="" required :showRequired="false"
>
<uni-easyinput v-model="specifications.list[index].options[optionIndex].optionName"
@input="inpuChange(index,optionIndex)"
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
placeholder="请输入规格值,如:S、M" />
placeholder="选项名" />
</uni-forms-item>
</view>
<view class=" u-flex">
<uni-forms-item :key="optionIndex" label-width="0" label=""
:showRequired="false">
<view class="u-p-l-60 u-flex-1 u-flex">
<uni-forms-item :key="optionIndex"
:rules="[{'required': true,errorMessage: '必填'}]"
:ref="setFormInputRef(index,optionIndex)"
:name="['options',optionIndex,'optionPrice']" label-width="0" label="" required :showRequired="false"
>
<view class="u-flex">
<!-- <uni-easyinput v-model="specifications.list[index].options[optionIndex].optionPrice"
<uni-easyinput v-model="specifications.list[index].options[optionIndex].optionPrice"
@input="inpuChange(index,optionIndex)"
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
type="digit" placeholder="填写价格" /> -->
type="digit" placeholder="填写价格" />
<view class="icon icon-reduce u-m-l-38"
@click="delOption(index,optionIndex)">
@@ -70,7 +79,7 @@
</view>
</uni-forms-item>
<view class="u-flex u-m-t-48 u-m-b-24" @click="delSpecificationsGroup(index)">
<view class="icon icon-reduce u-m-r-22 ">
@@ -97,14 +106,10 @@
<script setup>
import go from '@/commons/utils/go.js';
import {
$productSpec
} from '@/http/yskApi/goods.js'
import {
onLoad,
onReady,
onReady
} from '@dcloudio/uni-app';
import infoBox from '@/commons/utils/infoBox.js'
import {
onMounted,
reactive,
@@ -112,9 +117,8 @@
ref,
onBeforeMount
} from 'vue';
const nameFormRef = ref(null)
// 表单样式
const placeholderStyle = ref('font-size:28rpx;')
const placeholderStyle = ref('font-size:28rpx;')
//表单边框
const inputBorder = ref(false)
const form = ref(null)
@@ -139,6 +143,12 @@
errorMessage: '必填'
}]
},
optionName: {
rules: [{
required: true,
errorMessage: '必填'
}]
},
optionPrice: {
rules: [{
required: true,
@@ -147,10 +157,10 @@
}
}
// 构造规格的选项值的基础数据
const specificationsOptionsBasicData = {
name: '',
optionName: '',
optionPrice: '0.00'
}
@@ -162,8 +172,8 @@
// 构造规格的基础数据
const specificationsBasicData = {
name: '',
// MinOptional: 1,
// MaxOptional: 1,
MinOptional: 1,
MaxOptional: 1,
options: []
}
@@ -179,7 +189,6 @@
}
// 规格列表
const specifications = reactive({
name: '',
list: [returnSpecificationsOptionsBasicData()]
})
@@ -226,8 +235,7 @@
};
}
// 绑定option input元素
const refFormInput = ref([])
const refFormInput=ref([])
function setFormInputRef(index, index1) {
const newIndex = index * 10000 + index1
return (el) => {
@@ -244,104 +252,61 @@
console.log(refFormInput.value[newIndex]);
refFormInput.value[newIndex].onFieldChange()
}
const option = {
type: 'add',
id: undefined
let emitName=''
function triggerEvent (emitName,data){
if(emitName){
uni.$emit(emitName,data)
}
}
onLoad(opt => {
onLoad(opt=>{
const arr=uni.getStorageSync('guige')
if(arr.length){
specifications.list=arr
console.log(arr);
}
console.log(opt);
if (opt && JSON.stringify(opt) !== '{}' && opt.type) {
option.type = opt.type
const data = uni.getStorageSync('spec')
uni.removeStorageSync('spec')
if(data){
specifications.name = data.name
specifications.id = data.id
specifications.list = data.specList.map(v => {
return {
...v,
options: v.value.map(v => {
return {
name: v
}
})
}
})
}
if(opt&&JSON.stringify(opt)!=='{}'&&opt.emitName){
emitName=opt.emitName
}
uni.setNavigationBarTitle({
title: option.type === 'edit' ? '编辑规格模版' : '添加规格模版'
title:emitName?'编辑规格模版':'添加规格模版'
})
})
function returnPromise(prosise, index) {
return new Promise((resolve, reject) => {
prosise.then(res => {
function emitspecificationsSave(){
// emitspecificationsSave 触发规格保存事件将数据给到添加商品页面
// guigeEdit 触发规格保存事件将数据给到添加规格页面
uni.removeStorageSync('guige')
triggerEvent(emitName,specifications.list)
}
function returnPromise(index,prosise){
return new Promise((resolve,reject)=>{
prosise.then(res=>{
console.log(res);
resolve({
sucees: true
})
}).catch(err => {
resolve({sucees:true})
}).catch(err=>{
console.log(err);
resolve({
sucees: false
})
resolve({sucees:false})
})
})
}
let timer = null
function settimeoutBack(time) {
clearTimeout(timer)
timer = setTimeout(() => {
uni.navigateBack()
}, time)
}
async function save() {
let isAllPassForm = 0
const nameFormRes = await returnPromise(nameFormRef.value.validate())
console.log(nameFormRes);
if (!nameFormRes.sucees) {
isAllPassForm -= 1
}
async function save() {
let isAllPassForm=0
for (let i in specifications.list) {
const res = await returnPromise(formRefs.value[i].validate(), i)
isAllPassForm += res.sucees ? 1 : 0
const res=await returnPromise(i,formRefs.value[i].validate())
isAllPassForm+=res.sucees?1:0
}
//判断验证是否通过
if (isAllPassForm === specifications.list.length) {
if(isAllPassForm===specifications.list.length){
console.log('pass');
const data = {
name: specifications.name,
id:specifications.id,
specList: specifications.list.map(v => {
return {
...v,
value: v.options.map(v => v.name),
options: undefined
}
})
}
if (option.type === 'add') {
return $productSpec.add(data).then(res => {
infoBox.showSuccessToast('添加成功')
settimeoutBack(1500)
})
}
$productSpec.update(data).then(res => {
infoBox.showSuccessToast('修改成功')
settimeoutBack(1500)
})
emitspecificationsSave()
go.back()
}
}

View File

@@ -0,0 +1,134 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9" :zIndex="999">
<view class="u-p-32 box u-font-28">
<view class="u-flex u-relative u-row-center">
<view class="u-font-32">报损</view>
<view class="u-absolute close">
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
</view>
</view>
<view class="u-m-t-48">
<view>商品名称</view>
<view class="u-m-t-16">{{data.name}}</view>
<view class="u-m-t-38">
<view class="u-m-b-32">
<view class="u-flex ">
报损数量
</view>
<view class="u-m-t-16">
<up-input v-model="form.number">
<template #suffix>
<view>{{data.unitName}}</view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>上传图片</view>
</view>
<view class="u-m-t-16">
<scroll-view scroll-y="true" style="max-height: 300rpx;">
<my-up-upload v-model="form.images"></my-up-upload>
</scroll-view>
</view>
</view>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
保存
</view>
</my-button>
</view>
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$tbShopUnit
} from '@/http/yskApi/goods.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
skuList: []
}
}
})
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
note: '',
number: 1,
images: []
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = props.goods
}
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
function save() {
console.log(form.images);
}
</script>
<style lang="scss" scoped>
.box {
width: 556rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>

View File

@@ -0,0 +1,141 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
<view class="u-p-32 box u-font-28">
<view class="u-flex u-relative u-row-center">
<view class="u-font-32">{{data.specSnap}}</view>
<view class="u-absolute close">
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
</view>
</view>
<view class="u-m-t-48">
<view class="u-flex u-row-between border-bottom u-p-b-30">
<view>当前状态</view>
<view class="u-flex">
<up-radio-group v-model="isGrounding" placement="row" @change="isGroundingChange">
<up-radio :customStyle="{marginRight: '10px'}" v-for="(item, index) in status.list"
:key="index" :label="item.label" :name="item.name">
</up-radio>
</up-radio-group>
</view>
</view>
<view class=" u-flex u-row-between u-m-t-30">
<view>售罄</view>
<up-switch :size="20" @change="isPauseSaleChange" v-model="isPauseSale"></up-switch>
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$updateGrounding, $updateProductStatus
} from '@/http/yskApi/goods.js'
import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
skuList: []
}
}
})
const status = reactive({
list: [{
name: 1,
label: '上架中'
}, {
name: 0,
label: '已下架'
}],
})
// 是否售罄
const isPauseSale = ref(false)
// 是否上架
const isGrounding = ref(1)
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save', 'isGroundingChange','isPauseSaleChange'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
console.log(props.goods);
data.value = props.goods
isPauseSale.value = props.goods.isPauseSale ? true : false
isGrounding.value = props.goods.isGrounding
}
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
function save() {
emits('save')
}
async function isGroundingChange(e) {
console.log(e);
await $updateGrounding({
isGrounding: e ? true : false,
skuId: props.goods.id
})
emits('isGroundingChange', e)
infoBox.showToast('更新成功')
}
async function isPauseSaleChange(e) {
console.log(e);
await $updateProductStatus({
targetId: props.goods.id,
updateKey: "pauseSaleSku",
updateValue: e?1:0
})
emits('isPauseSaleChange', e)
infoBox.showToast('更新成功')
}
</script>
<style lang="scss" scoped>
.box {
width: 556rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>

View File

@@ -0,0 +1,186 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
<view class="u-p-32 box u-font-28">
<view class="u-flex u-relative u-row-center">
<view class="u-font-32">修改价格</view>
<view class="u-absolute close">
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
</view>
</view>
<view class="u-m-t-48">
<view>商品名称</view>
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
<view class="u-m-t-38">
<template v-if="!isSku">
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>{{data.name}}</view>
<view class="u-font-24">
<text>变动金额</text>
<text class="number">{{data.lowPrice-data._lowPrice}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input v-model="data.lowPrice">
<template #suffix>
<view></view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</template>
<template v-else>
<scroll-view scroll-y="true" style="max-height: 50vh;">
<view class="u-m-b-32" v-for="(item,index) in data.skuList" :key="index">
<view class="u-flex u-row-between">
<view>{{item.name}}</view>
<view class="u-font-24">
<text>变动金额</text>
<text class="number">{{item.lowPrice-item._lowPrice}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input v-model="item.lowPrice">
<template #suffix>
<view></view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</scroll-view>
</template>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
保存
</view>
</my-button>
</view>
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
computed,
reactive,
ref,
watch
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
return {
lowPrice:0,
skuList: []
}
}
}
})
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = props.goods
}
})
const isSku=computed(()=>{
return data.value.typeEnum=='多规格'
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
function save() {
emits('save', {
...data.value,
})
}
// function save() {
// const skuSnap = returnSkuSnap(data.value)
// let typeEnum = returnTypeEnum(data.value.typeEnum)
// let lowPrice = undefined
// typeEnum = typeEnum ? typeEnum : 'normal'
// const findCategory = returnCategory(data.value.categoryName, props.category)
// console.log(typeEnum);
// console.log(findCategory);
// const categoryId = findCategory ? findCategory.id : ''
// if (typeEnum == 'normal') {
// // 单规格
// lowPrice = data.value.skuList[0].salePrice
// }
// emits('save', {
// ...data.value,
// lowPrice,
// typeEnum,
// images: data.value.images ? data.value.images : [data.value.coverImg],
// categoryId,
// skuSnap: JSON.stringify(skuSnap)
// })
// }
</script>
<style lang="scss" scoped>
.box {
width: 556rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>

View File

@@ -0,0 +1,235 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
<view class="u-p-32 box u-font-28">
<view class="u-flex u-relative u-row-center">
<view class="u-font-32">修改库存</view>
<view class="u-absolute close">
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
</view>
</view>
<view class="u-m-t-48">
<view>商品名称</view>
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
<view class="u-m-t-38">
<template v-if="!isSku">
<view class="u-m-b-32" >
<view class="u-flex u-row-between">
<view>{{data.name}}</view>
<view class="u-font-24">
<text>变动数量</text>
<text class="number">{{data.stockNumber-data._stockNumber}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input v-model="data.stockNumber">
<template #suffix>
<view>{{data.unitName||''}}</view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</template>
<template v-else>
<scroll-view scroll-y="true" style="max-height: 30vh;">
<view class="u-m-b-32" v-for="(item,index) in data.skuList" :key="index">
<view class="u-flex u-row-between">
<view>{{item.name}}</view>
<view class="u-font-24">
<text>变动数量</text>
<text class="number">{{item.stockNumber-item._stockNumber}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input v-model="item.stockNumber">
<template #suffix>
<view>{{data.unitName||''}}</view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</scroll-view>
</template>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
保存
</view>
</my-button>
<view class="u-m-t-30">
<template v-if="!recoders.show">
<view class="color-999 u-font-24 u-flex u-row-center u-col-center">
<view class="u-flex" @click="changeShowRecoders(true)">
<view class="u-m-r-6">查看记录</view>
<up-icon name="arrow-down" :size="12"></up-icon>
</view>
</view>
</template>
<template v-else>
<scroll-view scroll-y="true" style="max-height: 30vh;">
<my-step :list="recoders.list"></my-step>
</scroll-view>
<view class="color-999 u-font-24 u-flex u-row-center u-col-center">
<view class="u-flex" @click="changeShowRecoders(false)">
<view class="u-m-r-6">收起记录</view>
<up-icon name="arrow-up" :size="12"></up-icon>
</view>
</view>
</template>
</view>
</view>
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted,
computed
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$tbShopUnit
} from '@/http/yskApi/goods.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
skuList: []
}
}
})
function changeShowRecoders(show) {
recoders.show = show
}
const recoders = reactive({
list: [{
title: '2024-09-15 112030',
content: '开启了库存库存由0件修改为5件'
},
{
title: '2024-09-15 ',
content: '开启了库存库存由0件修改为4件'
},
{
title: '2024-09-15 ',
content: '开启了库存库存由0件修改为3件'
},
{
title: '2024-09-15 ',
content: '开启了库存库存由0件修改为2件'
},
],
show: false,
active: 0
})
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = props.goods
}
})
const isSku = computed(() => {
// return data.value.typeEnum == '多规格'
return false
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
function save() {
emits('save', {
...data.value,
})
}
// function save() {
// const skuSnap = returnSkuSnap(data.value)
// let typeEnum = returnTypeEnum(data.value.typeEnum)
// let lowPrice = undefined
// typeEnum = typeEnum ? typeEnum : 'normal'
// const findCategory = returnCategory(data.value.categoryName, props.category)
// console.log(typeEnum);
// console.log(findCategory);
// const categoryId = findCategory ? findCategory.id : ''
// if (typeEnum == 'normal') {
// // 单规格
// lowPrice = data.value.skuList[0].salePrice
// }
// emits('save', {
// ...data.value,
// lowPrice,
// typeEnum,
// images: data.value.images ? data.value.images : [data.value.coverImg],
// categoryId,
// skuSnap: JSON.stringify(skuSnap)
// })
// }
</script>
<style lang="scss" scoped>
.box {
width: 556rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>

View File

@@ -7,55 +7,81 @@
<text class="u-m-l-20">{{data.sort}}</text>
</view>
<view class="color-333 u-m-l-42 u-flex">
<up-icon name="edit-pen" :size="16" :color="ColorMain"></up-icon>
<text class="stock">库存:</text>
<text class="font-bold u-m-l-10">{{data.stockNumber}}</text>
<up-icon @click="editStock" name="edit-pen" :size="16" :color="ColorMain"></up-icon>
<text class="stock u-m-l-4">库存:{{data.stockNumber}}</text>
</view>
</view>
<text class="u-font-28 color-666" @click="changeClick">修改</text>
<view>
<!-- <text class="u-font-28 color-666" @click="changeClick">修改</text> -->
<text class="u-font-28 color-666" @click="changePrice">改价</text>
<text class="u-font-28 color-red u-m-l-24" @click="baosun">报损</text>
</view>
</view>
<view class="u-m-t-48 u-flex">
<view class="u-m-t-48 u-flex u-col-top u-relative">
<view v-if="props.showChecked">
<label class="radio">
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
:checked="props.data.checked" /><text></text>
</label>
</view>
<image :src="data.coverImg" lazy-load class="img"></image>
<view class="h-100 u-p-l-16 u-flex-1 u-flex u-flex-col u-row-between">
<view class="color-333 w-full u-flex u-row-between">
<view class="img">
<up--image :width="63" :height="63" :radius="3" :src="data.coverImg"></up--image>
</view>
<view class="w-full info">
<view class="info-p-l color-333 u-flex u-row-between">
<view class="u-flex">
<text class="u-m-r-24">{{data.name}}</text><uni-tag size="small" type="primary"
custom-style="background-color: #318AFE;" :text="data.typeEnum"></uni-tag>
<text class="u-m-r-24">{{data.name}}</text>
<!-- <uni-tag size="small" type="primary"
custom-style="background-color: #318AFE;" :text="data.typeEnum"></uni-tag> -->
</view>
<view class="u-font-32">
<text>{{data.lowPrice}}</text>
<!-- <text>¥</text>
<text>{{data.lowPrice}}</text>
<text v-if="data.typeEnum == '多规格'">~{{data.maxPrice }}</text> -->
</view>
<view class="price">¥{{data.lowPrice}}</view>
</view>
<view class="u-m-t-44">
<template v-if="data.skuList.length>=2">
<view class="u-flex u-flex-wrap w-full gap-10 u-col-top">
<view class="u-font-24 info-p-l u-m-t-14">规格</view>
<view class="skd" v-for="(item,index) in data.skuList" :key="index"
@click="guigeClick(index)">
<text>{{item.specSnap||item.name}}</text>
<view class="tag-primary tag" v-if="item.isGrounding">上架中</view>
<view class="tag-gray tag" v-else>已下架</view>
<!-- <template v-if="item.isPauseSale">
<view class="tag-gray tag" >已售罄</view>
</template>
<template v-else>
<view class="tag-primary tag" v-if="item.isGrounding">上架中</view>
<view class="tag-gray tag" v-else>已下架</view>
</template> -->
</view>
</view>
</template>
<template v-else>
<view style="height: 24rpx;">
</view>
</template>
</view>
</view>
</view>
<view class="u-m-t-16 skus u-text-center" v-if="data.skuList.length>=2">
<!-- <view class="u-flex u-row-between font-bold">
<view class="u-flex-1">商品信息</view>
<view class="u-flex-1">售价</view>
<view class="u-flex-1">库存</view>
</view>
<view v-for="(item,index) in data.skuList" :key="index">
<view class="u-flex u-m-t-10">
<view class="color-333 u-flex-1"> <text class="u-m-r-24">{{item.specSnap||''}}</text></view>
<view class="price u-flex-1">¥{{data.lowPrice||0}}</view>
<view class=" u-flex-1">{{item.stockNumber||0}} {{data.unitName||''}}</view>
</view>
</view> -->
<!-- <view class="u-m-t-16 skus u-text-center" v-if="data.skuList.length>=2">
<view class="u-flex u-flex-wrap skds">
<view class="skd" v-for="(item,index) in data.skuList" :key="index"><text>{{item.specSnap}}</text>
<view class="tag-primary tag">上架中</view>
</view>
</view>
</view>
</view> -->
<view class="u-m-t-24 u-flex u-row-between">
<view class="u-flex">
<view class="u-flex">
@@ -93,7 +119,7 @@
import {
ColorMain
} from '@/commons/color.js'
const emits = defineEmits(['radioClick', 'changeClick', 'xiajia', 'del'])
const emits = defineEmits(['radioClick', 'changeClick', 'xiajia', 'del', 'changePrice', 'baosun', 'guigeClick','editStock'])
const props = defineProps({
index: {
type: Number
@@ -113,7 +139,8 @@
default: false
}
})
function isHotChange(e) {
$goodsIsHot({
@@ -155,6 +182,20 @@
emits('del', props.index)
}
function changePrice() {
emits('changePrice', props.index)
}
function baosun() {
emits('baosun', props.index)
}
function guigeClick(guigeIndex) {
emits('guigeClick', props.index, guigeIndex)
}
function editStock(){
emits('editStock', props.index)
}
//携带参数type edit跳转到商品添加页面编辑与添加同一页面根据type值来判断
function toEdit() {
go.to('PAGES_PRODUCT_ADD', {
@@ -174,9 +215,12 @@
border: 2rpx solid transparent;
}
.gap-10 {
gap: 10rpx;
}
.btn-primary {
border-color: $my-main-color;
;
color: $my-main-color;
}
@@ -194,8 +238,15 @@
}
.img {
width: $imgSize;
height: $imgSize;
position: absolute;
left: 0;
top: 0;
// width: $imgSize;
// height: $imgSize;
}
.info-p-l {
padding-left: 71px;
}
.icon-arrow-right {
@@ -219,6 +270,10 @@
// border: 2rpx solid #333333;
}
.color-red {
color: #F0465B;
}
.goods {
border-radius: 10rpx 10rpx 10rpx 10rpx;
background-color: #fff;
@@ -239,33 +294,37 @@
.skds {
gap: 10rpx 50rpx;
}
}
}
.skd {
padding: 14rpx 40rpx 14rpx 20rpx;
background: #F0F2F5;
border-radius: 4rpx;
position: relative;
color: #666;
overflow: hidden;
margin-bottom: 10rpx;
.skd {
padding: 14rpx 40rpx 14rpx 20rpx;
background: #F0F2F5;
border-radius: 4rpx;
position: relative;
color: #666;
overflow: hidden;
margin-bottom: 10rpx;
font-size: 24rpx;
.tag {
position: absolute;
right: 0;
top: 0;
font-size: 12rpx;
right: 0;
padding: 2rpx 4rpx;
border-radius: 0rpx 4rpx 4rpx 4rpx;
}
.tag-primary {
background-color: $my-main-color;
color: #fff;
}
}
.tag {
position: absolute;
right: 0;
top: 0;
font-size: 12rpx;
right: 0;
padding: 2rpx 4rpx;
border-radius: 0rpx 4rpx 4rpx 4rpx;
}
.tag-primary {
background-color: $my-main-color;
color: #fff;
}
.tag-gray {
background-color: rgb(144, 147, 153);
color: #fff;
}
}
</style>

View File

@@ -8,7 +8,8 @@
<view class="input-wrapper">
<view class="input-main">
<view class="u-flex u-p-r-30 u-font-28" @click="onCategoryShowChange(true)">
<text class="u-m-r-10 u-line-1" style="max-width: 100rpx;">{{pageData.categoryName||'分类' }}</text>
<text class="u-m-r-10 u-line-1"
style="max-width: 100rpx;">{{pageData.categoryName||'分类' }}</text>
<up-icon name="arrow-down" size="16"></up-icon>
</view>
<uni-easyinput clearable class='jeepay-search' :inputBorder="false"
@@ -40,8 +41,10 @@
<view class="goods-list u-p-30">
<template v-if="pageData.goodsList.length">
<view class="u-m-b-32" v-for="(item,index) in pageData.goodsList" :key="index">
<my-goods @changeClick="goodsChangeClick" @radioClick="goodsRadioClick" :index="index" :data="item"
@del="goodsDel" :showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
<my-goods @changePrice="changePriceShow" @changeClick="goodsChangeClick"
@editStock="changeStockShow" @guigeClick="editGuigeShow" @baosun="baosunShow"
@radioClick="goodsRadioClick" :index="index" :data="item" @del="goodsDel"
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
</view>
</template>
<template v-if="pageData.hasAjax&&!pageData.goodsList.length">
@@ -53,9 +56,8 @@
</view>
<my-control ref="control" :categoryShow="pageData.categoryShow" :categoryName="pageData.categoryName"
@categoryChange="categoryIdChange" @offShelf="offShelf" @allCheckedChange="allCheckedChange"
@controlChange="controlChange" @toggleCategory="toggleCategory"
:bottom="pageData.componentBottom"></my-control>
@offShelf="offShelf" @allCheckedChange="allCheckedChange" @controlChange="controlChange"
@toggleCategory="toggleCategory" :bottom="pageData.componentBottom"></my-control>
<!-- <my-category ref="category" @change="onCategoryShowChange" @cateClick="cateClick"
:bottom="pageData.componentBottom+100"></my-category> -->
<!-- 下架弹窗 -->
@@ -113,7 +115,19 @@
</my-model>
<!-- 分类 -->
<my-category v-model:isShow="pageData.categoryShow" @confirm="setCategory"></my-category>
<my-category v-model:isShow="pageData.categoryShow" @confirm="setCategory"></my-category>
<!-- 修改价格弹窗 -->
<edit-price :category="pageData.categoryList" v-model:show="popup.price.show" @save="changePriceConfirm"
:goods="pageData.selGoods"></edit-price>
<!-- 修改库存弹窗 -->
<edit-stock :category="pageData.categoryList" v-model:show="popup.stock.show" @save="changeStockConfirm"
:goods="pageData.selGoods"></edit-stock>
<!-- 规格弹窗 -->
<edit-guige @isGroundingChange="isGroundingChange" v-model:show="popup.guige.show"
:goods="popup.guige.data"></edit-guige>
<!-- 报损 -->
<baosun-vue :category="pageData.categoryList" v-model:show="popup.baosun.show"
:goods="pageData.selGoods"></baosun-vue>
</view>
</template>
@@ -136,14 +150,25 @@
import myControl from './components/control.vue'
import myCategory from './components/category.vue'
import infoBox from "@/commons/utils/infoBox.js"
import editPrice from './components/edit-price.vue';
import editGuige from './components/edit-guige.vue';
import editStock from './components/edit-stock.vue';
import baosunVue from './components/baosun.vue';
import {
$tbProduct,
$upProSort,
$updateProduct,
$getProductDetail,
$delProduct,
$updateProductStatus
$tbShopCategory,
$updateProductStatus,
$tbProductV2,
$updateProductData
} from "@/http/yskApi/goods.js"
import {
returnAllCategory
} from '@/pageProduct/util.js'
const pageData = reactive({
modelDesc: '是否下架',
stateCurrent: 0,
@@ -154,6 +179,7 @@
},
showGoodsDetail: false,
selGoodsIndex: '',
selGoods: {},
totalElements: 0,
totalPage: 0,
goodsList: [],
@@ -164,24 +190,179 @@
name: ''
},
category: '',
categoryList: [], //分类列表
categoryShow: false,
categoryName: '',
hasAjax: false
})
watch(()=>pageData.query.categoryId,(newval)=>{
watch(() => pageData.query.categoryId, (newval) => {
getGoodsList()
})
const popup = reactive({
price: {
show: false
},
guige: {
show: false,
data: {},
goodsIndex: '',
guigeIndex: '',
},
stock: {
show: false
},
baosun: {
show: false
}
})
//报损弹窗展示
function baosunShow(index) {
pageData.selGoodsIndex = index
const goods = pageData.goodsList[index]
pageData.selGoods = goods
popup.baosun.show = true
}
// 修改价格弹窗展示
function changePriceShow(index) {
pageData.selGoodsIndex = index
const goods = pageData.goodsList[index]
goods.skuList = goods.skuList.map(v => {
return {
...v,
_lowPrice: v.lowPrice
}
})
const lowPrice = goods.lowPrice.replace('¥', '') * 1
pageData.selGoods = {
...goods,
lowPrice,
_lowPrice: lowPrice
}
popup.price.show = true
}
async function changePriceConfirm(goods) {
let goodsArr = []
if (goods.typeEnum == '单规格') {
goodsArr = [{
shopId: uni.getStorageSync('shopId'),
isSku: false,
id: goods.id,
key: 'salePrice',
value: goods.lowPrice
}]
} else {
goodsArr = goods.skuList.map(v => {
return {
shopId: uni.getStorageSync('shopId'),
isSku: true,
id: v.id,
key: 'salePrice',
value: v.lowPrice
}
})
}
const res = await $updateProductData(goodsArr)
popup.price.show = false
getGoodsList()
}
// 修改库存弹窗展示
function changeStockShow(index) {
pageData.selGoodsIndex = index
const goods = pageData.goodsList[index]
goods.skuList = goods.skuList.map(v => {
return {
...v,
_stockNumber: v.stockNumber
}
})
const stockNumber = goods.stockNumber
pageData.selGoods = {
...goods,
stockNumber,
_stockNumber: stockNumber
}
popup.stock.show = true
}
async function changeStockConfirm(goods) {
let goodsArr = []
// if (goods.typeEnum == '单规格') {
// goodsArr = [{
// shopId: uni.getStorageSync('shopId'),
// isSku: false,
// id: goods.id,
// key: 'stockNumber',
// value: goods.stockNumber
// }]
// } else {
// goodsArr = goods.skuList.map(v => {
// return {
// shopId: uni.getStorageSync('shopId'),
// isSku: true,
// id: v.id,
// key: 'stockNumber',
// value: v.stockNumber
// }
// })
// }
goodsArr = [{
shopId: uni.getStorageSync('shopId'),
isSku: false,
id: goods.id,
key: 'stockNumber',
value: goods.stockNumber
}]
const res = await $updateProductData(goodsArr)
popup.stock.show = false
getGoodsList()
}
//修改规格上下架,售罄
function editGuigeShow(goodsIndex, guigeIndex) {
console.log(goodsIndex, guigeIndex);
const goodsGuige = pageData.goodsList[goodsIndex].skuList[guigeIndex]
popup.guige.data = goodsGuige
popup.guige.goodsIndex = goodsIndex
popup.guige.guigeIndex = guigeIndex
popup.guige.show = true
}
function isGroundingChange(e) {
const {
goodsIndex,
guigeIndex
} = popup.guige
pageData.goodsList[goodsIndex].skuList[guigeIndex].isGrounding = e
}
function isPauseSaleChange(e) {
const {
goodsIndex,
guigeIndex
} = popup.guige
pageData.goodsList[goodsIndex].skuList[guigeIndex].isPauseSale = e
}
function onCategoryShowChange(show) {
console.log(show);
pageData.categoryShow = show
}
function setCategory(category){
function setCategory(category) {
pageData.query.categoryId = category.id
pageData.categoryName = category.name
}
function getGoodsList() {
$tbProduct(pageData.query).then(res => {
$tbProductV2(pageData.query).then(res => {
pageData.hasAjax = true
console.log(res);
pageData.goodsList = res.content.map(v => {
@@ -198,9 +379,18 @@
onShow(() => {
getGoodsList()
})
onLoad(() => {
$tbShopCategory({
page: 0,
size: 200
}).then(res => {
pageData.categoryList = returnAllCategory(res.content)
console.log(pageData.categoryList);
})
})
const tabsList = ['简洁', '详情']
const statesTabsList = ['全部', '已售罄','在售中', '已下架']
const statesTabsList = ['全部', '已售罄', '在售中', '已下架']
const control = ref(null)
const model = ref(null)
const goodsStockModel = ref(null)

41
pageProduct/util.js Normal file
View File

@@ -0,0 +1,41 @@
import {
$types
} from '@/pageProduct/goodsData.js'
export function returnSkuSnap(goods) {
const selectSpec = typeof goods.selectSpec === 'string' ? JSON.parse(goods.selectSpec) : goods.selectSpec
let result = selectSpec.map(v => {
return {
name: v.name,
value: v.selectSpecResult.join(',')
}
})
return result
}
export function returnTypeEnum(typeEnum) {
const item = $types.find(v => v.title == typeEnum)
let result = item ? item.value : undefined
return result
}
export function returnCategory(cateName, cateList) {
console.log(cateName);
console.log(cateList);
const item = cateList.find(v => v.name == cateName)
let result = item ? item : undefined
return result
}
export function returnAllCategory(arr) {
const result = arr.reduce((prve, cur) => {
prve.push(...[{
...cur,
name: '' + cur.name,
childrenList: undefined
}, ...cur.childrenList.map(v => {
return {
...v,
name: '' + v.name
}
})])
return prve
}, [])
return result
}