fix: updated leads/deals list view code
This commit is contained in:
parent
3e7dcbc800
commit
71a0b67808
@ -28,8 +28,8 @@
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Filter doctype="CRM Lead" />
|
<Filter doctype="CRM Deal" />
|
||||||
<SortBy doctype="CRM Lead" />
|
<SortBy doctype="CRM Deal" />
|
||||||
<Button icon="more-horizontal" />
|
<Button icon="more-horizontal" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -96,23 +96,20 @@ const currentView = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function getFilter() {
|
function getFilter() {
|
||||||
return {
|
return getArgs() || {}
|
||||||
...(getArgs() || {}),
|
|
||||||
is_deal: 1,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const leads = createListResource({
|
const deals = createListResource({
|
||||||
type: 'list',
|
type: 'list',
|
||||||
doctype: 'CRM Lead',
|
doctype: 'CRM Deal',
|
||||||
fields: [
|
fields: [
|
||||||
'name',
|
'name',
|
||||||
'organization',
|
'organization',
|
||||||
'annual_revenue',
|
'annual_revenue',
|
||||||
'deal_status',
|
'status',
|
||||||
'email',
|
'email',
|
||||||
'mobile_no',
|
'mobile_no',
|
||||||
'lead_owner',
|
'deal_owner',
|
||||||
'modified',
|
'modified',
|
||||||
],
|
],
|
||||||
filters: getFilter(),
|
filters: getFilter(),
|
||||||
@ -125,8 +122,8 @@ watch(
|
|||||||
() => getOrderBy(),
|
() => getOrderBy(),
|
||||||
(value, old_value) => {
|
(value, old_value) => {
|
||||||
if (!value && !old_value) return
|
if (!value && !old_value) return
|
||||||
leads.orderBy = getOrderBy() || 'modified desc'
|
deals.orderBy = getOrderBy() || 'modified desc'
|
||||||
leads.reload()
|
deals.reload()
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
@ -135,8 +132,8 @@ watch(
|
|||||||
storage,
|
storage,
|
||||||
useDebounceFn((value, old_value) => {
|
useDebounceFn((value, old_value) => {
|
||||||
if (JSON.stringify([...value]) === JSON.stringify([...old_value])) return
|
if (JSON.stringify([...value]) === JSON.stringify([...old_value])) return
|
||||||
leads.filters = getFilter()
|
deals.filters = getFilter()
|
||||||
leads.reload()
|
deals.reload()
|
||||||
}, 300),
|
}, 300),
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
@ -154,7 +151,7 @@ const columns = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Status',
|
label: 'Status',
|
||||||
key: 'deal_status',
|
key: 'status',
|
||||||
width: '10rem',
|
width: '10rem',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -168,8 +165,8 @@ const columns = [
|
|||||||
width: '11rem',
|
width: '11rem',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Lead owner',
|
label: 'Deal owner',
|
||||||
key: 'lead_owner',
|
key: 'deal_owner',
|
||||||
width: '10rem',
|
width: '10rem',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -180,28 +177,28 @@ const columns = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const rows = computed(() => {
|
const rows = computed(() => {
|
||||||
if (!leads.data) return []
|
if (!deals.data) return []
|
||||||
return leads.data.map((lead) => {
|
return deals.data.map((deal) => {
|
||||||
return {
|
return {
|
||||||
name: lead.name,
|
name: deal.name,
|
||||||
organization: {
|
organization: {
|
||||||
label: lead.organization,
|
label: deal.organization,
|
||||||
logo: getOrganization(lead.organization)?.organization_logo,
|
logo: getOrganization(deal.organization)?.organization_logo,
|
||||||
},
|
},
|
||||||
annual_revenue: formatNumberIntoCurrency(lead.annual_revenue),
|
annual_revenue: formatNumberIntoCurrency(deal.annual_revenue),
|
||||||
deal_status: {
|
status: {
|
||||||
label: lead.deal_status,
|
label: deal.status,
|
||||||
color: dealStatuses[lead.deal_status]?.color,
|
color: dealStatuses[deal.status]?.color,
|
||||||
},
|
},
|
||||||
email: lead.email,
|
email: deal.email,
|
||||||
mobile_no: lead.mobile_no,
|
mobile_no: deal.mobile_no,
|
||||||
lead_owner: {
|
deal_owner: {
|
||||||
label: lead.lead_owner && getUser(lead.lead_owner).full_name,
|
label: deal.deal_owner && getUser(deal.deal_owner).full_name,
|
||||||
...(lead.lead_owner && getUser(lead.lead_owner)),
|
...(deal.deal_owner && getUser(deal.deal_owner)),
|
||||||
},
|
},
|
||||||
modified: {
|
modified: {
|
||||||
label: dateFormat(lead.modified, dateTooltipFormat),
|
label: dateFormat(deal.modified, dateTooltipFormat),
|
||||||
timeAgo: timeAgo(lead.modified),
|
timeAgo: timeAgo(deal.modified),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -253,25 +250,19 @@ const viewsDropdownOptions = [
|
|||||||
const showNewDialog = ref(false)
|
const showNewDialog = ref(false)
|
||||||
|
|
||||||
let newDeal = reactive({
|
let newDeal = reactive({
|
||||||
salutation: '',
|
|
||||||
first_name: '',
|
|
||||||
last_name: '',
|
|
||||||
lead_name: '',
|
|
||||||
organization: '',
|
organization: '',
|
||||||
deal_status: 'Qualification',
|
status: 'Qualification',
|
||||||
email: '',
|
email: '',
|
||||||
mobile_no: '',
|
mobile_no: '',
|
||||||
lead_owner: getUser().email,
|
deal_owner: getUser().email,
|
||||||
is_deal: 1,
|
|
||||||
created_as_deal: 1,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const createLead = createResource({
|
const createDeal = createResource({
|
||||||
url: 'frappe.client.insert',
|
url: 'frappe.client.insert',
|
||||||
makeParams(values) {
|
makeParams(values) {
|
||||||
return {
|
return {
|
||||||
doc: {
|
doc: {
|
||||||
doctype: 'CRM Lead',
|
doctype: 'CRM Deal',
|
||||||
...values,
|
...values,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -281,7 +272,7 @@ const createLead = createResource({
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
function createNewDeal(close) {
|
function createNewDeal(close) {
|
||||||
createLead
|
createDeal
|
||||||
.submit(newDeal, {
|
.submit(newDeal, {
|
||||||
validate() {
|
validate() {
|
||||||
if (!newDeal.first_name) {
|
if (!newDeal.first_name) {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ const currentView = ref({
|
|||||||
function getFilter() {
|
function getFilter() {
|
||||||
return {
|
return {
|
||||||
...(getArgs() || {}),
|
...(getArgs() || {}),
|
||||||
is_deal: 0,
|
converted: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user