Zlpt_Portal/src/views/parity/index.vue

668 lines
20 KiB
Vue
Raw Normal View History

2024-11-28 09:29:25 +08:00
<template>
<div class="equipList">
<NavMenu></NavMenu>
<div class="screen">
<div class="choose">
<template v-for="(v, i) in screenChooseList" :key="i">
<div class="line">
<div class="label">
{{ v.name }}
</div>
<div class="select">
<div
class="item"
:class="{
active: val.isChecked,
}"
@click="selectScreen(v.type, val, i)"
v-for="(val, index) in v.list"
:key="index"
>
{{ val.name }}
</div>
</div>
</div>
</template>
<div class="line" v-if="screenTags.length > 0">
<div class="label">已选条件</div>
<div class="select tags">
<el-tag
v-for="(tag, i) in screenTags"
:key="i"
class="item"
@close="handleClose(tag)"
closable
>
{{ tag.name }}
</el-tag>
<span class="clear-btn" @click="onClearTags"> 清除选项 </span>
</div>
</div>
</div>
<div class="btns">
<div
class="item"
@click="changeOption(v)"
:class="v.id == optionActive && 'active'"
v-for="(v, i) in screenOptionList"
:key="i"
>
{{ v.name }}
<template v-if="v.sort">
<el-icon class="icon" v-show="v.sort == 'DESC'">
<CaretBottom />
</el-icon>
<el-icon class="icon" v-show="v.sort == 'ASC'">
<CaretTop />
</el-icon>
</template>
</div>
</div>
</div>
2024-11-28 15:11:08 +08:00
<div class="showList" v-if="leaseList.length > 0">
<div class="demand-card" v-for="item in leaseList" :key="item.id">
2024-12-01 16:21:35 +08:00
<div class="count-down">
<!-- <el-icon style="margin-right: 10px"><Warning /></el-icon> -->
<svg
class="icon"
aria-hidden="true"
style="width: 24px; height: 24px; margin-right: 10px"
>
<use xlink:href="#icon-daojishi-copy"></use>
</svg>
<!-- 剩余08天12小时24分 -->
<div>
<el-countdown
format="剩余: DD [天] HH [小时] mm [分]"
:value="moment(item.endTime, 'YYYY-MM-DD HH:mm:ss').valueOf()"
>
</el-countdown>
</div>
</div>
2024-11-28 09:29:25 +08:00
<el-row>
<el-col :span="18">
2024-11-28 15:11:08 +08:00
<div style="font-size: 20px; font-weight: bold; letter-spacing: 1px">
{{ item.leaseName }}
</div>
2024-11-28 09:29:25 +08:00
</el-col>
2024-12-01 16:21:35 +08:00
<el-col :span="6"> </el-col>
2024-11-28 09:29:25 +08:00
</el-row>
<el-row>
<el-col :span="2">
<div>装备类目</div>
</el-col>
2024-11-28 15:11:08 +08:00
<el-col :span="5">
<div>{{ item.groupName }}</div>
2024-11-28 09:29:25 +08:00
</el-col>
</el-row>
<el-row>
<el-col :span="2">
<div>租赁公司</div>
</el-col>
2024-11-28 15:11:08 +08:00
<el-col :span="5">
<div>{{ item.companyName }}</div>
2024-11-28 09:29:25 +08:00
</el-col>
2024-12-06 17:48:56 +08:00
<el-col :span="2">
<div>预估数量</div>
</el-col>
<el-col :span="5">
<div>{{ item.leaseTotalNum }}</div>
</el-col>
2024-11-28 09:29:25 +08:00
</el-row>
<el-row>
<el-col :span="2">
<div>联系人</div>
</el-col>
2024-11-28 15:11:08 +08:00
<el-col :span="5">
<div>{{ item.person }}</div>
</el-col>
<el-col :span="2">
<div>联系电话</div>
</el-col>
<el-col :span="6">
<div>{{ item.personPhone }}</div>
2024-11-28 09:29:25 +08:00
</el-col>
</el-row>
<el-row>
2024-11-28 15:11:08 +08:00
<el-col :span="2">
2024-12-06 17:48:56 +08:00
<div>租赁开始日期</div>
2024-11-28 15:11:08 +08:00
</el-col>
<el-col :span="5">
2024-12-06 17:48:56 +08:00
<div>{{ item.leaseStartTime }}</div>
2024-11-28 09:29:25 +08:00
</el-col>
2024-11-28 15:11:08 +08:00
<el-col :span="2">
2024-12-06 17:48:56 +08:00
<div>租赁结束日期</div>
2024-11-28 15:11:08 +08:00
</el-col>
<el-col :span="6">
2024-12-06 17:48:56 +08:00
<div>{{ item.leaseEndTime }}</div>
2024-11-28 09:29:25 +08:00
</el-col>
</el-row>
<el-row>
2024-11-28 15:11:08 +08:00
<el-col :span="2">
<div>发布时间</div>
2024-11-28 09:29:25 +08:00
</el-col>
2024-11-28 15:11:08 +08:00
<el-col :span="5">
<div>{{ item.startTime }}</div>
</el-col>
<el-col :span="2">
<div>截止时间</div>
</el-col>
<el-col :span="6">
<div>{{ item.endTime }}</div>
2024-11-28 09:29:25 +08:00
</el-col>
</el-row>
2024-11-28 15:11:08 +08:00
<div class="btn-items">
2024-12-01 16:21:35 +08:00
<!-- <el-button
2024-11-28 15:11:08 +08:00
@click="router.push({ name: 'demand-details', query: { id: item.id } })"
>
需求详情
</el-button>
<el-button
:disabled="userId == item.publishUser"
@click="onAcceptOrders(item.id)"
>
接单
2024-12-01 16:21:35 +08:00
</el-button> -->
<div
@click="router.push({ name: 'demand-details', query: { id: item.id } })"
style="margin-bottom: 26px; border: 1px solid #00ae9c; color: #00ae9c"
>
需求详情
</div>
<!-- <div
style="background-color: #00ae9c"
@click="onAcceptOrders(item.id, item.publishUser)"
>
接单
</div> -->
<div>
<el-button
style="
width: 100%;
height: 100%;
background-color: #00ae9c;
color: #fff;
border: none;
border-radius: 0;
"
2024-12-05 11:51:00 +08:00
:disabled="
userId == item.publishUser || companyId == item.publishCompany
"
2024-12-05 12:04:24 +08:00
:style="
userId == item.publishUser || companyId == item.publishCompany
? 'opacity:0.5;color:#fff'
: ''
"
2024-12-01 16:21:35 +08:00
@click="onAcceptOrders(item.id)"
>
接单
</el-button>
</div>
2024-11-28 15:11:08 +08:00
</div>
2024-11-28 09:29:25 +08:00
</div>
</div>
2024-11-28 15:11:08 +08:00
<div class="noData" v-else>
2024-11-28 09:29:25 +08:00
<el-empty :image-size="200" />
2024-11-28 15:11:08 +08:00
</div>
2024-11-28 09:29:25 +08:00
2024-11-28 15:11:08 +08:00
<div class="pagination" v-if="leaseList.length > 0">
2024-11-28 09:29:25 +08:00
<el-pagination
size="small"
background
layout="prev, pager, next"
:page-size="pageData.pageSize"
:total="total"
class="mt-4"
@current-change="onCurrentChange"
v-if="total > 0"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
2024-11-28 15:11:08 +08:00
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTypeListApi, getDeviceListApi } from 'http/api/equip'
2024-12-01 16:21:35 +08:00
import { getCompanyListApi, getLeaseListApi, setAcceptByIdApi, getAreaApi } from 'http/api/home'
2024-11-28 15:11:08 +08:00
import $bus from 'utils/bus'
import NavMenu from 'components/Navmenu/index.vue'
import moment from 'moment'
import { mainStore } from 'store/main'
2024-11-28 09:29:25 +08:00
const router = useRouter()
const route: any = useRoute()
2024-11-28 15:11:08 +08:00
const store: any = mainStore()
const userId = store.userInfo.userId
2024-12-05 11:51:00 +08:00
const companyId = store.userInfo.companyId
2024-11-28 15:11:08 +08:00
const leaseList = ref<any>([])
2024-11-28 09:29:25 +08:00
//筛选条件列表数据
const screenChooseList: any = reactive([
{
type: 'deviceClass',
name: '装备分类:',
list: [
{
name: '全部',
value: '',
isChecked: true,
index: 0,
},
],
},
{
type: 'companyId',
2024-12-01 16:21:35 +08:00
name: '项目所在地:',
2024-11-28 09:29:25 +08:00
list: [
{
isChecked: true,
name: '全部',
value: '',
index: 1,
},
],
},
{
type: 'companyId',
name: '需求单位:',
list: [
{
isChecked: true,
name: '全部',
value: '',
index: 2,
},
],
},
])
// 已选条件的tag标签
const screenTags = computed(() => {
const selectTagList: any = []
screenChooseList.forEach((e: any) => {
e.list.forEach((j: any) => {
if (j.isChecked && j.name !== '全部') {
selectTagList.push(j)
}
})
})
return selectTagList
})
// 综合排序 更新时间 月租金 排序按钮
const screenOptionList: any = reactive([
{
name: '发布时间',
id: 0,
sort: 'DESC',
},
{
name: '租期',
id: 1,
sort: 'DESC',
},
{
name: '截止时间',
id: 2,
sort: 'DESC', //desc or desc
},
{
name: '租赁数量',
id: 3,
sort: 'DESC', //desc or desc
},
])
//激活 排序按钮
const optionActive = ref(0)
//分页参数
const pageData = reactive({
pageNum: 1,
2024-11-28 19:07:24 +08:00
pageSize: 10,
2024-11-28 09:29:25 +08:00
})
// 总条数
const total = ref(0)
//装备列表
const equipList: any = ref([])
// 获取装备分类
const getTypeListData = async () => {
2024-11-28 15:11:08 +08:00
const res: any = await getTypeListApi()
2024-11-28 09:29:25 +08:00
const typeList = res.data.map((e: any) => {
return { ...e, name: e.typeName, value: e.typeId, isChecked: false, index: 0 }
})
screenChooseList[0].list.push(...typeList)
}
getTypeListData()
// 获取设备所在地
const getCompanyAddressListData = async () => {
2024-11-28 15:11:08 +08:00
const res: any = await getCompanyListApi()
2024-12-05 11:51:00 +08:00
const result: any = await getAreaApi(34)
2024-12-01 16:21:35 +08:00
const addressList = result.data.map((e: any) => {
2024-12-05 11:51:00 +08:00
return { ...e, name: e.areaName, value: e.areaCode, isChecked: false, index: 1 }
2024-11-28 09:29:25 +08:00
})
const companyList = res.data.map((e: any) => {
return { ...e, name: e.companyName, value: e.companyId, isChecked: false, index: 2 }
})
screenChooseList[1].list.push(...addressList)
screenChooseList[2].list.push(...companyList)
}
getCompanyAddressListData()
2024-12-01 16:21:35 +08:00
const getLeaseListData = async (keyWord: any = '') => {
2024-11-28 09:29:25 +08:00
const searchParams: any = {
2024-12-01 16:21:35 +08:00
keyWord,
2024-11-28 09:29:25 +08:00
companyId: '',
typeId: '',
level: '',
2024-12-05 11:51:00 +08:00
cityCode: '',
2024-11-28 19:07:24 +08:00
startTime: optionActive.value == 0 ? screenOptionList[optionActive.value].sort : '',
rentDay: optionActive.value == 1 ? screenOptionList[optionActive.value].sort : '',
endTime: optionActive.value == 2 ? screenOptionList[optionActive.value].sort : '',
rentNum: optionActive.value == 3 ? screenOptionList[optionActive.value].sort : '',
2024-11-28 09:29:25 +08:00
}
screenChooseList.forEach((e: any, index: number) => {
e.list.forEach((j: any) => {
if (index === 0 && j.isChecked) {
searchParams.typeId = j.value
2024-11-28 15:11:08 +08:00
searchParams.level = j.value ? 1 : ''
2024-11-28 09:29:25 +08:00
}
2024-11-28 15:11:08 +08:00
if (index == 1 && j.isChecked) {
2024-12-05 11:51:00 +08:00
searchParams.cityCode = j.value
2024-11-28 15:11:08 +08:00
}
if (index == 2 && j.isChecked) {
2024-12-01 16:21:35 +08:00
searchParams.companyId = j.value
2024-11-28 09:29:25 +08:00
}
})
})
2024-11-28 19:07:24 +08:00
Object.assign(searchParams, pageData)
2024-11-28 15:11:08 +08:00
const { data: res }: any = await getLeaseListApi(searchParams)
leaseList.value = res.rows
2024-11-28 09:29:25 +08:00
total.value = res.total
}
// 清除筛选条件
const onClearTags = () => {
screenChooseList.forEach((e: any) => {
e.list.forEach((j: any, index: number) => {
j.isChecked = false
if (index === 0) {
j.isChecked = true
}
})
})
2024-11-28 15:11:08 +08:00
getLeaseListData()
2024-11-28 09:29:25 +08:00
}
//删除条件
const handleClose = (tag: any) => {
tag.isChecked = false
screenChooseList[tag.index].list[0].isChecked = true
2024-11-28 15:11:08 +08:00
// getDeviceListData()
2024-11-28 19:07:24 +08:00
getLeaseListData()
2024-11-28 09:29:25 +08:00
}
// 排序操作
const changeOption = (val: any) => {
if (val.sort && optionActive.value == val.id) {
val.sort = val.sort == 'ASC' ? 'DESC' : 'ASC'
}
console.log(screenOptionList, 'screenOptionList')
optionActive.value = val.id
2024-11-28 15:11:08 +08:00
// getDeviceListData()
2024-11-28 19:07:24 +08:00
getLeaseListData()
2024-11-28 09:29:25 +08:00
}
//选中后添加到 大类中的select字段
const selectScreen = (type: any, item: any, index: number) => {
screenChooseList[index].list.forEach((e: any) => {
e.isChecked = false
})
item.isChecked = !item.isChecked
2024-11-28 15:11:08 +08:00
// getDeviceListData()
getLeaseListData()
2024-11-28 09:29:25 +08:00
}
//分页page变化
const onCurrentChange = (val: number) => {
pageData.pageNum = val
2024-11-28 15:11:08 +08:00
// getDeviceListData()
2024-11-28 19:07:24 +08:00
getLeaseListData()
2024-11-28 09:29:25 +08:00
}
onMounted(() => {
2024-11-28 15:11:08 +08:00
getLeaseListData()
2024-11-28 09:29:25 +08:00
$bus.on('search', (val: any) => {
2024-12-01 16:21:35 +08:00
getLeaseListData(val)
2024-11-28 09:29:25 +08:00
})
})
onUnmounted(() => {
$bus.off('search')
})
2024-11-28 15:11:08 +08:00
// 接单
const onAcceptOrders = (id: any) => {
ElMessageBox.confirm('确定接单吗?', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
})
.then(async () => {
const res: any = await setAcceptByIdApi({ id })
if (res.code === 200) {
ElMessage({
type: 'success',
message: '接单成功',
})
getLeaseListData()
}
})
.catch(() => {})
2024-11-28 09:29:25 +08:00
}
</script>
2024-11-28 09:29:25 +08:00
<style lang="scss" scoped>
.equipList {
.showScreen {
margin: 15px 0;
display: flex;
align-items: center;
border-bottom: 1px solid #ccc;
// height: 30px;
2023-12-12 09:23:09 +08:00
2024-11-28 09:29:25 +08:00
.title {
font-size: 16px;
font-weight: 500;
color: #949494;
}
}
.screen {
margin-bottom: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #ccc;
.choose {
margin-top: 20px;
2024-12-23 13:52:38 +08:00
// font-size: 14px;
2024-11-28 09:29:25 +08:00
.line {
padding: 14px 0;
display: flex;
align-items: center;
// border-bottom: 1px solid #dddddd;
.label {
// width: 100px;
box-sizing: border-box;
// padding: 0 15px;
// background: #f3f3f3;
}
.select {
flex: 1;
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
padding: 0 15px;
.item {
padding: 2px 16px;
margin-right: 15px;
cursor: pointer;
color: #939393;
2024-12-23 13:52:38 +08:00
font-size: 17px;
2024-11-28 09:29:25 +08:00
line-height: 25px;
height: 25px;
&:hover {
color: #3cb4a6;
}
}
2023-12-12 09:23:09 +08:00
2024-11-28 09:29:25 +08:00
.active {
background-color: #3cb4a6;
color: #fff !important;
border-radius: 25px;
}
}
.tags {
display: flex;
align-items: center;
color: #138472;
.item {
margin-left: 10px;
}
.clear-btn {
cursor: pointer;
}
.el-tag {
background-color: #fff;
border: 1px solid #138472;
color: #138472;
}
:deep .el-tag .el-tag__close {
color: #138472;
}
}
}
}
.active {
color: #138472 !important;
font-weight: bold !important;
}
.btns {
display: flex;
align-items: center;
// margin-top: 20px;
.item {
background: #f7f9fa;
border-radius: 12px;
padding: 10px 20px;
2024-12-23 13:52:38 +08:00
// font-size: 17px;
2024-11-28 09:29:25 +08:00
font-weight: 500;
color: #9d9d9d;
margin-right: 10px;
cursor: pointer;
user-select: none;
.icon {
font-size: 15px;
}
}
}
}
2024-11-28 09:29:25 +08:00
.showList {
2024-11-28 15:11:08 +08:00
.demand-card {
margin-bottom: 15px;
2024-12-23 13:52:38 +08:00
padding: 20px 25px;
2024-11-28 15:11:08 +08:00
border-radius: 14px;
2024-12-01 16:21:35 +08:00
background-color: #fff;
position: relative;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
2024-11-28 15:11:08 +08:00
position: relative;
.el-row {
padding: 10px 0;
2024-12-23 13:52:38 +08:00
font-size: 14px;
2024-11-28 15:11:08 +08:00
}
.count-down {
display: flex;
align-items: center;
2024-12-01 16:21:35 +08:00
justify-content: center;
2024-11-28 15:11:08 +08:00
font-size: 16px;
font-weight: bold;
2024-12-01 16:21:35 +08:00
color: #fff;
position: absolute;
right: 0;
top: 0;
background-color: orange;
width: 30%;
padding: 12px 0;
background: linear-gradient(to right, #4dd1c7, #00af9f);
2024-11-28 15:11:08 +08:00
}
.btn-items {
position: absolute;
right: 80px;
bottom: 30px;
2024-12-01 16:21:35 +08:00
display: flex;
flex-direction: column;
align-items: center;
div {
cursor: pointer;
width: 180px;
text-align: center;
// padding: 10px 0;
color: #fff;
box-sizing: border-box;
height: 38px;
line-height: 38px;
}
2024-11-28 15:11:08 +08:00
}
}
2024-11-28 09:29:25 +08:00
}
.pagination {
margin-top: 20px;
display: flex;
justify-content: flex-end;
}
}
:deep.el-pagination.is-background .el-pager li.is-active {
background-color: #3cb4a6;
}
2024-11-28 15:11:08 +08:00
:deep .el-statistic__content {
2024-12-01 16:21:35 +08:00
color: #fff;
2024-11-28 15:11:08 +08:00
font-size: 16px;
}
</style>