1.优化商品列表全部加载动画 2.退款界面自定义退款使inpt自动获得焦点

This commit is contained in:
gyq 2025-03-25 14:42:42 +08:00
parent 3e84edbb6c
commit 4245b5a098
7 changed files with 16338 additions and 97 deletions

View File

@ -5,7 +5,10 @@ ENV = development
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss' # VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
# 正式ws # 正式ws
VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss' # VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
# 本地ws
VITE_API_WSS = 'ws://192.168.1.43:2348'
# 正式 php # 正式 php
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api' VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
@ -16,9 +19,6 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
# 正式 php 开票 # 正式 php 开票
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api' VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
# 阿伟
# VITE_API_URL = 'http://192.168.1.21:9200/'
# 杰哥 # 杰哥
# VITE_API_URL = 'http://192.168.1.34:10589/cashier-client' # VITE_API_URL = 'http://192.168.1.34:10589/cashier-client'
@ -34,9 +34,12 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
# 谭凯凯 # 谭凯凯
# VITE_API_URL = 'http://192.168.1.35/' # VITE_API_URL = 'http://192.168.1.35/'
# 阿伟
VITE_API_URL = 'http://192.168.1.21:8000/'
# 测试 # 测试
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn' # VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
# 正式 # 正式
VITE_API_URL = 'https://cashier.sxczgkj.com' # VITE_API_URL = 'https://cashier.sxczgkj.com'

View File

@ -16,11 +16,8 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
# 正式 php 开票 # 正式 php 开票
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api' VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
# 测试 # 测试Java
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn' # VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
# 预发布 # 正式Java
# VITE_API_URL = 'https://pre-cashierclient.sxczgkj.cn/cashier-client'
# 正式
VITE_API_URL = 'https://cashier.sxczgkj.com/' VITE_API_URL = 'https://cashier.sxczgkj.com/'

File diff suppressed because one or more lines are too long

View File

