feat: new select agent
This commit is contained in:
parent
56e6eaf874
commit
7fde4eb2ef
2 changed files with 131 additions and 53 deletions
|
|
@ -1,13 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import useUserStore from 'stores/user';
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import SelectInput from 'src/components/shared/SelectInput.vue';
|
||||
import { QSelect } from 'quasar';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { locale } = useI18n({ useScope: 'global' });
|
||||
import SelectAgent from 'src/components/shared/select/SelectAgent.vue';
|
||||
|
||||
defineProps<{
|
||||
readonly?: boolean;
|
||||
|
|
@ -20,41 +12,6 @@ const officeTel = defineModel<string>('officeTel');
|
|||
const agent = defineModel<string>('agent');
|
||||
|
||||
const agentUserId = defineModel<string>('agentUserId');
|
||||
|
||||
const agentOptions = ref<{ id: string; label: string; labelEN: string }[]>([]);
|
||||
|
||||
async function fetchAgentOptions(query: string) {
|
||||
const res = await userStore.fetchList({
|
||||
includeBranch: true,
|
||||
query: query,
|
||||
pageSize: 99999,
|
||||
userType: 'DELEGATE',
|
||||
status: 'ACTIVE',
|
||||
});
|
||||
|
||||
if (res) {
|
||||
agentOptions.value = res.result.map((v) => ({
|
||||
id: v.id,
|
||||
label: v.firstName + ' ' + v.lastName,
|
||||
labelEN: v.firstNameEN + ' ' + v.lastNameEN,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
async function filter(val: string, update: (...args: unknown[]) => void) {
|
||||
update(
|
||||
async () => {
|
||||
await fetchAgentOptions(val);
|
||||
},
|
||||
|
||||
(ref: QSelect) => {
|
||||
if (val !== '' && ref.options && ref.options?.length > 0) {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -153,18 +110,12 @@ async function filter(val: string, update: (...args: unknown[]) => void) {
|
|||
</template>
|
||||
</q-input>
|
||||
|
||||
<SelectInput
|
||||
@click="fetchAgentOptions"
|
||||
<SelectAgent
|
||||
:label="$t('customer.form.agent')"
|
||||
v-model:value="agentUserId"
|
||||
:readonly
|
||||
incremental
|
||||
v-model="agentUserId"
|
||||
id="quotation-branch"
|
||||
class="col-md-6 col-12"
|
||||
:option="agentOptions"
|
||||
:label="$t('customer.form.agent')"
|
||||
option-value="id"
|
||||
:option-label="locale === 'eng' ? 'labelEN' : 'label'"
|
||||
@filter="(val: string, update) => filter(val, update)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue