Commit 85291c3f authored by tao.huang's avatar tao.huang

feat: 多选

parent 5b57105a
<template> <template>
<Layer <Layer
:modelValue="modelValue" :modelValue="modelValue"
:title="title" :customHeader="true"
:showCancel="true" :showCancel="false"
:showConfirm="true" :showConfirm="false"
@update:modelValue="$emit('update:modelValue', $event)" @update:modelValue="$emit('update:modelValue', $event)"
@confirm="onConfirm" @confirm="onConfirm"
@cancel="onCancel" @cancel="onCancel"
> >
<template> <template>
<view class="multi-select-title">{{ title }}</view>
<view class="multi-select-list"> <view class="multi-select-list">
<view <view
v-for="opt in options" v-for="opt in options"
...@@ -21,18 +22,22 @@ ...@@ -21,18 +22,22 @@
<image <image
v-if="selectedSet.has(opt)" v-if="selectedSet.has(opt)"
class="check-icon" class="check-icon"
src="/static/check.png" :src="$baseUrl + 'person/icon_gou.png'"
/> />
</view> </view>
</view> </view>
<view class="multi-select-btn" @click="onConfirm"> 保存 </view>
</template> </template>
</Layer> </Layer>
</template> </template>
<script setup> <script setup>
import { ref, watch, computed } from "vue"; import { ref, watch, computed, getCurrentInstance } from "vue";
import Layer from "./Layer.vue"; import Layer from "./Layer.vue";
const { proxy } = getCurrentInstance();
const $baseUrl = proxy.$baseUrl;
const props = defineProps({ const props = defineProps({
modelValue: Boolean, modelValue: Boolean,
title: String, title: String,
...@@ -40,7 +45,12 @@ const props = defineProps({ ...@@ -40,7 +45,12 @@ const props = defineProps({
modelSelected: { type: Array, default: () => [] }, modelSelected: { type: Array, default: () => [] },
max: Number, max: Number,
}); });
const emit = defineEmits(["update:modelValue", "update:selected", "confirm", "cancel"]); const emit = defineEmits([
"update:modelValue",
"update:selected",
"confirm",
"cancel",
]);
const selected = ref([...props.modelSelected]); const selected = ref([...props.modelSelected]);
watch( watch(
...@@ -72,32 +82,50 @@ function onCancel() { ...@@ -72,32 +82,50 @@ function onCancel() {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.multi-select-btn {
width: 686rpx;
height: 94rpx;
background: #d3a358;
color: #fff;
border-radius: 46rpx;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
margin-top: 24rpx;
font-size: 32rpx;
}
.multi-select-title {
font-size: 32rpx;
color: #222;
font-weight: bold;
margin-bottom: 24rpx;
}
.multi-select-list { .multi-select-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 24rpx 20rpx; gap: 15rpx 20rpx;
} }
.multi-select-tag { .multi-select-tag {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 32rpx; padding: 0 24rpx;
height: 56rpx; height: 56rpx;
background: #fff; background: #ffffff;
border-radius: 28rpx; border-radius: 28rpx;
color: #222; color: #1d1e25;
font-size: 28rpx; font-size: 24rpx;
margin-bottom: 24rpx;
position: relative; position: relative;
border: 1rpx solid #eee;
.check-icon { .check-icon {
width: 28rpx; width: 19rpx;
height: 28rpx; height: 19rpx;
margin-left: 8rpx; position: absolute;
right: 2rpx;
top: 3rpx;
display: block;
} }
&.selected { &.selected {
background: #e9d3b1; background: #efe7da;
color: #b88a3a;
border: 1rpx solid #b88a3a;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<picker-view <picker-view
class="picker-layer-view" class="picker-layer-view"
mask-style="background: rgb(246, 248, 250); z-index: 0;" mask-style="background: rgb(246, 248, 250); z-index: 0;"
indicator-style="border-radius: 10px; height: 50px;background:#ffffff; z-index:0" indicator-style="border-radius: 10px; height: 50px; background:#ffffff; z-index:0"
:value="pickerValue" :value="pickerValue"
@change="onChange" @change="onChange"
> >
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
</picker-view-column> </picker-view-column>
</template> </template>
<template v-else> <template v-else>
<picker-view-column v-for="(col, colIdx) in columns" :key="colIdx"> <picker-view-column>
<view <view
v-for="(item, idx) in col" v-for="(item, idx) in columns[0]"
:key="idx" :key="idx"
class="picker-layer-item" class="picker-layer-item"
> >
...@@ -309,6 +309,7 @@ function onChange(e) { ...@@ -309,6 +309,7 @@ function onChange(e) {
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative;
} }
.picker-layer-header { .picker-layer-header {
display: flex; display: flex;
...@@ -350,6 +351,7 @@ function onChange(e) { ...@@ -350,6 +351,7 @@ function onChange(e) {
.picker-layer-view { .picker-layer-view {
flex: 1; flex: 1;
width: 100%; width: 100%;
height: 100%;
} }
.picker-layer-item { .picker-layer-item {
height: 100rpx; height: 100rpx;
......
This diff is collapsed.
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<BabySwitcher <BabySwitcher
v-if="showBabySwitcher" v-if="showBabySwitcher"
:show="showBabySwitcher" :show="showBabySwitcher"
:babyList="babyInfo.allBabyBaseInfo" :babyList="babyInfo.allBabyBaseInfo || []"
:addIcon="$baseUrl + 'my/baby_add_btn.png'" :addIcon="$baseUrl + 'my/baby_add_btn.png'"
@close="showBabySwitcher = false" @close="showBabySwitcher = false"
@select="onSelectBaby" @select="onSelectBaby"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment