17 changed files with 1305 additions and 1 deletions
@ -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}` }); |
@ -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}` }); |
@ -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[]>; |
@ -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[]>; |
@ -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> |
@ -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 |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
@ -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> |
@ -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> |
@ -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 |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
@ -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> |
@ -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> |
@ -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 |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
@ -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> |
@ -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> |
@ -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 |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
@ -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…
Reference in new issue