|
@@ -0,0 +1,175 @@
|
|
|
+<template>
|
|
|
+ <div class="c-search">
|
|
|
+ <div class="searchList" v-for="(item, index) in searchFields" :key="index">
|
|
|
+ <div class="twoSeacher" v-if="item.type == 'plate'">
|
|
|
+ <div class="twoLeft">
|
|
|
+ <span>{{ item.title }}</span>
|
|
|
+ </div>
|
|
|
+ <div v-if="!item.show" class="twoRight">
|
|
|
+ <div class="label" :class="[tags.is_active ? 'show' : '']" v-for="(tags, indexs) in plateList.slice(0, 6)" :key="indexs" @click="toSelect(tags, 'plate')">
|
|
|
+ {{ tags.title }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else class="twoRight">
|
|
|
+ <div class="label" :class="[tags.is_active ? 'show' : '']" v-for="(tags, indexs) in plateList" :key="indexs" @click="toSelect(tags, 'plate')">
|
|
|
+ {{ tags.title }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="button">
|
|
|
+ <span v-if="!item.show" @click="item.show = true">
|
|
|
+ <el-icon><ArrowDown /></el-icon>
|
|
|
+ </span>
|
|
|
+ <span v-else @click="item.show = false">
|
|
|
+ <el-icon><ArrowUp /></el-icon>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="twoSeacher" v-if="item.type == 'field'">
|
|
|
+ <div class="twoLeft">
|
|
|
+ <span>{{ item.title }}</span>
|
|
|
+ </div>
|
|
|
+ <div v-if="!twoShow" class="twoRight">
|
|
|
+ <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in typeList.slice(0, 10)" :key="index" @click="toSelect(item, 'field')">
|
|
|
+ {{ item.label }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else class="twoRight">
|
|
|
+ <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in typeList" :key="index" @click="toSelect(item, 'field')">
|
|
|
+ {{ item.label }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="button">
|
|
|
+ <span v-if="!twoShow" @click="twoShow = true">
|
|
|
+ <el-icon><ArrowDown /></el-icon>
|
|
|
+ </span>
|
|
|
+ <span v-else @click="twoShow = false">
|
|
|
+ <el-icon><ArrowUp /></el-icon>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="twoSeacher" v-else-if="item.type == 'city'">
|
|
|
+ <div class="twoLeft">
|
|
|
+ <span>{{ item.title }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="twoRight">
|
|
|
+ <div class="label" :class="[tags.is_active ? 'show' : '']" v-for="(tags, indexs) in cityList" :key="indexs" @click="toSelect(tags, 'city')">
|
|
|
+ {{ tags.name }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="twoIpunt">
|
|
|
+ <el-input class="input" v-for="(item, index) in fields" :key="index" clearable size="large" v-model="searchForm[item.model]" :placeholder="getField('placeholder', item)" />
|
|
|
+ <el-button class="button" size="large" type="primary" @click="toSearchInfo">检索</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { get } from 'lodash-es'
|
|
|
+const props = defineProps({
|
|
|
+ searchFields: { type: Array, default: () => [] },
|
|
|
+ fields: { type: Array, default: () => [] },
|
|
|
+ plateList: { type: Array, default: () => [] },
|
|
|
+ cityList: { type: Array, default: () => [] },
|
|
|
+ typeList: { type: Array, default: () => [] }
|
|
|
+})
|
|
|
+const searchForm = ref({})
|
|
|
+
|
|
|
+const emits = defineEmits(['toSelect', 'toDel', 'toSearchInfo'])
|
|
|
+
|
|
|
+const toSelect = (data, type) => {
|
|
|
+ emits('toSelect', data, type)
|
|
|
+}
|
|
|
+const toDel = (data, type) => {
|
|
|
+ emits('toDel', data, type)
|
|
|
+}
|
|
|
+const toSearchInfo = () => {
|
|
|
+ emits('toSearchInfo', searchForm.value)
|
|
|
+}
|
|
|
+const getField = (item, data) => {
|
|
|
+ let res = get(data, item, null)
|
|
|
+ if (item === 'type') res = res === null ? `text` : res
|
|
|
+ if (item === 'placeholder') res = res === null ? `请输入${data.label}` : res
|
|
|
+ if (item === `selectplaceholder`) res = res === null ? `请选择${data.label}` : res
|
|
|
+ if (item === 'required') res = res === null ? false : res
|
|
|
+ if (item === `error`) res = res === null ? `${data.label}错误` : res
|
|
|
+ return res
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.c-search {
|
|
|
+ .twoSeacher {
|
|
|
+ background-color: #fff;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: stretch;
|
|
|
+ position: relative;
|
|
|
+ border: solid 1px #e5e5e5;
|
|
|
+ border-bottom: 0;
|
|
|
+ font-size: $global-font-size-18;
|
|
|
+ color: #666;
|
|
|
+ min-height: 60px;
|
|
|
+ overflow: hidden;
|
|
|
+ .twoLeft {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ flex-shrink: 0;
|
|
|
+ width: 110px;
|
|
|
+ text-align: center;
|
|
|
+ color: #000;
|
|
|
+ font-weight: bold;
|
|
|
+ background-color: #fafafa;
|
|
|
+ }
|
|
|
+ .twoRight {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ align-items: center;
|
|
|
+ padding: 12px;
|
|
|
+ flex: 1;
|
|
|
+ border-left: solid 1px #e5e5e5;
|
|
|
+ background-color: #fff;
|
|
|
+ .label {
|
|
|
+ margin-right: 3px;
|
|
|
+ color: #313131;
|
|
|
+ padding: 8px 10px;
|
|
|
+ border-radius: 3px;
|
|
|
+ background-color: #fff;
|
|
|
+ border: solid 1px transparent;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ .show {
|
|
|
+ color: #0a58c2;
|
|
|
+ border: solid 1px #006dd2;
|
|
|
+ }
|
|
|
+
|
|
|
+ .label:hover {
|
|
|
+ color: $global-color-107;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .button {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin: 0 5px 0 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .searchList:last-child {
|
|
|
+ .twoSeacher {
|
|
|
+ border-bottom: 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .twoIpunt {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin: 10px 0 0 0;
|
|
|
+ .input {
|
|
|
+ margin: 0 5px 0 0;
|
|
|
+ }
|
|
|
+ .button {
|
|
|
+ margin: 0 0 0 5px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|