diff --git a/pageProduct/add-Product/add-Product-9-19-back.vue b/pageProduct/add-Product/add-Product-9-19-back.vue index 5dc1ade..b638e16 100644 --- a/pageProduct/add-Product/add-Product-9-19-back.vue +++ b/pageProduct/add-Product/add-Product-9-19-back.vue @@ -1228,7 +1228,7 @@ } if (type === 'stockTips') { modelProps = { - desc: '清先保存商品基础信息', + desc: '请先保存商品基础信息', showIcon: false } model.value.open() diff --git a/pageProduct/add-Product/add-Product.vue b/pageProduct/add-Product/add-Product.vue index faeecc9..7237039 100644 --- a/pageProduct/add-Product/add-Product.vue +++ b/pageProduct/add-Product/add-Product.vue @@ -884,7 +884,7 @@ } if (type === 'stockTips') { modelProps = { - desc: '清先保存商品基础信息', + desc: '请先保存商品基础信息', showIcon: false } model.value.open() diff --git a/pageProduct/add-specifications/add-specifications.vue b/pageProduct/add-specifications/add-specifications.vue index 1b8fcac..ca76f22 100644 --- a/pageProduct/add-specifications/add-specifications.vue +++ b/pageProduct/add-specifications/add-specifications.vue @@ -39,7 +39,7 @@ - + @@ -70,13 +70,15 @@ - - - - + + @@ -192,6 +194,9 @@ } //删除规格组 function delSpecificationsGroup(index) { + if(specifications.list.length<=1){ + return + } specifications.list.splice(index, 1) } // 向指定索引的规格组添加规格项 @@ -200,6 +205,9 @@ } // 删除指定索引的规格组添加规格项 function delOption(index, optionIndex) { + if(specifications.list[index].options.length<=1){ + return + } specifications.list[index].options.splice(optionIndex, 1) } //页面滚动到最底部 diff --git a/pageProduct/add-specifications/choose-specifications.vue b/pageProduct/add-specifications/choose-specifications.vue index 1577f25..5e50350 100644 --- a/pageProduct/add-specifications/choose-specifications.vue +++ b/pageProduct/add-specifications/choose-specifications.vue @@ -90,17 +90,18 @@ :placeholderStyle="placeholderStyle" :inputBorder="inputBorder" v-model="item.skus.suit" type="digit" placeholder="请输入起售数量" /> - + + { - const min = 0; - const max = 100000000; + let min = 0; + let max = 100000000; console.log(item[key]); + if (key == 'suit') { + min = 1 + } const newval = formatPrice(item[key], min, max, true) if (typeof newval !== 'number') { item[key] = newval.value @@ -242,7 +246,7 @@ }) } - + function updateSkuKey(arr) { for (let i in FormData.result) { @@ -417,9 +421,18 @@ }, suit: { rules: [{ - required: true, - errorMessage: '必填' - }] + required: true, + errorMessage: '必填' + }, + { + validateFunction: function(rule, value, data, callback) { + if (value < 1) { + callback('起售数量至少为1个') + } + return true + } + } + ] } } @@ -468,13 +481,13 @@ disabledStock.value = !res } } - - onShow(()=>{ + + onShow(() => { canEditGoodsStock() }) - + onLoad(opt => { - Object.assign(option,opt) + Object.assign(option, opt) getTbProductSpec() const obj = uni.getStorageSync('guige') if (obj && JSON.stringify(obj) !== '{}') { @@ -513,6 +526,9 @@ }) }).catch(err => { console.log(err); + if(err.length>=1){ + infoBox.showToast(err[0].errorMessage) + } resolve({ sucees: false }) @@ -521,7 +537,7 @@ } async function save() { if (!FormData.result.length) { - return infoBox.showToast('清先选择规格!') + return infoBox.showToast('请先选择规格!') } let isAllPassForm = 0 for (let i in FormData.result) { @@ -529,7 +545,7 @@ isAllPassForm += res.sucees ? 1 : 0 } if (isAllPassForm < FormData.result.length) { - return infoBox.showToast('清完善规格属性的参数!') + return } //判断验证是否通过 console.log('pass'); diff --git a/pageProduct/goodsData.js b/pageProduct/goodsData.js index e74b5b7..3fa480a 100644 --- a/pageProduct/goodsData.js +++ b/pageProduct/goodsData.js @@ -32,7 +32,7 @@ export const $defaultSku = { memberPrice: '', costPrice: '', originPrice: '', - stockNumber: '', + // stockNumber: '', firstShared: '', suit: 1, barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`, diff --git a/pageProduct/index/components/edit-price.vue b/pageProduct/index/components/edit-price.vue index 0cfd190..5896d8c 100644 --- a/pageProduct/index/components/edit-price.vue +++ b/pageProduct/index/components/edit-price.vue @@ -8,47 +8,22 @@ - 商品名称 - {{data.name}} - - - + - - - - 保存 - - + + + + 保存 + + + - + @@ -84,13 +88,39 @@ computed, reactive, ref, - watch + watch, + nextTick } from 'vue'; import { returnSkuSnap, returnTypeEnum, returnCategory } 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({ show: { type: Boolean, @@ -104,14 +134,30 @@ type: Object, default: () => { return { - lowPrice:0, + lowPrice: 0, 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 form = reactive({ note: '' @@ -120,11 +166,13 @@ watch(() => props.show, (newval) => { popShow.value = newval if (newval) { - data.value = props.goods + data.value = { + ...props.goods + } } }) - const isSku=computed(()=>{ - return data.value.typeEnum=='多规格' + const isSku = computed(() => { + return data.value.typeEnum == '多规格' }) watch(() => popShow.value, (newval) => { emits('update:show', newval) @@ -137,11 +185,21 @@ function open() { } - + function save() { - emits('save', { - ...data.value, - }) + refForm.value.validate().then(valid => { + if (valid) { + emits('save', { + ...data.value, + }) + } else { + console.log(err); + } + }).catch(() => { + // 处理验证错误 + }); + + } // function save() { diff --git a/pageProduct/index/components/edit-stock.vue b/pageProduct/index/components/edit-stock.vue index 7bcfd10..4ab183a 100644 --- a/pageProduct/index/components/edit-stock.vue +++ b/pageProduct/index/components/edit-stock.vue @@ -8,6 +8,7 @@ + 商品名称 {{data.name}} @@ -21,11 +22,14 @@ - - - + + + + + + @@ -99,6 +103,7 @@ + @@ -120,6 +125,7 @@ import { $tbShopUnit,$getProductStockDetail } from '@/http/yskApi/goods.js' + const refForm = ref(null) const props = defineProps({ show: { type: Boolean, @@ -136,7 +142,15 @@ } } }) - + const rules =reactive({ + 'stockNumber': [{ + type: 'number', + required: true, + message: '请填写库存', + trigger: ['blur', 'change'] + } + ] + }) function toRecodes(){ } function changeShowRecoders(show) { @@ -189,15 +203,24 @@ function close() { popShow.value = false + form.note='' } function open() { } function save() { - emits('save', { - ...data.value, - }) + refForm.value.validate().then(valid => { + if (valid) { + emits('save', { + ...data.value, + }) + } else { + console.log(err); + } + }).catch(() => { + // 处理验证错误 + }); } // function save() { // const skuSnap = returnSkuSnap(data.value) diff --git a/pageProduct/index/index.vue b/pageProduct/index/index.vue index a86e70d..dca9a33 100644 --- a/pageProduct/index/index.vue +++ b/pageProduct/index/index.vue @@ -13,7 +13,9 @@