chore: remove stale ManagedUserSelector copy
This commit is contained in:
@@ -1,183 +0,0 @@
|
|||||||
<template>
|
|
||||||
<bottom-popup
|
|
||||||
v-model="popupVisible"
|
|
||||||
:title="title"
|
|
||||||
height="80vh"
|
|
||||||
left-button-text="关闭"
|
|
||||||
right-button-text=""
|
|
||||||
@left-button-click="close"
|
|
||||||
>
|
|
||||||
<div class="managed-user-selector">
|
|
||||||
<div class="search-wrap">
|
|
||||||
<t-input
|
|
||||||
v-model.trim="keyword"
|
|
||||||
class="search"
|
|
||||||
borderless
|
|
||||||
clearable
|
|
||||||
placeholder="搜索姓名、昵称或手机号"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<t-cell-group v-if="filteredUserList.length" class="list">
|
|
||||||
<t-cell
|
|
||||||
v-for="item in filteredUserList"
|
|
||||||
:key="item.id || item.userId"
|
|
||||||
class="item"
|
|
||||||
:title="getUserName(item)"
|
|
||||||
:description="getUserDescription(item)"
|
|
||||||
@click="select(item)"
|
|
||||||
>
|
|
||||||
<template #left-icon>
|
|
||||||
<t-checkbox
|
|
||||||
:model-value="item.userId === modelValue"
|
|
||||||
borderless
|
|
||||||
@change="select(item)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</t-cell>
|
|
||||||
</t-cell-group>
|
|
||||||
<div v-else class="center-tips" v-text="loading ? '正在加载负责人' : '暂无可选负责人'" />
|
|
||||||
</div>
|
|
||||||
</bottom-popup>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { BottomPopup } from "timi-tdesign-mobile";
|
|
||||||
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
|
||||||
import { Message } from "@/utils/message";
|
|
||||||
import type { ManagedUser } from "@/types/ManagedUser";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
modelValue: string;
|
|
||||||
visible: boolean;
|
|
||||||
storeId?: string;
|
|
||||||
title?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
storeId: "",
|
|
||||||
title: "选择负责人"
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
"update:modelValue": [value: string];
|
|
||||||
"update:visible": [value: boolean];
|
|
||||||
change: [value: ManagedUser];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const popupVisible = computed({
|
|
||||||
get: () => props.visible,
|
|
||||||
set: value => emit("update:visible", value)
|
|
||||||
});
|
|
||||||
const keyword = ref("");
|
|
||||||
const loading = ref(false);
|
|
||||||
const userList = ref<ManagedUser[]>([]);
|
|
||||||
|
|
||||||
const filteredUserList = computed(() => {
|
|
||||||
const normalizedKeyword = keyword.value.toLowerCase();
|
|
||||||
return userList.value.filter(item => {
|
|
||||||
const user = item.user;
|
|
||||||
return !normalizedKeyword || [item.userId, user?.name, user?.nick, user?.phoneNo]
|
|
||||||
.some(value => Boolean(value?.toLowerCase().includes(normalizedKeyword)));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function getUserName(item: ManagedUser): string {
|
|
||||||
return item.user?.nick || item.user?.name || item.userId || "未命名用户";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUserDescription(item: ManagedUser): string {
|
|
||||||
const phone = item.user?.phoneNo || "未填写手机号";
|
|
||||||
const verified = item.user?.phoneNoVerified ? "已验证" : "未验证";
|
|
||||||
return `${phone} · ${verified}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadUsers(): Promise<void> {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const result = await ManagedUserAPI.list({
|
|
||||||
index: 0,
|
|
||||||
size: 1000,
|
|
||||||
equalsExample: {
|
|
||||||
storeId: props.storeId || undefined,
|
|
||||||
enabled: true
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
storeId: props.storeId || undefined
|
|
||||||
});
|
|
||||||
userList.value = result.list || [];
|
|
||||||
} catch (error) {
|
|
||||||
userList.value = [];
|
|
||||||
Message.error(getErrorMessage(error, "负责人列表加载失败"));
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function select(item: ManagedUser): void {
|
|
||||||
if (!item.userId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit("update:modelValue", item.userId);
|
|
||||||
emit("change", item);
|
|
||||||
emit("update:visible", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function close(): void {
|
|
||||||
emit("update:visible", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => props.visible, async value => {
|
|
||||||
if (!value) {
|
|
||||||
keyword.value = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await loadUsers();
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(() => props.storeId, async () => {
|
|
||||||
if (props.visible) {
|
|
||||||
await loadUsers();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.managed-user-selector {
|
|
||||||
height: 100%;
|
|
||||||
overflow: auto;
|
|
||||||
background: var(--td-bg-color-page, #f5f5f8);
|
|
||||||
|
|
||||||
.search-wrap {
|
|
||||||
padding: .75rem 1rem;
|
|
||||||
background: var(--td-bg-color-container, #fff);
|
|
||||||
}
|
|
||||||
|
|
||||||
.search {
|
|
||||||
--td-input-vertical-padding: 8px 14px;
|
|
||||||
|
|
||||||
border: 1px solid var(--td-component-border);
|
|
||||||
border-radius: .75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item {
|
|
||||||
padding: .25rem 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
|
||||||
.managed-user-selector {
|
|
||||||
background: #10161f;
|
|
||||||
|
|
||||||
.search-wrap,
|
|
||||||
.item {
|
|
||||||
background: rgba(30, 41, 59, .9);
|
|
||||||
}
|
|
||||||
|
|
||||||
.search {
|
|
||||||
background: rgba(15, 23, 42, .72);
|
|
||||||
border-color: rgba(148, 163, 184, .16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Reference in New Issue
Block a user