优化结算订单

This commit is contained in:
gyq 2024-03-15 11:12:55 +08:00
parent 861e62ce15
commit 2b8910f6a1
8 changed files with 107 additions and 38 deletions

View File

@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" /> <meta http-equiv="Content-Security-Policy" />
<title>Vite + Vue</title> <title>银收客</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -77,3 +77,16 @@ export function queryOrder(params) {
params params
}); });
} }
/**
* 打印
* @param {*} params
* @returns
*/
export function print(params) {
return request({
method: "get",
url: "cloudPrinter/print",
params
});
}

View File

@ -186,6 +186,9 @@ async function queryPayTypeAjax() {
shopId: store.userInfo.shopId shopId: store.userInfo.shopId
}) })
payList.value = res payList.value = res
if (res[0].payType == 'scanCode') {
scanModalRef.value.show()
}
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }

View File

@ -14,10 +14,11 @@
</div> </div>
<div class="input"> <div class="input">
<el-input ref="inputRef" v-model="scanCode" <el-input ref="inputRef" v-model="scanCode"
style="height: calc(var(--el-component-size-large) + 20px);" placeholder="请扫描付款码" style="height: calc(var(--el-component-size-large) + 30px);" placeholder="请扫描付款码" clearable
@keydown.enter="enterHandle" clearable></el-input> @change="inputChange"></el-input>
<div class="tips">注意扫码支付请保证输入框获得焦点</div>
</div> </div>
<div class="number_warp"> <!-- <div class="number_warp">
<div class="item" v-for="item in 9" :key="item" @click="inputHandle(item)">{{ item }}</div> <div class="item" v-for="item in 9" :key="item" @click="inputHandle(item)">{{ item }}</div>
<div class="item disabled">.</div> <div class="item disabled">.</div>
<div class="item" @click="inputHandle(0)">0</div> <div class="item" @click="inputHandle(0)">0</div>
@ -26,7 +27,7 @@
<CloseBold /> <CloseBold />
</el-icon> </el-icon>
</div> </div>
</div> </div> -->
<div class="btn"> <div class="btn">
<el-button type="primary" style="width: 100%;" v-loading="loading" <el-button type="primary" style="width: 100%;" v-loading="loading"
@click="submitHandle">立即支付</el-button> @click="submitHandle">立即支付</el-button>
@ -160,13 +161,14 @@ function delHandle() {
} }
// //
function enterHandle() { // function enterHandle() {
inputRef.value.focus() // inputRef.value.focus()
} // }
// const inputChange = _.debounce(function (e) { const inputChange = _.debounce(function (e) {
// console.log(e); // console.log(e);
// }, 300) submitHandle()
}, 500)
function show() { function show() {
dialogVisible.value = true dialogVisible.value = true
@ -192,6 +194,11 @@ defineExpose({
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.tips {
padding-top: 10px;
color: #999;
}
.dialog :deep(.el-dialog__body) { .dialog :deep(.el-dialog__body) {
padding: 0 !important; padding: 0 !important;
} }
@ -263,9 +270,9 @@ defineExpose({
} }
} }
.btn { // .btn {
padding-top: 20px; // padding-top: 20px;
} // }
} }
.pay_wait { .pay_wait {

View File

@ -3,7 +3,7 @@
<div class="header"> <div class="header">
<div class="menus scroll-x"> <div class="menus scroll-x">
<div class="item" :class="{ active: categorysActive == index }" v-for="(item, index) in categorys" <div class="item" :class="{ active: categorysActive == index }" v-for="(item, index) in categorys"
:key="item.id" @click="changeCategory(item, index)"> :key="item.id" @click="changeCategory(index)">
<el-text>{{ item.name }}</el-text> <el-text>{{ item.name }}</el-text>
</div> </div>
</div> </div>
@ -58,6 +58,7 @@
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import _ from 'lodash' import _ from 'lodash'
import useStorage from "@/utils/useStorage";
import skuModal from '@/components/skuModal.vue' import skuModal from '@/components/skuModal.vue'
@ -78,7 +79,6 @@ const skuModalRef = ref(null)
const shopListType = ref('text') const shopListType = ref('text')
const categoryId = ref('')
const categorys = ref([]) const categorys = ref([])
const categorysActive = ref(0) const categorysActive = ref(0)
@ -135,16 +135,41 @@ function changeShopListType() {
} else { } else {
shopListType.value = 'text' shopListType.value = 'text'
} }
useStorage.set('shopListType', shopListType.value)
}
//
function localUpdateShopListType() {
return new Promise((resolve, reject) => {
let type = useStorage.get('shopListType')
if (type != null) {
shopListType.value = type
}
resolve()
})
} }
// //
function changeCategory(item, index) { function changeCategory(index) {
showPopover.value = false showPopover.value = false
categorysActive.value = index categorysActive.value = index
categoryId.value = item.id
useStorage.set('categorysActive', index)
productqueryCommodityInfoAjax() productqueryCommodityInfoAjax()
} }
//
function updateCategoryActive() {
return new Promise((resolve, reject) => {
let index = useStorage.get('categorysActive')
if (index != null) {
categorysActive.value = index
}
resolve()
})
}
// //
async function queryCategoryAjax() { async function queryCategoryAjax() {
try { try {
@ -169,7 +194,7 @@ async function productqueryCommodityInfoAjax() {
loading.value = true loading.value = true
const res = await productqueryCommodityInfo({ const res = await productqueryCommodityInfo({
shopId: store.userInfo.shopId, shopId: store.userInfo.shopId,
categoryId: categoryId.value, categoryId: categorys.value[categorysActive.value].id,
commdityName: commdityName.value, commdityName: commdityName.value,
page: 1, page: 1,
pageSize: 500, pageSize: 500,
@ -185,6 +210,8 @@ async function productqueryCommodityInfoAjax() {
// //
async function updateData() { async function updateData() {
localUpdateShopListType()
await updateCategoryActive()
await queryCategoryAjax() await queryCategoryAjax()
await productqueryCommodityInfoAjax() await productqueryCommodityInfoAjax()
} }

View File

@ -14,7 +14,8 @@
<div class="master_id">{{ props.masterId }}</div> <div class="master_id">{{ props.masterId }}</div>
<div class="btm"> <div class="btm">
<span class="p">服务员{{ store.userInfo.shopName || '暂无' }}</span> <span class="p">服务员{{ store.userInfo.shopName || '暂无' }}</span>
<span class="t">03-01 09:05</span> <span class="t">{{ props.orderInfo.createdAt &&
dayjs(props.orderInfo.createdAt).format('MM-DD HH:mm') }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -47,12 +48,12 @@
<el-checkbox v-model="isPrint" border label="打印结算小票" style="width: 100%;" /> <el-checkbox v-model="isPrint" border label="打印结算小票" style="width: 100%;" />
</div> </div>
<div class="print"> <div class="print">
<el-button type="primary" @click="printHandle">打印预结单</el-button> <el-button type="primary" v-loading="printLoading" @click="printHandle">打印预结单</el-button>
</div> </div>
</div> </div>
</div> </div>
<div class="pay_wrap"> <div class="pay_wrap">
<payCard :amount="props.amount" :orderId="props.orderId" @paySuccess="paySuccess" /> <payCard :amount="props.amount" :orderId="props.orderInfo.id" @paySuccess="paySuccess" />
</div> </div>
</div> </div>
</el-drawer> </el-drawer>
@ -62,6 +63,9 @@
import { ref } from 'vue' import { ref } from 'vue'
import { useUser } from "@/store/user.js" import { useUser } from "@/store/user.js"
import payCard from '@/components/payCard/payCard.vue' import payCard from '@/components/payCard/payCard.vue'
import { print } from '@/api/pay'
import { ElMessage } from "element-plus";
import dayjs from 'dayjs'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
@ -69,6 +73,8 @@ const store = useUser()
const emit = defineEmits('paySuccess') const emit = defineEmits('paySuccess')
const printLoading = ref(false)
const dialogVisible = ref(false) const dialogVisible = ref(false)
const props = defineProps({ const props = defineProps({
cart: { cart: {
@ -83,8 +89,8 @@ const props = defineProps({
type: String, type: String,
default: '' default: ''
}, },
orderId: { orderInfo: {
type: [String, Number], type: Object,
default: '' default: ''
}, },
masterId: { masterId: {
@ -95,16 +101,29 @@ const props = defineProps({
const isPrint = ref(true) const isPrint = ref(true)
function printHandle() { async function printHandle() {
if (!isPrint.value) return // if (!isPrint.value) return
const data = { // const data = {
shop_name: store.userInfo.merchantName, // shop_name: store.userInfo.merchantName,
carts: props.cart, // carts: props.cart,
amount: props.amount, // amount: props.amount,
remark: props.remark, // remark: props.remark,
orderId: props.orderId // orderId: props.orderId
// }
// ipcRenderer.send('printerInfoSync', JSON.stringify(data))
try {
printLoading.value = true
await print({
type: 'normal',
ispre: true,
orderId: props.orderInfo.id
})
printLoading.value = false
ElMessage.success('打印成功')
} catch (error) {
printLoading.value = false
console.log(error)
} }
ipcRenderer.send('printerInfoSync', JSON.stringify(data))
} }
// //

View File

@ -99,7 +99,7 @@
<takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" />
<!-- 结算订单 --> <!-- 结算订单 -->
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark" <settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
:orderId="orderId" :masterId="masterId" @paySuccess="createCodeAjax(1)" /> :masterId="masterId" :orderInfo="orderInfo" @paySuccess="createCodeAjax(1)" />
<!-- 挂起订单 --> <!-- 挂起订单 -->
<pendingCartModal ref="pendingCartModalRef" @select="pendingCartHandle" /> <pendingCartModal ref="pendingCartModalRef" @select="pendingCartHandle" />
</template> </template>
@ -142,7 +142,7 @@ const cartList = ref([])
const cartInfo = ref({}) const cartInfo = ref({})
const cartLoading = ref(false) const cartLoading = ref(false)
const orderId = ref('') const orderInfo = ref({})
const createOrderLoading = ref(false) const createOrderLoading = ref(false)
// //
@ -160,7 +160,7 @@ async function createOrderHandle() {
shopId: store.userInfo.shopId, shopId: store.userInfo.shopId,
remark: remark.value remark: remark.value
}) })
orderId.value = res orderInfo.value = res
settleAccountRef.value.show() settleAccountRef.value.show()
createOrderLoading.value = false createOrderLoading.value = false
} catch (error) { } catch (error) {

View File

@ -9,7 +9,7 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
'/api': { '/api': {
target: 'https://cashierclient.sxczgkj.cn/cashier-client', // 测试 target: 'https://cashierclient.sxczgkj.cn/cashier-client', // 线上
// target: 'http://192.168.2.27:10587/cashier-client', // 国成 // target: 'http://192.168.2.27:10587/cashier-client', // 国成
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '') rewrite: (path) => path.replace(/^\/api/, '')