refactor: submit quotation
This commit is contained in:
parent
eb944bfafa
commit
a9d1425f8d
1 changed files with 46 additions and 2 deletions
|
|
@ -77,7 +77,10 @@ const ocrStore = useOcrStore();
|
|||
const { locale } = useI18n();
|
||||
const $q = useQuasar();
|
||||
|
||||
const { currentFormData: quotationFormData } = storeToRefs(quotationForm);
|
||||
const {
|
||||
currentFormData: quotationFormData,
|
||||
currentFormState: quotationFormState,
|
||||
} = storeToRefs(quotationForm);
|
||||
|
||||
const refSelectZoneEmployee = ref<InstanceType<typeof SelectZone>>();
|
||||
const selectedBranchIssuer = ref('');
|
||||
|
|
@ -157,6 +160,35 @@ const productServiceList = ref<
|
|||
Required<QuotationPayload['productServiceList'][number]>[]
|
||||
>([]);
|
||||
|
||||
function convertDataToFormSubmit() {
|
||||
quotationFormData.value.productServiceList = JSON.parse(
|
||||
JSON.stringify(
|
||||
productServiceList.value.map((v, i) => ({
|
||||
workerIndex: [0, 1],
|
||||
discount: 1,
|
||||
amount: 1,
|
||||
product: v.product,
|
||||
work: v.work,
|
||||
service: v.service,
|
||||
})),
|
||||
),
|
||||
);
|
||||
|
||||
quotationFormData.value.worker = JSON.parse(
|
||||
JSON.stringify(
|
||||
selectedWorker.value.map((v, i) => {
|
||||
if (v.id === undefined) {
|
||||
return v;
|
||||
} else {
|
||||
return v.id;
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
quotationForm.submitQuotation();
|
||||
}
|
||||
|
||||
async function getAllProduct(
|
||||
groupId: string,
|
||||
opts?: { force?: false; page?: number; pageSize?: number },
|
||||
|
|
@ -311,6 +343,11 @@ onMounted(async () => {
|
|||
quotationFormData.value.customerBranchId =
|
||||
urlParams.get('customerBranchId') || '';
|
||||
|
||||
quotationFormState.value.mode = urlParams.get('statusDialog') as
|
||||
| 'info'
|
||||
| 'edit'
|
||||
| 'create';
|
||||
|
||||
// fetch option
|
||||
const resultOption = await fetch('/option/option.json');
|
||||
const rawOption = await resultOption.json();
|
||||
|
|
@ -587,7 +624,14 @@ watch(
|
|||
<q-icon name="mdi-play-box-outline" size="xs" class="q-mr-xs" />
|
||||
{{ $t('general.view', { msg: $t('general.example') }) }}
|
||||
</q-btn>
|
||||
<SaveButton solid />
|
||||
<SaveButton
|
||||
@click="
|
||||
() => {
|
||||
convertDataToFormSubmit();
|
||||
}
|
||||
"
|
||||
solid
|
||||
/>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue