cashier_admin_app/pageProduct/index/components/edit-price.vue

186 lines
4.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>