1.新增套餐商品
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="item number" @click="props.item.id && takeFoodCodeRef.show()">
|
||||
<el-text class="num">{{ props.item.number || 1 }}</el-text>
|
||||
<el-text class="num">{{ formatDecimal(props.item.number || 1, 2, true) }}</el-text>
|
||||
</div>
|
||||
<div class="item" @click="numberChange('add')">
|
||||
<el-icon class="icon add">
|
||||
@@ -19,6 +19,12 @@
|
||||
</el-icon>
|
||||
<el-text class="t">规格</el-text>
|
||||
</div>
|
||||
<div class="item" @click="showDiscountModalHandle">
|
||||
<el-icon class="icon">
|
||||
<PriceTag />
|
||||
</el-icon>
|
||||
<el-text class="t">打折</el-text>
|
||||
</div>
|
||||
<div class="item" :class="{ disabled: props.item.isGift == 'true' }" @click="giftPackHandle('isGift')">
|
||||
<el-icon class="icon">
|
||||
<ShoppingBag />
|
||||
@@ -32,6 +38,12 @@
|
||||
</el-icon>
|
||||
<el-text class="t">打包</el-text>
|
||||
</div>
|
||||
<div class="item" :class="{ disabled: props.item.isPrint == 0 }" @click="kitchenPrint">
|
||||
<el-icon class="icon">
|
||||
<DishDot />
|
||||
</el-icon>
|
||||
<el-text class="t">免厨</el-text>
|
||||
</div>
|
||||
<div class="item" @click="props.item.id && emit('delete', props.item)">
|
||||
<el-icon class="icon">
|
||||
<Delete />
|
||||
@@ -54,17 +66,51 @@
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="修改商品数量" placeholder="请输入商品数量" @success="updateNumber" />
|
||||
<!-- 购物车选择规格 -->
|
||||
<skuModal ref="skuModalRef" @success="skuConfirm" />
|
||||
<!-- 单品打折 -->
|
||||
<el-dialog v-model="showDiscountModal" title="单品打折" @open="resetDiscountForm = { ...discountForm }"
|
||||
@closed="discountModalClose">
|
||||
<div class="dialog">
|
||||
<div class="el-popover__title content">
|
||||
<el-form ref="discountFormRef" :model="discountForm" :rules="discountFormRules" label-width="100px"
|
||||
label-position="left">
|
||||
<el-form-item label="价格更改" prop="amount">
|
||||
<el-input v-model="discountForm.amount" placeholder="减8.88元请输入8.88" @input="priceInput">
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="更改原因">
|
||||
<el-input v-model="discountForm.note" type="textarea" placeholder="请输入自定义备注" />
|
||||
<div class="remark_list">
|
||||
<div class="item" v-for="item in noteList" :key="item" @click="addNote(item)">
|
||||
{{ item }}
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="footer_wrap">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="showDiscountModal = false">取消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%;" :loading="discountFormLoading"
|
||||
@click="discountFormSubmit">确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import takeFoodCode from '@/components/takeFoodCode.vue'
|
||||
import skuModal from '@/components/skuModal.vue'
|
||||
import { useShop } from '@/store/shop.js'
|
||||
import { inputFilterFloat, formatDecimal } from '@/utils/index.js'
|
||||
import { updatePrice, orderPrint } from '@/api/product.js'
|
||||
|
||||
const shopStore = useShop()
|
||||
console.log('---------')
|
||||
console.log(shopStore)
|
||||
const props = defineProps({
|
||||
item: {
|
||||
type: Object,
|
||||
@@ -126,6 +172,114 @@ function skuConfirm(e) {
|
||||
if (!props.item.id) return
|
||||
emit('confirm', e)
|
||||
}
|
||||
|
||||
/**单品打折 start */
|
||||
const showDiscountModal = ref(false)
|
||||
const resetDiscountForm = ref({})
|
||||
const discountFormRef = ref(null)
|
||||
const discountFormLoading = ref(false)
|
||||
const discountForm = ref({
|
||||
masterId: '',
|
||||
cartId: '',
|
||||
amount: '',
|
||||
note: '',
|
||||
shopId: ''
|
||||
})
|
||||
|
||||
function validateAmount(rule, value, callback) {
|
||||
if (value == '') {
|
||||
callback(new Error('请输入折扣价格'))
|
||||
} else if (value <= 0) {
|
||||
callback(new Error('输入价格有误'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const discountFormRules = ref({
|
||||
amount: [
|
||||
{
|
||||
required: true,
|
||||
validator: validateAmount,
|
||||
trigger: 'blur',
|
||||
}
|
||||
]
|
||||
})
|
||||
const noteList = ref([
|
||||
'顾客投诉质量...',
|
||||
'友情打折',
|
||||
'临时活动',
|
||||
])
|
||||
|
||||
// 显示
|
||||
function showDiscountModalHandle() {
|
||||
if (props.item.id) {
|
||||
showDiscountModal.value = true
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤价格输入
|
||||
function priceInput(e) {
|
||||
setTimeout(() => {
|
||||
discountForm.value.amount = inputFilterFloat(e)
|
||||
}, 50)
|
||||
}
|
||||
|
||||
// 关闭
|
||||
function discountModalClose() {
|
||||
discountForm.value = { ...resetDiscountForm.value }
|
||||
discountFormRef.value.resetFields()
|
||||
}
|
||||
|
||||
// 添加快捷备注
|
||||
function addNote(str) {
|
||||
if (!discountForm.value.note.length) {
|
||||
discountForm.value.note += str
|
||||
} else {
|
||||
discountForm.value.note += `,${str}`
|
||||
}
|
||||
}
|
||||
|
||||
// 提交
|
||||
function discountFormSubmit() {
|
||||
discountFormRef.value.validate(async valid => {
|
||||
try {
|
||||
if (valid) {
|
||||
discountFormLoading.value = true
|
||||
|
||||
discountForm.value.masterId = props.item.masterId
|
||||
discountForm.value.cartId = props.item.id
|
||||
discountForm.value.shopId = props.item.shopId
|
||||
|
||||
await updatePrice(discountForm.value)
|
||||
discountFormLoading.value = false
|
||||
|
||||
showDiscountModal.value = false
|
||||
ElMessage.success('操作成功')
|
||||
emit('confirm', { isTemporary: true })
|
||||
}
|
||||
} catch (error) {
|
||||
discountFormLoading.value = false
|
||||
console.log(error);
|
||||
}
|
||||
})
|
||||
}
|
||||
/**单品打折 end */
|
||||
|
||||
/**免厨打印 start */
|
||||
async function kitchenPrint() {
|
||||
try {
|
||||
const res = await orderPrint({
|
||||
isPrint: props.item.isPrint ? 0 : 1,
|
||||
shopId: props.item.shopId,
|
||||
cartId: props.item.id
|
||||
})
|
||||
emit('confirm', { isTemporary: true })
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
/**免厨打印 end */
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -133,7 +287,7 @@ function skuConfirm(e) {
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
gap: 10px;
|
||||
|
||||
.item {
|
||||
width: 70px;
|
||||
@@ -178,4 +332,33 @@ function skuConfirm(e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog {
|
||||
|
||||
.content {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.footer_wrap {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.remark_list {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 10px;
|
||||
|
||||
.item {
|
||||
padding: 0 10px;
|
||||
border: 1px solid #ddd;
|
||||
color: #999;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user