商品管理更新修复部分已知问题

This commit is contained in:
YeMingfei666 2024-10-16 14:15:27 +08:00
parent ce6f0ef230
commit d0bb6bff46
8 changed files with 203 additions and 94 deletions

View File

@ -1228,7 +1228,7 @@
} }
if (type === 'stockTips') { if (type === 'stockTips') {
modelProps = { modelProps = {
desc: '先保存商品基础信息', desc: '先保存商品基础信息',
showIcon: false showIcon: false
} }
model.value.open() model.value.open()

View File

@ -884,7 +884,7 @@
} }
if (type === 'stockTips') { if (type === 'stockTips') {
modelProps = { modelProps = {
desc: '先保存商品基础信息', desc: '先保存商品基础信息',
showIcon: false showIcon: false
} }
model.value.open() model.value.open()

View File

@ -39,7 +39,7 @@
</uni-forms-item> </uni-forms-item>
</view> </view>
<view class=" u-flex"> <view class=" u-flex" v-if="item.options.length>1">
<uni-forms-item :key="optionIndex" label-width="0" label="" <uni-forms-item :key="optionIndex" label-width="0" label=""
:showRequired="false"> :showRequired="false">
<view class="u-flex"> <view class="u-flex">
@ -70,13 +70,15 @@
</view> </view>
</uni-forms-item> </uni-forms-item>
<template v-if="specifications.list.length>1">
<view class="u-flex u-m-t-48 u-m-b-24" @click="delSpecificationsGroup(index)"> <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 class="icon icon-reduce u-m-r-22 ">
</view>
<view class="color-red">删除规格组</view>
</view> </view>
<view class="color-red">删除规格组</view> </template>
</view>
</view> </view>
</uni-forms> </uni-forms>
</view> </view>
@ -192,6 +194,9 @@
} }
// //
function delSpecificationsGroup(index) { function delSpecificationsGroup(index) {
if(specifications.list.length<=1){
return
}
specifications.list.splice(index, 1) specifications.list.splice(index, 1)
} }
// //
@ -200,6 +205,9 @@
} }
// //
function delOption(index, optionIndex) { function delOption(index, optionIndex) {
if(specifications.list[index].options.length<=1){
return
}
specifications.list[index].options.splice(optionIndex, 1) specifications.list[index].options.splice(optionIndex, 1)
} }
// //

View File

