代码更新
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
<view class="u-m-t-48">
|
||||
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm">
|
||||
<view>商品名称</view>
|
||||
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
|
||||
<view class="u-m-t-16" v-if="data.type == 'sku'">{{data.name}}</view>
|
||||
<view class="u-m-t-38">
|
||||
<template v-if="!isSku">
|
||||
<template v-if="data.type != 'sku'">
|
||||
<view class="u-m-b-32">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>{{data.name}}</view>
|
||||
@@ -84,41 +84,11 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
nextTick,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
returnSkuSnap,
|
||||
returnTypeEnum,
|
||||
returnCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import {
|
||||
formatPrice
|
||||
} from "@/commons/utils/format.js";
|
||||
|
||||
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)
|
||||
|
||||
|
||||
import { computed, reactive, ref, watch, onMounted } from 'vue';
|
||||
import { returnSkuSnap, returnTypeEnum, returnCategory } from '@/pageProduct/util.js'
|
||||
import { formatPrice } from "@/commons/utils/format.js";
|
||||
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
@@ -135,10 +105,11 @@
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
let popShow = ref(props.show)
|
||||
let data = ref({
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
@@ -159,37 +130,57 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const refForm = ref(null)
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
emits('update:show', newval)
|
||||
})
|
||||
|
||||
/**
|
||||
* 金额处理
|
||||
* @param {Object} item
|
||||
* @param {Object} key
|
||||
* @param {Object} val
|
||||
*/
|
||||
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 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() {
|
||||
refForm.value.validate().then(valid => {
|
||||
if (valid) {
|
||||
console.log(data)
|
||||
emits('save', {
|
||||
...data.value,
|
||||
})
|
||||
@@ -200,37 +191,16 @@
|
||||
// 处理验证错误
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function close() {
|
||||
popShow.value = false
|
||||
}
|
||||
|
||||
function open() {
|
||||
|
||||
}
|
||||
|
||||
// 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)
|
||||
// })
|
||||
// }
|
||||
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -32,15 +32,11 @@
|
||||
<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> -->
|
||||
</view>
|
||||
<view class="u-font-32">
|
||||
<text v-if="data.type=='single'">¥</text>
|
||||
<text>{{data.lowPrice}}</text>
|
||||
<!-- <text>¥</text>
|
||||
<text>{{data.lowPrice}}</text>
|
||||
<text v-if="data.typeEnum == '多规格'">~¥{{data.maxPrice }}</text> -->
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-24">
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<view class="u-flex">
|
||||
<view class="u-p-l-16 item u-p-r-16 u-p-t-6 u-p-b-6 tranistion u-text-center color-333"
|
||||
:class="{'active':pageData.stateCurrent==index}" @tap="statesTableClick(index)"
|
||||
v-for="(item,index) in statesTabsList" :key="index">
|
||||
{{item}}
|
||||
v-for="(item,index) in pageData.statesTabsList" :key="index">
|
||||
{{item.laber}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-col-center" @click="go.to('PAGES_PRODUCT_SPECIF_TEMPLATE')">
|
||||
@@ -83,31 +83,6 @@
|
||||
<my-switch v-model="goodsStockData.isStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-m-t-32">
|
||||
<view class="">共享库存:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isDistribute"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">售罄:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isSoldStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">上架:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isSale"></my-switch>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- <view class="u-m-t-24 u-m-t-32" v-if="goodsStockData.isStock">
|
||||
<view class="">数量:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="goodsStockData.stockNumber" placeholder="请输入库存数量"></uni-easyinput>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
</template>
|
||||
@@ -138,22 +113,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onPullDownRefresh
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js';
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js';
|
||||
import myGoods from './components/goods.vue'
|
||||
import myControl from './components/control.vue'
|
||||
import myCategory from './components/category.vue'
|
||||
@@ -163,8 +126,6 @@
|
||||
import editStock from './components/edit-stock.vue';
|
||||
import baosunVue from './components/baosun.vue';
|
||||
import {
|
||||
$tbProduct,
|
||||
$upProSort,
|
||||
$updateProduct,
|
||||
$getProductDetail,
|
||||
$delProduct,
|
||||
@@ -175,7 +136,8 @@
|
||||
} from "@/http/yskApi/goods.js"
|
||||
import {
|
||||
getProductList,
|
||||
getCategoryList
|
||||
getCategoryList,
|
||||
updateProduct
|
||||
} from '@/api/product.js'
|
||||
|
||||
import {
|
||||
@@ -190,6 +152,12 @@
|
||||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
statesTabsList: [
|
||||
{ laber: '全部', value: ''},
|
||||
{ laber: '已售罄', value: 'sold_out'},
|
||||
{ laber: '在售中', value: 'on_sale'},
|
||||
{ laber: '已下架', value: 'off_sale'},
|
||||
],
|
||||
showGoodsDetail: false,
|
||||
selGoodsIndex: '',
|
||||
selGoods: {},
|
||||
@@ -202,8 +170,7 @@
|
||||
categoryId: '',
|
||||
name: '',
|
||||
orderBy: "create_time desc",
|
||||
isSoldStock: '',
|
||||
isSale: ''
|
||||
status: '',
|
||||
},
|
||||
category: '',
|
||||
categoryList: [], //分类列表
|
||||
@@ -211,6 +178,11 @@
|
||||
categoryName: '',
|
||||
hasAjax: false
|
||||
})
|
||||
const tabsList = ['简洁', '详情']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
watch(() => pageData.query.categoryId, (newval) => {
|
||||
getGoodsList()
|
||||
})
|
||||
@@ -292,16 +264,19 @@
|
||||
*/
|
||||
function changePriceShow(index) {
|
||||
pageData.selGoodsIndex = index
|
||||
const goods = pageData.goodsList[index]
|
||||
let goods = pageData.goodsList[index]
|
||||
console.log(goods)
|
||||
if(goods.type != 'sku') {
|
||||
goods.lowPrice = goods.skuList[0].salePrice
|
||||
}
|
||||
goods.skuList = goods.skuList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
_lowPrice: v.lowPrice
|
||||
_lowPrice: v.salePrice
|
||||
}
|
||||
})
|
||||
console.log(goods)
|
||||
const lowPrice = goods.lowPrice.toString().replace('¥', '') * 1
|
||||
let lowPrice = goods.lowPrice.toString().replace('¥', '') * 1
|
||||
pageData.selGoods = {
|
||||
...goods,
|
||||
lowPrice,
|
||||
@@ -310,20 +285,14 @@
|
||||
popup.price.show = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改价格确认
|
||||
* @param {Object} goods
|
||||
*/
|
||||
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 {
|
||||
if (goods.type == 'sku') {
|
||||
goodsArr = goods.skuList.map(v => {
|
||||
return {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
@@ -333,8 +302,17 @@
|
||||
value: v.lowPrice
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
id: goods.id,
|
||||
key: 'salePrice',
|
||||
value: goods.lowPrice
|
||||
}]
|
||||
}
|
||||
const res = await $updateProductData(goodsArr)
|
||||
const res = await updateProduct(goodsArr)
|
||||
infoBox.showToast('修改成功')
|
||||
popup.price.show = false
|
||||
getGoodsList()
|
||||
@@ -365,25 +343,7 @@
|
||||
}
|
||||
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,
|
||||
@@ -454,12 +414,7 @@
|
||||
}
|
||||
|
||||
|
||||
const tabsList = ['简洁', '详情']
|
||||
const statesTabsList = ['全部', '已售罄', '在售中', '已下架']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
|
||||
// 商品报损
|
||||
function reportDamageClick(index) {
|
||||
pageData.reportData = pageData.goodsList[index]
|
||||
@@ -537,6 +492,7 @@
|
||||
function resetQuery() {
|
||||
pageData.totalElements = 0;
|
||||
pageData.query.page = 1;
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
async function toGoodsDetail(id) {
|
||||
@@ -549,31 +505,15 @@
|
||||
productId: id
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品类型切换
|
||||
* @param {Object} index
|
||||
*/
|
||||
function statesTableClick(index) {
|
||||
pageData.stateCurrent = index;
|
||||
pageData.query.status = pageData.statesTabsList[index].value
|
||||
resetQuery()
|
||||
console.log(index);
|
||||
if (index == 0) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = ''
|
||||
return
|
||||
}
|
||||
if (index == 1) {
|
||||
pageData.query.isSoldStock = 1
|
||||
pageData.query.isSale = ''
|
||||
return
|
||||
}
|
||||
if (index == 2) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = 1
|
||||
return
|
||||
}
|
||||
if (index == 3) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = 0
|
||||
return
|
||||
}
|
||||
}
|
||||
let test = ref(false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user