refactor: แก้ กดแก้ไขไม่ได้
This commit is contained in:
parent
ea4234a313
commit
a0a14ca009
1 changed files with 25 additions and 15 deletions
|
|
@ -838,15 +838,15 @@ async function onDelete(id: string) {
|
|||
}
|
||||
|
||||
async function submitBranch() {
|
||||
if (formData.value.customerBranch?.[0]) {
|
||||
delete formData.value.customerBranch[0]['id'];
|
||||
if (formData.value.customerBranch?.[indexTab.value]) {
|
||||
delete formData.value.customerBranch[indexTab.value]['id'];
|
||||
|
||||
formData.value.customerBranch[0].status = statusToggle.value
|
||||
formData.value.customerBranch[indexTab.value].status = statusToggle.value
|
||||
? 'ACTIVE'
|
||||
: 'INACTIVE';
|
||||
|
||||
await editBranchById(currentBranchId.value, {
|
||||
...formData.value.customerBranch[0],
|
||||
...formData.value.customerBranch[indexTab.value],
|
||||
customerId: currentCustomerId.value,
|
||||
});
|
||||
|
||||
|
|
@ -903,7 +903,7 @@ const prevCustomer = ref<CustomerCreate>({
|
|||
registeredBranchId: '',
|
||||
});
|
||||
|
||||
async function assignFormData(customerId: string) {
|
||||
async function assignFormData(customerId: string, branch?: CustomerBranch) {
|
||||
let data;
|
||||
const res = await fetchListById(customerId);
|
||||
if (res) {
|
||||
|
|
@ -965,8 +965,6 @@ function cloneData() {
|
|||
...prevCustomer.value,
|
||||
customerBranch: structuredClone(toRaw(prevCustomer.value.customerBranch)),
|
||||
};
|
||||
|
||||
console.log(formData.value);
|
||||
}
|
||||
|
||||
async function assignFormDataEmployee(id: string) {
|
||||
|
|
@ -1819,19 +1817,25 @@ watch([inputSearch, currentStatus], async () => {
|
|||
clearForm();
|
||||
}
|
||||
"
|
||||
@dialog="dialogInputCustomerBranchForm = true"
|
||||
@dialog="
|
||||
() => {
|
||||
indexTab = 0;
|
||||
dialogInputCustomerBranchForm = true;
|
||||
}
|
||||
"
|
||||
@viewDetail="
|
||||
async (v) => {
|
||||
currentBranchId = v[0].id;
|
||||
async (v, i) => {
|
||||
currentBranchId = v.id;
|
||||
indexTab = i;
|
||||
|
||||
statusToggle = v[0].status === 'INACTIVE' ? false : true;
|
||||
statusToggle = v.status === 'INACTIVE' ? false : true;
|
||||
|
||||
currentBranch = {
|
||||
name: v[0].name,
|
||||
code: v[0].code,
|
||||
name: v.name,
|
||||
code: v.code,
|
||||
};
|
||||
|
||||
if (currentCustomer) assignFormData(currentCustomer.id);
|
||||
if (currentCustomer) assignFormData(currentCustomer.id, v);
|
||||
|
||||
await fetchListOfOptionBranch();
|
||||
|
||||
|
|
@ -2452,7 +2456,11 @@ watch([inputSearch, currentStatus], async () => {
|
|||
:isEdit="infoDrawerEdit"
|
||||
:close="() => onClose()"
|
||||
:editData="() => (infoDrawerEdit = true)"
|
||||
:submit="() => onSubmitEdit(currentCustomerId)"
|
||||
:submit="
|
||||
() => () => {
|
||||
onSubmitEdit(currentCustomerId);
|
||||
}
|
||||
"
|
||||
:deleteData="
|
||||
() => {
|
||||
deleteCustomerById(currentCustomerId);
|
||||
|
|
@ -2667,6 +2675,7 @@ watch([inputSearch, currentStatus], async () => {
|
|||
:deleteData="() => deleteBranchId(currentBranchId)"
|
||||
:submit="
|
||||
() => {
|
||||
console.log(formData.customerBranch?.[indexTab]);
|
||||
submitBranch();
|
||||
}
|
||||
"
|
||||
|
|
@ -2736,6 +2745,7 @@ watch([inputSearch, currentStatus], async () => {
|
|||
|
||||
<div class="col-12 row bordered q-pt-none rounded">
|
||||
<TabComponent
|
||||
:edit="true"
|
||||
:readonly="true"
|
||||
v-model:customer-branch="formData.customerBranch"
|
||||
v-model:tab-index="indexTab"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue