Browse Source

feat: 新加聊天室功能

master
wangxiang 2 years ago
parent
commit
67d5bdb2f6
  1. 2
      src/api/common/data/entity/index.ts
  2. 28
      src/api/platform/common/controller/pushChatGroup.ts
  3. 25
      src/api/platform/common/controller/pushChatGroupType.ts
  4. 13
      src/api/platform/common/entity/pushChatGroup.ts
  5. 13
      src/api/platform/common/entity/pushChatGroupType.ts
  6. 83
      src/views/common/push/pushChatGroup/ChatGroupModal.vue
  7. 122
      src/views/common/push/pushChatGroup/chatGroup.data.ts
  8. 105
      src/views/common/push/pushChatGroup/index.vue
  9. 83
      src/views/common/push/pushChatGroupAudit/ChatGroupAuditModal.vue
  10. 120
      src/views/common/push/pushChatGroupAudit/chatGroup.data.ts
  11. 100
      src/views/common/push/pushChatGroupAudit/index.vue
  12. 83
      src/views/common/push/pushChatGroupMessageAudit/ChatGroupAuditModal.vue
  13. 120
      src/views/common/push/pushChatGroupMessageAudit/chatGroup.data.ts
  14. 100
      src/views/common/push/pushChatGroupMessageAudit/index.vue
  15. 73
      src/views/common/push/pushChatGroupType/ChatGroupTypeModal.vue
  16. 99
      src/views/common/push/pushChatGroupType/chatGroupType.data.ts
  17. 137
      src/views/common/push/pushChatGroupType/index.vue

2
src/api/common/data/entity/index.ts

@ -26,7 +26,7 @@ export interface CommonEntity {
} }
/** 树结构模型 */ /** 树结构模型 */
export interface TreeEntity<T = any> { export interface TreeEntity<T = any> extends CommonEntity {
id:string; id:string;
parentId: string; parentId: string;
name: string; name: string;

28
src/api/platform/common/controller/pushChatGroup.ts

@ -0,0 +1,28 @@
/**
* api模板规范代码参考,
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-
*/
import type { PushChatGroup, PushChatGroupParams, PushChatGroupResult } from '/@/api/platform/common/entity/pushChatGroup';
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/common_proxy/common/pushChatGroup/list',
get = '/common_proxy/common/pushChatGroup',
add = '/common_proxy/common/pushChatGroup/save',
edit = '/common_proxy/common/pushChatGroup/update',
del = '/common_proxy/common/pushChatGroup/remove',
rejectAuth = '/common_proxy/common/pushChatGroup/rejectAuth',
}
export const listPushChatGroup = (params?: Partial<PushChatGroupParams>) => defHttp.get<PushChatGroup[]>({ url: Api.list, params });
export const addPushChatGroup = (params: Partial<PushChatGroup>) => defHttp.post({ url: Api.add, data: params });
export const editPushChatGroup = (params: Partial<PushChatGroup>) => defHttp.put({ url: Api.edit, data: params });
export const getPushChatGroup = (id: string) => defHttp.get<PushChatGroup>({ url: `${Api.get}/${id}` });
export const delPushChatGroup = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });
export const rejectAuthPushChatGroup = (ids: string) => defHttp.put({ url: `${Api.rejectAuth}/${ids}` });

25
src/api/platform/common/controller/pushChatGroupType.ts

@ -0,0 +1,25 @@
/**
* api模板规范代码参考,
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-
*/
import type { PushChatGroupType, PushChatGroupParams, PushChatTypeResult } from '/@/api/platform/common/entity/pushChatGroupType';
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/common_proxy/common/pushChatGroupType/list',
get = '/common_proxy/common/pushChatGroupType',
add = '/common_proxy/common/pushChatGroupType/save',
edit = '/common_proxy/common/pushChatGroupType/update',
del = '/common_proxy/common/pushChatGroupType/remove',
}
export const listPushChatGroupType = (params?: Partial<PushChatGroupParams>) => defHttp.get<PushChatTypeResult>({ url: Api.list, params }, { isReturnResultResponse: true });
export const addPushChatGroupType = (params: Partial<PushChatGroupType>) => defHttp.post({ url: Api.add, data: params });
export const editPushChatGroupType = (params: Partial<PushChatGroupType>) => defHttp.put({ url: Api.edit, data: params });
export const getPushChatGroupType = (id: string) => defHttp.get<PushChatGroupType>({ url: `${Api.get}/${id}` });
export const delPushChatGroupType = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });

13
src/api/platform/common/entity/pushChatGroup.ts

@ -0,0 +1,13 @@
import type { R } from '/#/axios';
import type { Page } from '/@/api/common/data/entity';
import { TreeEntity } from '/@/api/common/data/entity';
export type PushChatGroupParams = Page & PushChatGroup;
export interface PushChatGroup extends TreeEntity {
status: number;
typeId: string;
[key:string]: any;
}
export type PushChatGroupResult = R<PushChatGroup[]>;

13
src/api/platform/common/entity/pushChatGroupType.ts

@ -0,0 +1,13 @@
import type { R } from '/#/axios';
import type { CommonEntity, Page } from '/@/api/common/data/entity';
export type PushChatGroupParams = Page & PushChatGroupType;
export interface PushChatGroupType extends CommonEntity {
id: string;
name: string;
isReviewed: string;
[key:string]: any;
}
export type PushChatTypeResult = R<PushChatGroupType[]>;

83
src/views/common/push/pushChatGroup/ChatGroupModal.vue

@ -0,0 +1,83 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './chatGroup.data';
import { listPushChatGroup, addPushChatGroup, editPushChatGroup, getPushChatGroup } from '/@/api/platform/common/controller/pushChatGroup';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { listToTree } from '/@/utils/helper/treeHelper';
/** 通用变量统一声明区域 */
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: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
tag.value = data._tag;
const topData = { id: '0', name: '顶级聊天室', children: [] };
topData.children = listToTree(await listPushChatGroup());
await updateSchema({
field: 'parentId',
componentProps: {
treeData: [topData]
}
});
const refId = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增聊天室';
refId && await setFieldsValue({ parentId: refId });
break;
case 'edit':
props.title = '编辑聊天室';
await setFieldsValue(await getPushChatGroup(refId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushChatGroup(formData);
break;
case 'edit':
await editPushChatGroup(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

122
src/views/common/push/pushChatGroup/chatGroup.data.ts

@ -0,0 +1,122 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { listPushChatGroupType } from '/@/api/platform/common/controller/pushChatGroupType';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '聊天室名称',
dataIndex: 'name'
},
{
title: '聊天室排序',
dataIndex: 'sort',
width: 100
},
{
title: '备注',
dataIndex: 'remarks',
customRender: ({record}) => {
return record.remarks || h(Tag, { color: 'red' }, () => '暂无数据');
}
},
{
title: '创建人',
dataIndex: 'createByName'
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 200
}
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '聊天室名称',
component: 'Input',
componentProps: {
placeholder: '请输入聊天室名称',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'parentId',
label: '上级菜单',
component: 'TreeSelect',
defaultValue: '0',
required: true,
componentProps: {
allowClear: false,
fieldNames: {
label: 'name',
key: 'id',
value: 'id'
},
getPopupContainer: () => document.body
}
},
{
field: 'name',
label: '聊天室名称',
component: 'Input',
required: true,
colProps: {
span: 24
}
},
{
field: 'sort',
label: '聊天室排序',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
required: true,
colProps: {
span: 12
}
},
{
field: 'typeId',
label: '聊天室类型',
component: 'ApiSelect',
required: true,
componentProps: {
api: listPushChatGroupType,
params: { size: 30 },
resultField: 'data',
labelField: 'name',
valueField: 'id'
},
colProps: {
span: 12
}
},
{
label: '备注',
field: 'remarks',
component: 'InputTextArea',
componentProps: {
rows: 6
},
colProps: {
span: 24
}
}
];

105
src/views/common/push/pushChatGroup/index.vue

@ -0,0 +1,105 @@
<template>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleAdd()">新增聊天室</a-button>
<a-button type="default" @click="expandAll">展开全部</a-button>
<a-button type="default" @click="collapseAll">折叠全部</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction :actions="[
{
label: '编辑',
icon: 'fa6-regular:pen-to-square',
onClick: handleEdit.bind(null, record)
},
{
label: '新增',
icon: 'ant-design:plus-circle-outlined',
onClick: handleAdd.bind(null, record)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
onClick: handleDel.bind(null, record)
}]"
/>
</template>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ChatGroupModal @register="registerModal" @success="handleRefreshTable"/>
</div>
</template>
<script lang="ts" setup>
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushChatGroup, delPushChatGroup } from '/@/api/platform/common/controller/pushChatGroup';
import { useModal } from '/@/components/Modal';
import ChatGroupModal from './ChatGroupModal.vue';
import { columns, searchFormSchema } from './chatGroup.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { listToTree } from '/@/utils/helper/treeHelper';
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, expandAll, collapseAll, getDataSource }] = useTable({
title: '聊天室列表',
api: listPushChatGroup,
rowKey: 'id',
columns: columns,
formConfig: {
compact: true,
labelWidth: 80,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
},
isTreeTable: true,
pagination: false,
striped: false,
useSearchForm: true,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
canResize: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
fixed: false
},
afterFetch: result => listToTree(result),
});
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd(record?: Recordable) {
openModal(true,{ _tag: 'add', record });
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
openModal(true, { _tag: 'edit', record });
}
async function handleDel(record?: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除编号为${record?.id}的数据?`,
onOk: async () => {
await delPushChatGroup(record?.id);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
function handleRefreshTable() {
reload();
}
</script>

83
src/views/common/push/pushChatGroupAudit/ChatGroupAuditModal.vue

@ -0,0 +1,83 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './chatGroup.data';
import { listPushChatGroup, addPushChatGroup, editPushChatGroup, getPushChatGroup } from '/@/api/platform/common/controller/pushChatGroup';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { listToTree } from '/@/utils/helper/treeHelper';
/** 通用变量统一声明区域 */
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: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
tag.value = data._tag;
const topData = { id: '0', name: '顶级聊天室', children: [] };
topData.children = listToTree(await listPushChatGroup());
await updateSchema({
field: 'parentId',
componentProps: {
treeData: [topData]
}
});
const refId = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增聊天室';
refId && await setFieldsValue({ parentId: refId });
break;
case 'edit':
props.title = '编辑聊天室';
await setFieldsValue(await getPushChatGroup(refId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushChatGroup(formData);
break;
case 'edit':
await editPushChatGroup(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

120
src/views/common/push/pushChatGroupAudit/chatGroup.data.ts

@ -0,0 +1,120 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { listPushChatGroupType } from '/@/api/platform/common/controller/pushChatGroupType';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '聊天室名称',
dataIndex: 'name'
},
{
title: '聊天室排序',
dataIndex: 'sort',
width: 100
},
{
title: '备注',
dataIndex: 'remarks',
customRender: ({record}) => {
return record.remarks || h(Tag, { color: 'red' }, () => '暂无数据');
}
},
{
title: '创建人',
dataIndex: 'createByName'
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 200
}
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '聊天室名称',
component: 'Input',
componentProps: {
placeholder: '请输入聊天室名称',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'parentId',
label: '上级菜单',
component: 'TreeSelect',
defaultValue: '0',
required: true,
componentProps: {
allowClear: false,
fieldNames: {
label: 'name',
key: 'id',
value: 'id'
},
getPopupContainer: () => document.body
}
},
{
field: 'name',
label: '聊天室名称',
component: 'Input',
required: true,
colProps: {
span: 24
}
},
{
field: 'sort',
label: '聊天室排序',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
required: true,
colProps: {
span: 12
}
},
{
field: 'typeId',
label: '聊天室类型',
component: 'ApiSelect',
required: true,
componentProps: {
api: listPushChatGroupType,
params: { size: 30 },
resultField: 'data'
},
colProps: {
span: 12
}
},
{
label: '备注',
field: 'remarks',
component: 'InputTextArea',
componentProps: {
rows: 6
},
colProps: {
span: 24
}
}
];

100
src/views/common/push/pushChatGroupAudit/index.vue

@ -0,0 +1,100 @@
<template>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleAdd()">新增聊天室</a-button>
<a-button type="default" @click="expandAll">展开全部</a-button>
<a-button type="default" @click="collapseAll">折叠全部</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<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>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ChatGroupAuditModal @register="registerModal" @success="handleRefreshTable"/>
</div>
</template>
<script lang="ts" setup>
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushChatGroup, delPushChatGroup } from '/@/api/platform/common/controller/pushChatGroup';
import { useModal } from '/@/components/Modal';
import ChatGroupAuditModal from './ChatGroupAuditModal.vue';
import { columns, searchFormSchema } from './chatGroup.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { listToTree } from '/@/utils/helper/treeHelper';
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, expandAll, collapseAll, getDataSource }] = useTable({
title: '聊天室列表',
api: listPushChatGroup,
rowKey: 'id',
columns: columns,
formConfig: {
compact: true,
labelWidth: 80,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
},
isTreeTable: true,
pagination: false,
striped: false,
useSearchForm: true,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
canResize: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
fixed: false
},
afterFetch: result => listToTree(result),
});
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
openModal(true, { _tag: 'edit', record });
}
async function handleDel(record?: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除编号为${record?.id}的数据?`,
onOk: async () => {
await delPushChatGroup(record?.id);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
function handleRefreshTable() {
reload();
}
</script>

83
src/views/common/push/pushChatGroupMessageAudit/ChatGroupAuditModal.vue

@ -0,0 +1,83 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './chatGroup.data';
import { listPushChatGroup, addPushChatGroup, editPushChatGroup, getPushChatGroup } from '/@/api/platform/common/controller/pushChatGroup';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { listToTree } from '/@/utils/helper/treeHelper';
/** 通用变量统一声明区域 */
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: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
tag.value = data._tag;
const topData = { id: '0', name: '顶级聊天室', children: [] };
topData.children = listToTree(await listPushChatGroup());
await updateSchema({
field: 'parentId',
componentProps: {
treeData: [topData]
}
});
const refId = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增聊天室';
refId && await setFieldsValue({ parentId: refId });
break;
case 'edit':
props.title = '编辑聊天室';
await setFieldsValue(await getPushChatGroup(refId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushChatGroup(formData);
break;
case 'edit':
await editPushChatGroup(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

120
src/views/common/push/pushChatGroupMessageAudit/chatGroup.data.ts

@ -0,0 +1,120 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { listPushChatGroupType } from '/@/api/platform/common/controller/pushChatGroupType';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '聊天室名称',
dataIndex: 'name'
},
{
title: '聊天室排序',
dataIndex: 'sort',
width: 100
},
{
title: '备注',
dataIndex: 'remarks',
customRender: ({record}) => {
return record.remarks || h(Tag, { color: 'red' }, () => '暂无数据');
}
},
{
title: '创建人',
dataIndex: 'createByName'
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 200
}
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '聊天室名称',
component: 'Input',
componentProps: {
placeholder: '请输入聊天室名称',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'parentId',
label: '上级菜单',
component: 'TreeSelect',
defaultValue: '0',
required: true,
componentProps: {
allowClear: false,
fieldNames: {
label: 'name',
key: 'id',
value: 'id'
},
getPopupContainer: () => document.body
}
},
{
field: 'name',
label: '聊天室名称',
component: 'Input',
required: true,
colProps: {
span: 24
}
},
{
field: 'sort',
label: '聊天室排序',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
required: true,
colProps: {
span: 12
}
},
{
field: 'typeId',
label: '聊天室类型',
component: 'ApiSelect',
required: true,
componentProps: {
api: listPushChatGroupType,
params: { size: 30 },
resultField: 'data'
},
colProps: {
span: 12
}
},
{
label: '备注',
field: 'remarks',
component: 'InputTextArea',
componentProps: {
rows: 6
},
colProps: {
span: 24
}
}
];

100
src/views/common/push/pushChatGroupMessageAudit/index.vue

@ -0,0 +1,100 @@
<template>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleAdd()">新增聊天室</a-button>
<a-button type="default" @click="expandAll">展开全部</a-button>
<a-button type="default" @click="collapseAll">折叠全部</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<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>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ChatGroupAuditModal @register="registerModal" @success="handleRefreshTable"/>
</div>
</template>
<script lang="ts" setup>
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushChatGroup, delPushChatGroup } from '/@/api/platform/common/controller/pushChatGroup';
import { useModal } from '/@/components/Modal';
import ChatGroupAuditModal from './ChatGroupAuditModal.vue';
import { columns, searchFormSchema } from './chatGroup.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { listToTree } from '/@/utils/helper/treeHelper';
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, expandAll, collapseAll, getDataSource }] = useTable({
title: '聊天室列表',
api: listPushChatGroup,
rowKey: 'id',
columns: columns,
formConfig: {
compact: true,
labelWidth: 80,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
},
isTreeTable: true,
pagination: false,
striped: false,
useSearchForm: true,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
canResize: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
fixed: false
},
afterFetch: result => listToTree(result),
});
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
openModal(true, { _tag: 'edit', record });
}
async function handleDel(record?: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除编号为${record?.id}的数据?`,
onOk: async () => {
await delPushChatGroup(record?.id);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
function handleRefreshTable() {
reload();
}
</script>

73
src/views/common/push/pushChatGroupType/ChatGroupTypeModal.vue

@ -0,0 +1,73 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, toRaw, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './chatGroupType.data';
import { addPushChatGroupType, editPushChatGroupType, getPushChatGroupType } from '/@/api/platform/common/controller/pushChatGroupType';
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: BoxPayload = { _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 getPushChatGroupType(refId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushChatGroupType(formData);
break;
case 'edit':
await editPushChatGroupType(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

99
src/views/common/push/pushChatGroupType/chatGroupType.data.ts

@ -0,0 +1,99 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '类型名称',
dataIndex: 'name'
},
{
title: '是否审核',
dataIndex: 'isReviewed',
width: 80,
customRender: ({ record }) => {
const playSound = record?.isReviewed;
const enable = ~~playSound === 1;
const color = enable ? 'green' : 'red';
const text = enable ? '是' : '否';
return h(Tag, { color: color }, () => text);
}
},
{
title: '备注',
dataIndex: 'remarks',
customRender: ({record}) => {
return record.remarks || h(Tag, { color: 'red' }, () => '暂无数据');
}
},
{
title: '创建人',
dataIndex: 'createByName'
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 200
}
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '类型名称',
component: 'Input',
componentProps: {
placeholder: '请输入聊天室类型名称',
},
colProps: { span: 6 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'name',
label: '类型名称',
component: 'Input',
required: true,
colProps: {
span: 24
}
},
{
field: 'isReviewed',
label: '是否审核',
component: 'RadioGroup',
required: true,
defaultValue: '0',
componentProps: {
options: [
{ label: '否', value: '0' },
{ label: '是', value: '1' }
]
},
colProps: {
span: 12
}
},
{
label: '备注',
field: 'remarks',
component: 'InputTextArea',
componentProps: {
rows: 6
},
colProps: {
span: 24
}
}
];

137
src/views/common/push/pushChatGroupType/index.vue

@ -0,0 +1,137 @@
<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 #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<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>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ChatGroupTypeModal @register="registerModal" @success="handleRefreshTable"/>
</div>
</template>
<script lang="ts" setup>
import { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushChatGroupType, delPushChatGroupType } from '/@/api/platform/common/controller/pushChatGroupType';
import { useModal } from '/@/components/Modal';
import ChatGroupTypeModal from './ChatGroupTypeModal.vue';
import { columns, searchFormSchema } from './chatGroupType.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: listPushChatGroupType,
rowKey: 'id',
columns,
formConfig: {
compact: true,
labelWidth: 80,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
},
rowSelection: { type: 'checkbox' },
useSearchForm: true,
showTableSetting: true,
bordered: true,
clickToRowSelect: false,
showIndexColumn: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: '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 delPushChatGroupType(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
/** 处理表格刷新 */
function handleRefreshTable() {
clearSelectedRowKeys();
reload();
}
</script>
Loading…
Cancel
Save