refactor: delete worker & branch, cus-branch state
This commit is contained in:
parent
20349f0cf7
commit
a9650ad1b6
3 changed files with 85 additions and 31 deletions
|
|
@ -5,6 +5,8 @@ import useBranchStore from 'src/stores/branch';
|
|||
import useCustomerStore from 'src/stores/customer';
|
||||
import SelectInput from '../shared/SelectInput.vue';
|
||||
import { QSelect } from 'quasar';
|
||||
import { Branch } from 'src/stores/branch/types';
|
||||
import { CustomerBranch } from 'src/stores/customer/types';
|
||||
|
||||
const { locale } = useI18n({ useScope: 'global' });
|
||||
const branchStore = useBranchStore();
|
||||
|
|
@ -66,17 +68,20 @@ async function init(val: string, type: 'branch' | 'customer') {
|
|||
});
|
||||
if (res) {
|
||||
if (type === 'branch') {
|
||||
branchOption.value = res.result.map((v) => ({
|
||||
branchOption.value = (res.result as Branch[]).map((v: Branch) => ({
|
||||
value: v.id,
|
||||
label: v.name,
|
||||
labelEN: v.nameEN,
|
||||
}));
|
||||
} else if (type === 'customer') {
|
||||
customerOption.value = res.result.map((v) => ({
|
||||
value: v.id,
|
||||
label: v.registerName || `${v.firstName} ${v.lastName}` || '-',
|
||||
labelEN: v.registerNameEN || `${v.firstNameEN} ${v.lastNameEN}` || '-',
|
||||
}));
|
||||
customerOption.value = (res.result as CustomerBranch[]).map(
|
||||
(v: CustomerBranch) => ({
|
||||
value: v.id,
|
||||
label: v.registerName || `${v.firstName} ${v.lastName}` || '-',
|
||||
labelEN:
|
||||
v.registerNameEN || `${v.firstNameEN} ${v.lastNameEN}` || '-',
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +94,8 @@ onMounted(async () => {
|
|||
watch(
|
||||
() => branchId.value,
|
||||
async (v) => {
|
||||
if (v && props.onCreate) {
|
||||
if (v && customerBranchId.value && props.onCreate) {
|
||||
console.log('form');
|
||||
customerBranchId.value = '';
|
||||
}
|
||||
},
|
||||
|
|
@ -137,7 +143,7 @@ watch(
|
|||
:label="$t('quotation.branch')"
|
||||
:option-label="locale === 'eng' ? 'labelEN' : 'label'"
|
||||
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||
@filter="(val, update) => filter(val, update, 'branch')"
|
||||
@filter="(val: string, update) => filter(val, update, 'branch')"
|
||||
/>
|
||||
|
||||
<SelectInput
|
||||
|
|
@ -151,7 +157,7 @@ watch(
|
|||
:label="$t('quotation.customer')"
|
||||
:option-label="locale === 'eng' ? 'labelEN' : 'label'"
|
||||
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||
@filter="(val, update) => filter(val, update, 'customer')"
|
||||
@filter="(val: string, update) => filter(val, update, 'customer')"
|
||||
>
|
||||
<template #option="{ scope }">
|
||||
<q-item
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { QTableProps } from 'quasar';
|
|||
import TableComponents from 'src/components/TableComponents.vue';
|
||||
|
||||
defineEmits<{
|
||||
(e: 'delete'): void;
|
||||
(e: 'delete', index: number): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
|
|
@ -89,7 +89,7 @@ const columns = [
|
|||
:columns
|
||||
:rows
|
||||
hidePagination
|
||||
@delete="$emit('delete')"
|
||||
@delete="(i) => $emit('delete', i)"
|
||||
>
|
||||
<template v-slot:img-column="{ props }">
|
||||
<q-avatar class="q-mr-sm" size="md">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue