1
0
forked from test/crm

fix: set default status in newlead/deal dialog

This commit is contained in:
Shariq Ansari 2023-12-13 21:00:30 +05:30
parent 71bc3d9fb2
commit dd93342601
2 changed files with 160 additions and 140 deletions

View File

@ -8,7 +8,7 @@
v-if="field.type === 'select'"
type="select"
:options="field.options"
v-model="field.value"
v-model="newDeal[field.name]"
>
<template v-if="field.prefix" #prefix>
<IndicatorIcon :class="field.prefix" />
@ -71,7 +71,7 @@ import OrganizationModal from '@/components/Modals/OrganizationModal.vue'
import { usersStore } from '@/stores/users'
import { statusesStore } from '@/stores/statuses'
import { FormControl, Tooltip } from 'frappe-ui'
import { ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
const { getUser } = usersStore()
const { getDealStatus, statusOptions } = statusesStore()
@ -86,7 +86,8 @@ const props = defineProps({
const showOrganizationModal = ref(false)
const _organization = ref({})
const allFields = [
const allFields = computed(() => {
return [
{
section: 'Deal Details',
fields: [
@ -140,8 +141,10 @@ const allFields = [
label: 'Status',
name: 'status',
type: 'select',
options: statusOptions('deal'),
value: props.newDeal.status || getDealStatus(props.newDeal.status).name,
options: statusOptions(
'deal',
(field, value) => (props.newDeal[field] = value)
),
prefix: getDealStatus(props.newDeal.status).iconColorClass,
},
{
@ -154,5 +157,12 @@ const allFields = [
},
],
},
]
]
})
onMounted(() => {
if (!props.newDeal.status) {
props.newDeal.status = getDealStatus(props.newDeal.status).name
}
})
</script>

View File

@ -8,7 +8,7 @@
v-if="field.type === 'select'"
type="select"
:options="field.options"
v-model="field.value"
v-model="newLead[field.name]"
>
<template v-if="field.prefix" #prefix>
<IndicatorIcon :class="field.prefix" />
@ -71,7 +71,7 @@ import Link from '@/components/Controls/Link.vue'
import { usersStore } from '@/stores/users'
import { statusesStore } from '@/stores/statuses'
import { FormControl, Tooltip } from 'frappe-ui'
import { ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
const { getUser } = usersStore()
const { getLeadStatus, statusOptions } = statusesStore()
@ -86,7 +86,8 @@ const props = defineProps({
const showOrganizationModal = ref(false)
const _organization = ref({})
const allFields = [
const allFields = computed(() => {
return [
{
section: 'Lead Details',
fields: [
@ -140,8 +141,10 @@ const allFields = [
label: 'Status',
name: 'status',
type: 'select',
options: statusOptions('lead'),
value: props.newLead.status || getLeadStatus(props.newLead.status).name,
options: statusOptions(
'lead',
(field, value) => (props.newLead[field] = value)
),
prefix: getLeadStatus(props.newLead.status).iconColorClass,
},
{
@ -154,5 +157,12 @@ const allFields = [
},
],
},
]
]
})
onMounted(() => {
if (!props.newLead.status) {
props.newLead.status = getLeadStatus(props.newLead.status).name
}
})
</script>