更新折扣优惠和代客下单
This commit is contained in:
@@ -56,14 +56,37 @@
|
||||
<el-checkbox v-model="isPrint" border label="打印结算小票" style="width: 100%" />
|
||||
</div>
|
||||
<div class="print">
|
||||
<el-button type="primary" v-loading="printLoading" @click="printHandle">打印预结单</el-button>
|
||||
<el-button type="warning" :loading="discountLoading" @click="showStaffDiscountHandle">添加折扣</el-button>
|
||||
</div>
|
||||
<div class="print">
|
||||
<el-button type="primary" :loading="printLoading" @click="printHandle">打印预结单</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pay_wrap">
|
||||
<payCard :amount="props.amount" :orderId="props.orderInfo.id" @paySuccess="paySuccess" />
|
||||
<payCard :amount="props.amount" :discount="propsDiscount" :orderId="props.orderInfo.id" @paySuccess="paySuccess"
|
||||
@cancelDiscount="propsDiscount = 0" />
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="showStaffDiscount" title="员工折扣" @close="global.updateData(true)">
|
||||
<el-form>
|
||||
<el-form-item label="折扣比例">
|
||||
<div>
|
||||
<el-input-number v-model="discount" :min="staffDiscount" :max="0.99" :step="0.1"
|
||||
:disabled="staffDiscount == 0" />
|
||||
<div class="tips">最低折扣比例:{{ staffDiscount }}折</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="footer_wrap">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="showStaffDiscount = false">取消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%;" @click="discountConfirm">确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
@@ -73,7 +96,7 @@ import { onMounted, ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import payCard from "@/components/payCard/payCard.vue";
|
||||
import { print } from "@/api/pay";
|
||||
import { orderfindOrder } from '@/api/order/index.js'
|
||||
import { orderfindOrder, getStaffDiscount } from '@/api/order/index.js'
|
||||
import { ElMessage } from "element-plus";
|
||||
import dayjs from "dayjs";
|
||||
import useStorage from '@/utils/useStorage'
|
||||
@@ -92,6 +115,11 @@ const emit = defineEmits("paySuccess");
|
||||
|
||||
const printLoading = ref(false);
|
||||
|
||||
const showStaffDiscount = ref(false)
|
||||
const staffDiscount = ref(0)
|
||||
const discount = ref(0)
|
||||
const propsDiscount = ref(0)
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const props = defineProps({
|
||||
cart: {
|
||||
@@ -122,6 +150,43 @@ const props = defineProps({
|
||||
|
||||
const isPrint = ref(true);
|
||||
|
||||
|
||||
const discountLoading = ref(false)
|
||||
// 显示员工折扣
|
||||
async function showStaffDiscountHandle() {
|
||||
discountLoading.value = true
|
||||
await getStaffDiscountAjax()
|
||||
discountLoading.value = false
|
||||
if (staffDiscount.value <= 0) {
|
||||
ElMessage.error('暂无折扣,请稍后再试')
|
||||
} else {
|
||||
showStaffDiscount.value = true
|
||||
discountLoading.value = false
|
||||
global.updateData(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取员工折扣
|
||||
async function getStaffDiscountAjax() {
|
||||
try {
|
||||
const res = await getStaffDiscount({
|
||||
orderId: props.orderInfo.id,
|
||||
staffId: store.userInfo.staffId
|
||||
})
|
||||
staffDiscount.value = res
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 确认折扣
|
||||
function discountConfirm() {
|
||||
if (discount.value >= staffDiscount.value) {
|
||||
propsDiscount.value = discount.value
|
||||
}
|
||||
showStaffDiscount.value = false
|
||||
}
|
||||
|
||||
// 预打印操作
|
||||
const printHandle = _.throttle(async function () {
|
||||
try {
|
||||
@@ -132,7 +197,9 @@ const printHandle = _.throttle(async function () {
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
isBefore: true,
|
||||
carts: props.cart,
|
||||
amount: props.amount,
|
||||
amount: formatDecimal(props.amount),
|
||||
discountAmount: propsDiscount.value > 0 ? formatDecimal(props.amount * propsDiscount.value) : formatDecimal(props.amount),
|
||||
discount: formatDecimal(propsDiscount.value * 10, 1, true),
|
||||
remark: props.remark,
|
||||
orderInfo: props.orderInfo,
|
||||
createdAt: dayjs(props.orderInfo.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
@@ -176,7 +243,9 @@ async function printOrderLable() {
|
||||
shop_name: store.userInfo.shopName,
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
carts: [],
|
||||
amount: printLabelOrder.orderAmount,
|
||||
amount: formatDecimal(printLabelOrder.orderAmount),
|
||||
discountAmount: printLabelOrder.discountRatio > 0 ? formatDecimal(printLabelOrder.orderAmount - printLabelOrder.discountAmount) : formatDecimal(printLabelOrder.orderAmount),
|
||||
discount: formatDecimal(printLabelOrder.discountRatio * 10, 1, true) || 0,
|
||||
remark: printLabelOrder.remark,
|
||||
orderInfo: printLabelOrder,
|
||||
outNumber: printLabelOrder.outNumber,
|
||||
@@ -219,6 +288,7 @@ async function printOrderLable() {
|
||||
|
||||
// 订单已支付
|
||||
function paySuccess() {
|
||||
propsDiscount.value = 0
|
||||
dialogVisible.value = false;
|
||||
global.setOrderMember({})
|
||||
global.setOrderTable({})
|
||||
@@ -243,6 +313,15 @@ defineExpose({
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.footer_wrap {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.drawer_wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -310,12 +389,13 @@ defineExpose({
|
||||
}
|
||||
|
||||
.list_wrap {
|
||||
padding: var(--el-font-size-base);
|
||||
padding: 0 var(--el-font-size-base);
|
||||
height: calc(100vh - 200px);
|
||||
overflow-y: auto;
|
||||
|
||||
.item {
|
||||
padding-bottom: var(--el-font-size-base);
|
||||
padding: var(--el-font-size-base) 0;
|
||||
border-bottom: 1px solid #ececec;
|
||||
|
||||
.top {
|
||||
display: flex;
|
||||
@@ -326,11 +406,12 @@ defineExpose({
|
||||
}
|
||||
|
||||
.n {
|
||||
margin-right: 50px;
|
||||
width: 50px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.p {
|
||||
width: 50px;
|
||||
color: #555;
|
||||
}
|
||||
}
|
||||
@@ -345,8 +426,6 @@ defineExpose({
|
||||
.tag_wrap {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
|
||||
.tag {
|
||||
padding: 2px 6px;
|
||||
|
||||
Reference in New Issue
Block a user