fix: updated lead/deal page code
This commit is contained in:
parent
199e15779b
commit
3e7dcbc800
@ -7,12 +7,12 @@
|
|||||||
<FormControl
|
<FormControl
|
||||||
type="autocomplete"
|
type="autocomplete"
|
||||||
:options="activeAgents"
|
:options="activeAgents"
|
||||||
:value="getUser(deal.data.lead_owner).full_name"
|
:value="getUser(deal.data.deal_owner).full_name"
|
||||||
@change="(option) => updateAssignedAgent(option.email)"
|
@change="(option) => updateAssignedAgent(option.email)"
|
||||||
placeholder="Deal owner"
|
placeholder="Deal owner"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<UserAvatar class="mr-2" :user="deal.data.lead_owner" size="sm" />
|
<UserAvatar class="mr-2" :user="deal.data.deal_owner" size="sm" />
|
||||||
</template>
|
</template>
|
||||||
<template #item-prefix="{ option }">
|
<template #item-prefix="{ option }">
|
||||||
<UserAvatar class="mr-2" :user="option.email" size="sm" />
|
<UserAvatar class="mr-2" :user="option.email" size="sm" />
|
||||||
@ -20,17 +20,16 @@
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
<Dropdown :options="statusDropdownOptions(deal.data, 'deal', updateDeal)">
|
<Dropdown :options="statusDropdownOptions(deal.data, 'deal', updateDeal)">
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
<Button :label="deal.data.deal_status">
|
<Button :label="deal.data.status">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<IndicatorIcon
|
<IndicatorIcon :class="dealStatuses[deal.data.status].color" />
|
||||||
:class="dealStatuses[deal.data.deal_status].color"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<template #suffix
|
<template #suffix>
|
||||||
><FeatherIcon
|
<FeatherIcon
|
||||||
:name="open ? 'chevron-up' : 'chevron-down'"
|
:name="open ? 'chevron-up' : 'chevron-down'"
|
||||||
class="h-4 text-gray-600"
|
class="h-4 text-gray-600"
|
||||||
/></template>
|
/>
|
||||||
|
</template>
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
@ -254,7 +253,8 @@
|
|||||||
:debounce="500"
|
:debounce="500"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
/>
|
/>
|
||||||
<Tooltip :text="field.tooltip"
|
<Tooltip
|
||||||
|
:text="field.tooltip"
|
||||||
class="flex h-7 cursor-pointer items-center px-2 py-1"
|
class="flex h-7 cursor-pointer items-center px-2 py-1"
|
||||||
v-else-if="field.type === 'read_only'"
|
v-else-if="field.type === 'read_only'"
|
||||||
>
|
>
|
||||||
@ -272,7 +272,11 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<ExternalLinkIcon
|
<ExternalLinkIcon
|
||||||
v-if="field.type === 'link' && field.link && deal.data[field.name]"
|
v-if="
|
||||||
|
field.type === 'link' &&
|
||||||
|
field.link &&
|
||||||
|
deal.data[field.name]
|
||||||
|
"
|
||||||
class="h-4 w-4 shrink-0 cursor-pointer text-gray-600"
|
class="h-4 w-4 shrink-0 cursor-pointer text-gray-600"
|
||||||
@click="field.link(deal.data[field.name])"
|
@click="field.link(deal.data[field.name])"
|
||||||
/>
|
/>
|
||||||
@ -335,7 +339,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const deal = createResource({
|
const deal = createResource({
|
||||||
url: 'crm.fcrm.doctype.crm_lead.api.get_lead',
|
url: 'crm.fcrm.doctype.crm_deal.api.get_deal',
|
||||||
params: { name: props.dealId },
|
params: { name: props.dealId },
|
||||||
cache: ['deal', props.dealId],
|
cache: ['deal', props.dealId],
|
||||||
auto: true,
|
auto: true,
|
||||||
@ -347,7 +351,7 @@ function updateDeal(fieldname, value) {
|
|||||||
createResource({
|
createResource({
|
||||||
url: 'frappe.client.set_value',
|
url: 'frappe.client.set_value',
|
||||||
params: {
|
params: {
|
||||||
doctype: 'CRM Lead',
|
doctype: 'CRM Deal',
|
||||||
name: props.dealId,
|
name: props.dealId,
|
||||||
fieldname,
|
fieldname,
|
||||||
value,
|
value,
|
||||||
@ -377,7 +381,7 @@ function updateDeal(fieldname, value) {
|
|||||||
const breadcrumbs = computed(() => {
|
const breadcrumbs = computed(() => {
|
||||||
let items = [{ label: 'Deals', route: { name: 'Deals' } }]
|
let items = [{ label: 'Deals', route: { name: 'Deals' } }]
|
||||||
items.push({
|
items.push({
|
||||||
label: organization.value.name,
|
label: organization.value?.name,
|
||||||
route: { name: 'Deal', params: { dealId: deal.data.name } },
|
route: { name: 'Deal', params: { dealId: deal.data.name } },
|
||||||
})
|
})
|
||||||
return items
|
return items
|
||||||
@ -435,12 +439,16 @@ const detailSections = computed(() => {
|
|||||||
type: 'read_only',
|
type: 'read_only',
|
||||||
name: 'website',
|
name: 'website',
|
||||||
value: organization.value?.website,
|
value: organization.value?.website,
|
||||||
tooltip: 'It is a read only field, value is fetched from organization',
|
tooltip:
|
||||||
|
'It is a read only field, value is fetched from organization',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Amount',
|
label: 'Amount',
|
||||||
type: 'number',
|
type: 'read_only',
|
||||||
name: 'annual_revenue',
|
name: 'annual_revenue',
|
||||||
|
value: organization.value?.annual_revenue,
|
||||||
|
tooltip:
|
||||||
|
'It is a read only field, value is fetched from organization',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Close date',
|
label: 'Close date',
|
||||||
@ -514,8 +522,8 @@ const organization = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function updateAssignedAgent(email) {
|
function updateAssignedAgent(email) {
|
||||||
deal.data.lead_owner = email
|
deal.data.deal_owner = email
|
||||||
updateDeal('lead_owner', email)
|
updateDeal('deal_owner', email)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -336,6 +336,7 @@ import {
|
|||||||
Avatar,
|
Avatar,
|
||||||
Tabs,
|
Tabs,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
@ -372,9 +373,6 @@ function updateLead(fieldname, value) {
|
|||||||
},
|
},
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
if (fieldname == 'is_deal') {
|
|
||||||
router.push({ name: 'Deal', params: { dealId: lead.data.name } })
|
|
||||||
}
|
|
||||||
lead.reload()
|
lead.reload()
|
||||||
contacts.reload()
|
contacts.reload()
|
||||||
reload.value = true
|
reload.value = true
|
||||||
@ -565,8 +563,23 @@ const organization = computed(() => {
|
|||||||
|
|
||||||
function convertToDeal() {
|
function convertToDeal() {
|
||||||
lead.data.status = 'Qualified'
|
lead.data.status = 'Qualified'
|
||||||
lead.data.is_deal = 1
|
lead.data.converted = 1
|
||||||
updateLead('is_deal', 1)
|
createDeal(lead.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createDeal(lead) {
|
||||||
|
let d = await call('frappe.client.insert', {
|
||||||
|
doc: {
|
||||||
|
doctype: 'CRM Deal',
|
||||||
|
organization: lead.organization,
|
||||||
|
email: lead.email,
|
||||||
|
mobile_no: lead.mobile_no,
|
||||||
|
lead: lead.name,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (d.name) {
|
||||||
|
router.push({ name: 'Deal', params: { dealId: d.name } })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAssignedAgent(email) {
|
function updateAssignedAgent(email) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user