This commit is contained in:
duan
2025-09-29 10:42:48 +08:00
parent 89db955ec1
commit 096f591123
80 changed files with 8735 additions and 3286 deletions

View File

@@ -6,22 +6,22 @@
{{data.productName}}
</view>
<view class="u-flex u-m-t-32" :class="{'gray':data.productId=='-999'}">
<up-number-box :min="1" :max="data.num" :buttonSize="44" v-model="number" integer :disabled="data.productId=='-999'">
<up-number-box :min="0" :max="maxNum" :buttonSize="44" v-model="number" integer
:disabled="data.productId=='-999'">
<template #minus>
<view class="minus number-box-btn">
</view>
<view class="minus number-box-btn"></view>
</template>
<template #input>
<view class="u-flex-1 u-row-center u-text-center input">
<up-input
:disabled="data.productId=='-999'"
@change="parseIntNumber($event,false)" @blur="parseIntNumber($event,true)"
v-model="number" border="none" type="number"></up-input>
<up-input :disabled="data.productId=='-999'" @change="parseIntNumber($event,false)"
@blur="parseIntNumber($event,true)" v-model="number" border="none"
type="digit"></up-input>
</view>
</template>
<template #plus>
<view class="plus number-box-btn">
<up-icon v-if="data.productId=='-999'" name="plus" color="#ccc" size="16" bold></up-icon>
<up-icon v-if="data.productId=='-999'" name="plus" color="#ccc" size="16"
bold></up-icon>
<up-icon v-else name="plus" color="#999" size="16" bold></up-icon>
</view>
</template>
@@ -50,8 +50,7 @@
<view class="u-p-t-18 u-p-l-30 u-p-r-30 u-p-b-10">
<my-button box-shadow shape="circle" @tap="confirm">确认退菜</my-button>
<view class="u-m-t-10">
<my-button @tap="onModelClose" shape="circle" bgColor="#fff" type="cancel"
box-shadow>取消</my-button>
<my-button @tap="onModelClose" shape="circle" bgColor="#fff" type="cancel" box-shadow>取消</my-button>
</view>
</view>
@@ -60,18 +59,15 @@
</template>
<script setup>
import {
reactive,
ref,
watch
} from 'vue';
import { reactive, ref, watch } from 'vue';
import infoBox from '@/commons/utils/infoBox.js'
const emits = defineEmits(['update:show', 'confirm'])
const props = defineProps({
data: {
type: Object,
default: () => {
return {
productId:'-999'
productId: '-999'
}
}
},
@@ -83,10 +79,11 @@
const form = reactive({
note: ''
})
const emits = defineEmits(['update:show', 'confirm'])
let model = ref(null)
let modelShow = ref(props.show)
let number = ref(1)
let number = ref(0)
let maxNum = ref(0)
const tags = ref([{
label: "点错",
checked: false
@@ -101,28 +98,6 @@
checked: false
}])
let timer = null
function parseIntNumber(val, isNow) {
console.log(val);
let newval = parseInt(val)
if (newval > props.data.num) {
newval = props.data.num
}
if (newval < 1) {
newval = 1
}
if (isNow) {
number.value = parseInt(newval)
return
}
timer = setTimeout(() => {
number.value = newval
}, 100)
}
function changeTagSel(item) {
item.checked = !item.checked
}
watch(() => props.show, (newval) => {
modelShow.value = newval
})
@@ -134,14 +109,34 @@
close()
}
})
function parseIntNumber(val, isNow) {
console.log(val)
let newval = val * 1
if (newval > props.data.num - props.data.returnNum) {
newval = props.data.num - props.data.returnNum
}
if (isNow) {
number.value = newval * 1
return
}
timer = setTimeout(() => {
number.value = newval
}, 100)
}
function changeTagSel(item) {
item.checked = !item.checked
}
function toggleModelShow(show) {
modelShow.value = show ? true : false
}
function onModelClose() {
number.value=1
number.value = 1
modelShow.value = false
}
@@ -151,19 +146,21 @@
function open() {
model.value.open()
if(props.data.productId=='-999'){
number.value=props.data.num
}
number.value = props.data.num - props.data.returnNum
maxNum.value = props.data.num - props.data.returnNum
}
function close() {
model.value.close()
tags.value.map(v=>{
v.checked=false
tags.value.map(v => {
v.checked = false
})
form.note=''
form.note = ''
}
/**
* 确认退菜
*/
function confirm() {
const selTag = tags.value.filter(item => item.checked).map(item => item.label).join(",")
const note = selTag + (form.note.length > 0 ? "," + form.note : "");
@@ -174,10 +171,17 @@
if (!note) {
return infoBox.showToast("请输入退菜原因");
}
emits('confirm', {
note,
num: number.value
})
let par = {
orderId: props.data.orderId,
refundAmount: number.value * props.data.unitPrice,
refundReason: note,
refundDetails: [{
id: props.data.id,
returnAmount: number.value * props.data.unitPrice,
num: number.value,
}],
}
emits('confirm', par)
}
</script>
@@ -206,12 +210,14 @@
::v-deep .uni-input-input {
text-align: center;
}
.gray{
.minus::after{
.gray {
.minus::after {
border-color: #ccc;
}
}
.minus {
&::after {
content: '';