push-level-children-table.vue
5.09 KB
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
<script setup lang="ts">
import { createVNode, onBeforeMount, onMounted, ref } from 'vue';
import { usePushLevelRecordApi } from '@/http/broker';
import { AnyObject, Option } from '@/types/global';
import useLoading from '@/hooks/loading';
import useTagApi from '@/http/Tag';
import { Input, Select, Link, TableData, Textarea } from '@arco-design/web-vue';
import FilterSearch from '@/components/filter/search.vue';
import FilterSearchItem from '@/components/filter/search-item.vue';
import FilterTable from '@/components/filter/table.vue';
import FilterTableColumn from '@/components/filter/table-column.vue';
import UserTableColumn from '@/components/filter/user-table-column.vue';
import EnumTableColumn from '@/components/filter/enum-table-column.vue';
import SpaceTableColumn from '@/components/filter/space-table-column.vue';
import { createFormItemVNode, createFormVNode, createModalVNode } from '@/utils/createVNode';
import { get } from 'lodash';
const props = defineProps<{ recordId: number }>();
const { getChildren } = usePushLevelRecordApi;
const { loading, setLoading } = useLoading(false);
const filter = ref({ userName: '', authIds: [], status: '', readStatus: '' });
const tableRef = ref();
const statusOption = [
{ value: 0, label: '待发送' },
{ value: 1, label: '发送中' },
{ value: 2, label: '已发送' },
{ value: 3, label: '已撤销' },
{ value: -1, label: '发送失败' },
];
const readStatusOption = [
{ value: 0, label: '未查看' },
{ value: 1, label: '已查看' },
];
const onQuery = async (params: AnyObject) => {
setLoading(true);
return getChildren(props.recordId, {
...filter.value,
...params,
setWith: ['user:id,nick_name,identity', 'user.authTags:id,name'],
}).finally(() => setLoading(false));
};
const onSearch = () => tableRef.value?.onPageChange(1);
const onReset = () => {
filter.value = { userName: '', authIds: [], status: '', readStatus: '' };
onSearch();
};
onMounted(() => onReset());
const authTagOptions = ref<Option[]>([]);
onBeforeMount(() => useTagApi.getOption({ type: 4 }).then((data) => (authTagOptions.value = data)));
const onView = (row: TableData) => {
createModalVNode(
() =>
createFormVNode({ model: row, autoLabelWidth: true }, [
createFormItemVNode({ label: '通知标题' }, createVNode(Input, { modelValue: row.title })),
createFormItemVNode(
{ label: '通知内容', rowClass: 'mb-0' },
createVNode(Textarea, { modelValue: row.content, autoSize: { minRows: 6, maxRows: 12 } })
),
]),
{
title: '查看',
titleAlign: 'center',
footer: false,
escToClose: true,
maskClosable: true,
}
);
};
</script>
<template>
<FilterSearch :loading="loading" :model="filter" @search="onSearch" @reset="onReset">
<FilterSearchItem label="经纪人">
<Input v-model="filter.userName" placeholder="请输入" allow-clear />
</FilterSearchItem>
<FilterSearchItem label="认证能力">
<Select
v-model="filter.authIds"
placeholder="请选择"
:options="authTagOptions"
multiple
allow-clear
allow-search
:max-tag-count="2"
/>
</FilterSearchItem>
<FilterSearchItem label="发送状态">
<Select v-model="filter.status" :options="statusOption" placeholder="请选择" allow-clear />
</FilterSearchItem>
<FilterSearchItem label="用户行为">
<Select v-model="filter.readStatus" :options="readStatusOption" placeholder="请选择" allow-clear />
</FilterSearchItem>
</FilterSearch>
<FilterTable ref="tableRef" :loading="loading" :on-query="onQuery">
<UserTableColumn title="经纪人" data-index="user_id" user="user" show-href :width="160" />
<FilterTableColumn title="认证能力" data-index="user_id" :width="200">
<template #default="{ record }">
<!-- eslint-disable -->
<span v-if="get(record, 'user.auth_tags')">
{{
get(record, 'user.auth_tags')
?.map((item: any) => item.name)
?.join('|') || ''
}}
</span>
<!--eslint-enable-->
<span v-else style="color: rgba(44, 44, 44, 0.5)">无</span>
</template>
</FilterTableColumn>
<FilterTableColumn title="通知内容" data-index="content" :width="200" />
<FilterTableColumn title="发送时间" data-index="send_at" :width="180" />
<EnumTableColumn title="发送状态" data-index="status" :option="statusOption" :width="100" />
<FilterTableColumn data-index="read_at" title="用户行为" :width="100">
<template #default="{ record }: { record: { read_at?: string } }">{{ record.read_at ? '已查看' : '未查看' }}</template>
</FilterTableColumn>
<SpaceTableColumn data-index="operation" title="操作" :width="70">
<template #default="{ record }">
<Link class="link-hover" :hoverable="false" @click="onView(record)">查看</Link>
</template>
</SpaceTableColumn>
</FilterTable>
</template>
<style scoped lang="less"></style>