Files
fini-ui/src/views/login/components/Select.vue
T

548 lines
16 KiB
Vue
Raw Normal View History

2023-04-13 23:31:04 +08:00
<template>
2023-06-16 16:02:24 +08:00
<div class="selectWrap" @click="preVant">
2023-04-13 23:31:04 +08:00
<div class="box">
<div class="content">
2023-04-21 16:54:59 +08:00
<li>
2023-06-16 16:02:24 +08:00
<div class="word" :class="checkedAll == 1 && 'active'" @click="checkAll(1)">
2023-04-21 16:54:59 +08:00
{{ $t(i18n.global.t('home.title.All')) }}
<div class="check">
2023-04-23 16:31:24 +08:00
<el-icon v-if="checkedAll == 1">
<Check></Check>
</el-icon>
2023-04-21 16:54:59 +08:00
</div>
</div>
2023-06-16 16:02:24 +08:00
<div class="word" :class="checkedAll == 2 && 'active'" @click="checkAll(2)">{{
$t(i18n.global.t('home.title.None')) }}
2023-04-21 16:54:59 +08:00
<div class="check">
2023-04-23 16:31:24 +08:00
<el-icon v-if="checkedAll == 2">
<Check></Check>
</el-icon>
2023-04-21 16:54:59 +08:00
</div>
2023-04-23 16:31:24 +08:00
2023-04-21 16:54:59 +08:00
</div>
</li>
<div class="title">{{ $t(i18n.global.t('home.title.IPOStatus')) }}</div>
2023-04-13 23:31:04 +08:00
<li>
2023-06-16 16:02:24 +08:00
<div class="word" v-for="item in obj.ipoStatus" :key="item.key" :class="item.isSelcted && 'active'"
2023-04-23 16:31:24 +08:00
@click="checkOne(item.key, 'ipoStatus')">
2023-04-13 23:31:04 +08:00
<div class="check">
<el-icon v-if="item.isSelcted">
<Check />
</el-icon>
</div>
<span>{{ item.value }}</span>
</div>
</li>
2023-04-21 16:54:59 +08:00
<div class="title">{{ $t(i18n.global.t('home.title.TradingCurrency')) }}</div>
2023-04-13 23:31:04 +08:00
<li>
<div class="word" v-for="item in obj.tradingCurrency" :key="item.key"
2023-06-16 16:02:24 +08:00
:class="item.isSelcted && 'active'" @click="checkOne(item.key, 'tradingCurrency')">
2023-04-13 23:31:04 +08:00
<div class="check">
<el-icon v-if="item.isSelcted">
<Check />
</el-icon>
</div>
<span>{{ item.value }}</span>
</div>
</li>
2023-04-21 16:54:59 +08:00
<div class="title">{{ $t(i18n.global.t('home.title.OfferingType')) }}</div>
<li>
2023-06-16 16:02:24 +08:00
<div class="word" v-for="item in obj.offeringType" :key="item.key" :class="item.isSelcted && 'active'"
2023-04-23 16:31:24 +08:00
@click="checkOne(item.key, 'offeringType')">
2023-04-21 16:54:59 +08:00
<div class="check">
<el-icon v-if="item.isSelcted">
<Check />
</el-icon>
</div>
<span>{{ item.value }}</span>
</div>
</li>
<div class="title">{{ $t(i18n.global.t('home.title.SecuritiestobeListed')) }}</div>
<li>
2023-04-23 16:31:24 +08:00
<div class="word" v-for="item in obj.SecuritiestobeListed" :key="item.key"
2023-06-16 16:02:24 +08:00
:class="item.isSelcted && 'active'" @click="checkOne(item.key, 'SecuritiestobeListed')">
2023-04-21 16:54:59 +08:00
<div class="check">
<el-icon v-if="item.isSelcted">
<Check />
</el-icon>
</div>
<span>{{ item.value }}</span>
</div>
</li>
2023-06-16 16:02:24 +08:00
2023-04-13 23:31:04 +08:00
</div>
<div class="footer">
2023-04-21 16:54:59 +08:00
<button @click="confirm">{{ $t(i18n.global.t('home.title.APPLY')) }}</button>
2023-04-23 16:31:24 +08:00
<button @click="Cancel">{{ $t(i18n.global.t('home.title.Cancel')) }}</button>
2023-04-13 23:31:04 +08:00
</div>
</div>
</div>
</template>
<script lang="ts">
export default {
name: "XSelect",
};
</script>
<script lang="ts" setup>
2023-06-16 16:02:24 +08:00
import { ref, defineExpose, reactive, inject, onMounted } from 'vue';
2023-04-21 16:54:59 +08:00
import i18n from '@/locales'
import { getCurrentInstance } from 'vue'
2023-04-23 16:31:24 +08:00
import { getSelectList } from "@/api/reqIpo/ipo"
2023-06-16 16:02:24 +08:00
import { ipoStore } from "@/stores/ipo"
import { getDataFromId } from "@/api/mock/home"
const store = ipoStore()
type keyType = 'ipoStatus' | 'tradingCurrency' | 'offeringType' | 'SecuritiestobeListed'
type requestType = 'status' | 'trade_currency' | 'offer_type' | 'list_securities'
2023-04-21 16:54:59 +08:00
const { proxy } = (getCurrentInstance() as any)
2023-04-13 23:31:04 +08:00
const showSelect = ref(false)
2023-04-23 16:31:24 +08:00
const checkedAll = ref(0)
2023-06-16 16:02:24 +08:00
const selectCards = inject('selectCards') as Function
//const status = inject('status')
onMounted(() => {
//console.log('select组件挂载');
if ((store.$state.selectedArr as any).status) {
console.log('store', store.$state.selectedArr)
const storeData = store.$state.selectedArr as any;
if (storeData.status.length) {
obj.ipoStatus = obj.ipoStatus.map((item: any) => {
const j = storeData.status.some((i: string) => i == item.key)
if (j) {
return { ...item, isSelcted: true }
} else {
return item
}
})
}
if (storeData.trade_currency.length) {
obj.tradingCurrency = obj.tradingCurrency.map((item: any) => {
const j = storeData.trade_currency.some((i: string) => i == item.key)
if (j) {
return { ...item, isSelcted: true }
} else {
return item
}
})
}
if (storeData.offer_type.length) {
obj.offeringType = obj.offeringType.map((item: any) => {
const j = storeData.offer_type.some((i: string) => i == item.key)
if (j) {
return { ...item, isSelcted: true }
} else {
return item
}
})
}
if (storeData.list_securities.length) {
obj.SecuritiestobeListed = obj.SecuritiestobeListed.map((item: any) => {
const j = storeData.list_securities.some((i: string) => i == item.key)
if (j) {
return { ...item, isSelcted: true }
} else {
return item
}
})
}
// if (storeData.list_platform.length) {
// obj.ListingPlatform = obj.ListingPlatform.map((item: any) => {
// const j = storeData.list_platform.some((i: string) => i == item.key)
// if (j) {
// return { ...item, isSelcted: true }
// } else {
// return item
// }
// })
// }
}
2023-04-28 14:33:16 +08:00
})
2023-06-16 16:02:24 +08:00
const porps = defineProps<{ fn: Function }>()
2023-04-23 16:31:24 +08:00
const confirm = async () => {
2023-06-16 16:02:24 +08:00
if (checkedAll.value == 2) {
store.setSelectedArr({});
porps.fn()
return
}
var keyArry = ['status', 'trade_currency', 'offer_type', 'list_securities']
2023-04-23 16:31:24 +08:00
var reqeustObj = {
status: [] as string[],
trade_currency: [] as string[],
offer_type: [] as string[],
list_securities: [] as string[],
2023-06-16 16:02:24 +08:00
2023-04-23 16:31:24 +08:00
}
Object.keys(obj).forEach((item: string, index: number) => {
obj[item as keyType].forEach((element: any) => {
if (element.isSelcted) {
reqeustObj[keyArry[index] as requestType].push(element.key as string)
}
})
})
2023-06-16 16:02:24 +08:00
store.setSelectedArr(reqeustObj);
const result = await store.getSearchSelectList()
// const result = await getSelectList(reqeustObj)
//mock数据测试-----------
// const data = await getDataFromId("Select")
// var result = {
// data
// }
//mock数据测试-----------
2023-04-23 16:31:24 +08:00
selectCards(result);
2023-06-16 16:02:24 +08:00
showSelect.value = false
porps.fn()
2023-04-23 16:31:24 +08:00
}
const Cancel = () => {
2023-06-16 16:02:24 +08:00
// showSelect.value = false;
porps.fn()
2023-04-13 23:31:04 +08:00
}
const preVant = (e: any) => {
e.stopPropagation();
}
const obj = reactive({
ipoStatus: [{
2023-04-23 16:31:24 +08:00
key: "25",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.DealInitiated'),
2023-04-13 23:31:04 +08:00
isSelcted: false
},
{
2023-04-23 16:31:24 +08:00
key: "30",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.PublicOfferClosed'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-13 23:31:04 +08:00
}, {
2023-04-23 16:31:24 +08:00
key: "35",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.ApplicationValidated'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-13 23:31:04 +08:00
}, {
2023-04-23 16:31:24 +08:00
key: "45",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.AllotmentConfirmed'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-04-23 16:31:24 +08:00
key: "50",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.MoneySettlement'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-06-16 16:02:24 +08:00
key: "55",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.AllocationConfirmed'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-04-23 16:31:24 +08:00
key: "60",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.placingApproved'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-04-23 16:31:24 +08:00
key: "65",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.AllotmentResultsApproved'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-04-23 16:31:24 +08:00
key: "70",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.TradingStarted'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-04-23 16:31:24 +08:00
key: "80",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.Suspended'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}, {
2023-04-23 16:31:24 +08:00
key: "90",
2023-04-21 16:54:59 +08:00
value: proxy.$t('home.Cancelled'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}],
tradingCurrency: [
{
key: 'HKD',
2023-04-23 16:31:24 +08:00
value: proxy.$t('home.HongKongDollar'),
2023-04-13 23:31:04 +08:00
isSelcted: false
},
{
key: 'CNY',
2023-04-23 16:31:24 +08:00
value: proxy.$t('home.ChineseYuan'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-13 23:31:04 +08:00
},
{
key: 'USD',
2023-04-23 16:31:24 +08:00
value: proxy.$t('home.UnitedStatesDollar'),
2023-04-13 23:31:04 +08:00
isSelcted: false
}
2023-04-21 16:54:59 +08:00
],
2023-04-23 16:31:24 +08:00
offeringType: [{
key: '1',
value: proxy.$t('ipo.TypeofListing.Globalofferplacingandpublicoffer'),
2023-04-21 16:54:59 +08:00
isSelcted: false
2023-04-23 16:31:24 +08:00
}, {
key: '2',
value: proxy.$t('ipo.TypeofListing.Byplacingonly'),
2023-04-21 16:54:59 +08:00
isSelcted: false
2023-04-23 16:31:24 +08:00
}, {
key: '3',
value: proxy.$t('ipo.TypeofListing.Bypublicofferonly'),
2023-04-21 16:54:59 +08:00
isSelcted: false
2023-04-23 16:31:24 +08:00
}, {
key: '4',
value: proxy.$t('ipo.TypeofListing.Byintroduction'),
2023-04-21 16:54:59 +08:00
isSelcted: false
},
{
2023-04-23 16:31:24 +08:00
key: '5',
value: proxy.$t('ipo.TypeofListing.TransferfromGEM'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-21 16:54:59 +08:00
}
2023-04-23 16:31:24 +08:00
],
SecuritiestobeListed: [{
key: '1',
value: proxy.$t('ipo.TypeofListing.Ordinaryshares'),
2023-04-21 16:54:59 +08:00
isSelcted: false
2023-04-23 16:31:24 +08:00
}, {
key: '2',
value: proxy.$t('ipo.TypeofListing.OrdinarysharesHshares'),
2023-04-21 16:54:59 +08:00
isSelcted: false
2023-04-23 16:31:24 +08:00
}, {
key: '3',
value: proxy.$t('ipo.TypeofListing.OrdinarysharesconversionfromBtoHshares'),
isSelcted: false
}, {
key: '4',
value: proxy.$t('ipo.TypeofListing.Preferenceshares'),
2023-04-21 16:54:59 +08:00
isSelcted: false
},
{
2023-04-23 16:31:24 +08:00
key: '5',
value: proxy.$t('ipo.TypeofListing.RealEstateInvestmentTrust'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-21 16:54:59 +08:00
},
{
2023-04-23 16:31:24 +08:00
key: '6',
value: proxy.$t('ipo.TypeofListing.ExchangeTradedProduct'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-21 16:54:59 +08:00
},
{
2023-04-23 16:31:24 +08:00
key: '7',
value: proxy.$t('ipo.TypeofListing.DepositaryReceipts'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-21 16:54:59 +08:00
},
{
2023-04-23 16:31:24 +08:00
key: '8',
value: proxy.$t('ipo.TypeofListing.ShareStapledUnits'),
2023-04-28 14:33:16 +08:00
isSelcted: false
2023-04-21 16:54:59 +08:00
},
{
2023-04-23 16:31:24 +08:00
key: '99',
value: proxy.$t('ipo.TypeofListing.Other'),
2023-04-21 16:54:59 +08:00
isSelcted: false
}
2023-04-23 16:31:24 +08:00
],
2023-06-16 16:02:24 +08:00
// ListingPlatform: [{
// key: '1',
// value: proxy.$t('home.Mainboard'),
// isSelcted: false
// }, {
// key: '2',
// value: proxy.$t('home.GEM'),
// isSelcted: false
// }],
2023-04-23 16:31:24 +08:00
// ListingType: [{
// key: '1',
// value: proxy.$t('ipo.TypeofListing.Ordinaryshares'),
// isSelcted: false
// }, {
// key: '2',
// value: proxy.$t('ipo.TypeofListing.OrdinarysharesHshares'),
// isSelcted: false
// }, {
// key: '3',
// value: proxy.$t('ipo.TypeofListing.OrdinarysharesconversionfromBtoHshares'),
// isSelcted: false
// }, {
// key: '4',
// value: proxy.$t('ipo.TypeofListing.Preferenceshares'),
// isSelcted: false
// },
// {
// key: '5',
// value: proxy.$t('ipo.TypeofListing.RealEstateInvestmentTrust'),
2023-04-28 14:33:16 +08:00
// isSelcted: false
2023-04-23 16:31:24 +08:00
// },
// {
// key: '6',
// value: proxy.$t('ipo.TypeofListing.ExchangeTradedProduct'),
// isSelcted: true
// },
// {
// key: '7',
// value: proxy.$t('ipo.TypeofListing.DepositaryReceipts'),
// isSelcted: true
// },
// {
// key: '8',
// value: proxy.$t('ipo.TypeofListing.ShareStapledUnits'),
// isSelcted: true
// },
// {
// key: '99',
// value: proxy.$t('ipo.TypeofListing.Other'),
// isSelcted: false
// }
// ]
2023-04-13 23:31:04 +08:00
})
2023-04-23 16:31:24 +08:00
const checkOne = (key: number | string, objKey: keyType) => {
obj[objKey] = obj[objKey].map((item: any) => {
2023-04-13 23:31:04 +08:00
if (item.key == key) {
return { ...item, isSelcted: !item.isSelcted }
}
return item
})
}
2023-04-23 16:31:24 +08:00
const checkAll = (number: number) => {
if (checkedAll.value && checkedAll.value == number) {
checkedAll.value = 0;
} else {
checkedAll.value = number;
selectAll(number as 1 | 2)
2023-04-21 16:54:59 +08:00
}
}
2023-04-23 16:31:24 +08:00
function selectAll(all: 1 | 2) {
var boolean1 = all == 1 ? true : false;
Object.keys(obj).forEach((item: string) => {
obj[item as keyType] = obj[item as keyType].map(element => {
return { ...element, isSelcted: boolean1 } as any;
2023-04-21 16:54:59 +08:00
})
})
}
2023-06-16 16:02:24 +08:00
2023-04-13 23:31:04 +08:00
</script>
<style lang="scss" scoped>
.selectWrap {
width: 800px;
2023-04-28 14:33:16 +08:00
height: 620px;
2023-04-13 23:31:04 +08:00
background-color: #fff;
border-radius: 20px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
2023-06-16 16:02:24 +08:00
@media screen and (max-width: 768px) {
2023-04-28 14:33:16 +08:00
width: 90vw;
2023-06-16 16:02:24 +08:00
height: 93vh;
top: 50%;
left: 50%;
2023-04-28 14:33:16 +08:00
transform: translate(-50%, -50%);
2023-06-16 16:02:24 +08:00
overflow-y: scroll;
}
2023-04-13 23:31:04 +08:00
.box {
box-sizing: border-box;
padding: 10px 20px 20px 20px;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.content {
.title {
2023-04-21 16:54:59 +08:00
font-size: 18px;
color: #879db2;
2023-04-13 23:31:04 +08:00
margin-top: 10px;
2023-06-16 16:02:24 +08:00
// @media screen and (max-width: 768px){
// font-size: 12px;
// }
2023-04-13 23:31:04 +08:00
}
li {
display: flex;
font-size: 18px;
flex-wrap: wrap;
2023-06-16 16:02:24 +08:00
@media screen and (max-width: 768px) {
2023-04-28 14:33:16 +08:00
flex-direction: column;
2023-06-16 16:02:24 +08:00
flex-wrap: nowrap;
//font-size: 12px;
width: fit-content;
}
2023-04-13 23:31:04 +08:00
.word {
margin-right: 10px;
margin-top: 5px;
border-radius: 20px;
// width: 50px;
height: 20px;
2023-04-21 16:54:59 +08:00
background-color: #eff1f4;
2023-04-13 23:31:04 +08:00
padding: 5px 15px 5px 10px;
2023-04-21 16:54:59 +08:00
color: #879db2;
2023-04-13 23:31:04 +08:00
display: flex;
justify-content: space-between;
cursor: pointer;
2023-06-16 16:02:24 +08:00
@media screen and (max-width: 768px) {
height: fit-content;
width: fit-content;
}
2023-04-28 14:33:16 +08:00
&:hover {
2023-06-16 16:02:24 +08:00
background-color: #0F426F;
border-radius: 5px;
color: #fff;
}
&.active {
background-color: #0F426F;
border-radius: 5px;
color: #fff;
}
2023-04-13 23:31:04 +08:00
.check {
width: 30px;
span {
line-height: 35px;
2023-06-16 16:02:24 +08:00
2023-04-13 23:31:04 +08:00
}
}
}
}
}
.footer {
display: flex;
flex-direction: row-reverse;
// margin-bottom: 20px;
button {
margin-right: 10px;
font-size: 18px;
border: none;
font-weight: 600;
background-color: #fff;
2023-04-21 16:54:59 +08:00
color: #557795;
2023-04-13 23:31:04 +08:00
padding: 10px 20px 10px 20px;
2023-06-16 16:02:24 +08:00
@media screen and (max-width: 768px) {
margin: 0;
2023-04-28 14:33:16 +08:00
// font-size: 12px;
2023-06-16 16:02:24 +08:00
}
2023-04-13 23:31:04 +08:00
&:hover {
background-color: #0F426F;
border-radius: 5px;
color: #fff;
}
}
}
}
</style>