Browse Source

feat: 粉丝模块

master
wangxiang 2 years ago
parent
commit
703f3fd5a7
  1. 5
      src/views/common/push/pushConcern/index.vue
  2. 79
      src/views/common/push/pushFan/UserManageModal.vue
  3. 81
      src/views/common/push/pushFan/index.vue
  4. 132
      src/views/common/push/pushFan/userManage.data.ts

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

@ -20,11 +20,6 @@ @@ -20,11 +20,6 @@
</BasicTable>
</template>
<template #toolbar>
<a-button
type="primary"
:disabled="state.single"
@click="()=>{}"
>推送通知</a-button>
<a-button
type="primary"
:disabled="state.multiple"

79
src/views/common/push/pushFan/UserManageModal.vue

@ -1,79 +0,0 @@ @@ -1,79 +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 './userManage.data';
import { addPushUserManage, editPushUserManage, getPushUserManage } from '/@/api/platform/common/controller/pushUserManage';
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 getPushUserManage(refId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushUserManage(formData);
break;
case 'edit':
await editPushUserManage(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

81
src/views/common/push/pushFan/index.vue

@ -5,68 +5,53 @@ @@ -5,68 +5,53 @@
@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>
>移除粉丝</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 #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',
color: 'error',
onClick: handleDel.bind(null, record)
}]"
/>
</template>
</template>
</BasicTable>
<!--弹出窗体区域-->
<UserManageModal @register="registerModal" @success="handleRefreshTable"/>
<ConcernModal @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 { listPushUserManage, delPushUserManage } from '/@/api/platform/common/controller/pushUserManage';
import { listPushConcernFan, delPushConcernFan } from '/@/api/platform/common/controller/pushConcernFan';
import { useModal } from '/@/components/Modal';
import UserManageModal from './UserManageModal.vue';
import { columns, searchFormSchema } from './userManage.data';
import ConcernModal from '../pushConcern/ConcernModal.vue';
import { columns, searchFormSchema } from '../pushConcern/concern.data';
import { useMessage } from '/@/hooks/web/useMessage';
import {useUserStore} from '/@/store/modules/user';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const userInfoStore = userStore.getUserInfo;
/** 类型规范统一声明定义区域 */
interface TableState {
single: boolean;
multiple: boolean;
}
/** 通用变量统一声明区域 */
const state = reactive<TableState>({
//
single: true,
@ -76,8 +61,8 @@ @@ -76,8 +61,8 @@
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '推送列表',
api: listPushUserManage,
title: '粉丝列表',
api: listPushConcernFan,
rowKey: 'id',
columns,
formConfig: {
@ -98,12 +83,11 @@ @@ -98,12 +83,11 @@
width: 220,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
fixed: false
},
searchInfo: {
status: '1',
fromUserId: userInfoStore.id
concernUserId: userInfoStore.id
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
@ -115,15 +99,10 @@ @@ -115,15 +99,10 @@
state.multiple = !rowSelection.length;
}
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
/** 查看按钮操作,行内查看 */
function handleViewEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record });
openModal(true, { _tag: 'view', record });
}
/** 删除按钮操作,行内删除 */
@ -134,7 +113,7 @@ @@ -134,7 +113,7 @@
title: '警告',
content: `是否确认移除编号为${ids}的数据?`,
onOk: async () => {
await delPushUserManage(ids);
await delPushConcernFan(ids);
createMessage.success('移除成功!');
handleRefreshTable();
}

132
src/views/common/push/pushFan/userManage.data.ts

@ -1,132 +0,0 @@ @@ -1,132 +0,0 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '名称',
dataIndex: 'userName'
},
{
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: 'createByName'
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 200
}
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'userName',
label: '名称',
component: 'Input',
componentProps: {
placeholder: '请输入名称',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'toUserId',
label: '对方用户id',
component: 'Input',
show: false
},
{
field: 'fromUserId',
label: '发送方用户id',
component: 'Input',
show: false
},
{
field: 'userName',
label: '名称',
component: 'Input',
required: true,
componentProps: {
disabled: true
},
},
{
field: 'playSound',
label: '是否播放声音',
component: 'RadioGroup',
required: true,
defaultValue: '0',
componentProps: {
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'playVibrate',
label: '是否震动',
component: 'RadioGroup',
required: true,
defaultValue: '0',
componentProps: {
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
{
field: 'playLights',
label: '是否闪光',
component: 'RadioGroup',
required: true,
defaultValue: '0',
componentProps: {
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
},
colProps: {
span: 12
}
},
];
Loading…
Cancel
Save