|
|
@@ -25,6 +25,22 @@
|
|
|
class="col-12"
|
|
|
/>
|
|
|
|
|
|
+ <DefaultSelect
|
|
|
+ v-model="form.financial_plan_account_id"
|
|
|
+ v-model:error="validationErrors.financial_plan_account_id"
|
|
|
+ :options="planAccountOptions"
|
|
|
+ :loading="loadingPlanAccounts"
|
|
|
+ emit-value
|
|
|
+ map-options
|
|
|
+ use-input
|
|
|
+ input-debounce="0"
|
|
|
+ :rules="[inputRules.required]"
|
|
|
+ label="Plano de Contas"
|
|
|
+ placeholder="Selecione a conta"
|
|
|
+ class="col-12"
|
|
|
+ @filter="filterPlanAccounts"
|
|
|
+ />
|
|
|
+
|
|
|
<DefaultCurrencyInput
|
|
|
v-model="form.amount"
|
|
|
v-model:error="validationErrors.amount"
|
|
|
@@ -43,11 +59,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref } from "vue";
|
|
|
+import { ref, onMounted } from "vue";
|
|
|
import { useDialogPluginComponent } from "quasar";
|
|
|
import { useInputRules } from "src/composables/useInputRules";
|
|
|
import { useSubmitHandler } from "src/composables/useSubmitHandler";
|
|
|
import { createTreasuryLaunch } from "src/api/treasury_launch";
|
|
|
+import { getFinancialPlanAccounts } from "src/api/financial_plan_account";
|
|
|
|
|
|
import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
|
@@ -78,9 +95,37 @@ const typeOptions = [
|
|
|
const form = ref({
|
|
|
transaction_type: null,
|
|
|
description: "",
|
|
|
+ financial_plan_account_id: null,
|
|
|
amount: 0,
|
|
|
});
|
|
|
|
|
|
+const allPlanAccounts = ref([]);
|
|
|
+const planAccountOptions = ref([]);
|
|
|
+const loadingPlanAccounts = ref(false);
|
|
|
+
|
|
|
+const filterPlanAccounts = (needle, update) => {
|
|
|
+ update(() => {
|
|
|
+ const term = needle.toLowerCase();
|
|
|
+ planAccountOptions.value = term
|
|
|
+ ? allPlanAccounts.value.filter((o) => o.label.toLowerCase().includes(term))
|
|
|
+ : allPlanAccounts.value;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ loadingPlanAccounts.value = true;
|
|
|
+ try {
|
|
|
+ const accounts = await getFinancialPlanAccounts();
|
|
|
+ allPlanAccounts.value = accounts.map((a) => ({
|
|
|
+ label: `${a.code} - ${a.description}`,
|
|
|
+ value: a.id,
|
|
|
+ }));
|
|
|
+ planAccountOptions.value = allPlanAccounts.value;
|
|
|
+ } finally {
|
|
|
+ loadingPlanAccounts.value = false;
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
const {
|
|
|
loading,
|
|
|
validationErrors,
|
|
|
@@ -96,6 +141,7 @@ const onOKClick = async () => {
|
|
|
account_id: account.id,
|
|
|
transaction_type: form.value.transaction_type,
|
|
|
description: form.value.description,
|
|
|
+ financial_plan_account_id: form.value.financial_plan_account_id,
|
|
|
amount: form.value.amount,
|
|
|
}),
|
|
|
);
|