feat: employee page with channel tabs (WeChat/WhatsApp account lists)
Replace the sparse staff-record table on /staff with a channel-tabbed employee account view mirroring the 云客 backend's 员工微信列表 + WhatsApp 员工列表. Each tab loads /api/accounts?channel=<channel> with its own pagination state; rows open the existing account all-fields drawer (reused from AccountList via accountFields.ts). WeChat tab columns: 头像/微信昵称/微信号/手机号/员工姓名/好友数/群数/ 发送/接收/数据库大小/在职/在线状态/最后更新. WhatsApp tab columns: 头像(el-avatar initials)/昵称/员工姓名/手机/销售手机/好友数/群数/ 联系人数/新增好友/在职/最后更新. Reads raw_json via the structured-first readField helper; tolerates boolean and 1/0 forms of isOnJob/onlineStatus. Also fix the avatar field key in accountFields.ts (headImageUrl, with headImgUrl as a legacy alias) so the WeChat drawer avatar renders — the upstream wxUser record uses headImageUrl. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ export const ACCOUNT_FIELD_LABELS: Record<string, string> = {
|
|||||||
channel: '渠道',
|
channel: '渠道',
|
||||||
nickName: '昵称',
|
nickName: '昵称',
|
||||||
alias: '微信号',
|
alias: '微信号',
|
||||||
|
headImageUrl: '头像',
|
||||||
headImgUrl: '头像',
|
headImgUrl: '头像',
|
||||||
// 归属员工
|
// 归属员工
|
||||||
userName: '员工姓名',
|
userName: '员工姓名',
|
||||||
@@ -75,7 +76,7 @@ const STRUCTURED_ALIAS: Record<string, keyof Account> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Fields whose value is an image URL → render as a thumbnail. */
|
/** Fields whose value is an image URL → render as a thumbnail. */
|
||||||
const IMAGE_KEYS = new Set(['headImgUrl'])
|
const IMAGE_KEYS = new Set(['headImageUrl', 'headImgUrl'])
|
||||||
|
|
||||||
/** Fields whose value is a millisecond epoch → format to local datetime. */
|
/** Fields whose value is a millisecond epoch → format to local datetime. */
|
||||||
const TIMESTAMP_KEYS = new Set(['lastUpdate'])
|
const TIMESTAMP_KEYS = new Set(['lastUpdate'])
|
||||||
@@ -93,7 +94,7 @@ export interface AccountFieldGroup {
|
|||||||
export const ACCOUNT_FIELD_GROUPS: AccountFieldGroup[] = [
|
export const ACCOUNT_FIELD_GROUPS: AccountFieldGroup[] = [
|
||||||
{
|
{
|
||||||
title: '基本信息',
|
title: '基本信息',
|
||||||
keys: ['wechatId', 'uid', 'channel', 'nickName', 'alias', 'headImgUrl'],
|
keys: ['wechatId', 'uid', 'channel', 'nickName', 'alias', 'headImageUrl', 'headImgUrl'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '归属员工',
|
title: '归属员工',
|
||||||
|
|||||||
+509
-189
@@ -1,128 +1,219 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { getStaff } from '@/api'
|
import { getAccounts } from '@/api'
|
||||||
import type { Staff } from '@/api/types'
|
import type { Account, Channel } from '@/api/types'
|
||||||
import { useOrgStore } from '@/stores/org'
|
import { channelLabel, formatTime } from '@/utils/format'
|
||||||
import { buildStaffSections, readField } from '@/utils/staffFields'
|
import { buildAccountSections, formatBytes, readField } from '@/utils/accountFields'
|
||||||
|
|
||||||
const route = useRoute()
|
/**
|
||||||
const org = useOrgStore()
|
* 员工 list — channel-tabbed account view mirroring the 云客 backend's
|
||||||
|
* 员工微信列表 (WeChat staff accounts) and WhatsApp 员工列表. The earlier sparse
|
||||||
|
* staff-record table is replaced by the underlying messaging accounts, which
|
||||||
|
* carry the verbatim upstream record on `raw_json` (nickName/alias/userName/
|
||||||
|
* sendNum/receiveNum/dbSize/onlineStatus/lastUpdate/talkerCount/...).
|
||||||
|
*
|
||||||
|
* Each tab loads `/api/accounts?channel=<channel>` independently with its own
|
||||||
|
* pagination state. Row click opens the all-fields drawer reused from
|
||||||
|
* AccountList.vue (see accountFields.ts).
|
||||||
|
*/
|
||||||
|
|
||||||
// All-fields drawer state.
|
type TabKey = Channel
|
||||||
const drawerOpen = ref(false)
|
interface TabState {
|
||||||
const drawerStaff = ref<Staff | null>(null)
|
items: Account[]
|
||||||
|
total: number
|
||||||
const staff = ref<Staff[]>([])
|
page: number
|
||||||
const total = ref(0)
|
pageSize: number
|
||||||
const page = ref(1)
|
loading: boolean
|
||||||
const pageSize = ref(20)
|
errorMsg: string | null
|
||||||
const loading = ref(false)
|
/** Has this tab been loaded at least once? Tabs lazy-load on first activation. */
|
||||||
const errorMsg = ref<string | null>(null)
|
loaded: boolean
|
||||||
|
|
||||||
// On-job filter: 'all' (no filter) / 'on' (is_on_job=true) / 'off' (false).
|
|
||||||
const onJobFilter = ref<'all' | 'on' | 'off'>('all')
|
|
||||||
|
|
||||||
const departmentId = computed<string | undefined>(() =>
|
|
||||||
route.query.department_id ? String(route.query.department_id) : undefined,
|
|
||||||
)
|
|
||||||
|
|
||||||
const onJobOptions: { value: 'all' | 'on' | 'off'; label: string }[] = [
|
|
||||||
{ value: 'all', label: '全部' },
|
|
||||||
{ value: 'on', label: '在职' },
|
|
||||||
{ value: 'off', label: '离职' },
|
|
||||||
]
|
|
||||||
|
|
||||||
function onJobTagType(onJob?: boolean | null): 'success' | 'info' | '' {
|
|
||||||
if (onJob === true) return 'success'
|
|
||||||
if (onJob === false) return 'info'
|
|
||||||
return ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onJobLabel(onJob?: boolean | null): string {
|
function freshTabState(): TabState {
|
||||||
if (onJob === true) return '在职'
|
return {
|
||||||
if (onJob === false) return '离职'
|
items: [],
|
||||||
return '--'
|
total: 0,
|
||||||
}
|
page: 1,
|
||||||
|
pageSize: 20,
|
||||||
function deptName(deptId?: string | null): string | null {
|
loading: false,
|
||||||
if (!deptId) return null
|
errorMsg: null,
|
||||||
return org.findNode(deptId)?.label ?? deptId
|
loaded: false,
|
||||||
}
|
|
||||||
|
|
||||||
async function load(): Promise<void> {
|
|
||||||
loading.value = true
|
|
||||||
errorMsg.value = null
|
|
||||||
try {
|
|
||||||
const res = await getStaff({
|
|
||||||
department_id: departmentId.value,
|
|
||||||
is_on_job:
|
|
||||||
onJobFilter.value === 'all' ? undefined : onJobFilter.value === 'on',
|
|
||||||
page: page.value,
|
|
||||||
page_size: pageSize.value,
|
|
||||||
})
|
|
||||||
staff.value = res.items
|
|
||||||
total.value = res.total
|
|
||||||
} catch (e) {
|
|
||||||
errorMsg.value = (e as Error).message
|
|
||||||
ElMessage.error(`员工列表加载失败:${(e as Error).message}`)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePageChange(p: number): void {
|
const activeTab = ref<TabKey>('wechat')
|
||||||
page.value = p
|
const tabState = reactive<Record<TabKey, TabState>>({
|
||||||
load()
|
wechat: freshTabState(),
|
||||||
}
|
whatsapp: freshTabState(),
|
||||||
|
|
||||||
function handlePageSizeChange(s: number): void {
|
|
||||||
pageSize.value = s
|
|
||||||
page.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// React to the on-job filter + any dept query param.
|
|
||||||
watch(
|
|
||||||
() => [onJobFilter.value, departmentId.value] as const,
|
|
||||||
() => {
|
|
||||||
page.value = 1
|
|
||||||
load()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
// Dept names come from the org tree; best-effort load so the 部门 column
|
|
||||||
// can render names instead of bare ids. A load failure is non-fatal — the
|
|
||||||
// column falls back to the raw dept_id.
|
|
||||||
try {
|
|
||||||
await org.ensureLoaded()
|
|
||||||
} catch {
|
|
||||||
/* surfaced in the aside placeholder */
|
|
||||||
}
|
|
||||||
await load()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Read a raw_json camelCase key off a staff row, preferring the structured
|
// All-fields drawer state (shared across tabs).
|
||||||
* snake_case column when it is populated. */
|
const drawerOpen = ref(false)
|
||||||
function cell(row: Staff, camelKey: string): unknown {
|
const drawerAccount = ref<Account | null>(null)
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Cell helpers (structured-first, raw_json fallback via accountFields.readField)
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function cell(row: Account, camelKey: string): unknown {
|
||||||
return readField(row, camelKey)
|
return readField(row, camelKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cellText(row: Staff, camelKey: string): string {
|
function cellText(row: Account, camelKey: string): string {
|
||||||
const v = cell(row, camelKey)
|
const v = cell(row, camelKey)
|
||||||
return v === null || v === undefined || v === '' ? '--' : String(v)
|
return v === null || v === undefined || v === '' ? '--' : String(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
function openDrawer(row: Staff): void {
|
function cellNumber(row: Account, camelKey: string): number | undefined {
|
||||||
drawerStaff.value = row
|
const v = cell(row, camelKey)
|
||||||
|
return typeof v === 'number' && Number.isFinite(v) ? v : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function cellTime(row: Account, camelKey: string): number | undefined {
|
||||||
|
return cellNumber(row, camelKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
function imageCell(row: Account, camelKey: string): string | undefined {
|
||||||
|
const v = cell(row, camelKey)
|
||||||
|
return typeof v === 'string' && v !== '' ? v : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** First character of userName/nickName/account_id for avatar fallbacks. */
|
||||||
|
function initials(row: Account): string {
|
||||||
|
const name =
|
||||||
|
cell(row, 'userName') ?? cell(row, 'nickName') ?? row.account_id ?? '?'
|
||||||
|
const s = String(name).trim()
|
||||||
|
return s ? s.slice(0, 1).toUpperCase() : '?'
|
||||||
|
}
|
||||||
|
|
||||||
|
function avatarUrl(row: Account): string | undefined {
|
||||||
|
// WeChat records key the avatar as `headImageUrl`; tolerate the legacy
|
||||||
|
// `headImg` / `headImgUrl` shapes too so the column degrades gracefully.
|
||||||
|
return (
|
||||||
|
imageCell(row, 'headImageUrl') ??
|
||||||
|
imageCell(row, 'headImgUrl') ??
|
||||||
|
imageCell(row, 'headImg')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function dbSizeText(row: Account): string {
|
||||||
|
const v = cellNumber(row, 'dbSize')
|
||||||
|
return v === undefined ? '--' : formatBytes(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在职: structured column is boolean; raw_json may carry 1/0. Handle both so
|
||||||
|
// the tag is correct regardless of which source populated the row.
|
||||||
|
function onJobTagType(v: unknown): 'success' | 'info' | '' {
|
||||||
|
if (v === true || v === 1 || v === '1') return 'success'
|
||||||
|
if (v === false || v === 0 || v === '0') return 'info'
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function onJobLabel(v: unknown): string {
|
||||||
|
if (v === true || v === 1 || v === '1') return '在职'
|
||||||
|
if (v === false || v === 0 || v === '0') return '离职'
|
||||||
|
return '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在线状态: upstream sends "online"/"offline" (sometimes 1/0). Render as a tag
|
||||||
|
// when recognized; pass through other strings so info isn't hidden.
|
||||||
|
function onlineTagType(v: unknown): 'success' | 'info' | '' {
|
||||||
|
if (v === 'online' || v === 1 || v === '1') return 'success'
|
||||||
|
if (v === 'offline' || v === 0 || v === '0') return 'info'
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function onlineLabel(v: unknown): string {
|
||||||
|
if (v === 'online' || v === 1 || v === '1') return '在线'
|
||||||
|
if (v === 'offline' || v === 0 || v === '0') return '离线'
|
||||||
|
if (v === null || v === undefined || v === '') return '--'
|
||||||
|
return String(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
function channelTagType(c: Channel): 'success' | 'warning' {
|
||||||
|
return c === 'wechat' ? 'success' : 'warning'
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Per-tab loading
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
async function loadTab(ch: TabKey): Promise<void> {
|
||||||
|
const st = tabState[ch]
|
||||||
|
st.loading = true
|
||||||
|
st.errorMsg = null
|
||||||
|
try {
|
||||||
|
const res = await getAccounts({
|
||||||
|
channel: ch,
|
||||||
|
page: st.page,
|
||||||
|
page_size: st.pageSize,
|
||||||
|
})
|
||||||
|
st.items = res.items
|
||||||
|
st.total = res.total
|
||||||
|
st.loaded = true
|
||||||
|
} catch (e) {
|
||||||
|
st.errorMsg = (e as Error).message
|
||||||
|
ElMessage.error(`员工列表加载失败:${(e as Error).message}`)
|
||||||
|
} finally {
|
||||||
|
st.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePageChange(ch: TabKey, p: number): void {
|
||||||
|
tabState[ch].page = p
|
||||||
|
loadTab(ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePageSizeChange(ch: TabKey, s: number): void {
|
||||||
|
tabState[ch].pageSize = s
|
||||||
|
tabState[ch].page = 1
|
||||||
|
loadTab(ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Per-tab wrappers so template bindings carry proper types (vue-tsc strict
|
||||||
|
// mode does not infer inline-arrow params in @event handlers).
|
||||||
|
function onWechatPageChange(p: number): void {
|
||||||
|
handlePageChange('wechat', p)
|
||||||
|
}
|
||||||
|
function onWechatPageSizeChange(s: number): void {
|
||||||
|
handlePageSizeChange('wechat', s)
|
||||||
|
}
|
||||||
|
function onWhatsappPageChange(p: number): void {
|
||||||
|
handlePageChange('whatsapp', p)
|
||||||
|
}
|
||||||
|
function onWhatsappPageSizeChange(s: number): void {
|
||||||
|
handlePageSizeChange('whatsapp', s)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTabChange(name: string | number): void {
|
||||||
|
const ch = String(name) as TabKey
|
||||||
|
if (!tabState[ch].loaded) loadTab(ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Drawer
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function openDrawer(row: Account): void {
|
||||||
|
drawerAccount.value = row
|
||||||
drawerOpen.value = true
|
drawerOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const drawerSections = computed(() =>
|
const drawerSections = computed(() =>
|
||||||
drawerStaff.value ? buildStaffSections(drawerStaff.value) : [],
|
drawerAccount.value ? buildAccountSections(drawerAccount.value) : [],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const drawerAvatarSrc = computed<string | undefined>(() => {
|
||||||
|
const a = drawerAccount.value
|
||||||
|
return a ? avatarUrl(a) : undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// The visible tab on first paint is 微信员工 — load it. The other tab
|
||||||
|
// lazy-loads on activation.
|
||||||
|
loadTab('wechat')
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -130,103 +221,273 @@ const drawerSections = computed(() =>
|
|||||||
<div class="yk-staff__header">
|
<div class="yk-staff__header">
|
||||||
<div>
|
<div>
|
||||||
<h2 style="margin: 0 0 4px; font-size: 16px">员工列表</h2>
|
<h2 style="margin: 0 0 4px; font-size: 16px">员工列表</h2>
|
||||||
<span class="yk-staff__sub">共 {{ total }} 条</span>
|
<span class="yk-staff__sub">
|
||||||
</div>
|
按渠道展示员工账号(微信号 / WhatsApp 号),点击行查看全部字段。
|
||||||
<div class="yk-staff__filters">
|
</span>
|
||||||
<el-radio-group v-model="onJobFilter" size="small">
|
|
||||||
<el-radio-button
|
|
||||||
v-for="opt in onJobOptions"
|
|
||||||
:key="opt.value"
|
|
||||||
:value="opt.value"
|
|
||||||
>
|
|
||||||
{{ opt.label }}
|
|
||||||
</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-alert
|
<el-tabs v-model="activeTab" class="yk-staff__tabs" @tab-change="onTabChange">
|
||||||
v-if="errorMsg"
|
<!-- ============================================================
|
||||||
:title="errorMsg"
|
微信员工 (WeChat staff accounts)
|
||||||
type="error"
|
============================================================ -->
|
||||||
show-icon
|
<el-tab-pane label="微信员工" name="wechat">
|
||||||
:closable="false"
|
<el-alert
|
||||||
style="margin-bottom: 12px"
|
v-if="tabState.wechat.errorMsg"
|
||||||
/>
|
:title="tabState.wechat.errorMsg"
|
||||||
|
type="error"
|
||||||
|
show-icon
|
||||||
|
:closable="false"
|
||||||
|
style="margin-bottom: 12px"
|
||||||
|
/>
|
||||||
|
<el-table
|
||||||
|
v-loading="tabState.wechat.loading"
|
||||||
|
:data="tabState.wechat.items"
|
||||||
|
stripe
|
||||||
|
border
|
||||||
|
row-key="account_id"
|
||||||
|
style="width: 100%"
|
||||||
|
:row-class-name="() => 'yk-clickable-row'"
|
||||||
|
empty-text="暂无微信员工账号"
|
||||||
|
@row-click="openDrawer"
|
||||||
|
>
|
||||||
|
<el-table-column label="头像" width="64" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<template v-if="avatarUrl(row)">
|
||||||
|
<el-image
|
||||||
|
:src="avatarUrl(row)"
|
||||||
|
fit="cover"
|
||||||
|
class="yk-avatar-round"
|
||||||
|
>
|
||||||
|
<template #error>
|
||||||
|
<div class="yk-avatar-fallback">{{ initials(row) }}</div>
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
|
</template>
|
||||||
|
<el-avatar v-else :size="36" shape="circle">
|
||||||
|
{{ initials(row) }}
|
||||||
|
</el-avatar>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="微信昵称" min-width="120">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'nickName') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="微信号" min-width="120">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'alias') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="手机号" min-width="120">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'phone') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="员工姓名" min-width="110">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'userName') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="好友数" width="90" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ cellNumber(row, 'contactsNum') ?? 0 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="群数" width="80" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ cellNumber(row, 'groupNum') ?? 0 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="发送" width="90" align="right">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'sendNum') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="接收" width="90" align="right">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'receiveNum') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="数据库大小" width="110" align="right">
|
||||||
|
<template #default="{ row }">{{ dbSizeText(row) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="在职" width="90" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag
|
||||||
|
:type="onJobTagType(cell(row, 'isOnJob'))"
|
||||||
|
size="small"
|
||||||
|
effect="plain"
|
||||||
|
>
|
||||||
|
{{ onJobLabel(cell(row, 'isOnJob')) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="在线状态" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag
|
||||||
|
v-if="cell(row, 'onlineStatus') !== undefined && cell(row, 'onlineStatus') !== null && cell(row, 'onlineStatus') !== ''"
|
||||||
|
:type="onlineTagType(cell(row, 'onlineStatus'))"
|
||||||
|
size="small"
|
||||||
|
effect="plain"
|
||||||
|
>
|
||||||
|
{{ onlineLabel(cell(row, 'onlineStatus')) }}
|
||||||
|
</el-tag>
|
||||||
|
<span v-else style="color: #c0c4cc">--</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="最后更新" width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTime(cellTime(row, 'lastUpdate')) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
<el-table
|
<div class="yk-staff__pager">
|
||||||
v-loading="loading"
|
<el-pagination
|
||||||
:data="staff"
|
:current-page="tabState.wechat.page"
|
||||||
stripe
|
:page-size="tabState.wechat.pageSize"
|
||||||
border
|
:page-sizes="[20, 50, 100]"
|
||||||
row-key="user_id"
|
:total="tabState.wechat.total"
|
||||||
style="width: 100%"
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
:row-class-name="() => 'yk-clickable-row'"
|
background
|
||||||
empty-text="暂无员工数据"
|
@current-change="onWechatPageChange"
|
||||||
@row-click="openDrawer"
|
@size-change="onWechatPageSizeChange"
|
||||||
>
|
/>
|
||||||
<el-table-column label="员工ID" min-width="120">
|
</div>
|
||||||
<template #default="{ row }">{{ row.user_id }}</template>
|
</el-tab-pane>
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="姓名" min-width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span v-if="row.name">{{ row.name }}</span>
|
|
||||||
<span v-else style="color: #c0c4cc">--</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="手机" min-width="130">
|
|
||||||
<template #default="{ row }">{{ cellText(row, 'phone') }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="销售手机" min-width="130">
|
|
||||||
<template #default="{ row }">{{ cellText(row, 'sale_phone') }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="部门" min-width="140">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span v-if="deptName(row.dept_id)">{{ deptName(row.dept_id) }}</span>
|
|
||||||
<span v-else style="color: #c0c4cc">--</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="在职" width="100" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag
|
|
||||||
:type="onJobTagType(row.is_on_job)"
|
|
||||||
size="small"
|
|
||||||
effect="plain"
|
|
||||||
>
|
|
||||||
{{ onJobLabel(row.is_on_job) }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="yk-staff__pager">
|
<!-- ============================================================
|
||||||
<el-pagination
|
WhatsApp员工 (WhatsApp staff accounts)
|
||||||
:current-page="page"
|
============================================================ -->
|
||||||
:page-size="pageSize"
|
<el-tab-pane label="WhatsApp员工" name="whatsapp">
|
||||||
:page-sizes="[20, 50, 100]"
|
<el-alert
|
||||||
:total="total"
|
v-if="tabState.whatsapp.errorMsg"
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
:title="tabState.whatsapp.errorMsg"
|
||||||
background
|
type="error"
|
||||||
@current-change="handlePageChange"
|
show-icon
|
||||||
@size-change="handlePageSizeChange"
|
:closable="false"
|
||||||
/>
|
style="margin-bottom: 12px"
|
||||||
</div>
|
/>
|
||||||
<p class="yk-staff__hint">点击任意一行查看员工全部字段。</p>
|
<el-table
|
||||||
|
v-loading="tabState.whatsapp.loading"
|
||||||
|
:data="tabState.whatsapp.items"
|
||||||
|
stripe
|
||||||
|
border
|
||||||
|
row-key="account_id"
|
||||||
|
style="width: 100%"
|
||||||
|
:row-class-name="() => 'yk-clickable-row'"
|
||||||
|
empty-text="暂无 WhatsApp 员工账号"
|
||||||
|
@row-click="openDrawer"
|
||||||
|
>
|
||||||
|
<el-table-column label="头像" width="64" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-avatar :size="36" shape="circle">
|
||||||
|
{{ initials(row) }}
|
||||||
|
</el-avatar>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="昵称" min-width="120">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'nickName') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="员工姓名" min-width="110">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'userName') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="手机" min-width="120">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'phone') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="销售手机" min-width="120">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'salePhone') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="好友数" width="90" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ cellNumber(row, 'contactsNum') ?? 0 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="群数" width="80" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ cellNumber(row, 'groupNum') ?? 0 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="联系人数" width="100" align="right">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'talkerCount') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="新增好友" width="100" align="right">
|
||||||
|
<template #default="{ row }">{{ cellText(row, 'friendAddNum') }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="在职" width="90" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag
|
||||||
|
:type="onJobTagType(cell(row, 'isOnJob'))"
|
||||||
|
size="small"
|
||||||
|
effect="plain"
|
||||||
|
>
|
||||||
|
{{ onJobLabel(cell(row, 'isOnJob')) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="最后更新" width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTime(cellTime(row, 'lastUpdate')) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
<!-- All-fields drawer -->
|
<div class="yk-staff__pager">
|
||||||
|
<el-pagination
|
||||||
|
:current-page="tabState.whatsapp.page"
|
||||||
|
:page-size="tabState.whatsapp.pageSize"
|
||||||
|
:page-sizes="[20, 50, 100]"
|
||||||
|
:total="tabState.whatsapp.total"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
background
|
||||||
|
@current-change="onWhatsappPageChange"
|
||||||
|
@size-change="onWhatsappPageSizeChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
|
||||||
|
<p class="yk-staff__hint">点击任意一行查看员工账号全部字段。</p>
|
||||||
|
|
||||||
|
<!-- All-fields drawer (reused from AccountList.vue / accountFields.ts) -->
|
||||||
<el-drawer
|
<el-drawer
|
||||||
v-model="drawerOpen"
|
v-model="drawerOpen"
|
||||||
:title="drawerStaff ? `员工详情 · ${drawerStaff.name ?? drawerStaff.user_id}` : '员工详情'"
|
:title="drawerAccount ? `员工详情 · ${drawerAccount.user_name ?? drawerAccount.nickname ?? drawerAccount.account_id}` : '员工详情'"
|
||||||
direction="rtl"
|
direction="rtl"
|
||||||
size="520px"
|
size="560px"
|
||||||
>
|
>
|
||||||
<template v-if="drawerStaff">
|
<template v-if="drawerAccount">
|
||||||
|
<div class="yk-drawer__avatar">
|
||||||
|
<el-avatar :size="56" :src="drawerAvatarSrc" shape="square">
|
||||||
|
{{ initials(drawerAccount) }}
|
||||||
|
</el-avatar>
|
||||||
|
<div class="yk-drawer__avatar-meta">
|
||||||
|
<div class="yk-drawer__avatar-name">
|
||||||
|
{{ drawerAccount.user_name ?? drawerAccount.nickname ?? drawerAccount.account_id }}
|
||||||
|
</div>
|
||||||
|
<div class="yk-drawer__avatar-sub">
|
||||||
|
<el-tag
|
||||||
|
:type="channelTagType(drawerAccount.channel)"
|
||||||
|
size="small"
|
||||||
|
effect="plain"
|
||||||
|
>
|
||||||
|
{{ channelLabel(drawerAccount.channel) }}
|
||||||
|
</el-tag>
|
||||||
|
<el-tag
|
||||||
|
:type="onJobTagType(cell(drawerAccount, 'isOnJob'))"
|
||||||
|
size="small"
|
||||||
|
effect="plain"
|
||||||
|
style="margin-left: 6px"
|
||||||
|
>
|
||||||
|
{{ onJobLabel(cell(drawerAccount, 'isOnJob')) }}
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-for="section in drawerSections" :key="section.title" class="yk-drawer__section">
|
<div v-for="section in drawerSections" :key="section.title" class="yk-drawer__section">
|
||||||
<el-divider content-position="left">{{ section.title }}</el-divider>
|
<el-divider content-position="left">{{ section.title }}</el-divider>
|
||||||
<dl class="yk-drawer__kv">
|
<dl class="yk-drawer__kv">
|
||||||
<div v-for="f in section.fields" :key="f.key" class="yk-drawer__kv-item">
|
<div v-for="f in section.fields" :key="f.key" class="yk-drawer__kv-item">
|
||||||
<dt>{{ f.label }}</dt>
|
<dt>{{ f.label }}</dt>
|
||||||
<dd v-if="f.render === 'empty'" class="yk-drawer__empty">—</dd>
|
<dd v-if="f.render === 'image'" class="yk-drawer__img">
|
||||||
|
<el-image
|
||||||
|
:src="String(f.value)"
|
||||||
|
:preview-src-list="[String(f.value)]"
|
||||||
|
fit="cover"
|
||||||
|
hide-on-click-modal
|
||||||
|
/>
|
||||||
|
</dd>
|
||||||
|
<dd v-else-if="f.render === 'empty'" class="yk-drawer__empty">—</dd>
|
||||||
<dd v-else>{{ f.text }}</dd>
|
<dd v-else>{{ f.text }}</dd>
|
||||||
</div>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -251,11 +512,8 @@ const drawerSections = computed(() =>
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.yk-staff__filters {
|
.yk-staff__tabs {
|
||||||
display: flex;
|
margin-top: 4px;
|
||||||
gap: 8px;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.yk-staff__pager {
|
.yk-staff__pager {
|
||||||
@@ -270,6 +528,61 @@ const drawerSections = computed(() =>
|
|||||||
color: #c0c4cc;
|
color: #c0c4cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Round 36px avatar — el-image renders an <img> inside; size + round it. */
|
||||||
|
.yk-avatar-round {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #f0f2f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yk-avatar-round :deep(img) {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yk-avatar-fallback {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
line-height: 36px;
|
||||||
|
text-align: center;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 14px;
|
||||||
|
background: #f0f2f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yk-drawer__avatar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yk-drawer__avatar-meta {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yk-drawer__avatar-name {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yk-drawer__avatar-sub {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
margin-top: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.yk-drawer__kv {
|
.yk-drawer__kv {
|
||||||
margin: 0 0 8px;
|
margin: 0 0 8px;
|
||||||
}
|
}
|
||||||
@@ -295,6 +608,13 @@ const drawerSections = computed(() =>
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.yk-drawer__img :deep(.el-image) {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid var(--el-border-color-light, #e4e7ed);
|
||||||
|
}
|
||||||
|
|
||||||
.yk-drawer__empty {
|
.yk-drawer__empty {
|
||||||
color: #c0c4cc;
|
color: #c0c4cc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user