liu
2026-09-30 b1e27feae0b951218fd2f0b0561f9be4c8b67771
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { UmsMemberApi } from '#/api/ums/member';
 
import { Page, useVbenModal } from '@vben/common-ui';
 
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
 
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getMemberPage } from '#/api/ums/member';
 
import { MemberType, useGridFormSchema } from './data';
import Form from './modules/form.vue';
 
/** 会员通讯录(按地区/行业检索,只读) */
defineOptions({ name: 'UmsMemberDirectory' });
 
const [FormModal, formModalApi] = useVbenModal({
  connectedComponent: Form,
  destroyOnClose: true,
});
 
/** 查看会员详情 */
function handleDetail(row: UmsMemberApi.Member) {
  formModalApi.setData({ formType: 'detail', id: row.id }).open();
}
 
/** 等级字典映射:根据会员类型显示对应的等级名称 */
const personalGradeOptions = getDictOptions(DICT_TYPE.UMS_PERSONAL_GRADE, 'string');
const unitGradeOptions = getDictOptions(DICT_TYPE.UMS_UNIT_GRADE, 'string');
function getGradeLabel(row: UmsMemberApi.Member) {
  const options =
    row.memberType === MemberType.UNIT ? unitGradeOptions : personalGradeOptions;
  return options?.find((o) => o.value === row.memberGrade)?.label || row.memberGrade;
}
 
const [Grid] = useVbenVxeGrid({
  formOptions: {
    schema: useGridFormSchema(),
  },
  gridOptions: {
    columns: [
      { type: 'seq', title: '序号', width: 55, fixed: 'left' },
      { field: 'no', title: '会员编号', width: 180, fixed: 'left' },
      { field: 'name', title: '姓名/单位', minWidth: 150 },
      {
        field: 'memberType',
        title: '会员类型',
        minWidth: 100,
        cellRender: {
          name: 'CellDict',
          props: { type: DICT_TYPE.UMS_MEMBER_TYPE },
        },
      },
      {
        field: 'memberGrade',
        title: '会员等级',
        minWidth: 100,
        slots: { default: 'memberGrade' },
      },
      { field: 'contactPhone', title: '联系电话', minWidth: 130 },
      { field: 'contactEmail', title: '邮箱', minWidth: 160 },
      { field: 'workUnit', title: '工作单位', minWidth: 160 },
      {
        field: 'industry',
        title: '行业',
        minWidth: 100,
        cellRender: {
          name: 'CellDict',
          props: { type: DICT_TYPE.UMS_INDUSTRY },
        },
      },
      {
        field: 'regionCode',
        title: '地区',
        minWidth: 110,
      },
      {
        field: 'joinDate',
        title: '入会日期',
        width: 115,
        formatter: 'formatDate',
      },
      {
        title: '操作',
        width: 90,
        fixed: 'right',
        slots: { default: 'actions' },
      },
    ],
    height: 'auto',
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getMemberPage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<UmsMemberApi.Member>,
});
</script>
 
<template>
  <Page auto-content-height>
    <FormModal />
    <Grid table-title="会员通讯录">
      <template #memberGrade="{ row }">
        <span>{{ getGradeLabel(row) }}</span>
      </template>
      <template #actions="{ row }">
        <TableAction
          :actions="[
            {
              label: '详情',
              type: 'link',
              icon: ACTION_ICON.VIEW,
              auth: ['ums:member:directory'],
              onClick: handleDetail.bind(null, row),
            },
          ]"
        />
      </template>
    </Grid>
  </Page>
</template>