Browse Source

refactor: 重构推送记录

master
wangxiang 2 years ago
parent
commit
6f8ab33458
  1. 5
      src/views/common/push/pushBlacklist/index.vue
  2. 41
      src/views/common/push/pushChatMessage/ChatMessageModal.vue
  3. 266
      src/views/common/push/pushChatMessage/chatMessage.data.ts
  4. 48
      src/views/common/push/pushChatMessage/index.vue
  5. 84
      src/views/common/push/pushChatMessage/message.data.ts

5
src/views/common/push/pushBlacklist/index.vue

@ -101,11 +101,6 @@ @@ -101,11 +101,6 @@
state.multiple = !rowSelection.length;
}
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 查看按钮操作,行内查看 */
function handleViewEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };

41
src/views/common/push/pushChatMessage/ChatMessageModal.vue

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
:showOkBtn="false"
@register="registerModal"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './chatMessage.data';
import { getPushChatMessage } from '/@/api/platform/common/controller/pushChatMessage';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
/** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 24 }
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
tag.value = data._tag;
const refId = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false };
props.title = '查看推送记录';
await setFieldsValue(await getPushChatMessage(refId));
// :
setModalProps(props);
});
</script>

266
src/views/common/push/pushChatMessage/chatMessage.data.ts

@ -0,0 +1,266 @@ @@ -0,0 +1,266 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { listPushRingtone } from '/@/api/platform/common/controller/pushRingtone';
import { listPushType } from '/@/api/platform/common/controller/pushType';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '通知标题',
dataIndex: 'title'
},
{
title: '通知内容',
dataIndex: 'text'
},
{
title: '播放声音',
dataIndex: 'playSound',
width: 80,
customRender: ({ record }) => {
const playSound = record?.playSound;
const enable = ~~playSound === 0;
const color = enable ? 'green' : 'red';
const text = enable ? '是' : '否';
return h(Tag, { color: color }, () => text);
}
},
{
title: '震动',
dataIndex: 'playVibrate',
width: 80,
customRender: ({ record }) => {
const playVibrate = record?.playVibrate;
const enable = ~~playVibrate === 0;
const color = enable ? 'green' : 'red';
const text = enable ? '是' : '否';
return h(Tag, { color: color }, () => text);
}
},
{
title: '闪光',
dataIndex: 'playLights',
width: 80,
customRender: ({ record }) => {
const playLights = record?.playLights;
const enable = ~~playLights === 0;
const color = enable ? 'green' : 'red';
const text = enable ? '是' : '否';
return h(Tag, { color: color }, () => text);
}
},
{
title: '文字转语音',
dataIndex: 'playToText',
width: 120,
customRender: ({ record }) => {
const playToText = record?.playToText;
const enable = ~~playToText === 1;
const color = enable ? 'green' : 'red';
const text = enable ? '是': '否';
return h(Tag, { color: color }, () => text);
}
},
{
title: '离线铃声',
dataIndex: 'sound'
},
{
title: '自定义通知传输数据',
dataIndex: 'custom'
},
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'title',
label: '通知标题',
component: 'Input',
componentProps: {
placeholder: '请输入通知标题',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'pushTypeId',
label: '推送类型',
component: 'ApiSelect',
componentProps: {
disabled: true,
api: listPushType,
params: {
size: 99
},
labelField: 'name',
valueField: 'id',
resultField: 'data'
},
},
{
field: 'status',
label: '推送状态',
component: 'Select',
colProps: {
span: 12
},
componentProps: {
disabled: true,
options: [
{ label: '待审核', value: '0' },
{ label: '未读', value: '1' },
{ label: '已读', value: '2' }
]
}
},
{
field: 'aliasType',
label: '别名类型',
component: 'Input',
colProps: {
span: 12
},
componentProps: {
disabled: true
}
},
{
field: 'alias',
label: '推送别名',
component: 'Input',
colProps: {
span: 12
},
componentProps: {
disabled: true
}
},
{
field: 'title',
label: '通知标题',
component: 'Input',
componentProps: {
disabled: true
}
},
{
field: 'text',
label: '通知内容',
component: 'Input',
componentProps: {
disabled: true
}
},
{
field: 'playSound',
label: '播放声音',
component: 'RadioGroup',
defaultValue: '0',
componentProps: {
disabled: true,
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'playVibrate',
label: '震动',
component: 'RadioGroup',
defaultValue: '0',
componentProps: {
disabled: true,
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'playLights',
label: '闪光',
component: 'RadioGroup',
defaultValue: '0',
componentProps: {
disabled: true,
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'playToText',
label: '文字转语音',
component: 'RadioGroup',
defaultValue: '0',
componentProps: {
disabled: true,
options: [
{ label: '否', value: '0' },
{ label: '是', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'sound',
label: '离线铃声',
component: 'Input',
componentProps: {
disabled: true,
placeholder: '格式为R.raw.[sound]',
},
colProps: {
span: 12
}
},
{
field: 'onlineRingtone',
label: '在线铃声',
component: 'ApiSelect',
componentProps: {
disabled: true,
api: listPushRingtone,
params: {
size: 99
},
labelField: 'name',
valueField: 'id',
resultField: 'data'
},
},
{
field: 'custom',
label: '自定义通知传输数据',
component: 'InputTextArea',
componentProps: {
disabled: true,
rows: 6
},
},
];

48
src/views/common/push/pushChatMessage/index.vue

@ -11,9 +11,14 @@ @@ -11,9 +11,14 @@
@click="handleDel()"
>删除消息</a-button>
</template>
<template #action="{ record }">
<TableAction
:actions="[
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction :actions="[
{
label: '查看',
icon: 'fa6-regular:pen-to-square',
onClick: handleViewEdit.bind(null, record)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
@ -22,20 +27,29 @@ @@ -22,20 +27,29 @@
}]"
/>
</template>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ChatMessageModal @register="registerModal" @success="handleRefreshTable"/>
</div>
</template>
<script lang="ts" setup>
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔
*/
import { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushMessage, delPushMessage } from '/@/api/platform/common/controller/pushMessage';
import { columns, searchFormSchema } from './message.data';
import { listPushChatMessage, delPushChatMessage } from '/@/api/platform/common/controller/pushChatMessage';
import { useModal } from '/@/components/Modal';
import ChatMessageModal from './ChatMessageModal.vue';
import { columns, searchFormSchema } from './chatMessage.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStore } from '/@/store/modules/user';
import { useRoute } from 'vue-router';
const userStore = useUserStore();
const userInfoStore = userStore.getUserInfo;
/** 类型规范统一声明定义区域 */
interface TableState {
single: boolean;
@ -49,15 +63,17 @@ @@ -49,15 +63,17 @@
//
multiple: true
});
const router = useRoute();
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '推送消息列表',
api: listPushMessage,
api: listPushChatMessage,
rowKey: 'id',
columns,
formConfig: {
compact: true,
labelWidth: 80,
labelWidth: 60,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
@ -73,12 +89,8 @@ @@ -73,12 +89,8 @@
width: 220,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
fixed: false
},
searchInfo: {
fromUserId: userInfoStore.id
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
@ -89,6 +101,12 @@ @@ -89,6 +101,12 @@
state.multiple = !rowSelection.length;
}
/** 查看按钮操作,行内查看 */
function handleViewEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'view', record });
}
/** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) {
const ids = record?.id || getSelectRowKeys();
@ -97,7 +115,7 @@ @@ -97,7 +115,7 @@
title: '警告',
content: `是否确认删除编号为${ids}的数据?`,
onOk: async () => {
await delPushMessage(ids);
await delPushChatMessage(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}

84
src/views/common/push/pushChatMessage/message.data.ts

@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '发送方用户id',
dataIndex: 'fromUserId'
},
{
title: '消息类型',
dataIndex: 'type'
},
{
title: '别名类型',
dataIndex: 'aliasType'
},
{
title: '别名',
dataIndex: 'alias'
},
{
title: '消息显示类型',
dataIndex: 'displayType'
},
{
title: '通知标题',
dataIndex: 'title'
},
{
title: '通知文字描述',
dataIndex: 'text'
},
{
title: '别名类型',
dataIndex: 'aliasType'
},
{
title: '别名类型',
dataIndex: 'aliasType'
},
{
title: '是否播放声音',
dataIndex: 'playSound',
customRender: ({record}) => {
return ~~record?.playSound === 0 ? '是' : '否';
}
},
{
title: '是否震动',
dataIndex: 'playVibrate',
customRender: ({record}) => {
return ~~record?.playVibrate === 0 ? '是' : '否';
}
},
{
title: '是否闪光',
dataIndex: 'playLights',
customRender: ({record}) => {
return ~~record?.playLights === 0 ? '是' : '否';
}
},
{
title: '自定义播放文件名称',
dataIndex: 'customPlayFileName'
},
{
title: '自定义活动点击跳转内容',
dataIndex: 'custom'
},
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'title',
label: '通知标题',
component: 'Input',
componentProps: {
placeholder: '请输入通知标题',
},
colProps: { span: 6 }
}
];
Loading…
Cancel
Save