Browse Source

🚀 消息推送模块

master
wangxiang 2 years ago
parent
commit
00f8e3336b
  1. 3
      src/views/common/push/pushThirdParty/index.vue
  2. 8
      src/views/common/push/pushThirdParty/thirdParty.data.ts
  3. 78
      src/views/common/push/pushThirdPartyManage/ThirdPartyManageModal.vue
  4. 135
      src/views/common/push/pushThirdPartyManage/index.vue
  5. 126
      src/views/common/push/pushThirdPartyManage/thirdPartyManage.data.ts
  6. 2
      src/views/common/push/pushTodoThirdParty/index.vue

3
src/views/common/push/pushThirdParty/index.vue vendored

@ -90,6 +90,9 @@ @@ -90,6 +90,9 @@
slots: { customRender: 'action' },
fixed: false
},
searchInfo: {
status: '1'
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});

8
src/views/common/push/pushThirdParty/thirdParty.data.ts vendored

@ -1,7 +1,5 @@ @@ -1,7 +1,5 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
/** 表格列配置 */
export const columns: BasicColumn[] = [
@ -11,7 +9,7 @@ export const columns: BasicColumn[] = [ @@ -11,7 +9,7 @@ export const columns: BasicColumn[] = [
},
{
title: '企业名称',
dataIndex: 'enterpName'
dataIndex: 'entName'
},
{
title: '手机号',
@ -34,7 +32,7 @@ export const columns: BasicColumn[] = [ @@ -34,7 +32,7 @@ export const columns: BasicColumn[] = [
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'enterpName',
field: 'entName',
label: '企业名称',
component: 'Input',
componentProps: {
@ -65,7 +63,7 @@ export const formSchema: FormSchema[] = [ @@ -65,7 +63,7 @@ export const formSchema: FormSchema[] = [
required: true,
},
{
field: 'enterpName',
field: 'entName',
label: '企业名称',
component: 'Input',
required: true,

78
src/views/common/push/pushThirdPartyManage/ThirdPartyManageModal.vue

@ -1,78 +0,0 @@ @@ -1,78 +0,0 @@
<template>
<BasicModal v-bind="$attrs"
width="720px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔
*/
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './thirdPartyManage.data';
import { addPushThirdPartyManage, editPushThirdPartyManage, getPushThirdPartyManage } from '/@/api/platform/common/controller/pushThirdPartyManage';
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 };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增第三方推送';
break;
case 'edit':
props.title = '编辑第三方推送';
await setFieldsValue(await getPushThirdPartyManage(refId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushThirdPartyManage(formData);
break;
case 'edit':
await editPushThirdPartyManage(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

135
src/views/common/push/pushThirdPartyManage/index.vue

@ -1,135 +0,0 @@ @@ -1,135 +0,0 @@
<template>
<div>
<BasicTable @register="registerTable"
@selection-change="handleSelectionChange"
>
<template #toolbar>
<a-button type="primary"
@click="handleAdd()"
>新增第三方推送</a-button>
<a-button type="primary"
:disabled="state.single"
@click="handleEdit()"
>修改第三方推送</a-button>
<a-button type="primary"
:disabled="state.multiple"
@click="handleDel()"
>删除第三方推送</a-button>
</template>
<template #action="{ record }">
<TableAction :actions="[
{
label: '编辑',
icon: 'fa6-regular:pen-to-square',
onClick: handleEdit.bind(null, record)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
onClick: handleDel.bind(null, record)
}]"
/>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ThirdPartyManageModal @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 { listPushThirdPartyManage, delPushThirdPartyManage } from '/@/api/platform/common/controller/pushThirdPartyManage';
import { useModal } from '/@/components/Modal';
import ThirdPartyManageModal from './ThirdPartyManageModal.vue';
import { columns, searchFormSchema } from './thirdPartyManage.data';
import { useMessage } from '/@/hooks/web/useMessage';
/** 类型规范统一声明定义区域 */
interface TableState {
single: boolean;
multiple: boolean;
}
/** 通用变量统一声明区域 */
const state = reactive<TableState>({
//
single: true,
//
multiple: true
});
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '第三方推送列表',
api: listPushThirdPartyManage,
rowKey: 'id',
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true
},
rowSelection: { type: 'checkbox' },
useSearchForm: true,
showTableSetting: true,
bordered: true,
clickToRowSelect: false,
showIndexColumn: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
fixed: false
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
/** 处理多选框选中数据 */
function handleSelectionChange(selection?: Recordable) {
const rowSelection = toRaw(selection?.keys) || [];
state.single = rowSelection.length != 1;
state.multiple = !rowSelection.length;
}
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record });
}
/** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) {
const ids = record?.id || getSelectRowKeys();
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除编号为${ids}的数据?`,
onOk: async () => {
await delPushThirdPartyManage(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
/** 处理表格刷新 */
function handleRefreshTable() {
clearSelectedRowKeys();
reload();
}
</script>

126
src/views/common/push/pushThirdPartyManage/thirdPartyManage.data.ts

@ -1,126 +0,0 @@ @@ -1,126 +0,0 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '企业名称',
dataIndex: 'enterpName'
},
{
title: '是否震动',
dataIndex: 'isVibration',
customRender: ({record}) => {
return ~~record?.isVibration === 0 ? '是' : '否';
}
},
{
title: '是否响铃',
dataIndex: 'isSound',
customRender: ({record}) => {
return ~~record?.isSound === 0 ? '是' : '否';
}
},
{
title: '自定义响铃',
dataIndex: 'customSound',
},
{
title: '创建人',
dataIndex: 'createByName',
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 200
}
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'enterpName',
label: '企业名称',
component: 'Input',
componentProps: {
placeholder: '请输入企业名称',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'enterpName',
label: '企业名称',
component: 'Input',
required: true,
colProps: {
span: 24
}
},
{
field: 'thirdPartyId',
label: '第三方ID',
component: 'Input',
required: true,
colProps: {
span: 12
}
},
{
field: 'pushTypeId',
label: '推送类型ID',
component: 'Input',
required: true,
colProps: {
span: 12
}
},
{
field: 'isVibration',
label: '是否震动',
component: 'RadioGroup',
defaultValue: '0',
componentProps: {
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'isSound',
label: '是否响铃',
component: 'RadioGroup',
defaultValue: '0',
componentProps: {
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'customSound',
label: '自定义响铃',
component: 'Input',
required: true,
colProps: {
span: 24
}
},
];

2
src/views/common/push/pushTodoThirdParty/index.vue vendored

@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
fixed: false
},
searchInfo: {
status: "0"
status: '0'
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});

Loading…
Cancel
Save