refactor: handle can edit employee
This commit is contained in:
parent
fcb122a47e
commit
f54ca1bd68
3 changed files with 78 additions and 50 deletions
|
|
@ -3,6 +3,7 @@ import { ref, onMounted, watch } from 'vue';
|
|||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { QTableProps } from 'quasar';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { baseUrl } from 'src/stores/utils';
|
||||
import useCustomerStore from 'stores/customer';
|
||||
|
|
@ -42,6 +43,7 @@ import { formatAddress } from 'src/utils/address';
|
|||
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
|
||||
import { nextTick } from 'vue';
|
||||
|
||||
const route = useRoute();
|
||||
const flowStore = useFlowStore();
|
||||
const customerStore = useCustomerStore();
|
||||
const employeeFormStore = useEmployeeForm();
|
||||
|
|
@ -74,6 +76,7 @@ const maxPageBranch = ref<number>(1);
|
|||
const pageSizeBranch = ref<number>(30);
|
||||
|
||||
const statusEmployeeCreate = defineModel<boolean>('statusEmployeeCreate');
|
||||
const statusEmployeeEdit = defineModel<boolean>('statusEmployeeEdit');
|
||||
|
||||
const prop = withDefaults(
|
||||
defineProps<{
|
||||
|
|
@ -103,11 +106,8 @@ defineEmits<{
|
|||
}>();
|
||||
|
||||
onMounted(async () => {
|
||||
const url = window.location.href;
|
||||
const parts = url.split('/');
|
||||
|
||||
customerBranchFormState.value.currentCustomerId = parts[4];
|
||||
|
||||
customerBranchFormState.value.currentCustomerId = route.params
|
||||
.customerId as string;
|
||||
await fetchList();
|
||||
|
||||
branch.value?.forEach((v) => {
|
||||
|
|
@ -244,9 +244,9 @@ watch([customerId, inputSearch, currentStatus, pageSizeBranch], async () => {
|
|||
await fetchList();
|
||||
});
|
||||
watch(
|
||||
() => statusEmployeeCreate.value,
|
||||
() => [statusEmployeeCreate.value, statusEmployeeEdit.value],
|
||||
async () => {
|
||||
if (statusEmployeeCreate.value) {
|
||||
if (!statusEmployeeCreate.value || !statusEmployeeEdit.value) {
|
||||
await fetchEmployee({
|
||||
branchId: currentBranchEmployee.value,
|
||||
pageSize: 999,
|
||||
|
|
@ -255,7 +255,7 @@ watch(
|
|||
const br = branch.value?.find(
|
||||
(v) => v.id === currentBranchEmployee.value,
|
||||
);
|
||||
if (br) br._count.employee += 1;
|
||||
if (br) br._count.employee = listEmployee.value.length;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
@ -407,6 +407,7 @@ watch(
|
|||
<NoData v-if="totalBranch === 0" :not-found="!!inputSearch" />
|
||||
|
||||
<div style="width: 100%" v-else>
|
||||
{{ console.log(branch) }}
|
||||
<q-table
|
||||
v-if="branch"
|
||||
flat
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue