|
@@ -1,20 +1,35 @@
|
|
<template>
|
|
<template>
|
|
<div class="search-head">
|
|
<div class="search-head">
|
|
- <van-search v-model="value" placeholder="请输入搜索关键词" @search="emit('handle-search-emit', value)" />
|
|
|
|
|
|
+ <van-search
|
|
|
|
+ v-model="value"
|
|
|
|
+ placeholder="请输入搜索关键词"
|
|
|
|
+ @search="emit('handle-search-emit', value)"
|
|
|
|
+ />
|
|
<van-dropdown-menu active-color="#FF5B00">
|
|
<van-dropdown-menu active-color="#FF5B00">
|
|
<van-dropdown-item
|
|
<van-dropdown-item
|
|
- active-color="#FF5B00"
|
|
|
|
|
|
+ active-color="#FF5B00"
|
|
:title="i.title"
|
|
:title="i.title"
|
|
ref="itemRef"
|
|
ref="itemRef"
|
|
v-for="(i, o) in menuTypeOptions"
|
|
v-for="(i, o) in menuTypeOptions"
|
|
:key="o"
|
|
:key="o"
|
|
v-model="i.changeValue"
|
|
v-model="i.changeValue"
|
|
:options="i.type !== 'Double' ? i.options : []"
|
|
:options="i.type !== 'Double' ? i.options : []"
|
|
- :class="[activeMenu === o ? 'activeMenu' : '']"
|
|
|
|
- @close="handleDropdownClose"
|
|
|
|
|
|
+ @close="handleDropdownClose"
|
|
|
|
+ @open="handleOpen(o)"
|
|
>
|
|
>
|
|
- <template v-if="o !== 3">
|
|
|
|
- <van-search :disabled="o === 2" v-model="searchValue" placeholder="请输入搜索关键词" />
|
|
|
|
|
|
+ <template v-if="o === 0">
|
|
|
|
+ <van-search
|
|
|
|
+ v-model="labelKeyParams.v"
|
|
|
|
+ placeholder="请输入搜索关键词"
|
|
|
|
+ @search="reqLabelKeyList"
|
|
|
|
+ />
|
|
|
|
+ </template>
|
|
|
|
+ <template v-if="o === 1">
|
|
|
|
+ <van-search
|
|
|
|
+ v-model="storeParams.productName"
|
|
|
|
+ placeholder="请输入搜索关键词"
|
|
|
|
+ @search="reqStoreList"
|
|
|
|
+ />
|
|
</template>
|
|
</template>
|
|
<template v-if="i.type === 'Double'">
|
|
<template v-if="i.type === 'Double'">
|
|
<van-checkbox-group v-model="checked">
|
|
<van-checkbox-group v-model="checked">
|
|
@@ -25,7 +40,7 @@
|
|
:key="index"
|
|
:key="index"
|
|
:title="item.text"
|
|
:title="item.text"
|
|
@click="toggle(item.value)"
|
|
@click="toggle(item.value)"
|
|
- :class="checked.indexOf(item.value) > -1 ? 'd-checked' : ''"
|
|
|
|
|
|
+ :class="checked.indexOf(item.value) > -1 ? 'd-checked' : ''"
|
|
>
|
|
>
|
|
<template #right-icon>
|
|
<template #right-icon>
|
|
<van-checkbox
|
|
<van-checkbox
|
|
@@ -43,16 +58,28 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { ref, reactive, onBeforeUpdate, onMounted, VNodeRef } from 'vue';
|
|
|
|
-import type { DMenu, DMenuList, DEmit } from '@/types/views/database.type';
|
|
|
|
|
|
+import { ref, reactive, onBeforeUpdate, onMounted, VNodeRef } from "vue";
|
|
|
|
+import type { DMenu, DMenuList, DEmit } from "@/types/views/database.type";
|
|
import { getLabelKeyList, getStoreList } from "@/api/context/context";
|
|
import { getLabelKeyList, getStoreList } from "@/api/context/context";
|
|
-import { CheckboxInstance } from 'vant';
|
|
|
|
|
|
+import { CheckboxInstance } from "vant";
|
|
|
|
+import { ILabelKeyRequest, IStoreRequest } from "@/types/api/context.type";
|
|
|
|
|
|
type menuOptions = Array<DMenuList<DMenu>>; // 菜单类型
|
|
type menuOptions = Array<DMenuList<DMenu>>; // 菜单类型
|
|
-
|
|
|
|
-const activeMenu = ref<number>(0) // 切换tab
|
|
|
|
-const searchValue = ref<string>('') // 搜索条件
|
|
|
|
-const value = ref<string>(''); // 标题搜索
|
|
|
|
|
|
+const activePadding = ref<string>("20vw 1vw 1vw 1vw"); // vue 样式
|
|
|
|
+const handleOpen = (val: number) => {
|
|
|
|
+ activePadding.value = val < 2 ? "20vw 1vw 1vw 1vw" : "5vw 1vw 1vw 1vw";
|
|
|
|
+};
|
|
|
|
+const storeParams = ref<IStoreRequest>({
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 10,
|
|
|
|
+ productName: "",
|
|
|
|
+}); // 搜索条件
|
|
|
|
+const labelKeyParams = ref<ILabelKeyRequest>({
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 10,
|
|
|
|
+ v: "",
|
|
|
|
+}); // 搜索条件
|
|
|
|
+const value = ref<string>(""); // 标题搜索
|
|
const checked = ref<Array<number | null>>([]); // 默认选中
|
|
const checked = ref<Array<number | null>>([]); // 默认选中
|
|
const checkboxRefs = ref<Array<CheckboxInstance | VNodeRef>>([]); // 多选默认
|
|
const checkboxRefs = ref<Array<CheckboxInstance | VNodeRef>>([]); // 多选默认
|
|
|
|
|
|
@@ -98,44 +125,36 @@ const menuTypeOptions = reactive<menuOptions>([
|
|
]);
|
|
]);
|
|
|
|
|
|
const toggle = (index: number) => {
|
|
const toggle = (index: number) => {
|
|
- (checkboxRefs.value[index] as CheckboxInstance).toggle();
|
|
|
|
|
|
+ (checkboxRefs.value[index] as CheckboxInstance).toggle();
|
|
};
|
|
};
|
|
-const emit = defineEmits<DEmit>()
|
|
|
|
|
|
+const emit = defineEmits<DEmit>();
|
|
const handleDropdownClose = (): void => {
|
|
const handleDropdownClose = (): void => {
|
|
- emit('handle-change-emit', {
|
|
|
|
|
|
+ emit("handle-change-emit", {
|
|
labelIds: checked.value.join(),
|
|
labelIds: checked.value.join(),
|
|
productId: menuTypeOptions[1].changeValue!,
|
|
productId: menuTypeOptions[1].changeValue!,
|
|
- stageStatus: menuTypeOptions[2].changeValue!.toString()
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
+ stageStatus: menuTypeOptions[2].changeValue!.toString(),
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
|
|
const reqLabelKeyList = async () => {
|
|
const reqLabelKeyList = async () => {
|
|
- const { data } = await getLabelKeyList({
|
|
|
|
- pageNum: 1,
|
|
|
|
- pageSize: 10,
|
|
|
|
- v: ''
|
|
|
|
- })
|
|
|
|
- menuTypeOptions[0].options = data!.list!.map(e => ({
|
|
|
|
|
|
+ const { data } = await getLabelKeyList(labelKeyParams.value);
|
|
|
|
+ menuTypeOptions[0].options = data!.list!.map((e) => ({
|
|
text: e.v,
|
|
text: e.v,
|
|
- value: Number(e.k)
|
|
|
|
- }))
|
|
|
|
-}
|
|
|
|
|
|
+ value: Number(e.k),
|
|
|
|
+ }));
|
|
|
|
+};
|
|
const reqStoreList = async () => {
|
|
const reqStoreList = async () => {
|
|
- const { data } = await getStoreList({
|
|
|
|
- pageNum: 1,
|
|
|
|
- pageSize: 10,
|
|
|
|
- productName: ''
|
|
|
|
- })
|
|
|
|
- menuTypeOptions[1].options = data!.list!.map(e => ({
|
|
|
|
|
|
+ const { data } = await getStoreList(storeParams.value);
|
|
|
|
+ menuTypeOptions[1].options = [{ text: '商品(全部)',value: 0 }, ...data!.list!.map((e) => ({
|
|
text: e.productName,
|
|
text: e.productName,
|
|
- value: e.productId
|
|
|
|
- }))
|
|
|
|
-}
|
|
|
|
|
|
+ value: e.productId,
|
|
|
|
+ }))]
|
|
|
|
+};
|
|
|
|
|
|
-onMounted(async () => {
|
|
|
|
- await reqLabelKeyList()
|
|
|
|
- await reqStoreList()
|
|
|
|
-})
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
+ reqLabelKeyList();
|
|
|
|
+ reqStoreList();
|
|
|
|
+});
|
|
// 组件更新
|
|
// 组件更新
|
|
onBeforeUpdate(() => {
|
|
onBeforeUpdate(() => {
|
|
checkboxRefs.value = [];
|
|
checkboxRefs.value = [];
|
|
@@ -154,9 +173,9 @@ onBeforeUpdate(() => {
|
|
font-size: 13px;
|
|
font-size: 13px;
|
|
padding: 0;
|
|
padding: 0;
|
|
border: 1px solid #e1e1e1;
|
|
border: 1px solid #e1e1e1;
|
|
- .van-search__field {
|
|
|
|
- padding: 0;
|
|
|
|
- }
|
|
|
|
|
|
+ .van-search__field {
|
|
|
|
+ padding: 0;
|
|
|
|
+ }
|
|
.van-search__content {
|
|
.van-search__content {
|
|
background: #fff;
|
|
background: #fff;
|
|
}
|
|
}
|
|
@@ -182,31 +201,31 @@ onBeforeUpdate(() => {
|
|
color: #333;
|
|
color: #333;
|
|
position: relative;
|
|
position: relative;
|
|
}
|
|
}
|
|
- .van-cell {
|
|
|
|
- padding: 7.5px;
|
|
|
|
- .van-cell__title {
|
|
|
|
- color: rgb(37, 1, 1);
|
|
|
|
- font-size: 13px;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- .van-checkbox__icon--checked .van-icon,
|
|
|
|
- .van-checkbox__icon .van-icon {
|
|
|
|
- background: none;
|
|
|
|
- border: none;
|
|
|
|
- }
|
|
|
|
|
|
+ .van-cell {
|
|
|
|
+ padding: 7.5px;
|
|
|
|
+ .van-cell__title {
|
|
|
|
+ color: rgb(37, 1, 1);
|
|
|
|
+ font-size: 13px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .van-checkbox__icon--checked .van-icon,
|
|
|
|
+ .van-checkbox__icon .van-icon {
|
|
|
|
+ background: none;
|
|
|
|
+ border: none;
|
|
|
|
+ }
|
|
.van-dropdown-menu__title::after {
|
|
.van-dropdown-menu__title::after {
|
|
opacity: 1;
|
|
opacity: 1;
|
|
}
|
|
}
|
|
- .van-dropdown-item__option--active,
|
|
|
|
- .van-dropdown-menu__title--active {
|
|
|
|
- .van-cell__title,
|
|
|
|
- .van-dropdown-menu__title::after {
|
|
|
|
- color: $basicColor !important;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ .van-dropdown-item__option--active,
|
|
|
|
+ .van-dropdown-menu__title--active {
|
|
|
|
+ .van-cell__title,
|
|
|
|
+ .van-dropdown-menu__title::after {
|
|
|
|
+ color: $basicColor !important;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
.van-dropdown-menu__title--active::before {
|
|
.van-dropdown-menu__title--active::before {
|
|
- content: '';
|
|
|
|
|
|
+ content: "";
|
|
position: absolute;
|
|
position: absolute;
|
|
width: 30px;
|
|
width: 30px;
|
|
height: 2px;
|
|
height: 2px;
|
|
@@ -218,16 +237,17 @@ onBeforeUpdate(() => {
|
|
.van-popup--top {
|
|
.van-popup--top {
|
|
max-height: 50vh;
|
|
max-height: 50vh;
|
|
position: relative;
|
|
position: relative;
|
|
- padding: 45px 5px 5px 5px;
|
|
|
|
|
|
+ padding: v-bind(activePadding);
|
|
.van-search {
|
|
.van-search {
|
|
position: absolute;
|
|
position: absolute;
|
|
- top: 24px;
|
|
|
|
|
|
+ top: 40px;
|
|
left: 50%;
|
|
left: 50%;
|
|
width: 96%;
|
|
width: 96%;
|
|
height: 40px;
|
|
height: 40px;
|
|
transform: translate(-50%, -50%);
|
|
transform: translate(-50%, -50%);
|
|
}
|
|
}
|
|
- .van-cell__title, .van-cell__value {
|
|
|
|
|
|
+ .van-cell__title,
|
|
|
|
+ .van-cell__value {
|
|
flex: auto;
|
|
flex: auto;
|
|
width: 20px;
|
|
width: 20px;
|
|
}
|
|
}
|
|
@@ -237,14 +257,14 @@ onBeforeUpdate(() => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.d-checked {
|
|
.d-checked {
|
|
- :deep() {
|
|
|
|
- .van-checkbox__icon--checked .van-icon,
|
|
|
|
- .van-cell__title {
|
|
|
|
- color: $basicColor;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ :deep() {
|
|
|
|
+ .van-checkbox__icon--checked .van-icon,
|
|
|
|
+ .van-cell__title {
|
|
|
|
+ color: $basicColor;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
.activeMenu {
|
|
.activeMenu {
|
|
- color: $basicColor;
|
|
|
|
|
|
+ color: $basicColor;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|