14 changed files with 1065 additions and 1 deletions
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
/** |
||||
* @program: kicc-ui |
||||
* @description: 文件模块动态渲染配置 |
||||
* @author: entfrm开发团队-王翔 |
||||
* @create: 2022/4/21 |
||||
*/ |
||||
|
||||
import { BasicColumn } from '/@/components/Table'; |
||||
import { FormSchema } from '/@/components/Table'; |
||||
import { getFileSize } from '/@/utils/file/download'; |
||||
|
||||
/** 表格列配置 */ |
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '源文件名称', |
||||
dataIndex: 'original' |
||||
}, |
||||
{ |
||||
title: '空间名称', |
||||
dataIndex: 'bucketName' |
||||
}, |
||||
{ |
||||
title: '文件名称', |
||||
dataIndex: 'fileName' |
||||
}, |
||||
{ |
||||
title: '文件类型', |
||||
dataIndex: 'type' |
||||
}, |
||||
{ |
||||
title: '文件大小', |
||||
dataIndex: 'fileSize', |
||||
customRender: ({ record }) => getFileSize(record.fileSize) |
||||
}, |
||||
{ |
||||
title: '上传人', |
||||
dataIndex: 'createByName' |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime' |
||||
} |
||||
]; |
||||
|
||||
/** 搜索表单配置 */ |
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'fileName', |
||||
label: '文件名称', |
||||
component: 'Input', |
||||
componentProps: { |
||||
placeholder: '请输入文件名称', |
||||
}, |
||||
colProps: { span: 6 } |
||||
} |
||||
]; |
@ -0,0 +1,142 @@
@@ -0,0 +1,142 @@
|
||||
<template> |
||||
<div> |
||||
<BasicTable @register="registerTable" |
||||
@selection-change="handleSelectionChange" |
||||
> |
||||
<template #toolbar> |
||||
<BasicUpload v-model:value="state.fileList" |
||||
v-auth="['file_upload']" |
||||
:maxSize="20" |
||||
:maxNumber="10" |
||||
:showPreviewNumber="false" |
||||
:emptyHidePreview="true" |
||||
:api="commonUpload" |
||||
:accept="['image/*']" |
||||
multiple |
||||
@change="handleUploadSave" |
||||
/> |
||||
<a-button v-auth="['file_del']" |
||||
type="primary" |
||||
:disabled="state.multiple" |
||||
@click="handleDel()" |
||||
>删除</a-button> |
||||
</template> |
||||
<template #action="{ record }"> |
||||
<TableAction :actions="[ |
||||
{ |
||||
label: '文件下载', |
||||
icon: 'fa6-regular:circle-down', |
||||
auth: ['file_download'], |
||||
onClick: handleFileDownLoad.bind(null, record) |
||||
}, |
||||
{ |
||||
label: '删除', |
||||
icon: 'ant-design:delete-outlined', |
||||
color: 'error', |
||||
auth: ['file_del'], |
||||
onClick: handleDel.bind(null, record) |
||||
}]" |
||||
/> |
||||
</template> |
||||
</BasicTable> |
||||
</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 { listFile, delFile, getFile } from '/@/api/platform/system/controller/file'; |
||||
import { columns, searchFormSchema } from './file.data'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
import { commonUpload } from '/@/api/platform/core/controller/upload'; |
||||
import { BasicUpload } from '/@/components/Upload'; |
||||
|
||||
/** 类型规范统一声明定义区域 */ |
||||
interface TableState { |
||||
single: boolean; |
||||
multiple: boolean; |
||||
fileList: Recordable[]; |
||||
} |
||||
|
||||
/** 通用变量统一声明区域 */ |
||||
const state = reactive<TableState>({ |
||||
// 非单个禁用 |
||||
single: true, |
||||
// 非多个禁用 |
||||
multiple: true, |
||||
// 文件列表 |
||||
fileList: [] |
||||
}); |
||||
const { createConfirm, createMessage } = useMessage(); |
||||
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||
title: '文件列表', |
||||
api: listFile, |
||||
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 handleUploadSave(fileList: string[]) { |
||||
state.fileList = []; |
||||
handleRefreshTable(); |
||||
} |
||||
|
||||
/** 处理行内文件下载 */ |
||||
function handleFileDownLoad(record?: Recordable) { |
||||
getFile(record?.bucketName, record?.fileName).then(() => createMessage.success(`${record?.fileName}文件下载成功!`)); |
||||
} |
||||
|
||||
/** 删除按钮操作,行内删除 */ |
||||
async function handleDel(record?: Recordable) { |
||||
const ids = record?.id || getSelectRowKeys(); |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '警告', |
||||
content: `是否确认删除文件编号为${ids}文件吗?`, |
||||
onOk: async () => { |
||||
await delFile(ids); |
||||
createMessage.success('删除成功!'); |
||||
handleRefreshTable(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** 处理表格刷新 */ |
||||
function handleRefreshTable() { |
||||
clearSelectedRowKeys(); |
||||
reload(); |
||||
} |
||||
|
||||
</script> |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
<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 './application.data'; |
||||
import { addPushApplication, editPushApplication, getPushApplication } from '/@/api/platform/common/controller/pushApplication'; |
||||
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 getPushApplication(refId)); |
||||
break; |
||||
} |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
/** 处理弹出框提交 */ |
||||
async function handleSubmit() { |
||||
try { |
||||
// 提取验证数据 |
||||
const formData = await validate(); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
// 采用tag标签区分操作 |
||||
switch (unref(tag)) { |
||||
case 'add': |
||||
await addPushApplication(formData); |
||||
break; |
||||
case 'edit': |
||||
await editPushApplication(formData); |
||||
break; |
||||
} |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
<template> |
||||
<BasicModal v-bind="$attrs" |
||||
width="720px" |
||||
@register="registerModal" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm"/> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||
import { sendFormSchema } from './application.data'; |
||||
import { sendMessage } from '/@/api/platform/common/controller/pushApplication'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
import { ref } from 'vue'; |
||||
import { useUserStore } from '/@/store/modules/user'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
|
||||
const { createMessage } = useMessage(); |
||||
const messageSecret = ref<Nullable<string>>(''); |
||||
const userStore = useUserStore(); |
||||
const userInfoStore = userStore.getUserInfo; |
||||
const emit = defineEmits(['success', 'register']); |
||||
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||
labelWidth: 150, |
||||
schemas: sendFormSchema, |
||||
showActionButtonGroup: false, |
||||
baseColProps: { span: 24 } |
||||
}); |
||||
const [registerModal, { setModalProps, closeModal, redoModalHeight }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||
// 处理清除脏数据 |
||||
await resetFields(); |
||||
await clearValidate(); |
||||
messageSecret.value = data.record?.messageSecret; |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
props.title = '发送消息'; |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
redoModalHeight(); |
||||
}); |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
// 提取验证数据 |
||||
const formData = await validate(); |
||||
formData.fromUserId = userInfoStore.id; |
||||
formData.messageSecret = messageSecret.value; |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
await sendMessage(formData); |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
createMessage.success('发送成功!'); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,219 @@
@@ -0,0 +1,219 @@
|
||||
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: 'status', |
||||
width: 120, |
||||
customRender: ({record}) => { |
||||
const status = record.status; |
||||
const enable = ~~status === 0; |
||||
const color = enable ? 'green' : 'red'; |
||||
const text = enable ? '开通' : '关闭'; |
||||
return h(Tag, { color: color }, () => text); |
||||
} |
||||
}, |
||||
{ |
||||
title: '限制ip', |
||||
dataIndex: 'ip' |
||||
}, |
||||
{ |
||||
title: '创建人', |
||||
dataIndex: 'createByName' |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime', |
||||
width: 200 |
||||
}, |
||||
{ |
||||
title: '备注', |
||||
dataIndex: 'remarks', |
||||
width: 200, |
||||
customRender: ({record}) => { |
||||
return record.remarks || h(Tag, { color: 'red' }, () => '暂无数据'); |
||||
} |
||||
} |
||||
]; |
||||
|
||||
/** 搜索表单配置 */ |
||||
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: 'ip', |
||||
label: '限制ip', |
||||
component: 'Input', |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'status', |
||||
label: '状态', |
||||
component: 'RadioGroup', |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '开通', value: '0' }, |
||||
{ label: '停止', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
label: '备注', |
||||
field: 'remarks', |
||||
component: 'InputTextArea', |
||||
componentProps: { |
||||
rows: 6 |
||||
}, |
||||
colProps: { |
||||
span: 24 |
||||
} |
||||
} |
||||
]; |
||||
|
||||
export const sendFormSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'fromUserId', |
||||
label: '发送方用户id', |
||||
component: 'Input', |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'messageSecret', |
||||
label: 'app发送密钥', |
||||
component: 'Input', |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'title', |
||||
label: '标题', |
||||
component: 'Input', |
||||
required: true, |
||||
colProps: { |
||||
span: 24 |
||||
} |
||||
}, |
||||
{ |
||||
label: '通知文字描述', |
||||
field: 'text', |
||||
component: 'InputTextArea', |
||||
required: true, |
||||
componentProps: { |
||||
rows: 6 |
||||
}, |
||||
colProps: { |
||||
span: 24 |
||||
} |
||||
}, |
||||
{ |
||||
label: '自定义通知声音', |
||||
field: 'sound', |
||||
component: 'Input', |
||||
componentProps: { |
||||
placeholder: '格式为R.raw.[sound]', |
||||
}, |
||||
colProps: { |
||||
span: 24 |
||||
} |
||||
}, |
||||
{ |
||||
label: '自定义播放文件名称', |
||||
field: 'customPlayFileName', |
||||
component: 'Input', |
||||
colProps: { |
||||
span: 24 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'customTypeId', |
||||
label: '自定义推送类型ID', |
||||
component: 'Input', |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'playVibrate', |
||||
label: '收到通知是否震动', |
||||
component: 'RadioGroup', |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '是', value: '0' }, |
||||
{ label: '否', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'playLights', |
||||
label: '收到通知是否闪灯', |
||||
component: 'RadioGroup', |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '是', value: '0' }, |
||||
{ label: '否', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'playSound', |
||||
label: '收到通知是否发出声音', |
||||
component: 'RadioGroup', |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '是', value: '0' }, |
||||
{ label: '否', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
]; |
@ -0,0 +1,147 @@
@@ -0,0 +1,147 @@
|
||||
<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:message', |
||||
onClick: handleSend.bind(null, record) |
||||
}, |
||||
{ |
||||
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> |
||||
<!--弹出窗体区域--> |
||||
<ApplicationModal @register="registerModal" @success="handleRefreshTable"/> |
||||
<SendMessageModal @register="registerSendModal"/> |
||||
</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 { listPushApplication, delPushApplication } from '/@/api/platform/common/controller/pushApplication'; |
||||
import { useModal } from '/@/components/Modal'; |
||||
import ApplicationModal from './ApplicationModal.vue'; |
||||
import SendMessageModal from './SendMessageModal.vue'; |
||||
import { columns, searchFormSchema } from './application.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 [registerSendModal, { openModal: openSendModal }] = useModal(); |
||||
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||
title: '推送应用列表', |
||||
api: listPushApplication, |
||||
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 }); |
||||
} |
||||
|
||||
function handleSend(record?: Recordable) { |
||||
openSendModal(true, { record }); |
||||
} |
||||
|
||||
/** 删除按钮操作,行内删除 */ |
||||
async function handleDel(record?: Recordable) { |
||||
const ids = record?.id || getSelectRowKeys(); |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '警告', |
||||
content: `是否确认删除编号为${ids}的数据?`, |
||||
onOk: async () => { |
||||
await delPushApplication(ids); |
||||
createMessage.success('删除成功!'); |
||||
handleRefreshTable(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** 处理表格刷新 */ |
||||
function handleRefreshTable() { |
||||
clearSelectedRowKeys(); |
||||
reload(); |
||||
} |
||||
|
||||
</script> |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
<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> |
@ -0,0 +1,135 @@
@@ -0,0 +1,135 @@
|
||||
<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> |
||||
<!--弹出窗体区域--> |
||||
<UserManageModal @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 { useModal } from '/@/components/Modal'; |
||||
import UserManageModal from './UserManageModal.vue'; |
||||
import { columns, searchFormSchema } from './userManage.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: listPushUserManage, |
||||
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 delPushUserManage(ids); |
||||
createMessage.success('删除成功!'); |
||||
handleRefreshTable(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** 处理表格刷新 */ |
||||
function handleRefreshTable() { |
||||
clearSelectedRowKeys(); |
||||
reload(); |
||||
} |
||||
|
||||
</script> |
@ -0,0 +1,148 @@
@@ -0,0 +1,148 @@
|
||||
import { BasicColumn } from '/@/components/Table'; |
||||
import { FormSchema } from '/@/components/Table'; |
||||
|
||||
/** 表格列配置 */ |
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '用户昵称', |
||||
dataIndex: 'nickName' |
||||
}, |
||||
{ |
||||
title: '性别', |
||||
dataIndex: 'sex', |
||||
customRender: ({record}) => { |
||||
return ~~record?.isVibration === 0 ? '男' : '女'; |
||||
} |
||||
}, |
||||
{ |
||||
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: 'nickName', |
||||
label: '用户昵称', |
||||
component: 'Input', |
||||
componentProps: { |
||||
placeholder: '请输入用户昵称', |
||||
}, |
||||
colProps: { span: 6 } |
||||
} |
||||
]; |
||||
|
||||
/** 表单配置 */ |
||||
export const formSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'id', |
||||
label: 'ID', |
||||
component: 'Input', |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'nickName', |
||||
label: '用户昵称', |
||||
component: 'Input', |
||||
required: true, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'sex', |
||||
label: '性别', |
||||
component: 'Select', |
||||
required: true, |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '男', value: '0' }, |
||||
{ label: '女', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'userId', |
||||
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 |
||||
} |
||||
}, |
||||
]; |
Loading…
Reference in new issue