@ -90,17 +90,18 @@
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder" :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.skus.suit" type="digit" placeholder="请输入起售数量" /> v-model="item.skus.suit" type="digit" placeholder="请输入起售数量" />
</uni-forms-item> </uni-forms-item>
<view class="u-relative"> <!-- <view class="u-relative">
<uni-forms-item label="库存数量" required> <uni-forms-item label="库存数量" required>
<uni-easyinput :disabled="disabledStock" @blur="priceFormat(item.skus,'stockNumber')" <uni-easyinput :disabled="disabledStock"
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle" @blur="priceFormat(item.skus,'stockNumber')" :paddingNone="inputPaddingNone"
:inputBorder="inputBorder" v-model="item.skus.stockNumber" type="digit" :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
placeholder="请输入库存数量" /> v-model="item.skus.stockNumber" type="digit" placeholder="请输入库存数量" />
</uni-forms-item> </uni-forms-item>
<view class="u-absolute position-all" v-if="disabledStock" @click="canEditGoodsStock(true)"> <view class="u-absolute position-all" v-if="disabledStock"
@click="canEditGoodsStock(true)">
</view> </view>
</view> </view> -->
<uni-forms-item label="分销金额" required> <uni-forms-item label="分销金额" required>
<uni-easyinput @blur="priceFormat(item.skus,'firstShared')" <uni-easyinput @blur="priceFormat(item.skus,'firstShared')"
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle" :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
@ -226,9 +227,12 @@
//number //number
function priceFormat(item, key) { function priceFormat(item, key) {
nextTick(() => { nextTick(() => {
const min = 0; let min = 0;
const max = 100000000; let max = 100000000;
console.log(item[key]); console.log(item[key]);
if (key == 'suit') {
min = 1
}
const newval = formatPrice(item[key], min, max, true) const newval = formatPrice(item[key], min, max, true)
if (typeof newval !== 'number') { if (typeof newval !== 'number') {
item[key] = newval.value item[key] = newval.value
@ -242,7 +246,7 @@
}) })
} }
function updateSkuKey(arr) { function updateSkuKey(arr) {
for (let i in FormData.result) { for (let i in FormData.result) {
@ -417,9 +421,18 @@
}, },
suit: { suit: {
rules: [{ rules: [{
required: true, required: true,
errorMessage: '必填' errorMessage: '必填'
}] },
{
validateFunction: function(rule, value, data, callback) {
if (value < 1) {
callback('起售数量至少为1个')
}
return true
}
}
]
} }
} }
@ -468,13 +481,13 @@
disabledStock.value = !res disabledStock.value = !res
} }
} }
onShow(()=>{ onShow(() => {
canEditGoodsStock() canEditGoodsStock()
}) })
onLoad(opt => { onLoad(opt => {
Object.assign(option,opt) Object.assign(option, opt)
getTbProductSpec() getTbProductSpec()
const obj = uni.getStorageSync('guige') const obj = uni.getStorageSync('guige')
if (obj && JSON.stringify(obj) !== '{}') { if (obj && JSON.stringify(obj) !== '{}') {
@ -513,6 +526,9 @@
}) })
}).catch(err => { }).catch(err => {
console.log(err); console.log(err);
if(err.length>=1){
infoBox.showToast(err[0].errorMessage)
}
resolve({ resolve({
sucees: false sucees: false
}) })
@ -521,7 +537,7 @@
} }
async function save() { async function save() {
if (!FormData.result.length) { if (!FormData.result.length) {
return infoBox.showToast('先选择规格!') return infoBox.showToast('先选择规格!')
} }
let isAllPassForm = 0 let isAllPassForm = 0
for (let i in FormData.result) { for (let i in FormData.result) {
@ -529,7 +545,7 @@
isAllPassForm += res.sucees ? 1 : 0 isAllPassForm += res.sucees ? 1 : 0
} }
if (isAllPassForm < FormData.result.length) { if (isAllPassForm < FormData.result.length) {
return infoBox.showToast('清完善规格属性的参数!') return
} }
// //
console.log('pass'); console.log('pass');

View File

@ -32,7 +32,7 @@ export const $defaultSku = {
memberPrice: '', memberPrice: '',
costPrice: '', costPrice: '',
originPrice: '', originPrice: '',
stockNumber: '', // stockNumber: '',
firstShared: '', firstShared: '',
suit: 1, suit: 1,
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`, barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`,

View File

@ -8,47 +8,22 @@
</view> </view>
</view> </view>
<view class="u-m-t-48"> <view class="u-m-t-48">
<view>商品名称</view> <up-form labelPosition="left" :model="data" :rules="rules" ref="refForm">
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view> <view>商品名称</view>
<view class="u-m-t-38"> <view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
<template v-if="!isSku"> <view class="u-m-t-38">
<view class="u-m-b-32"> <template v-if="!isSku">
<view class="u-flex u-row-between"> <view class="u-m-b-32">
<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 class="u-flex u-row-between">
<view>{{item.name}}</view> <view>{{data.name}}</view>
<view class="u-font-24"> <view class="u-font-24">
<text>变动金额</text> <text>变动金额</text>
<text class="number">{{item.lowPrice-item._lowPrice}}</text> <text class="number">{{data.lowPrice*1-data._lowPrice*1}}</text>
</view> </view>
</view> </view>
<view class="u-m-t-16"> <view class="u-m-t-16">
<up-input v-model="item.lowPrice"> <up-input v-model="data.lowPrice" type="number"
@change="priceFormat(data,'lowPrice',$event)">
<template #suffix> <template #suffix>
<view></view> <view></view>
</template> </template>
@ -63,17 +38,46 @@
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea> <up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view> </view>
</view> </view>
</scroll-view> </template>
</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 @change="priceFormat(item,'lowPrice',$event)" v-model="item.lowPrice"
type="number">
<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"> <view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save"> <my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32"> <view class="u-font-32">
保存 保存
</view> </view>
</my-button> </my-button>
</view>
</view> </view>
</view> </up-form>
</view> </view>
</view> </view>
</up-popup> </up-popup>
@ -84,13 +88,39 @@
computed, computed,
reactive, reactive,
ref, ref,
watch watch,
nextTick
} from 'vue'; } from 'vue';
import { import {
returnSkuSnap, returnSkuSnap,
returnTypeEnum, returnTypeEnum,
returnCategory returnCategory
} from '@/pageProduct/util.js' } from '@/pageProduct/util.js'
import {
formatPrice
} from "@/commons/utils/format.js";
import {
TRUE
} from 'sass';
function priceFormat(item, key, val) {
let min = 0;
let max = 100000000;
const returnNewVal = formatPrice(val, min, max, true)
const newval = typeof returnNewVal !== 'number' ? returnNewVal.value : returnNewVal
if (typeof returnNewVal !== 'number') {
uni.showToast({
title: `请输入${min}${max}范围内的数字`,
icon: 'none'
})
}
setTimeout(() => {
item[key] = newval
}, 100)
}
const refForm = ref(null)
const props = defineProps({ const props = defineProps({
show: { show: {
type: Boolean, type: Boolean,
@ -104,14 +134,30 @@
type: Object, type: Object,
default: () => { default: () => {
return { return {
lowPrice:0, lowPrice: 0,
skuList: [] skuList: []
} }
} }
} }
}) })
const data = ref(props.goods) let data = ref(props.goods)
const rules = {
'lowPrice': [{
type: 'Number',
min: 0,
required: true,
message: '价格不能小于0',
trigger: ['blur', 'change']
},
{
validator: (rule, value, callback) => {
return true
},
message: ''
}
]
}
const emits = defineEmits(['update:show', 'save']) const emits = defineEmits(['update:show', 'save'])
const form = reactive({ const form = reactive({
note: '' note: ''
@ -120,11 +166,13 @@
watch(() => props.show, (newval) => { watch(() => props.show, (newval) => {
popShow.value = newval popShow.value = newval
if (newval) { if (newval) {
data.value = props.goods data.value = {
...props.goods
}
} }
}) })
const isSku=computed(()=>{ const isSku = computed(() => {
return data.value.typeEnum=='多规格' return data.value.typeEnum == '多规格'
}) })
watch(() => popShow.value, (newval) => { watch(() => popShow.value, (newval) => {
emits('update:show', newval) emits('update:show', newval)
@ -137,11 +185,21 @@
function open() { function open() {
} }
function save() { function save() {
emits('save', { refForm.value.validate().then(valid => {
...data.value, if (valid) {
}) emits('save', {
...data.value,
})
} else {
console.log(err);
}
}).catch(() => {
//
});
} }
// function save() { // function save() {

View File

@ -8,6 +8,7 @@
</view> </view>
</view> </view>
<view class="u-m-t-48"> <view class="u-m-t-48">
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm" errorType="toast">
<view>商品名称</view> <view>商品名称</view>
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view> <view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
<view class="u-m-t-38"> <view class="u-m-t-38">
@ -21,11 +22,14 @@
</view> </view>
</view> </view>
<view class="u-m-t-16"> <view class="u-m-t-16">
<up-input v-model="data.stockNumber"> <up-form-item prop="stockNumber">
<template #suffix> <up-input v-model="data.stockNumber" type="number">
<view>{{data.unitName||''}}</view> <template #suffix>
</template> <view>{{data.unitName||''}}</view>
</up-input> </template>
</up-input>
</up-form-item>
</view> </view>
</view> </view>
<view class="u-m-b-32"> <view class="u-m-b-32">
@ -99,6 +103,7 @@
</view> </view>
</view> </view>
</up-form>
</view> </view>
</view> </view>
</up-popup> </up-popup>
@ -120,6 +125,7 @@
import { import {
$tbShopUnit,$getProductStockDetail $tbShopUnit,$getProductStockDetail
} from '@/http/yskApi/goods.js' } from '@/http/yskApi/goods.js'
const refForm = ref(null)
const props = defineProps({ const props = defineProps({
show: { show: {
type: Boolean, type: Boolean,
@ -136,7 +142,15 @@
} }
} }
}) })
const rules =reactive({
'stockNumber': [{
type: 'number',
required: true,
message: '请填写库存',
trigger: ['blur', 'change']
}
]
})
function toRecodes(){ function toRecodes(){
} }
function changeShowRecoders(show) { function changeShowRecoders(show) {
@ -189,15 +203,24 @@
function close() { function close() {
popShow.value = false popShow.value = false
form.note=''
} }
function open() { function open() {
} }
function save() { function save() {
emits('save', { refForm.value.validate().then(valid => {
...data.value, if (valid) {
}) emits('save', {
...data.value,
})
} else {
console.log(err);
}
}).catch(() => {
//
});
} }
// function save() { // function save() {
// const skuSnap = returnSkuSnap(data.value) // const skuSnap = returnSkuSnap(data.value)

View File

@ -13,7 +13,9 @@
<up-icon name="arrow-down" size="16"></up-icon> <up-icon name="arrow-down" size="16"></up-icon>
</view> </view>
<uni-easyinput clearable class='jeepay-search' :inputBorder="false" <uni-easyinput clearable class='jeepay-search' :inputBorder="false"
trim="all"
:placeholder="pageData.search.placeholder" v-model="pageData.query.name" :placeholder="pageData.search.placeholder" v-model="pageData.query.name"
@clear="searchFunc"
@confirm="searchFunc"> @confirm="searchFunc">
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/iconImg/icon-search.svg" class="input-icon" /> <image src="@/static/iconImg/icon-search.svg" class="input-icon" />
@ -286,6 +288,7 @@
}) })
} }
const res = await $updateProductData(goodsArr) const res = await $updateProductData(goodsArr)
infoBox.showToast('修改成功')
popup.price.show = false popup.price.show = false
getGoodsList() getGoodsList()
} }
@ -342,6 +345,7 @@
value: goods.stockNumber value: goods.stockNumber
}] }]
const res = await $updateProductData(goodsArr) const res = await $updateProductData(goodsArr)
infoBox.showToast('修改成功')
popup.stock.show = false popup.stock.show = false
getGoodsList() getGoodsList()
} }