1. 推广员功能增强
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
This commit is contained in:
@@ -37,6 +37,10 @@ interface Props {
|
||||
* 诊所ID
|
||||
*/
|
||||
storeId?: number;
|
||||
/**
|
||||
* 挂号ID(用于取价门店与毛利率权限)
|
||||
*/
|
||||
registerId?: number;
|
||||
/**
|
||||
* 是否禁用
|
||||
*/
|
||||
@@ -47,6 +51,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
type: 1,
|
||||
placeholder: '输入药品名称搜索',
|
||||
storeId: 2,
|
||||
registerId: undefined,
|
||||
disabled: false,
|
||||
});
|
||||
|
||||
@@ -120,6 +125,7 @@ const searchDrugs = debounce(async (keyword: string) => {
|
||||
name: keyword,
|
||||
type: props.type,
|
||||
store_id: props.storeId,
|
||||
...(props.registerId ? { register_id: props.registerId } : {}),
|
||||
});
|
||||
|
||||
// 处理返回数据
|
||||
|
||||
243
apps/web-antd/src/components/form/components/promoter-picker.vue
Normal file
243
apps/web-antd/src/components/form/components/promoter-picker.vue
Normal file
@@ -0,0 +1,243 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { Avatar, Empty, Input, Popover, Spin } from 'ant-design-vue';
|
||||
|
||||
import { getPromoterOptions } from '#/views/system/store-input/api';
|
||||
|
||||
defineOptions({
|
||||
name: 'PromoterPicker',
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
value?: string;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
const emits = defineEmits<{
|
||||
'update:value': [value: string | undefined];
|
||||
}>();
|
||||
|
||||
const mValue = useVModel(props, 'value', emits, { passive: true });
|
||||
|
||||
type PromoterOption = {
|
||||
id: number;
|
||||
nick_name: string;
|
||||
avatar: string;
|
||||
code: string;
|
||||
role_id: number;
|
||||
role_name: string;
|
||||
};
|
||||
|
||||
const open = ref(false);
|
||||
const loading = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
const options = ref<PromoterOption[]>([]);
|
||||
const triggerRef = ref<HTMLElement | null>(null);
|
||||
const searchInputRef = ref<InstanceType<typeof Input> | null>(null);
|
||||
|
||||
function filterPromoterOptions(keyword: string, list: PromoterOption[]) {
|
||||
const q = keyword.trim().toLowerCase();
|
||||
if (!q) return list;
|
||||
return list.filter((item) => {
|
||||
const name = (item.nick_name || '').toLowerCase();
|
||||
const code = (item.code || '').toLowerCase();
|
||||
const role = (item.role_name || '').toLowerCase();
|
||||
return name.includes(q) || code.includes(q) || role.includes(q);
|
||||
});
|
||||
}
|
||||
|
||||
const filteredOptions = computed(() =>
|
||||
filterPromoterOptions(searchKeyword.value, options.value),
|
||||
);
|
||||
|
||||
const selectedOption = computed(() =>
|
||||
options.value.find((item) => item.code === mValue.value),
|
||||
);
|
||||
|
||||
const displayText = computed(() => {
|
||||
const item = selectedOption.value;
|
||||
if (!item) return '';
|
||||
return `${item.nick_name || '-'} · ${item.code} · ${item.role_name || ''}`;
|
||||
});
|
||||
|
||||
async function loadOptions() {
|
||||
loading.value = true;
|
||||
try {
|
||||
options.value = (await getPromoterOptions()) || [];
|
||||
if (options.value.length === 1 && !mValue.value) {
|
||||
mValue.value = options.value[0].code;
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function selectOption(item: PromoterOption) {
|
||||
mValue.value = item.code;
|
||||
open.value = false;
|
||||
searchKeyword.value = '';
|
||||
}
|
||||
|
||||
function clearSelection(e: Event) {
|
||||
e.stopPropagation();
|
||||
mValue.value = undefined;
|
||||
}
|
||||
|
||||
function onOpenChange(next: boolean) {
|
||||
if (props.disabled) return;
|
||||
open.value = next;
|
||||
if (next) {
|
||||
searchKeyword.value = '';
|
||||
if (!options.value.length) {
|
||||
loadOptions();
|
||||
}
|
||||
nextTick(() => searchInputRef.value?.focus?.());
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.disabled,
|
||||
(disabled) => {
|
||||
if (disabled) open.value = false;
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
loadOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Popover
|
||||
:open="open"
|
||||
trigger="click"
|
||||
placement="bottomLeft"
|
||||
overlay-class-name="promoter-picker-popover"
|
||||
@open-change="onOpenChange"
|
||||
>
|
||||
<template #content>
|
||||
<div class="promoter-panel">
|
||||
<Input
|
||||
ref="searchInputRef"
|
||||
v-model:value="searchKeyword"
|
||||
allow-clear
|
||||
placeholder="搜索业务员姓名"
|
||||
class="promoter-search"
|
||||
/>
|
||||
<Spin :spinning="loading">
|
||||
<div v-if="filteredOptions.length" class="promoter-list">
|
||||
<button
|
||||
v-for="item in filteredOptions"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="promoter-item"
|
||||
:class="{ active: item.code === mValue }"
|
||||
@click="selectOption(item)"
|
||||
>
|
||||
<Avatar :src="item.avatar" :size="32">
|
||||
{{ (item.nick_name || '?').charAt(0) }}
|
||||
</Avatar>
|
||||
<div class="promoter-meta">
|
||||
<div class="promoter-name">{{ item.nick_name || '-' }}</div>
|
||||
<div class="promoter-sub">{{ item.code }} · {{ item.role_name }}</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<Empty v-else description="无匹配业务员" class="promoter-empty" />
|
||||
</Spin>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
ref="triggerRef"
|
||||
class="promoter-trigger"
|
||||
:class="{ disabled: disabled, placeholder: !displayText }"
|
||||
>
|
||||
<Input
|
||||
:value="displayText"
|
||||
readonly
|
||||
:disabled="disabled"
|
||||
placeholder="请选择业务员"
|
||||
class="promoter-trigger-input"
|
||||
>
|
||||
<template v-if="displayText && !disabled" #suffix>
|
||||
<span class="clear-btn" @click="clearSelection">×</span>
|
||||
</template>
|
||||
</Input>
|
||||
</div>
|
||||
</Popover>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.promoter-trigger {
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.promoter-trigger.disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.promoter-trigger-input {
|
||||
pointer-events: none;
|
||||
}
|
||||
.promoter-trigger:not(.disabled) :deep(.ant-input) {
|
||||
cursor: pointer;
|
||||
}
|
||||
.clear-btn {
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
color: #86909c;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.promoter-panel {
|
||||
width: 360px;
|
||||
max-width: 80vw;
|
||||
}
|
||||
.promoter-search {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.promoter-list {
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.promoter-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.promoter-item:hover,
|
||||
.promoter-item.active {
|
||||
background: #f2f3f5;
|
||||
}
|
||||
.promoter-meta {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.promoter-name {
|
||||
font-size: 14px;
|
||||
color: #1d2129;
|
||||
}
|
||||
.promoter-sub {
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
}
|
||||
.promoter-empty {
|
||||
margin: 12px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.promoter-picker-popover .ant-popover-inner {
|
||||
padding: 12px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user