Skip to content

Commit

Permalink
fix: correct import format number
Browse files Browse the repository at this point in the history
  • Loading branch information
newarifrh committed Jul 8, 2024
1 parent ab7d7c5 commit 9c45a77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
21 changes: 7 additions & 14 deletions src/components/contract/FormContractActivityItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
trigger: 'change',
}">
<el-select v-model="props.activity.activityId" placeholder="Pilih Nama Kegiatan" clearable filterable>
<el-option v-for="activity in activities" :key="activity._id" :label="activity.name" :value="activity._id" />
<el-option v-for="activity in props.activities" :key="activity._id" :label="activity.name"
:value="activity._id" />
</el-select>
</el-form-item>
<el-form-item required label="Tanggal Mulai" :prop="getProp('startDate')" :rules="{
Expand All @@ -32,15 +33,15 @@
message: 'Volume perlu terisi',
trigger: 'blur',
}">
<el-input :formatter="formatNumber" :parser="formatParserNumber" v-model="props.activity.volume"
placeholder="Masukkan Volume" />
<el-input v-model="props.activity.volume" placeholder="Masukkan Volume" :formatter="formatNumber"
:parser="formatParserNumber" />
</el-form-item>
<el-form-item required label="Rate" :prop="getProp('rate')" :rules="{
required: true,
message: 'Rate perlu terisi',
trigger: 'blur',
}">
<el-input :formatter="formatNumber" :parser="formatParserNumber" v-model="props.activity.rate"
<el-input v-model="props.activity.rate" :formatter="formatNumber" :parser="formatParserNumber"
placeholder="Masukkan Rate" />
</el-form-item>
<template #footer>
Expand All @@ -50,24 +51,16 @@
</template>

<script lang="ts" setup>
import { ref, onMounted } from "vue";
import { getActivities } from "@/api/activityApi";
import { formatNumber } from "chart.js/helpers";
import { formatParserNumber } from "@/utils/currency";
import { formatParserNumber, formatNumber } from "@/utils/currency";
const props: any = defineProps({
activity: Object,
index: Number,
activities: Object
});
const activities = ref<any[]>([]);
const getProp = (key: string) => {
return `activities[${props.index}].${key}`;
};
onMounted(async () => {
const data = await getActivities();
activities.value = data;
});
</script>
6 changes: 4 additions & 2 deletions src/components/contract/FormContractByPartner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</div>
</template>
<div style="display: flex; flex-wrap: wrap; gap: 20px">
<FormContractActivityItem v-for="(activity, index) in form.activities" :key="index" :index="index"
:activity="activity" @remove="removeActivity(index)" />
<FormContractActivityItem :activities="activities" v-for="(activity, index) in form.activities" :key="index"
:index="index" :activity="activity" @remove="removeActivity(index)" />
</div>

<template #footer><el-button @click="addActivity">Tambah Kegiatan</el-button>
Expand Down Expand Up @@ -87,6 +87,7 @@ const initialState = {
};
const partners = ref<any[]>([]);
const activities = ref<any[]>([]);
const loading = ref(false);
const form = reactive({ ...initialState });
Expand Down Expand Up @@ -170,5 +171,6 @@ const showNotification = async (title: string, message: string, type: string) =>
onMounted(async () => {
partners.value = await getPartners();
activities.value = await getPartners();
});
</script>

0 comments on commit 9c45a77

Please sign in to comment.