This commit is contained in:
weipengfei 2024-05-14 18:39:10 +08:00
parent 2bebabf1bc
commit 255a82adcf
18 changed files with 1257 additions and 105 deletions

View File

@ -1,5 +1,7 @@
VITE_NOW_TYPE = 'dist'
VITE_PUSH_URL = 'ws://192.168.1.22:8787'
VITE_BASE_URL = 'http://192.168.1.22:8546'
# VITE_BASE_URL = 'https://erp.lihaink.cn'
# VITE_BASE_URL = 'http://192.168.1.22:8546'
VITE_BASE_URL = 'https://erp.lihaink.cn'

View File

@ -5,6 +5,16 @@
<link rel="icon" type="image/svg+xml" href="/cashier.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>里海收银系统</title>
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js">
</script>
<script type="text/javascript">
document.addEventListener('UniAppJSBridgeReady', function() {
})
// window.receiveData = (e)=>{
// ElMessage.success("接收到消息:" + JSON.stringify(e));
// }
</script>
<style>
/* 小屏幕 */
@media screen and (max-width: 576px) {

View File

@ -127,3 +127,24 @@ export function createOrderApi(data) {
export function cashierinfoListApi(data) {
return request.get(`/order/cashierinfo/lists`, { params: data })
}
/**
* @description 商户给用户添加地址
*/
export function merchantCreateApi(data) {
return request.post(`/user/address/merchant_create`, data)
}
/**
* @description 采购订单记录列表
*/
export function opurchaseOrderApi(data) {
return request.get(`/order/OpurchaseOrder/lists`, { params: data })
}
/**
* @description 采购订单子订单列表
*/
export function subOrdersListApi(data) {
return request.get(`/order/OpurchaseOrder/sub_orders`, { params: data })
}

View File

@ -13,7 +13,8 @@ const list = ref([
{ name: "saleHome", title: "收银", ico: "Sell", count: 0 },
{ name: "saleOrder", title: "收银订单", ico: "DataLine", count: 0 },
{ name: "order", title: "待提采购", ico: "DataAnalysis", count: 0 },
{ name: "orderSystem", title: "采购订单", ico: "Tickets", count: 0 },
{ name: "purchaseOrder", title: "采购订单", ico: "Tickets", count: 0 },
{ name: "test", title: "打印", ico: "Tickets", count: 0 },
]);
const aup = () => {
let index = list.value.findIndex((item) => item.name == route.name);

View File

@ -1,9 +1,10 @@
<script setup>
import { useUserStore } from "@/store/user.js";
import { ref } from "vue";
import { onMounted, onUnmounted, ref } from "vue";
import { info, logout } from "@/api/user.js";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import mitt from "@/utils/mitt.js";
const userStore = useUserStore();
@ -16,6 +17,61 @@ const onLogout = () => {
userStore.setToken("");
router.push("/login");
};
const is_connect = ref(false); //
//
const connect = () => {
console.log("连接打印机");
uni.postMessage({
data: {
type: "connect",
},
});
};
//
const printReceipt = (content = "") => {
console.log("预打印");
uni.getEnv((res) => {
if (res.h5) ElMessage.error("请使用APP打印小票");
else APPprint(content);
});
};
// APP
const APPprint = (content = "") => {
let str = "";
if (content === "") {
str += "********************************\n";
str += "泸优采-小票\n";
str += "单号: CG171565043141139102\n";
str += "测试商品1 * 1 \t 1.00元 \n";
str += "测试商品2 * 1 \t 1.00元 \n";
str += "测试商品小黄鸭3 * 1 \t 1.00元 \n";
str += "\n";
str += "--------------------------------\n";
str += "\n";
} else str = content;
uni.postMessage({
data: {
type: "print",
content: str,
},
});
};
onMounted(() => {
mitt.on("printReceipt", printReceipt);
// ElMessage.success(":");
window.receiveData = (e)=>{
ElMessage.success("接收到消息:");
}
});
onUnmounted(() => {
mitt.off("printReceipt", printReceipt);
});
</script>
<template>
@ -30,6 +86,17 @@ const onLogout = () => {
<div class="card-title">里海收银系统</div>
</div>
<div class="card-body">
<div style="margin-right: 1rem">
<el-button @click="mitt.emit('printReceipt')" link type="warning">
打印测试
</el-button>
</div>
<div style="margin-right: 1rem" v-if="!is_connect">
<el-button @click="connect" link type="warning">
点击自动连接打印机
</el-button>
</div>
<div style="margin-right: 1rem; color: #333" v-else>打印机正常运行</div>
<el-dropdown trigger="hover">
<div class="el-dropdown-link">
<el-avatar :src="merInfo.avatar" icon="user-filled" />
@ -67,6 +134,10 @@ const onLogout = () => {
font-size: 1.6rem;
}
}
.card-body {
display: flex;
align-items: center;
}
}
.el-dropdown-link {
width: auto;

View File

@ -11,57 +11,34 @@ const routes = [
redirect: '/saleHome',
meta: { title: '里海收银系统' },
children: [
{
path: '/home',
name: 'home',
meta: { title: '收银' },
component: () => import('@/views/home/index.vue'),
},
{
path: '/order',
name: 'order',
meta: { title: '收银订单' },
component: () => import('@/views/order/index.vue'),
},
{
path: '/orderSystem',
name: 'orderSystem',
meta: { title: '平台订单' },
component: () => import('@/views/order/indexSystem.vue'),
},
{
path: '/saleHome',
name: 'saleHome',
meta: { title: '批发' },
meta: { title: '收银' },
component: () => import('@/views/saleHome/index.vue'),
},
{
path: '/saleOrder',
name: 'saleOrder',
meta: { title: '批发订单' },
meta: { title: '采购订单' },
component: () => import('@/views/saleOrder/index.vue'),
},
{
path: '/orderList',
name: 'orderList',
meta: { title: '统计' },
component: () => import('@/views/order/indexList.vue'),
path: '/order',
name: 'order',
meta: { title: '待提采购' },
component: () => import('@/views/order/index.vue'),
},
{
path: '/orderCount',
name: 'orderCount',
meta: { title: '统计' },
component: () => import('@/views/order/indexCount.vue'),
path: '/purchaseOrder',
name: 'purchaseOrder',
meta: { title: '采购订单' },
component: () => import('@/views/purchaseOrder/index.vue'),
},
{
path: '/shop',
name: 'shop',
component: () => import('@/views/shop/index.vue'),
},
{
path: '/convert',
name: 'convert',
component: () => import('@/views/convert/index.vue'),
path: '/test',
name: 'test',
component: () => import('@/views/test/test.vue'),
},
]
},
@ -70,11 +47,6 @@ const routes = [
name: 'login',
component: () => import('@/views/login/index.vue'),
},
{
path: '/test',
name: 'test',
component: () => import('@/views/test/test.vue'),
},
// 注意:通配符路由要放在最后
{
path: '/:catchAll(.*)',

View File

@ -32,24 +32,24 @@ request.interceptors.request.use(
request.interceptors.response.use(
response => {
// 对响应数据做些什么,例如解析数据、统一处理错误等
if (response.data.status === 401 || response.data.status === 40000 || (response.data.code === -1 && response.data.msg === '登录超时,请重新登录')) {
if (response.data.code === 401 || response.data.code === 40000 || (response.data.code === -1 && response.data.msg === '登录超时,请重新登录')) {
ElMessage({
message: response.data.message,
message: response.data.msg,
type: 'error',
})
setTimeout(()=>{
setTimeout(() => {
const userStore = useUserStore();
userStore.setUserInfo({});
userStore.setToken('');
router.push('/login');
},700)
}, 700)
}
if (response.data.status === 400) {
if (response.data.code === 400) {
ElMessage({
message: response.data.message,
message: response.data.msg,
type: 'error',
})
throw new Error(response.data.message);
throw new Error(response.data.msg);
}
if (response.data.show) {
ElMessage({
@ -57,13 +57,25 @@ request.interceptors.response.use(
type: 'error',
})
}
if (response.data.code === 500) {
response.data.msg = JSON.parse(response.data.msg);
ElMessage({
message: response.data.msg?.msg || response.data.msg,
type: 'error',
})
throw new Error(response.data.msg);
}
console.log(response.data);
if (response.data.code === 0) {
return Promise.reject(response.data)
}
return response.data;
},
error => {
// 处理响应错误
console.error(error);
ElMessage({
message: error.response?.data?.message || error,
message: error.response?.data?.msg || error,
type: 'error',
})
return Promise.reject(error);

View File

@ -107,17 +107,20 @@ const getOrderList = () => {
}
};
const emit = defineEmits(["addAddress"]);
const addAddress = (item) => {
emit("addAddress", item);
};
onMounted(() => {
mitt.on("set-c-order-detail", (res) => {
formData.value = res;
where.value.page_no = 1;
where.value.loadend = false;
where.value.loading = false;
goods_list.value = [];
getOrderList();
});
mitt.on("set-c-order-detail", (res) => {
formData.value = res;
where.value.page_no = 1;
where.value.loadend = false;
where.value.loading = false;
goods_list.value = [];
getOrderList();
});
});
onUnmounted(() => {
@ -201,8 +204,10 @@ onUnmounted(() => {
</div>
</div>
</div>
<div v-else class="add-address">
<el-button type="primary" @click="addAddress()" size="Large" >点击添加收货地址</el-button>
<div v-else class="addAddress">
<el-button type="primary" @click="addAddress(formData)" size="large"
>点击添加收货地址</el-button
>
</div>
<div style="font-size: 0.9rem">
共计
@ -253,7 +258,7 @@ onUnmounted(() => {
.table-title {
font-weight: bold;
}
.add-address{
.addAddress {
margin-top: 1rem;
margin-bottom: 1.5rem;
}

View File

@ -42,6 +42,9 @@ const payRef = ref(null);
const changeDate = (e) => {
getOrderList(true);
};
const disabledDate = (time)=>{
return time.getTime() > Date.now();
}
const where = ref({
page_no: 1,
@ -91,6 +94,15 @@ const setForm = (item, index) => {
mitt.emit("set-c-order-detail", item);
};
defineExpose({
getOrderList
})
const emit = defineEmits(['addAddress'])
const addAddress = (item)=>{
emit('addAddress',item)
}
onMounted(() => {
mitt.on("update-c-order-detail", (item) => {
orderList.value[activeStore.value].paid = 1;
@ -105,7 +117,7 @@ onUnmounted(()=>{
<div class="my-order">
<div class="header-nav">
<div class="nav-item">
{{ "收银订单" }}
{{ "待提交采购订单" }}
</div>
<div class="nav-item-btn">
<!-- <el-radio-group
@ -123,6 +135,7 @@ onUnmounted(()=>{
size="small"
:clearable="false"
value-format="YYYY-MM-DD"
:disabled-date="disabledDate"
@change="changeDate"
/>
</div>

View File

@ -3,15 +3,80 @@ import order from "./component/order.vue";
import detail from "./component/detail.vue";
import padding from "@/components/padding.vue";
import { ref, nextTick } from "vue";
import { merchantCreateApi } from "@/api/store";
const orderRef = ref(null);
const dialogFormVisible = ref(false);
const addAddress = (e) => {
if (e.id != form.value.order_id) {
form.value = {
real_name: "",
phone: "",
detail: "",
order_id: e.id,
};
} else form.value.order_id = e.id;
dialogFormVisible.value = true;
};
const form = ref({
real_name: "",
phone: "",
detail: "",
order_id: "",
});
const rules = ref({
real_name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
phone: [{ required: true, message: "请输入手机号", trigger: "blur" }],
detail: [{ required: true, message: "请输入地址", trigger: "blur" }],
});
const submit = () => {
merchantCreateApi(form.value).then((res) => {
dialogFormVisible.value = false;
orderRef.value?.getOrderList(true);
});
};
</script>
<template>
<div class="my-card">
<order style="flex-shrink: 0;" ref="orderRef"/>
<order style="flex-shrink: 0" ref="orderRef" @addAddress="addAddress" />
<padding />
<detail ref="detailRef"/>
<detail ref="detailRef" @addAddress="addAddress" />
<el-dialog v-model="dialogFormVisible" title="添加地址" width="500">
<el-form :model="form" label-width="100" :rules="rules">
<el-form-item
label="收货人"
:label-width="formLabelWidth"
prop="real_name"
>
<el-input
v-model="form.real_name"
autocomplete="off"
placeholder="请输入收货人"
/>
</el-form-item>
<el-form-item label="电话" :label-width="formLabelWidth" prop="phone">
<el-input
v-model="form.phone"
type="number"
placeholder="请输入电话"
/>
</el-form-item>
<el-form-item label="地址" :label-width="formLabelWidth" prop="detail">
<el-input v-model="form.detail" placeholder="请输入地址" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="submit"> 确认 </el-button>
</div>
</template>
</el-dialog>
</div>
</template>

View File

@ -0,0 +1,258 @@
<script setup>
import { nextTick, onMounted, onUnmounted, ref } from "vue";
import {
orderListApi,
orderStatusApi,
orderLadingApi,
cartListApi,
subOrdersListApi,
} from "@/api/store.js";
import { useUserStore } from "@/store/user.js";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import mitt from "@/utils/mitt.js";
import subDetail from "./sub.vue";
const userStore = useUserStore();
const router = useRouter();
const formData = ref({
id: "",
});
const list = ref([]);
const payRef = ref(null);
const loading = ref(false);
const total = ref(0);
const activeStore = ref(0);
const activeStoreList = ref(["商品信息", "订单详情"]);
const orderLadingSn = ref("");
const dialogVisible = ref(false);
const orderLadingComfirm = (order_sn) => {
orderLadingSn.value = order_sn;
dialogVisible.value = true;
};
const orderLading = () => {
dialogVisible.value = false;
orderLadingApi({
order_sn: orderLadingSn.value,
staff_id: userStore.userInfo.service.service_id,
}).then((res) => {
ElMessage({
message: res.message,
type: "success",
});
router.push({
name: "home",
});
});
};
const rePay = (row) => {
payRef.value.setRePay({
price: row.pay_price,
order_id: row.group_order_id,
});
payRef.value.drawer = true;
};
const getOrderStatus = (id) => {
orderStatusApi({
order_sn: id,
})
.then((res) => {
if (res.data.paid == 1 || res.message == "支付成功") {
ElMessage({
message: res.message,
type: "success",
});
mitt.emit("update-c-order-detail", {});
formData.value.paid = 1;
} else {
ElMessage({
message: res.message,
type: "error",
});
}
})
.catch((err) => {});
};
const where = ref({
page_no: 1,
page_size: 15,
loadend: false,
loading: false,
});
const goods_list = ref([]);
const getOrderList = () => {
console.log("触底");
if (formData.value.id && !where.value.loadend) {
console.log("加载");
where.value.loading = true;
subOrdersListApi({
id: formData.value.id,
page_no: where.value.page_no,
page_size: where.value.page_size,
}).then((res) => {
goods_list.value = [...goods_list.value, ...res.data.lists];
if (res.data.lists.length < where.value.page_size)
where.value.loadend = true;
where.value.loading = false;
where.value.page_no++;
});
}
};
const cellClick = (row) => {
console.log(row);
subRef.value.drawer = true;
subRef.value.setForm(row);
};
const emit = defineEmits(["addAddress"]);
const addAddress = (item) => {
emit("addAddress", item);
};
const subRef = ref(null);
onMounted(() => {
mitt.on("set-c-order-detail", (res) => {
formData.value = res;
where.value.page_no = 1;
where.value.loadend = false;
where.value.loading = false;
goods_list.value = [];
getOrderList();
// setTimeout(() => {
// nextTick(() => {
// console.log("===", subRef.value);
// subRef.value.drawer = true;
// subRef.value.setForm(formData.value);
// });
// }, 2000);
});
});
onUnmounted(() => {
mitt.off("set-c-order-detail");
});
</script>
<template>
<div class="my-order">
<div class="detail" v-loading="loading">
<div
class="table"
v-loading="loading"
v-infinite-scroll="getOrderList"
infinite-scroll-distance="300"
infinite-scroll-delay="300"
style="overflow: auto"
:infinite-scroll-immediate="false"
>
<div class="table-title">订单信息</div>
<div class="table-info">
<div class="info-item">
<div class="info-item-title">订单编号:</div>
<div class="info-item-info">{{ formData.number }}</div>
</div>
<div class="info-item">
<div class="info-item-title">订单数量:</div>
<div class="info-item-info">{{ formData.order_count }}</div>
</div>
<div class="info-item">
<div class="info-item-title">商品总价:</div>
<div class="info-item-info">¥{{ formData.total }}</div>
</div>
<div class="info-item">
<div class="info-item-title">创建时间:</div>
<div class="info-item-info">{{ formData.create_time }}</div>
</div>
</div>
<div style="font-size: 0.9rem">
共计
<span style="color: #ff4a00">{{ formData.order_count }}</span
>个订单 <span style="color: #777"> ( 点击订单查看订单详情 )</span>
</div>
<el-table
:data="goods_list"
style="cursor: pointer"
@cell-click="cellClick"
>
<el-table-column type="index" width="60" label="序号" />
<el-table-column prop="number" label="订单号" width="200" />
<el-table-column prop="real_name" label="收货人" width="150" />
<el-table-column prop="user_phone" label="联系方式" width="150" />
<el-table-column prop="user_address" label="收货地址">
</el-table-column>
<el-table-column
prop="update_time"
label="下单时间"
width="200"
></el-table-column>
</el-table>
</div>
</div>
<subDetail ref="subRef" />
</div>
</template>
<style scoped lang="scss">
.my-order {
border-radius: 1.2rem;
height: 100%;
flex: 1;
background-color: #fff;
position: relative;
overflow: hidden;
.detail {
height: calc(100vh - 100px - 4rem);
box-sizing: border-box;
position: relative;
.table {
padding: 1rem;
padding-bottom: 6rem;
overflow-y: auto;
height: 100%;
.table-title {
font-weight: bold;
}
.addAddress {
margin-top: 1rem;
margin-bottom: 1.5rem;
}
.table-info {
display: flex;
flex-wrap: wrap;
color: #777;
font-size: 0.9rem;
padding-bottom: 1rem;
margin-bottom: 1rem;
border-bottom: 1px solid #eee;
&:last-child {
border-bottom: none;
}
.info-item {
width: 33%;
display: flex;
padding-top: 1rem;
.info-item-title {
flex-shrink: 0;
padding-right: 1rem;
}
}
}
}
}
}
</style>

View File

@ -0,0 +1,342 @@
<script setup>
import { ref, onMounted, onUnmounted } from "vue";
import {
opurchaseOrderApi,
orderStatusApi,
orderLadingApi,
cartListApi,
saleOrderListApi,
createOrderApi
} from "@/api/store.js";
import { useUserStore } from "@/store/user.js";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import mitt from "@/utils/mitt.js";
import moment from "moment";
const userStore = useUserStore();
const props = defineProps({
isSystem: {
type: Boolean,
default: false,
},
source: {
type: Number,
default: 0,
},
});
const lists = ref([]);
const tabPosition = ref(1); // 1-, 2-
const changeTabPosition = (e) => {
where.value.page_no = 1;
loadEnd.value = false;
loading.value = false;
orderList.value = [];
getOrderList(true);
};
const payRef = ref(null);
const date = ref("");
const changeDate = () => {
where.value.start_time = date.value[0] + ' 00:00:00';
where.value.end_time = date.value[1] + ' 23:59:59';
getOrderList(true);
};
const disabledDate = (time)=>{
return time.getTime() > Date.now();
}
const where = ref({
page_no: 1,
page_size: 20,
number: "",
start_time: "",
end_time: "",
});
const loading = ref(false);
const total = ref(0);
const activeStore = ref(0);
const loadEnd = ref(false);
const orderList = ref([]);
const getOrderList = (reload = false) => {
if (reload) where.value.page_no = 1;
else if (loadEnd.value || loading.value) return;
loading.value = true;
if (tabPosition.value == 1) where.value.paid = null;
if (tabPosition.value == 2) where.value.paid = 0;
opurchaseOrderApi(where.value)
.then((res) => {
if (reload) orderList.value = res.data.lists;
else orderList.value = [...orderList.value, ...res.data.lists];
if (res.data.lists.length < where.value.page_size) loadEnd.value = true;
else where.value.page_no++;
activeStore.value = 0;
mitt.emit("set-c-order-detail", orderList.value[0]);
total.value = res.data.count;
loading.value = false;
})
.catch((err) => {
loadEnd.value = true;
loading.value = false;
});
};
const submitOrder = ()=>{
createOrderApi().then(res=>{
console.log(res);
})
}
const setForm = (item, index) => {
activeStore.value = index;
mitt.emit("set-c-order-detail", item);
};
defineExpose({
getOrderList
})
const emit = defineEmits(['addAddress'])
const addAddress = (item)=>{
emit('addAddress',item)
}
onMounted(() => {
mitt.on("update-c-order-detail", (item) => {
orderList.value[activeStore.value].paid = 1;
});
});
onUnmounted(()=>{
mitt.off("update-c-order-detail");
})
</script>
<template>
<div class="my-order">
<div class="header-nav">
<div class="nav-item">
{{ "采购订单" }}
</div>
<div class="nav-item-btn">
<el-date-picker
v-model="date"
type="daterange"
start-placeholder="开始时间"
end-placeholder="结束时间"
size="small"
value-format="YYYY-MM-DD"
:disabled-date="disabledDate"
@change="changeDate"
/>
</div>
</div>
<div class="header-input">
<el-input
v-model="where.number"
placeholder="请输入订单编号"
@keydown.enter="getOrderList(true)"
@clear="getOrderList(true)"
clearable
>
<template #append>
<el-button
type="primary"
style="
background-color: #1890ff;
color: #fff;
border-radius: 0 0.315rem 0.315rem 0;
"
@click="getOrderList(true)"
>搜索</el-button
>
</template>
</el-input>
</div>
<div
class="order-lists"
v-loading="loading"
v-infinite-scroll="getOrderList"
infinite-scroll-distance="300"
infinite-scroll-delay="500"
style="overflow: auto"
>
<div
class="item"
:class="{ 'item-active': activeStore == index }"
v-for="(item, index) in orderList"
:key="index"
@click="setForm(item, index)"
>
<div class="top">
<div class="sn">单号: {{ item.number }}</div>
<div class="create-time">{{ item.create_time }}</div>
</div>
<div class="shop">
<div class="left">
<div>订单数量 x {{item.order_count}}</div>
</div>
<div class="right">
<div class="money">¥{{ item.total }}</div>
</div>
</div>
<div class="bottom">
</div>
</div>
<div v-if="loadEnd" class="load-end">没有更多了</div>
<div v-if="loading" class="load-end">加载中...</div>
</div>
</div>
</template>
<style scoped lang="scss">
.my-order {
border-radius: 1.2rem;
height: 100%;
background-color: #fff;
width: 30rem;
position: relative;
overflow: hidden;
.header-nav {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 1rem;
height: 3.5rem;
span {
color: #ff4a00;
}
.nav-item {
font-weight: bold;
}
.nav-item-btn {
display: flex;
justify-content: space-between;
align-items: center;
}
}
.header-input {
padding: 1rem;
padding-top: 0;
height: 2.5rem;
border-bottom: 1px solid #eee;
}
.order-lists {
height: calc(100vh - 100px - 10.2rem);
overflow-y: auto;
.item {
padding: 1rem;
border-bottom: 1px solid #eee;
.top {
display: flex;
justify-content: space-between;
align-items: flex-end;
.sn {
font-weight: bold;
font-size: 0.9rem;
}
.cahier {
&::before {
content: "收银";
font-weight: 400;
font-size: 0.7rem;
padding: 0.1rem 0.1rem;
margin-right: 0.2rem;
border: 1px solid #2ec479;
color: #2ec479;
border-radius: 0.187rem;
}
}
.cahier2 {
&::before {
content: "平台";
font-weight: 400;
font-size: 0.7rem;
padding: 0.1rem 0.1rem;
margin-right: 0.2rem;
border: 1px solid #ff4a00;
color: #ff4a00;
border-radius: 0.187rem;
}
}
.create-time {
font-size: 0.8rem;
}
}
.shop {
display: flex;
justify-content: space-between;
.right {
flex-shrink: 0;
display: flex;
flex-direction: column;
justify-content: center;
.money {
font-size: 1rem;
color: #ff4a00;
font-weight: bold;
}
.count {
font-size: 0.7rem;
color: #999;
}
}
.left {
/* height: 4.5rem; */
display: flex;
align-items: center;
font-size: 0.8rem;
}
}
.bottom {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: #777;
.manage-btn {
color: #fff;
background-color: #e6a23c;
border-radius: 0.2rem;
padding: 0 0.2rem;
margin-left: 0.5rem;
}
}
}
.item-active {
background-color: #efefef;
}
}
.load-end {
text-align: center;
padding: 1rem;
color: #333;
font-size: 0.8rem;
}
.bottom-btn-fiexd {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
box-sizing: border-box;
border-top: 1px solid #eee;
background-color: #fff;
z-index: 100;
height: 5.2rem;
padding: 1rem 1.5rem;
.btn {
width: 100%;
height: 100%;
font-size: 1.2rem;
border-radius: 3rem;
}
}
}
</style>

View File

@ -0,0 +1,245 @@
<script setup>
import { ref, watch, nextTick, computed, onMounted, onUnmounted } from "vue";
import { ElMessage } from "element-plus";
import mitt from "@/utils/mitt.js";
import { useUserStore } from "@/store/user.js";
import {
orderListApi,
orderStatusApi,
orderLadingApi,
cartListApi,
cashierinfoListApi,
} from "@/api/store.js";
const drawer = ref(false);
const formData = ref({
id: "",
});
const list = ref([]);
const payRef = ref(null);
const loading = ref(false);
const where = ref({
page_no: 1,
page_size: 15,
loadend: false,
loading: false,
});
const goods_list = ref([]);
const getOrderList = () => {
console.log("触底");
if (formData.value.id && !where.value.loadend) {
console.log("加载");
where.value.loading = true;
cashierinfoListApi({
pid: formData.value.id,
page_no: where.value.page_no,
page_size: where.value.page_size,
}).then((res) => {
formData.value.goods_count = res.data.count;
goods_list.value = [...goods_list.value, ...res.data.lists];
if (res.data.lists.length < where.value.page_size)
where.value.loadend = true;
where.value.loading = false;
where.value.page_no++;
});
}
};
const setForm = (e) => {
formData.value = e;
where.value.page_no = 1;
where.value.loadend = false;
where.value.loading = false;
goods_list.value = [];
getOrderList();
};
defineExpose({
drawer,
setForm,
});
</script>
<template>
<el-drawer size="64rem" v-model="drawer" direction="rtl">
<template #header>
<h4 style="padding: 0; margin: 0; color: #000">订单详情</h4>
</template>
<template #default>
<div class="dra-body">
<div class="detail" v-loading="loading">
<div
class="table"
v-loading="loading"
v-infinite-scroll="getOrderList"
infinite-scroll-distance="300"
infinite-scroll-delay="300"
style="overflow: auto"
:infinite-scroll-immediate="false"
>
<div class="table-info">
<div class="info-item">
<div class="info-item-title">订单编号:</div>
<div class="info-item-info">{{ formData.number }}</div>
</div>
<div class="info-item">
<div class="info-item-title">商品款数:</div>
<div class="info-item-info">{{ formData.goods_count }}</div>
</div>
<div class="info-item">
<div class="info-item-title">商品总价:</div>
<div class="info-item-info">¥{{ formData.total }}</div>
</div>
<div class="info-item">
<div class="info-item-title">创建时间:</div>
<div class="info-item-info">{{ formData.create_time }}</div>
</div>
<div class="info-item">
<div class="info-item-title">优惠抵扣:</div>
<div class="info-item-info">
¥{{ formData.deduction_price }}
</div>
</div>
<div class="info-item">
<div class="info-item-title">实际支付:</div>
<div class="info-item-info">¥{{ formData.actual }}</div>
</div>
<div class="info-item">
<div class="info-item-title">支付时间:</div>
<div class="info-item-info">{{ formData.update_time }}</div>
</div>
<div class="info-item">
<div class="info-item-title">支付方式:</div>
<div class="info-item-info">
<span v-if="formData.pay_type == 9">微信收款</span>
<span v-if="formData.pay_type == 1">余额支付</span>
<span v-if="formData.pay_type == 3">微信支付</span>
</div>
</div>
</div>
<div class="table-title">收货人信息</div>
<div
class="table-info"
v-if="formData.user_phone"
style="flex-direction: column"
>
<div class="info-item">
<div class="info-item-title">收货人:</div>
<div class="info-item-info">
{{ formData.real_name }}
</div>
</div>
<div class="info-item">
<div class="info-item-title">联系方式:</div>
<div class="info-item-info">
{{ formData.user_phone }}
</div>
</div>
<div class="info-item">
<div class="info-item-title">收货地址:</div>
<div class="info-item-info">
{{ formData.user_address }}
</div>
</div>
</div>
<div v-else class="addAddress">
<el-button
type="primary"
@click="addAddress(formData)"
size="large"
>点击添加收货地址</el-button
>
</div>
<div style="font-size: 0.9rem">
共计
<span style="color: #ff4a00">{{ formData.goods_count }}</span>
款商品
</div>
<el-table :data="goods_list">
<el-table-column type="index" width="60" label="序号" />
<el-table-column label="商品信息">
<template #default="{ row }">
<div style="display: flex; align-items: center">
<el-image
style="height: 3rem; width: 3rem"
:src="row.imgs"
></el-image>
<span style="margin-left: 0.5rem">{{
row.goods_name
}}</span>
</div>
</template>
</el-table-column>
<el-table-column prop="price" label="单价" width="150" />
<el-table-column prop="nums" label="数量" width="150" />
<el-table-column prop="total" label="总价" width="150">
</el-table-column>
</el-table>
</div>
</div>
</div>
</template>
</el-drawer>
</template>
<style lang="scss">
.el-drawer__header {
margin-bottom: 0;
}
.el-drawer__body {
padding-top: 0;
}
</style>
<style lang="scss" scoped>
.dra-body {
width: 100%;
height: 100%;
.detail {
height: 100%;
box-sizing: border-box;
position: relative;
.table {
padding-bottom: 1rem;
overflow-y: auto;
height: 100%;
.table-title {
font-weight: bold;
}
.addAddress {
margin-top: 1rem;
margin-bottom: 1.5rem;
}
.table-info {
display: flex;
flex-wrap: wrap;
color: #777;
font-size: 0.9rem;
padding-bottom: 1rem;
margin-bottom: 1rem;
border-bottom: 1px solid #eee;
&:last-child {
border-bottom: none;
}
.info-item {
width: 33%;
display: flex;
padding-top: 1rem;
.info-item-title {
flex-shrink: 0;
padding-right: 1rem;
}
}
}
}
}
}
</style>

View File

@ -0,0 +1,108 @@
<script setup>
import order from "./component/order.vue";
import detail from "./component/detail.vue";
import padding from "@/components/padding.vue";
import { ref, nextTick } from "vue";
import { merchantCreateApi } from "@/api/store";
const orderRef = ref(null);
const dialogFormVisible = ref(false);
const addAddress = (e) => {
if (e.id != form.value.order_id) {
form.value = {
real_name: "",
phone: "",
detail: "",
order_id: e.id,
};
} else form.value.order_id = e.id;
dialogFormVisible.value = true;
};
const form = ref({
real_name: "",
phone: "",
detail: "",
order_id: "",
});
const rules = ref({
real_name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
phone: [{ required: true, message: "请输入手机号", trigger: "blur" }],
detail: [{ required: true, message: "请输入地址", trigger: "blur" }],
});
const submit = () => {
merchantCreateApi(form.value).then((res) => {
dialogFormVisible.value = false;
orderRef.value?.getOrderList(true);
});
};
</script>
<template>
<div class="my-card">
<order style="flex-shrink: 0" ref="orderRef" @addAddress="addAddress" />
<padding />
<detail ref="detailRef" @addAddress="addAddress" />
<el-dialog v-model="dialogFormVisible" title="添加地址" width="500">
<el-form :model="form" label-width="100" :rules="rules">
<el-form-item
label="收货人"
:label-width="formLabelWidth"
prop="real_name"
>
<el-input
v-model="form.real_name"
autocomplete="off"
placeholder="请输入收货人"
/>
</el-form-item>
<el-form-item label="电话" :label-width="formLabelWidth" prop="phone">
<el-input
v-model="form.phone"
type="number"
placeholder="请输入电话"
/>
</el-form-item>
<el-form-item label="地址" :label-width="formLabelWidth" prop="detail">
<el-input v-model="form.detail" placeholder="请输入地址" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="submit"> 确认 </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<style lang="scss">
.my-card {
display: flex;
}
/* 修改滚动条的样式 */
::-webkit-scrollbar {
width: 0.315rem; /* 设置滚动条的宽度 */
}
/* 设置滚动条的轨道样式 */
::-webkit-scrollbar-track {
background-color: #f1f1f1; /* 设置轨道的背景色 */
/* margin: 1.25rem 0; */
}
/* 设置滚动条的滑块样式 */
::-webkit-scrollbar-thumb {
background-color: #ccc; /* 设置滑块的背景色 */
border-radius: 0.315rem; /* 设置滑块的圆角 */
}
/* 设置滚动条鼠标悬停时的滑块样式 */
::-webkit-scrollbar-thumb:hover {
background-color: #999; /* 设置鼠标悬停时滑块的背景色 */
}
</style>

View File

@ -89,7 +89,7 @@ onUnmounted(() => {
<div
class="shop-list"
v-infinite-scroll="loadMore"
infinite-scroll-distance="100"
infinite-scroll-distance="1000"
infinite-scroll-delay="500"
:infinite-scroll-immediate="false"
style="overflow: auto"

View File

@ -119,7 +119,6 @@ const aF9 = () => {
};
onMounted(() => {
getStoreList();
where.value.page_no++;
mitt.on("F9", aF9);
});

View File

@ -118,6 +118,7 @@ onUnmounted(()=>{
end-placeholder="结束时间"
size="small"
value-format="YYYY/MM/DD"
:disabled-date="disabledDate"
@change="changeDate"
style="width: 14rem; margin-left: 1rem"
/>

View File

@ -1,31 +1,58 @@
<template>
<!-- 小票内容 -->
<div ref="receipt" id="receipt" style="max-width: 200px;">
<h2>小票标题</h2>
<p>商品名称: 商品1</p>
<p>价格: ¥10.00</p>
<p>数量: 1</p>
<p>-------------------</p>
<p>总计: ¥10.00</p>
<p>-------------------</p>
</div>
<el-button type="priamry" @click="onPrint">打印</el-button>
<!-- 小票内容 -->
<div ref="receipt" id="receipt" style="max-width: 200px">
<h2>小票标题</h2>
<p>商品名称: 商品1</p>
<p>价格: ¥10.00</p>
<p>数量: 1</p>
<p>-------------------</p>
<p>总计: ¥10.00</p>
<p>-------------------</p>
</div>
<!-- <el-button type="priamry" @click="onPrint">打印</el-button> -->
<el-button type="priamry" @click="printReceipt">打印</el-button>
</template>
<script setup>
import print from 'print-js'
import { ref } from 'vue';
import { ElMessage } from "element-plus";
import print from "print-js";
import { ref } from "vue";
const receipt = ref(null);
const onPrint = ()=>{
console.log('开始打印', receipt);
print({
printable: 'receipt',
type: 'html',
maxWidth: '200'
});
}
const onPrint = () => {
console.log("开始打印", receipt);
print({
printable: "receipt",
type: "html",
maxWidth: "200",
});
};
const printReceipt = () => {
uni.getEnv((res) => {
if(res.h5) ElMessage.error("请使用APP打印小票");
else APPprint();
});
};
const APPprint = () => {
let str = "";
str += "********************************\n";
str += "泸优采-小票\n";
str += "单号: CG171565043141139102\n";
str += "测试商品1 * 1 \t 1.00元 \n";
str += "测试商品2 * 1 \t 1.00元 \n";
str += "测试商品小黄鸭3 * 1 \t 1.00元 \n";
str += "\n";
str += "--------------------------------\n";
str += "\n";
uni.postMessage({
data: {
type: "print",
content: str,
},
});
};
</script>
<style lang="scss">