@ -42,6 +42,7 @@ export const useGoods = defineStore("goods", {
categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引, categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引,
categoryList: [], // 商品分类列表 categoryList: [], // 商品分类列表
originCategoryList: [], // 原始商品分类列表, originCategoryList: [], // 原始商品分类列表,
goodsListLoading: false, // 商品列表加载状态
goodsList: [], // 商品列表 goodsList: [], // 商品列表
originGoodsList: [], // 原始商品列表 originGoodsList: [], // 原始商品列表
orderList: [], // 订单列表 orderList: [], // 订单列表
@ -182,8 +183,9 @@ export const useGoods = defineStore("goods", {
}); });
} }
this.orderList = arr; this.orderList = arr;
console.log("this.orderList===", this.orderList); console.log("this.orderList===2222", this.orderList);
} }
this.calcCartInfo();
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -205,17 +207,23 @@ export const useGoods = defineStore("goods", {
if (index == 0) { if (index == 0) {
await this.getGoodsList(); await this.getGoodsList();
this.goodsList = _.chunk(this.originGoodsList, 12); this.goodsList = _.chunk(
} this.originGoodsList.filter((item) => item.isSale),
// else if (this.categoryList[index].id == "off_sale") { 12
// // 筛选已下架的商品 );
// } } else if (this.categoryList[index].id == "off_sale") {
else { // 筛选已下架的商品
this.goodsList = _.chunk(
this.originGoodsList.filter((item) => item.isSale == 0),
12
);
} else {
// 除了全部,其他只做本地筛选 // 除了全部,其他只做本地筛选
this.goodsList = _.chunk( this.goodsList = _.chunk(
this.originGoodsList.filter( this.originGoodsList.filter(
(item) => (item) =>
item.categoryId == this.categoryList[this.categoryIndex].id item.categoryId == this.categoryList[this.categoryIndex].id &&
item.isSale
), ),
12 12
); );
@ -223,6 +231,7 @@ export const useGoods = defineStore("goods", {
this.updateGoodsNumber(); this.updateGoodsNumber();
}, },
filterCategoryGoods(id) {},
// 根据商品名字模糊查询商品列表 // 根据商品名字模糊查询商品列表
filterNameGoods(name) { filterNameGoods(name) {
this.goodsList = _.chunk( this.goodsList = _.chunk(
@ -242,10 +251,10 @@ export const useGoods = defineStore("goods", {
name: "全部", name: "全部",
id: "", id: "",
}); });
// this.categoryList.push({ this.categoryList.push({
// name: "已下架", name: "已下架",
// id: "off_sale", id: "off_sale",
// }); });
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@ -253,8 +262,12 @@ export const useGoods = defineStore("goods", {
// 获取商品列表/更新商品列表 // 获取商品列表/更新商品列表
async getGoodsList() { async getGoodsList() {
try { try {
this.goodsListLoading = true;
const res = await productPage({ const res = await productPage({
categoryId: this.categoryList[this.categoryIndex].id, categoryId:
this.categoryList[this.categoryIndex].id == "off_sale"
? ""
: this.categoryList[this.categoryIndex].id,
name: this.goodsName, name: this.goodsName,
}); });
@ -269,14 +282,43 @@ export const useGoods = defineStore("goods", {
val.orderCount = 0; val.orderCount = 0;
}); });
// 将数组分割成每页12个 // // 将数组分割成每页12个
this.goodsList = _.chunk(res, 12); this.goodsList = _.chunk(res, 12);
let index = useStorage.get("categoryIndex") || 0;
if (index == 0) {
this.goodsList = _.chunk(
this.originGoodsList.filter((item) => item.isSale),
12
);
} else if (this.categoryList[index].id == "off_sale") {
// 筛选已下架的商品
this.goodsList = _.chunk(
this.originGoodsList.filter((item) => item.isSale == 0),
12
);
} else {
// 除了全部,其他只做本地筛选
this.goodsList = _.chunk(
this.originGoodsList.filter(
(item) =>
item.categoryId == this.categoryList[this.categoryIndex].id &&
item.isSale
),
12
);
}
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
setTimeout(() => {
this.goodsListLoading = false;
}, 1000);
}, },
// 获取购物车列表,数据必须由长链接返回 // 获取购物车列表,数据必须由长链接返回
async getCartList(arr) { async getCartList(arr) {
try {
const store = useUser(); const store = useUser();
let numCount = 0; let numCount = 0;
@ -305,24 +347,47 @@ export const useGoods = defineStore("goods", {
this.cartList = arr; this.cartList = arr;
this.isCartInit = true; this.isCartInit = true;
if (this.tableInfo.tableCode && store.shopInfo.registerType == "after") { // if (
await this.historyOrderAjax(this.tableInfo.tableCode); // this.tableInfo.tableCode &&
} // store.shopInfo.registerType == "after"
this.calcCartInfo(); // ) {
// await this.historyOrderAjax(this.tableInfo.tableCode);
// }
// this.calcCartInfo();
console.log("getCartList.cartList===", this.cartList); console.log("getCartList.cartList===", this.cartList);
} catch (error) {
console.log("getCartList===", error);
}
}, },
// 更新商品列表的角标 // 更新商品列表的角标
updateGoodsNumber() { updateGoodsNumber() {
let arr = [
...this.cartList,
...this.orderList
.map((item) => item.goods)
.flat()
.map((item) => {
item.discount_sale_amount = item.discountSaleAmount;
item.discount_sale_note = item.discountSaleNote;
item.is_print = item.isPrint;
item.is_gift = item.isGift;
item.is_temporary = item.isTemporary;
return item;
}),
];
this.goodsList.map((item) => { this.goodsList.map((item) => {
item.map((val) => { item.map((val) => {
val.number = 0; val.number = 0;
this.cartList.map((cart) => { arr.map((cart) => {
if (val.id == cart.product_id) { if (val.id == cart.product_id) {
val.number += +cart.number; val.number += +cart.number - (cart.returnNum || 0);
} }
}); });
}); });
}); });
console.log("updateGoodsNumber===", this.goodsList);
}, },
// 添加商品到购物车 // 添加商品到购物车
addCart(params) { addCart(params) {
@ -464,7 +529,7 @@ export const useGoods = defineStore("goods", {
item.skuList = val.skuList; item.skuList = val.skuList;
item.selectSpecInfo = val.selectSpecInfo; item.selectSpecInfo = val.selectSpecInfo;
item.group_text = group_text; item.group_text = group_text;
item.packFee = val.packFee; item.packFee = item.packAmount;
item.unitName = val.unitName; item.unitName = val.unitName;
} }
item.pack_number = item.packNumber; item.pack_number = item.packNumber;
@ -528,15 +593,22 @@ export const useGoods = defineStore("goods", {
// 存在真实台桌,需要拉取历史订单 // 存在真实台桌,需要拉取历史订单
if (this.tableInfo.id) { if (this.tableInfo.id) {
await this.historyOrderAjax(this.tableInfo.tableCode); await this.historyOrderAjax(this.tableInfo.tableCode);
} else {
this.calcCartInfo();
} }
this.calcCartInfo(); // 清空商品列表的角标
// this.goodsList.map((item) => {
// item.map((val) => {
// val.number = 0;
// });
// });
}, },
// 下单成功清除购物车,重新加载订单 // 下单成功清除购物车,重新加载订单
async updateOrderList() { async updateOrderList() {
await this.historyOrderAjax(this.cartList[0].table_code); await this.historyOrderAjax(this.cartList[0].table_code);
this.cartList = []; this.cartList = [];
this.calcCartInfo(); // this.calcCartInfo();
}, },
// 计算购物车信息 // 计算购物车信息
calcCartInfo() { calcCartInfo() {
@ -568,9 +640,11 @@ export const useGoods = defineStore("goods", {
}), }),
]; ];
console.log("arr===", arr); console.log("arr===11111", arr);
arr.map((val, index) => { arr.map((val, index) => {
console.log("val===", val);
let lowPrice = 0; let lowPrice = 0;
let number = val.number - (val.returnNum || 0); let number = val.number - (val.returnNum || 0);

View File

@ -4,7 +4,12 @@
<div class="menus scroll-x"> <div class="menus scroll-x">
<div class="item" :class="{ active: goodsStore.categoryIndex == index }" <div class="item" :class="{ active: goodsStore.categoryIndex == index }"
v-for="(item, index) in goodsStore.categoryList" :key="item.id" @click="changeCategory(index)"> v-for="(item, index) in goodsStore.categoryList" :key="item.id" @click="changeCategory(index)">
<el-text>{{ item.name }}</el-text> <el-icon v-if="item.id === ''" class="icon" :class="{ active: goodsStore.goodsListLoading }">
<RefreshRight />
</el-icon>
<el-text>
{{ item.name }}
</el-text>
</div> </div>
</div> </div>
<el-popover trigger="click" :width="600" title="全部分类" :visible="showPopover"> <el-popover trigger="click" :width="600" title="全部分类" :visible="showPopover">
@ -51,7 +56,7 @@
<transition name="el-fade-in"> <transition name="el-fade-in">
<div class="more" v-if="item.showMore" @click.stop> <div class="more" v-if="item.showMore" @click.stop>
<div class="ul"> <div class="ul">
<template v-if="goodsStore.categoryList[goodsStore.categoryIndex].id == '-1'"> <template v-if="goodsStore.categoryList[goodsStore.categoryIndex].id == 'off_sale'">
<div class="li" @click.stop="showPutawayHandle(item)">上架</div> <div class="li" @click.stop="showPutawayHandle(item)">上架</div>
</template> </template>
<template v-else> <template v-else>
@ -65,7 +70,7 @@
</transition> </transition>
<div class="dot" v-if="item.number">{{ item.number }}</div> <div class="dot" v-if="item.number">{{ item.number }}</div>
<div class="cover" v-if="shopListType == 'img'"> <div class="cover" v-if="shopListType == 'img'">
<el-image :src="`${item.coverImg}?x-oss-process=image/resize,m_lfit,w_150,h_150`" <el-image :src="`${item.coverImg}?x-oss-process=image/resize,m_lfit,w_120,h_120`"
class="el_img" fit="cover"></el-image> class="el_img" fit="cover"></el-image>
<div class="sell_out" v-if="item.isSoldStock"> <div class="sell_out" v-if="item.isSoldStock">
<img class="sell_out_icon" src="../../../assets/icon_xq.png"> <img class="sell_out_icon" src="../../../assets/icon_xq.png">
@ -491,7 +496,7 @@ function showSkuHandle(item) {
if (!item.isSale) { if (!item.isSale) {
ElMessage({ ElMessage({
type: 'error', type: 'error',
message: '该商品已下架,请上架后操作', message: '该商品已下架,请编辑上架后操作',
showClose: true, showClose: true,
}) })
return return
@ -656,7 +661,7 @@ const showPutawayLoading = ref(false)
async function showPutawayHandle(item) { async function showPutawayHandle(item) {
try { try {
await staffPermission('yun_xu_shang_xia_jia_shang_pin') // await staffPermission('yun_xu_shang_xia_jia_shang_pin')
goodEditorItem.value = item goodEditorItem.value = item
showPutaway.value = true showPutaway.value = true
} catch (error) { } catch (error) {
@ -668,11 +673,10 @@ async function showPutawayHandle(item) {
async function putawayHandle(item) { async function putawayHandle(item) {
try { try {
showPutawayLoading.value = true showPutawayLoading.value = true
const res = await productStatus({ await productOnOff({
shopId: store.userInfo.shopId, type: 'product',
productId: goodEditorItem.value.id, id: goodEditorItem.value.id,
type: 0, isSale: 1
state: 1
}) })
showPutawayLoading.value = false showPutawayLoading.value = false
showPutaway.value = false showPutaway.value = false
@ -835,6 +839,26 @@ defineExpose({
position: relative; position: relative;
white-space: nowrap; white-space: nowrap;
.icon {
margin-right: 4px;
animation: rotateAni 1s linear infinite;
animation-play-state: paused;
@keyframes rotateAni {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
&.active {
animation-play-state: running;
}
}
span { span {
font-size: var(--el-font-size-base); font-size: var(--el-font-size-base);
} }

View File

@ -24,8 +24,8 @@
<el-radio-button label="自定义" :value="3" /> <el-radio-button label="自定义" :value="3" />
</el-radio-group> </el-radio-group>
<div class="amount"> <div class="amount">
<el-input v-model="refundAmount" style="width: 400px;height: 42px;" :readonly="refundType != 3" <el-input ref="amountInputRef" v-model="refundAmount" style="width: 400px;height: 42px;"
placeholder="请输入退款金额" @input="inputChange"> :readonly="refundType != 3" placeholder="请输入退款金额" @input="inputChange">
<template #prepend></template> <template #prepend></template>
<template #append>最多可退{{ formatDecimal(item.payAmount - item.refundAmount, 2) }}</template> <template #append>最多可退{{ formatDecimal(item.payAmount - item.refundAmount, 2) }}</template>
</el-input> </el-input>
@ -166,6 +166,7 @@ const remarkTagList = ref([
const loading = ref(false) const loading = ref(false)
const takeFoodCodeRef = ref(null) const takeFoodCodeRef = ref(null)
const cash = ref(false) const cash = ref(false)
const amountInputRef = ref(null)
// 退 // 退
async function passwordSuccess(e = '') { async function passwordSuccess(e = '') {
@ -397,6 +398,7 @@ function refundTypeChange(val) {
tableRef.value.clearSelection() tableRef.value.clearSelection()
refundAmount.value = '' refundAmount.value = ''
modify.value = true modify.value = true
amountInputRef.value.focus()
break; break;
default: default:
break; break;

View File

@ -35,7 +35,7 @@
<el-button type="success" style="width: 100%;" @click="toOrderMeal(1)">加菜/管理</el-button> <el-button type="success" style="width: 100%;" @click="toOrderMeal(1)">加菜/管理</el-button>
</div> </div>
<div class="btn_wrap"> <div class="btn_wrap">
<el-button type="primary" style="width: 100%;" @click="showPayHandle">结算({{ <el-button type="primary" style="width: 100%;" :loading="payLoading" @click="showPayHandle">结算({{
orderInfo.orderAmount || 0 }})</el-button> orderInfo.orderAmount || 0 }})</el-button>
</div> </div>
</div> </div>
@ -76,20 +76,16 @@
</transition> </transition>
</div> </div>
<!-- 结算订单 --> <!-- 结算订单 -->
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="orderInfo.orderAmount" <SettleAccount ref="SettleAccountRef" @success="emits('success')" />
:remark="orderInfo.remark" :masterId="orderInfo.masterId" :orderInfo="orderInfo" @paySuccess="paySuccess" />
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, watch } from 'vue' import { ref, onMounted, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useUser } from "@/store/user.js" import { useUser } from "@/store/user.js"
import { useGlobal } from '@/store/global.js'
import { queryMembermember } from '@/api/member/index.js'
import { orderDetail } from '@/api/order/index.js'
import { formatDecimal } from '@/utils/index.js' import { formatDecimal } from '@/utils/index.js'
import settleAccount from "@/views/home/components/settleAccount.vue"; import SettleAccount from '@/views/home/components/settleAccount.vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { clearTable } from '@/api/table.js' import { clearTable } from '@/api/table.js'
import { useGoods } from "@/store/goods.js"; import { useGoods } from "@/store/goods.js";
@ -97,8 +93,8 @@ import { getOrderByIdAjax } from '@/utils/index.js'
const goodsStore = useGoods() const goodsStore = useGoods()
const router = useRouter() const router = useRouter()
const global = useGlobal()
const store = useUser() const store = useUser()
const SettleAccountRef = ref(null)
const emits = defineEmits(['close', 'success']) const emits = defineEmits(['close', 'success'])
@ -109,7 +105,6 @@ const props = defineProps({
} }
}) })
const showPeopleNum = ref(false) const showPeopleNum = ref(false)
const peopleNum = ref(0) const peopleNum = ref(0)
const peopleNumInputValue = ref('') const peopleNumInputValue = ref('')
@ -123,7 +118,6 @@ function inputFocus() {
peopleNum.value = 'custom' peopleNum.value = 'custom'
} }
const settleAccountRef = ref(null)
const orderInfo = ref({}) const orderInfo = ref({})
const cartList = ref([]) const cartList = ref([])
@ -140,8 +134,20 @@ const status = ref({
const payLoading = ref(false) const payLoading = ref(false)
// //
function showPayHandle() { async function showPayHandle() {
settleAccountRef.value.show() try {
payLoading.value = true
await goodsStore.historyOrderAjax('', props.tableInfo.orderId)
goodsStore.selectTable({
...props.tableInfo,
num: props.tableInfo.useNum
})
goodsStore.calcCartInfo()
SettleAccountRef.value.show()
} catch (error) {
console.log(error);
}
payLoading.value = false
} }
// //
@ -227,7 +233,10 @@ function orderDownHandle() {
function toOrderMeal(t) { function toOrderMeal(t) {
if (t == 1) { if (t == 1) {
// //
global.setOrderTable(props.tableInfo) goodsStore.selectTable({
...props.tableInfo,
num: props.tableInfo.useNum
})
router.push({ router.push({
name: 'home', name: 'home',
}) })