add telephone link
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<span class="gray" v-text="customerCode" />
|
||||
</div>
|
||||
<span class="telephone gray" v-text="customerTelephone" />
|
||||
<telephone-link class="telephone gray" :value="customerTelephone" />
|
||||
</div>
|
||||
<t-image-viewer
|
||||
v-model:visible="photoViewerVisible"
|
||||
@@ -105,6 +105,7 @@ function openPhotoViewer(): void {
|
||||
}
|
||||
|
||||
.telephone {
|
||||
display: inline-block;
|
||||
font-size: .875rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<t-cell
|
||||
v-for="(item, index) in customerOptions"
|
||||
:key="item.id || item.code || index"
|
||||
:description="item.telephone || '未填写电话'"
|
||||
:note="item.code"
|
||||
hover
|
||||
@click="selectCustomer(item)"
|
||||
@@ -27,6 +26,9 @@
|
||||
<gender-icon :value="item.gender" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
<telephone-link :value="item.telephone" placeholder="未填写电话" />
|
||||
</template>
|
||||
<template #leftIcon>
|
||||
<t-image v-if="getCustomerPhotoURL(item)" :src="getCustomerPhotoURL(item)" :alt="item.name" fit="cover" class="avatar" />
|
||||
<div v-else class="avatar fallback" v-text="(item.name || item.code || '客').slice(0, 1)" />
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<component
|
||||
:is="href ? 'a' : 'span'"
|
||||
v-if="displayText"
|
||||
:href="href || undefined"
|
||||
class="telephone-link"
|
||||
:class="{ clickable: !!href }"
|
||||
@click.stop
|
||||
>
|
||||
<span v-text="displayText" />
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { buildTelephoneURL, canDialTelephone } from "@/utils/telephone";
|
||||
|
||||
defineOptions({
|
||||
name: "TelephoneLink"
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
placeholder?: string;
|
||||
value?: string;
|
||||
}>(), {
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
const textValue = computed(() => props.value?.trim() || "");
|
||||
const displayText = computed(() => textValue.value || props.placeholder);
|
||||
const href = computed(() => canDialTelephone(textValue.value) ? buildTelephoneURL(textValue.value) : "");
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.telephone-link {
|
||||
color: inherit;
|
||||
word-break: break-all;
|
||||
text-decoration: none;
|
||||
|
||||
&.clickable {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: .16rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -13,10 +13,6 @@
|
||||
@decode="handleDecodedText"
|
||||
@status-change="handleScanStatusChange"
|
||||
/>
|
||||
<div class="code-box">
|
||||
<span class="required-label">扫出编码</span>
|
||||
<strong v-text="scanCode || '未识别'" />
|
||||
</div>
|
||||
<customer-profile-card
|
||||
v-if="matchedCustomer"
|
||||
:customer="matchedCustomer"
|
||||
|
||||
@@ -27,10 +27,12 @@
|
||||
<t-cell-group v-if="inviter" :title="`被 ${inviter.name} 邀请`" class="invite" theme="card">
|
||||
<t-cell
|
||||
:title="inviter.name"
|
||||
:description="inviter.telephone || '未填写电话'"
|
||||
arrow
|
||||
@click="goCustomerDetail(inviter)"
|
||||
>
|
||||
<template #description>
|
||||
<telephone-link :value="inviter.telephone" placeholder="未填写电话" />
|
||||
</template>
|
||||
<template #leftIcon>
|
||||
<t-image
|
||||
v-if="getCustomerPhotoURL(inviter)"
|
||||
@@ -67,7 +69,6 @@
|
||||
:key="item.id || item.code"
|
||||
>
|
||||
<t-cell
|
||||
:description="item.telephone || '未填写电话'"
|
||||
arrow
|
||||
hover
|
||||
@click="goCustomerDetail(item)"
|
||||
@@ -77,6 +78,9 @@
|
||||
<span v-text="item.name || item.code" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
<telephone-link :value="item.telephone" placeholder="未填写电话" />
|
||||
</template>
|
||||
<template #leftIcon>
|
||||
<t-image
|
||||
v-if="getCustomerPhotoURL(item)"
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
</t-radio-group>
|
||||
</t-form-item>
|
||||
<t-form-item label="手机号">
|
||||
<t-input v-model.trim="formModel.telephone" placeholder="手机号" borderless />
|
||||
<t-input v-model.trim="formModel.telephone" type="tel" placeholder="手机号" borderless />
|
||||
</t-form-item>
|
||||
<t-form-item label="介绍人">
|
||||
<div class="referrer">
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<div class="gray">
|
||||
<template v-if="item.telephone">
|
||||
<t-icon name="call" />
|
||||
<span class="word-space" v-text="item.telephone" />
|
||||
<telephone-link class="word-space" :value="item.telephone" />
|
||||
</template>
|
||||
</div>
|
||||
<t-tag
|
||||
|
||||
@@ -339,6 +339,9 @@ function buildEventStructureOption(): EChartsOption {
|
||||
function buildGenderStatOption(): EChartsOption {
|
||||
return {
|
||||
...buildBaseOption(),
|
||||
tooltip: {
|
||||
trigger: "item"
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data: ["男", "女", "未知"],
|
||||
@@ -349,30 +352,32 @@ function buildGenderStatOption(): EChartsOption {
|
||||
color: "#52607a"
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: "客户数量",
|
||||
type: "bar",
|
||||
data: [
|
||||
{
|
||||
value: getGenderCount("MALE"),
|
||||
itemStyle: {
|
||||
color: genderColorMap.MALE
|
||||
}
|
||||
series: [
|
||||
{
|
||||
name: "男",
|
||||
type: "bar",
|
||||
itemStyle: {
|
||||
color: genderColorMap.MALE
|
||||
},
|
||||
{
|
||||
value: getGenderCount("FEMALE"),
|
||||
itemStyle: {
|
||||
color: genderColorMap.FEMALE
|
||||
}
|
||||
data: [getGenderCount("MALE"), 0, 0]
|
||||
},
|
||||
{
|
||||
name: "女",
|
||||
type: "bar",
|
||||
itemStyle: {
|
||||
color: genderColorMap.FEMALE
|
||||
},
|
||||
{
|
||||
value: getGenderCount("UNKNOWN"),
|
||||
itemStyle: {
|
||||
color: genderColorMap.UNKNOWN
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
data: [0, getGenderCount("FEMALE"), 0]
|
||||
},
|
||||
{
|
||||
name: "未知",
|
||||
type: "bar",
|
||||
itemStyle: {
|
||||
color: genderColorMap.UNKNOWN
|
||||
},
|
||||
data: [0, 0, getGenderCount("UNKNOWN")]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@
|
||||
</t-radio-group>
|
||||
</t-form-item>
|
||||
<t-form-item label="手机号">
|
||||
<t-input :model-value="formModel.mobile" readonly borderless />
|
||||
<div class="mobile-value">
|
||||
<telephone-link v-if="formModel.mobile" :value="formModel.mobile" />
|
||||
<span v-else v-text="'未填写'" />
|
||||
</div>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<input
|
||||
@@ -259,6 +262,11 @@ onMounted(() => {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile-value {
|
||||
color: var(--td-text-color-primary);
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
|
||||
.save,
|
||||
.logout {
|
||||
left: 1rem;
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
</t-cell-group>
|
||||
|
||||
<t-cell-group v-if="currentUser" theme="card">
|
||||
<t-cell title="手机号" :description="currentUser.mobile || '未填写'" />
|
||||
<t-cell title="手机号">
|
||||
<template #description>
|
||||
<telephone-link :value="currentUser.mobile" placeholder="未填写" />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell title="上次登录时间" :description="currentUser.lastLoginAt || '暂无记录'" />
|
||||
</t-cell-group>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<t-input v-model.trim="formModel.name" placeholder="姓名" borderless />
|
||||
</t-form-item>
|
||||
<t-form-item v-if="isCreateMode" label="手机号">
|
||||
<t-input v-model.trim="formModel.mobile" placeholder="手机号" borderless />
|
||||
<t-input v-model.trim="formModel.mobile" type="tel" placeholder="手机号" borderless />
|
||||
</t-form-item>
|
||||
<t-form-item v-if="isCreateMode" label="密码">
|
||||
<t-input v-model.trim="formModel.password" type="password" placeholder="密码" borderless />
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
<t-cell-group class="user-card" theme="card">
|
||||
<t-cell
|
||||
:title="currentUserName"
|
||||
:description="currentUserDesc"
|
||||
arrow
|
||||
hover
|
||||
@click="go('/management/profile')"
|
||||
>
|
||||
<template #description>
|
||||
<telephone-link v-if="currentUser?.phoneNo" :value="currentUser.phoneNo" />
|
||||
<span v-else v-text="currentUserDesc" />
|
||||
</template>
|
||||
<template #leftIcon>
|
||||
<t-image
|
||||
class="avatar"
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export function normalizeTelephone(value?: string): string {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const trimmedValue = value.trim();
|
||||
if (!trimmedValue) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const normalizedValue = trimmedValue.startsWith("+")
|
||||
? `+${trimmedValue.slice(1).replace(/\D/g, "")}`
|
||||
: trimmedValue.replace(/\D/g, "");
|
||||
return normalizedValue === "+" ? "" : normalizedValue;
|
||||
}
|
||||
|
||||
export function canDialTelephone(value?: string): boolean {
|
||||
const normalizedValue = normalizeTelephone(value);
|
||||
return 2 < normalizedValue.replace("+", "").length;
|
||||
}
|
||||
|
||||
export function buildTelephoneURL(value?: string): string {
|
||||
const normalizedValue = normalizeTelephone(value);
|
||||
return normalizedValue ? `tel:${normalizedValue}` : "";
|
||||
}
|
||||
Reference in New Issue
Block a user