1
0
forked from test/crm

fix: render correct currency format

(cherry picked from commit 5420fcfe291a4059729aa1736aca21c6c2f1e00e)
This commit is contained in:
Shariq Ansari 2025-05-12 17:45:05 +05:30 committed by Mergify
parent d70a0e1979
commit 5d4e971398
2 changed files with 41 additions and 49 deletions

View File

@ -95,7 +95,13 @@
<FormControl
v-if="
field.read_only &&
!['Float', 'Currency', 'Check'].includes(field.fieldtype)
![
'Int',
'Float',
'Currency',
'Percent',
'Check',
].includes(field.fieldtype)
"
type="text"
:placeholder="field.placeholder"
@ -186,13 +192,22 @@
@change="fieldChange($event.target.value, field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Float'"
class="[&_input]:text-right"
type="text"
v-else-if="field.fieldtype === 'Select'"
class="text-sm text-ink-gray-8"
type="select"
variant="outline"
:value="getFormattedFloat(field.fieldname, row)"
v-model="row[field.fieldname]"
:options="field.options"
@change="(e) => fieldChange(e.target.value, field, row)"
/>
<FormControl
v-else-if="['Int'].includes(field.fieldtype)"
class="[&_input]:text-right"
type="number"
variant="outline"
:value="row[field.fieldname]"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
@change="fieldChange($event.target.value, field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Percent'"
@ -203,6 +218,15 @@
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Float'"
class="[&_input]:text-right"
type="text"
variant="outline"
:value="getFormattedFloat(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Currency'"
class="[&_input]:text-right"
@ -214,46 +238,6 @@
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Select'"
class="text-sm text-ink-gray-8"
type="select"
variant="outline"
v-model="row[field.fieldname]"
:options="field.options"
@change="(e) => fieldChange(e.target.value, field, row)"
/>
<FormControl
v-else-if="['Int'].includes(field.fieldtype)"
type="number"
variant="outline"
:value="row[field.fieldname]"
@change="fieldChange($event.target.value, field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Percent'"
type="text"
variant="outline"
:value="getFormattedPercent(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Float'"
type="text"
variant="outline"
:value="getFormattedFloat(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Currency'"
type="text"
variant="outline"
:value="getFormattedCurrency(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else
class="text-sm text-ink-gray-8"
@ -342,7 +326,7 @@ import {
dayjs,
} from 'frappe-ui'
import Draggable from 'vuedraggable'
import { ref, reactive, computed, inject } from 'vue'
import { ref, reactive, computed, inject, provide } from 'vue'
const props = defineProps({
label: {
@ -380,6 +364,9 @@ const { getUser } = usersStore()
const rows = defineModel()
const parentDoc = defineModel('parent')
provide('parentDoc', parentDoc)
const showRowList = ref(new Array(rows.value?.length || []).fill(false))
const selectedRows = reactive(new Set())

View File

@ -14,7 +14,9 @@
<FormControl
v-if="
field.read_only &&
!['Float', 'Currency', 'Check', 'Percent'].includes(field.fieldtype)
!['Int', 'Float', 'Currency', 'Percent', 'Check'].includes(
field.fieldtype,
)
"
type="text"
:placeholder="getPlaceholder(field)"
@ -164,6 +166,7 @@
type="number"
:placeholder="getPlaceholder(field)"
:value="data[field.fieldname]"
:disabled="Boolean(field.read_only)"
:description="field.description"
@change="fieldChange($event.target.value, field)"
/>
@ -188,7 +191,7 @@
<FormControl
v-else-if="field.fieldtype === 'Currency'"
type="text"
:value="getFormattedCurrency(field.fieldname, data)"
:value="getFormattedCurrency(field.fieldname, data, parentDoc)"
:placeholder="getPlaceholder(field)"
:disabled="Boolean(field.read_only)"
:description="field.description"
@ -235,6 +238,7 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
const { getUser } = usersStore()
let triggerOnChange
let parentDoc
if (!isGridRow) {
const {
@ -249,6 +253,7 @@ if (!isGridRow) {
provide('triggerOnRowRemove', triggerOnRowRemove)
} else {
triggerOnChange = inject('triggerOnChange')
parentDoc = inject('parentDoc')
}
const field = computed(() => {