413 lines
12 KiB
Vue
Raw Normal View History

2025-04-14 02:33:18 +01:00
<template>
<!-- <page-layout :menus="state.menus"> </page-layout>-->
<section>
<common>
<template #main>
<el-card shadow="none" style="border-radius: 14px">
<div class="tabs">
<div class="tab" style="color: rgba(153, 153, 153, 1)">仓储分类</div>
<div
class="tab cursor"
:class="{ active: currentTab === 0 }"
@click.stop="
currentTab = 0;
getWarehouseList('1');
"
>
普通仓库
</div>
<!-- <div class="tab cursor" :class="{ active: currentTab === 1 }" @click.stop="currentTab = 1">恒温仓库</div>-->
<div
class="tab cursor"
:class="{ active: currentTab === 2 }"
@click.stop="
currentTab = 2;
getWarehouseList('3');
"
>
冷库
</div>
<!-- <div class="tab cursor" :class="{ active: currentTab === 3 }" @click.stop="currentTab = 3">气调仓库</div>-->
<div class="tab">&nbsp;</div>
</div>
</el-card>
<el-row :gutter="20" style="margin-top: 10px">
<el-col v-for="(item, index) in state.data" :key="index" :span="12">
<el-card class="storage-card" shadow="hover">
<div class="storage-content">
<div class="storage-content-top" @click="toLink(item)">
<el-image :src="item.imgPath" fit="cover" class="storage-image" />
<div class="storage-info">
<h3 class="storage-title">{{ item.name }}</h3>
<div class="storage-desc">
<span>{{ item.parentTitle }}</span>
<img :src="getAssetsFile('images/warehouseLogistics/认证.png')" alt="" style="width: 20px" />
<img :src="getAssetsFile('images/warehouseLogistics/优先级.png')" alt="" style="width: 20px" />
</div>
<div class="storage-tags">
<el-tag
v-for="(tags, indexT) in item.tag"
:key="indexT"
effect="plain"
round
style="background-color: rgba(37, 191, 130, 0.2); color: #25bf82"
>
{{ tags }}
</el-tag>
<!-- <el-tag effect="plain" round style="background-color: rgba(37, 191, 130, 0.2); color: #25bf82">保鲜储存</el-tag>-->
</div>
<div class="storage-location">
<el-icon><Location /></el-icon>
{{ item.address }}
</div>
</div>
2025-04-14 02:33:18 +01:00
</div>
<div class="storage-price">
<div class="storage-price-left">
<span class="price-label">报价</span>
<span class="price-amount"
>¥{{ item.price }}/{{ item.priceSpec === 1 ? 'm³' : item.priceSpec === 2 ? '间' : item.priceSpec === 3 ? '㎡' : '' }}/{{
item.timeSpec === 1 ? '天' : item.timeSpec === 2 ? '月' : item.timeSpec === 3 ? '年' : ''
}}
</span>
</div>
<el-button type="success" class="contact-btn" @click="contact(item.id)">
<img :src="getAssetsFile('images/warehouseLogistics/messageBox.png')" alt="" style="height: 30px; margin-right: 5px" />
<span>联系卖家</span>
</el-button>
2025-04-14 02:33:18 +01:00
</div>
<div v-if="index >= 0 && index < 3" class="rank-badge">
<img :src="getAssetsFile('images/warehouseLogistics/top' + (index + 1) + '.png')" alt="" style="width: 80px" />
2025-04-14 02:33:18 +01:00
</div>
</div>
</el-card>
</el-col>
<el-pagination
:size="'large'"
:page-size="paginations.size"
:current-page="paginations.page"
:total="paginations.total"
background
layout="prev, pager, next"
@current-change="currentChange"
/>
</el-row>
<el-dialog v-model="dialogFormVisible" width="600" style="padding: 60px; border-radius: 16px">
<el-form :size="'large'" :model="state.query.current">
<el-form-item label="首选商家:" :label-width="formLabelWidth" style="color: #25bf82; font-size: 20px">
{{ state.query.current.parentTitle }}
</el-form-item>
<el-form-item label="选择服务:" :label-width="formLabelWidth" style="color: #25bf82">
{{ state.query.current.name }}
</el-form-item>
<el-form-item label="需求量:" :label-width="formLabelWidth">
<el-input v-model="formData.value.demand" autocomplete="off" placeholder="请填写您的需求量" style="font-size: 20px">
<template #append>kg</template>
</el-input>
</el-form-item>
<el-form-item label="您的称呼:" :label-width="formLabelWidth">
<el-input
v-model="formData.value.surname"
autocomplete="off"
placeholder="姓氏"
style="display: inline; width: 100px; font-size: 20px"
/>
<el-radio-group v-model="formData.value.sex" style="display: inline; margin-left: 20px">
<el-radio value="1">先生</el-radio>
<el-radio value="2">女士</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="您的电话:" :label-width="formLabelWidth">
<el-input v-model="formData.value.phoneNum" autocomplete="off" style="font-size: 20px" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer" style="text-align: center">
<el-button style="height: 50px; padding: 0 40px; border-radius: 16px" type="primary" @click="priceConfirm"> 发送询价 </el-button>
</div>
</template>
</el-dialog>
</template>
</common>
</section>
2025-04-14 02:33:18 +01:00
</template>
<script setup>
import { ref, reactive, watch, onMounted } from 'vue';
2025-04-14 02:33:18 +01:00
import { getAssetsFile } from '@/utils';
import { useRoute, useRouter } from 'vue-router';
import { getWarehouseInfo, warehouseList } from '@/apis/warehouseLogistics.js';
2025-04-14 02:33:18 +01:00
import warehouseLogisticsRoutes from '@/router/modules/warehouseLogistics';
import Common from '../components/common.vue';
import { useGetCommonData } from '@/store/modules/common.js';
2025-05-28 16:51:38 +08:00
import { storeToRefs } from 'pinia';
import { ElMessage } from 'element-plus';
2025-05-28 16:51:38 +08:00
const store = useGetCommonData();
const { data } = storeToRefs(store);
2025-04-14 02:33:18 +01:00
const route = useRoute();
const router = useRouter();
const state = reactive({
menus: warehouseLogisticsRoutes[0].children,
query: {
current: {},
2025-04-14 02:33:18 +01:00
},
data: [
{
imageUrl: '/storage1.jpg',
title: '果蔬保鲜仓储',
description: '绿鲜蔬选果蔬仓储中心 ',
location: '临沧市-耿马县',
price: '600.0',
rank: '1',
},
{
imageUrl: '/storage2.jpg',
title: '果蔬保鲜仓储',
description: '绿鲜蔬选果蔬仓储中心',
location: '临沧市-耿马县',
price: '600.0',
2025-05-28 11:43:31 +08:00
rank: '2',
2025-04-14 02:33:18 +01:00
},
{
imageUrl: '/storage3.jpg',
title: '果蔬保鲜仓储',
description: '绿鲜蔬选果蔬仓储中心 ',
location: '临沧市-耿马县',
price: '600.0',
rank: '3',
},
{
imageUrl: '/storage3.jpg',
title: '果蔬保鲜仓储',
description: '绿鲜蔬选果蔬仓储中心 ',
location: '临沧市-耿马县',
price: '600.0',
rank: '',
},
{
imageUrl: '/storage3.jpg',
title: '果蔬保鲜仓储',
description: '绿鲜蔬选果蔬仓储中心 ',
location: '临沧市-耿马县',
price: '600.0',
rank: '',
},
{
imageUrl: '/storage3.jpg',
title: '果蔬保鲜仓储',
description: '绿鲜蔬选果蔬仓储中心 ',
location: '临沧市-耿马县',
price: '600.0',
rank: '',
},
2025-04-14 02:33:18 +01:00
],
});
const formData = reactive({});
const paginations = reactive({
page: 1,
size: 2,
total: 0,
});
const dialogFormVisible = ref(false);
const formLabelWidth = ref('120px');
2025-04-14 02:33:18 +01:00
onMounted(() => {
getWarehouseList('1');
});
const currentTab = ref(0);
const currentChange = (current) => {
paginations.page = current;
getWarehouseList(currentTab.value + 1);
};
const getWarehouseList = (type) => {
warehouseList({ type: type, current: paginations.page, size: paginations.size }).then((res) => {
state.data = [];
paginations.total = res.total;
if (res.code === 200) {
state.data = res.data.records;
for (let i in state.data) {
state.data[i].tag = state.data[i].tags.split(',');
}
}
});
2025-04-14 02:33:18 +01:00
};
const toLink = (row) => {
2025-05-30 17:30:23 +08:00
router.push({
name: 'warehouse-detail',
query: { id: row?.id ?? '100' },
});
2025-04-14 02:33:18 +01:00
};
const contact = (id) => {
for (let i in state.data) {
if (state.data[i].id === id) {
state.query.current = state.data[i];
state.query.current.contactName = state.query.current.contactName.substring(0, 1);
}
}
formData.value = {
warehouseId: state.query.current.id,
type: 1,
demand: '',
surname: '',
sex: '',
phoneNum: '',
};
dialogFormVisible.value = true;
};
const priceConfirm = () => {
// 遍历 formData 的所有键
for (const key of Object.keys(formData.value)) {
if (formData.value[key] === '') {
ElMessage({
message: '请完整填写信息!',
type: 'warning',
});
return; // 这里 return 会直接退出整个函数
}
}
if (!/^1[3-9]\d{9}$/.test(formData.value.phoneNum)) {
ElMessage.warning('请填写正确的11位手机号码');
return;
}
getWarehouseInfo(formData.value).then((res) => {
if (res.code === 200) {
ElMessage.success('询价成功,后续请关注手机信息,我们将第一时间联系您');
} else {
ElMessage.error(res.errmsg);
}
});
};
2025-04-14 02:33:18 +01:00
</script>
<style lang="scss" scoped>
.el-form-item--large {
--font-size: 20px;
}
.tabs {
height: 50px;
line-height: 50px;
display: flex;
font-size: 18px;
justify-content: flex-start;
padding: 0 20px;
.tab {
margin: 0 20px;
}
}
.cursor {
cursor: pointer;
}
.active {
color: rgba(37, 191, 130, 1);
}
2025-04-14 02:33:18 +01:00
.storage-card {
position: relative;
overflow: hidden;
margin-bottom: 20px;
border: 0;
2025-05-20 13:05:37 +08:00
border-radius: 24px;
2025-04-14 02:33:18 +01:00
}
.storage-content {
2025-05-20 13:05:37 +08:00
@include flex-column;
2025-04-14 02:33:18 +01:00
2025-05-20 13:05:37 +08:00
gap: 16px;
2025-04-14 02:33:18 +01:00
&-top {
2025-05-20 13:05:37 +08:00
@include flex-row;
2025-04-14 02:33:18 +01:00
align-items: center;
}
}
.storage-price-left {
text-align: left;
}
2025-04-14 02:33:18 +01:00
.storage-image {
2025-05-20 13:05:37 +08:00
margin-right: 16px;
2025-04-14 02:33:18 +01:00
width: 120px;
height: 120px;
border-radius: 8px;
object-fit: cover;
}
.storage-info {
padding-right: 50px;
flex: 1;
cursor: pointer;
}
.storage-title,
.storage-desc,
.storage-tags,
.storage-location {
overflow: hidden;
2025-05-20 13:05:37 +08:00
margin: 10px 0;
width: 100%;
2025-04-14 02:33:18 +01:00
}
.storage-title {
font-size: 20px;
font-weight: 700;
2025-05-20 13:05:37 +08:00
color: #000000;
@include ellipsis;
2025-04-14 02:33:18 +01:00
}
.storage-desc {
font-size: 16px;
2025-05-20 13:05:37 +08:00
color: #999999;
@include ellipsis;
2025-04-14 02:33:18 +01:00
i {
display: inline-block;
width: 20px;
height: 20px;
}
}
.storage-tags {
span {
margin-right: 10px;
}
}
.storage-location {
display: flex;
align-items: center;
font-size: 16px;
font-weight: 400;
2025-05-20 13:05:37 +08:00
color: #000000;
2025-04-14 02:33:18 +01:00
}
.storage-price {
display: flex;
align-items: center;
&-left {
flex: 1;
}
}
.price-label {
margin-right: 10px;
2025-05-20 13:05:37 +08:00
font-size: 16px;
color: #999999;
2025-04-14 02:33:18 +01:00
}
.price-amount {
font-size: 20px;
font-weight: 700;
color: #25bf82;
2025-04-14 02:33:18 +01:00
}
.contact-btn {
width: 152px;
height: 48px;
font-size: 20px;
border-radius: 8px;
background: #25bf82 !important;
:deep(.el-icon) {
margin-right: 10px;
}
}
.rank-badge {
position: absolute;
top: 0;
right: 20px;
width: 80px;
height: 80px;
}
</style>