feat: add sort numbers
This commit is contained in:
parent
8520e2d8f5
commit
ff0bcf95c6
2 changed files with 46 additions and 11 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { CustomerBranchCreate } from 'stores/customer/types';
|
import { CustomerBranchCreate } from 'stores/customer/types';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
edit?: boolean;
|
edit?: boolean;
|
||||||
prefixId: string;
|
prefixId: string;
|
||||||
|
|
@ -12,15 +13,17 @@ const customerBranch = defineModel<CustomerBranchCreate[]>('customerBranch', {
|
||||||
default: [],
|
default: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const statBranchNo = defineModel<number>('statBranchNo', {
|
||||||
|
default: 0,
|
||||||
|
});
|
||||||
|
|
||||||
const tab = defineModel<number>('tabIndex', { required: true });
|
const tab = defineModel<number>('tabIndex', { required: true });
|
||||||
|
|
||||||
const index = ref<number>(0);
|
|
||||||
|
|
||||||
function addData() {
|
function addData() {
|
||||||
index.value++;
|
const currentNo = (customerBranch.value.at(-1)?.branchNo || 0) + 1;
|
||||||
customerBranch.value.push({
|
customerBranch.value.push({
|
||||||
code: '',
|
code: '',
|
||||||
branchNo: undefined,
|
branchNo: currentNo,
|
||||||
address: '',
|
address: '',
|
||||||
addressEN: '',
|
addressEN: '',
|
||||||
provinceId: '',
|
provinceId: '',
|
||||||
|
|
@ -65,7 +68,18 @@ function close(index: number) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customerBranch.value.splice(index, 1);
|
customerBranch.value.splice(index, 1);
|
||||||
|
|
||||||
|
customerBranch.value.forEach((v, i) => {
|
||||||
|
if (!!v.branchNo && v.branchNo >= index + 1) {
|
||||||
|
v.branchNo = v.branchNo - 1;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
customerBranch.value[0].branchNo =
|
||||||
|
statBranchNo.value !== 0 ? statBranchNo.value : 1;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="row no-wrap full-width">
|
<div class="row no-wrap full-width">
|
||||||
|
|
@ -98,7 +112,7 @@ function close(index: number) {
|
||||||
v-for="(v, index) in customerBranch"
|
v-for="(v, index) in customerBranch"
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="index"
|
:name="index"
|
||||||
:label="`${$t('customerBranchFormTab')} `"
|
:label="`${customerBranch[index].name !== '' ? customerBranch[index].name : $t('customerBranchFormTab')} `"
|
||||||
:disable="tab !== index && edit"
|
:disable="tab !== index && edit"
|
||||||
@click="tab = index"
|
@click="tab = index"
|
||||||
no-caps
|
no-caps
|
||||||
|
|
|
||||||
|
|
@ -474,6 +474,7 @@ const statsCustomerType = ref<CustomerStats>({
|
||||||
const currentCustomerId = ref<string>('');
|
const currentCustomerId = ref<string>('');
|
||||||
const dialogInputCustomerBranchForm = ref<boolean>(false);
|
const dialogInputCustomerBranchForm = ref<boolean>(false);
|
||||||
const currentCustomer = ref<Customer>();
|
const currentCustomer = ref<Customer>();
|
||||||
|
const statBranchNo = ref<number>(0);
|
||||||
|
|
||||||
const currentBranch = ref<{ name: string; code: string }>({
|
const currentBranch = ref<{ name: string; code: string }>({
|
||||||
name: '',
|
name: '',
|
||||||
|
|
@ -927,6 +928,7 @@ async function onSubmitCustomerBranch() {
|
||||||
currentCustomerName.value = result.customerName;
|
currentCustomerName.value = result.customerName;
|
||||||
currentCustomerUrlImage.value = result.imageUrl;
|
currentCustomerUrlImage.value = result.imageUrl;
|
||||||
branch.value = result.branch;
|
branch.value = result.branch;
|
||||||
|
statBranchNo.value = result.branch.length;
|
||||||
}
|
}
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
|
|
@ -1163,7 +1165,11 @@ const prevCustomer = ref<CustomerCreate>({
|
||||||
registeredBranchId: '',
|
registeredBranchId: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
async function assignFormData(customerId: string, branch?: CustomerBranch) {
|
async function assignFormData(
|
||||||
|
customerId: string,
|
||||||
|
branch?: CustomerBranch,
|
||||||
|
tabNo: number = 0,
|
||||||
|
) {
|
||||||
let data;
|
let data;
|
||||||
const res = await fetchListById(customerId);
|
const res = await fetchListById(customerId);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
@ -1172,6 +1178,8 @@ async function assignFormData(customerId: string, branch?: CustomerBranch) {
|
||||||
|
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
|
indexTab.value = tabNo;
|
||||||
|
|
||||||
prevCustomer.value = {
|
prevCustomer.value = {
|
||||||
registeredBranchId: data.registeredBranchId,
|
registeredBranchId: data.registeredBranchId,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
|
|
@ -1185,8 +1193,6 @@ async function assignFormData(customerId: string, branch?: CustomerBranch) {
|
||||||
};
|
};
|
||||||
|
|
||||||
data.branch.forEach((v) => {
|
data.branch.forEach((v) => {
|
||||||
console.log(v.taxNo);
|
|
||||||
|
|
||||||
prevCustomer.value.customerBranch?.push({
|
prevCustomer.value.customerBranch?.push({
|
||||||
code: v.code,
|
code: v.code,
|
||||||
branchNo: v.branchNo,
|
branchNo: v.branchNo,
|
||||||
|
|
@ -1666,6 +1672,9 @@ watch(isMainPage, () => {
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
indexTab = 0;
|
indexTab = 0;
|
||||||
|
|
||||||
|
console.log(statBranchNo);
|
||||||
|
|
||||||
dialogInputCustomerBranchForm = true;
|
dialogInputCustomerBranchForm = true;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
@ -2047,6 +2056,8 @@ watch(isMainPage, () => {
|
||||||
const { branch, ...payload } = props.row;
|
const { branch, ...payload } = props.row;
|
||||||
currentCustomer = payload;
|
currentCustomer = payload;
|
||||||
|
|
||||||
|
statBranchNo =
|
||||||
|
branch[branch.length - 1].branchNo + 1;
|
||||||
isMainPage = false;
|
isMainPage = false;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
@ -2128,6 +2139,7 @@ watch(isMainPage, () => {
|
||||||
|
|
||||||
currentCustomerId = props.row.id;
|
currentCustomerId = props.row.id;
|
||||||
customerType = props.row.customerType;
|
customerType = props.row.customerType;
|
||||||
|
|
||||||
assignFormData(props.row.id);
|
assignFormData(props.row.id);
|
||||||
openDialogInputForm('INFO', props.row.id);
|
openDialogInputForm('INFO', props.row.id);
|
||||||
}
|
}
|
||||||
|
|
@ -2339,6 +2351,8 @@ watch(isMainPage, () => {
|
||||||
|
|
||||||
const { branch, ...payload } = props.row;
|
const { branch, ...payload } = props.row;
|
||||||
currentCustomer = payload;
|
currentCustomer = payload;
|
||||||
|
statBranchNo =
|
||||||
|
branch[branch.length - 1].branchNo + 1;
|
||||||
isMainPage = false;
|
isMainPage = false;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
@ -2901,6 +2915,8 @@ watch(isMainPage, () => {
|
||||||
@back="
|
@back="
|
||||||
() => {
|
() => {
|
||||||
isMainPage = true;
|
isMainPage = true;
|
||||||
|
statBranchNo = 1;
|
||||||
|
indexTab = 0;
|
||||||
currentCustomerUrlImage = null;
|
currentCustomerUrlImage = null;
|
||||||
clearForm();
|
clearForm();
|
||||||
}
|
}
|
||||||
|
|
@ -2908,7 +2924,6 @@ watch(isMainPage, () => {
|
||||||
@viewDetail="
|
@viewDetail="
|
||||||
async (v, i) => {
|
async (v, i) => {
|
||||||
currentBranchId = v.id;
|
currentBranchId = v.id;
|
||||||
indexTab = i;
|
|
||||||
|
|
||||||
statusToggle = v.status === 'INACTIVE' ? false : true;
|
statusToggle = v.status === 'INACTIVE' ? false : true;
|
||||||
|
|
||||||
|
|
@ -2917,7 +2932,7 @@ watch(isMainPage, () => {
|
||||||
code: v.code,
|
code: v.code,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (currentCustomer) assignFormData(currentCustomer.id, v);
|
if (currentCustomer) assignFormData(currentCustomer.id, v, i);
|
||||||
|
|
||||||
await fetchListOfOptionBranch();
|
await fetchListOfOptionBranch();
|
||||||
|
|
||||||
|
|
@ -3010,6 +3025,8 @@ watch(isMainPage, () => {
|
||||||
<div class="col-12 row bordered q-pt-none rounded">
|
<div class="col-12 row bordered q-pt-none rounded">
|
||||||
<TabComponent
|
<TabComponent
|
||||||
prefix-id="form-dialog"
|
prefix-id="form-dialog"
|
||||||
|
v-model:branch-no="statBranchNo"
|
||||||
|
v-model:stat-branch-no="statBranchNo"
|
||||||
v-model:customer-branch="formData.customerBranch"
|
v-model:customer-branch="formData.customerBranch"
|
||||||
v-model:tab-index="indexTab"
|
v-model:tab-index="indexTab"
|
||||||
>
|
>
|
||||||
|
|
@ -3300,6 +3317,7 @@ watch(isMainPage, () => {
|
||||||
<div class="col-12 row bordered q-pt-none rounded">
|
<div class="col-12 row bordered q-pt-none rounded">
|
||||||
<TabComponent
|
<TabComponent
|
||||||
prefix-id="form-dialog-branch"
|
prefix-id="form-dialog-branch"
|
||||||
|
v-model:stat-branch-no="statBranchNo"
|
||||||
v-model:customer-branch="formData.customerBranch"
|
v-model:customer-branch="formData.customerBranch"
|
||||||
v-model:tab-index="indexTab"
|
v-model:tab-index="indexTab"
|
||||||
>
|
>
|
||||||
|
|
@ -3437,6 +3455,7 @@ watch(isMainPage, () => {
|
||||||
<div class="col-12 row bordered q-pt-none rounded">
|
<div class="col-12 row bordered q-pt-none rounded">
|
||||||
<TabComponent
|
<TabComponent
|
||||||
prefix-id="form-dialog"
|
prefix-id="form-dialog"
|
||||||
|
:stat-branch-no="statBranchNo"
|
||||||
v-model:customer-branch="formData.customerBranch"
|
v-model:customer-branch="formData.customerBranch"
|
||||||
v-model:tab-index="indexTab"
|
v-model:tab-index="indexTab"
|
||||||
>
|
>
|
||||||
|
|
@ -3633,6 +3652,7 @@ watch(isMainPage, () => {
|
||||||
<div class="col-12 row bordered q-pt-none rounded">
|
<div class="col-12 row bordered q-pt-none rounded">
|
||||||
<TabComponent
|
<TabComponent
|
||||||
prefix-id="drawer-info-customer"
|
prefix-id="drawer-info-customer"
|
||||||
|
:stat-branch-no="statBranchNo"
|
||||||
:readonly="!infoDrawerEdit"
|
:readonly="!infoDrawerEdit"
|
||||||
v-model:customer-branch="formData.customerBranch"
|
v-model:customer-branch="formData.customerBranch"
|
||||||
v-model:tab-index="indexTab"
|
v-model:tab-index="indexTab"
|
||||||
|
|
@ -3862,6 +3882,7 @@ watch(isMainPage, () => {
|
||||||
|
|
||||||
<div class="col-12 row bordered q-pt-none rounded">
|
<div class="col-12 row bordered q-pt-none rounded">
|
||||||
<TabComponent
|
<TabComponent
|
||||||
|
:stat-branch-no="statBranchNo"
|
||||||
prefix-id="drawer-info-customer-branch"
|
prefix-id="drawer-info-customer-branch"
|
||||||
:edit="true"
|
:edit="true"
|
||||||
:readonly="true"
|
:readonly="true"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue