6 changed files with 7 additions and 345 deletions
@ -1,78 +0,0 @@ |
|||||||
<template> |
|
||||||
<BasicModal v-bind="$attrs" |
|
||||||
width="720px" |
|
||||||
@register="registerModal" |
|
||||||
@ok="handleSubmit" |
|
||||||
> |
|
||||||
<BasicForm @register="registerForm"/> |
|
||||||
</BasicModal> |
|
||||||
</template> |
|
||||||
<script lang="ts" setup> |
|
||||||
/** |
|
||||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
||||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
|
||||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
||||||
* author entfrm开发团队-王翔 |
|
||||||
*/ |
|
||||||
import { ref, unref } from 'vue'; |
|
||||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
|
||||||
import { formSchema } from './thirdPartyManage.data'; |
|
||||||
import { addPushThirdPartyManage, editPushThirdPartyManage, getPushThirdPartyManage } from '/@/api/platform/common/controller/pushThirdPartyManage'; |
|
||||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
||||||
|
|
||||||
/** 通用变量统一声明区域 */ |
|
||||||
const tag = ref<Nullable<string>>(''); |
|
||||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
||||||
const emit = defineEmits(['success', 'register']); |
|
||||||
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
|
||||||
labelWidth: 100, |
|
||||||
schemas: formSchema, |
|
||||||
showActionButtonGroup: false, |
|
||||||
baseColProps: { span: 24 } |
|
||||||
}); |
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
|
||||||
// 处理清除脏数据 |
|
||||||
await resetFields(); |
|
||||||
await clearValidate(); |
|
||||||
// 处理设置数据 |
|
||||||
tag.value = data._tag; |
|
||||||
const refId = data.record?.id; |
|
||||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
||||||
// 采用tag标签区分操作 |
|
||||||
switch (unref(tag)) { |
|
||||||
case 'add': |
|
||||||
props.title = '新增第三方推送'; |
|
||||||
break; |
|
||||||
case 'edit': |
|
||||||
props.title = '编辑第三方推送'; |
|
||||||
await setFieldsValue(await getPushThirdPartyManage(refId)); |
|
||||||
break; |
|
||||||
} |
|
||||||
// 尾部:设置处理后的最终配置数据 |
|
||||||
setModalProps(props); |
|
||||||
}); |
|
||||||
|
|
||||||
/** 处理弹出框提交 */ |
|
||||||
async function handleSubmit() { |
|
||||||
try { |
|
||||||
// 提取验证数据 |
|
||||||
const formData = await validate(); |
|
||||||
// 处理提交之前逻辑 |
|
||||||
setModalProps({ confirmLoading: true }); |
|
||||||
// 采用tag标签区分操作 |
|
||||||
switch (unref(tag)) { |
|
||||||
case 'add': |
|
||||||
await addPushThirdPartyManage(formData); |
|
||||||
break; |
|
||||||
case 'edit': |
|
||||||
await editPushThirdPartyManage(formData); |
|
||||||
break; |
|
||||||
} |
|
||||||
// 处理提交完成之后逻辑 |
|
||||||
closeModal(); |
|
||||||
emit('success'); |
|
||||||
} finally { |
|
||||||
setModalProps({ confirmLoading: false }); |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
|
@ -1,135 +0,0 @@ |
|||||||
<template> |
|
||||||
<div> |
|
||||||
<BasicTable @register="registerTable" |
|
||||||
@selection-change="handleSelectionChange" |
|
||||||
> |
|
||||||
<template #toolbar> |
|
||||||
<a-button type="primary" |
|
||||||
@click="handleAdd()" |
|
||||||
>新增第三方推送</a-button> |
|
||||||
<a-button type="primary" |
|
||||||
:disabled="state.single" |
|
||||||
@click="handleEdit()" |
|
||||||
>修改第三方推送</a-button> |
|
||||||
<a-button type="primary" |
|
||||||
:disabled="state.multiple" |
|
||||||
@click="handleDel()" |
|
||||||
>删除第三方推送</a-button> |
|
||||||
</template> |
|
||||||
<template #action="{ record }"> |
|
||||||
<TableAction :actions="[ |
|
||||||
{ |
|
||||||
label: '编辑', |
|
||||||
icon: 'fa6-regular:pen-to-square', |
|
||||||
onClick: handleEdit.bind(null, record) |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '删除', |
|
||||||
icon: 'ant-design:delete-outlined', |
|
||||||
color: 'error', |
|
||||||
onClick: handleDel.bind(null, record) |
|
||||||
}]" |
|
||||||
/> |
|
||||||
</template> |
|
||||||
</BasicTable> |
|
||||||
<!--弹出窗体区域--> |
|
||||||
<ThirdPartyManageModal @register="registerModal" @success="handleRefreshTable"/> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
|
|
||||||
<script lang="ts" setup> |
|
||||||
/** |
|
||||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
||||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
|
||||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
||||||
* author entfrm开发团队-王翔 |
|
||||||
*/ |
|
||||||
import { reactive, toRaw } from 'vue'; |
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
|
||||||
import { listPushThirdPartyManage, delPushThirdPartyManage } from '/@/api/platform/common/controller/pushThirdPartyManage'; |
|
||||||
import { useModal } from '/@/components/Modal'; |
|
||||||
import ThirdPartyManageModal from './ThirdPartyManageModal.vue'; |
|
||||||
import { columns, searchFormSchema } from './thirdPartyManage.data'; |
|
||||||
import { useMessage } from '/@/hooks/web/useMessage'; |
|
||||||
|
|
||||||
/** 类型规范统一声明定义区域 */ |
|
||||||
interface TableState { |
|
||||||
single: boolean; |
|
||||||
multiple: boolean; |
|
||||||
} |
|
||||||
|
|
||||||
/** 通用变量统一声明区域 */ |
|
||||||
const state = reactive<TableState>({ |
|
||||||
// 非单个禁用 |
|
||||||
single: true, |
|
||||||
// 非多个禁用 |
|
||||||
multiple: true |
|
||||||
}); |
|
||||||
const { createConfirm, createMessage } = useMessage(); |
|
||||||
const [registerModal, { openModal }] = useModal(); |
|
||||||
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
|
||||||
title: '第三方推送列表', |
|
||||||
api: listPushThirdPartyManage, |
|
||||||
rowKey: 'id', |
|
||||||
columns, |
|
||||||
formConfig: { |
|
||||||
labelWidth: 120, |
|
||||||
schemas: searchFormSchema, |
|
||||||
autoSubmitOnEnter: true |
|
||||||
}, |
|
||||||
rowSelection: { type: 'checkbox' }, |
|
||||||
useSearchForm: true, |
|
||||||
showTableSetting: true, |
|
||||||
bordered: true, |
|
||||||
clickToRowSelect: false, |
|
||||||
showIndexColumn: false, |
|
||||||
actionColumn: { |
|
||||||
width: 220, |
|
||||||
title: '操作', |
|
||||||
dataIndex: 'action', |
|
||||||
slots: { customRender: 'action' }, |
|
||||||
fixed: false |
|
||||||
}, |
|
||||||
handleSearchInfoFn: () => clearSelectedRowKeys() |
|
||||||
}); |
|
||||||
|
|
||||||
/** 处理多选框选中数据 */ |
|
||||||
function handleSelectionChange(selection?: Recordable) { |
|
||||||
const rowSelection = toRaw(selection?.keys) || []; |
|
||||||
state.single = rowSelection.length != 1; |
|
||||||
state.multiple = !rowSelection.length; |
|
||||||
} |
|
||||||
|
|
||||||
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
|
||||||
function handleAdd() { |
|
||||||
openModal(true,{ _tag: 'add' }); |
|
||||||
} |
|
||||||
|
|
||||||
/** 编辑按钮操作,行内编辑 */ |
|
||||||
function handleEdit(record?: Recordable) { |
|
||||||
record = record || { id: getSelectRowKeys() }; |
|
||||||
openModal(true, { _tag: 'edit', record }); |
|
||||||
} |
|
||||||
|
|
||||||
/** 删除按钮操作,行内删除 */ |
|
||||||
async function handleDel(record?: Recordable) { |
|
||||||
const ids = record?.id || getSelectRowKeys(); |
|
||||||
createConfirm({ |
|
||||||
iconType: 'warning', |
|
||||||
title: '警告', |
|
||||||
content: `是否确认删除编号为${ids}的数据?`, |
|
||||||
onOk: async () => { |
|
||||||
await delPushThirdPartyManage(ids); |
|
||||||
createMessage.success('删除成功!'); |
|
||||||
handleRefreshTable(); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** 处理表格刷新 */ |
|
||||||
function handleRefreshTable() { |
|
||||||
clearSelectedRowKeys(); |
|
||||||
reload(); |
|
||||||
} |
|
||||||
|
|
||||||
</script> |
|
@ -1,126 +0,0 @@ |
|||||||
import { BasicColumn } from '/@/components/Table'; |
|
||||||
import { FormSchema } from '/@/components/Table'; |
|
||||||
|
|
||||||
/** 表格列配置 */ |
|
||||||
export const columns: BasicColumn[] = [ |
|
||||||
{ |
|
||||||
title: '企业名称', |
|
||||||
dataIndex: 'enterpName' |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '是否震动', |
|
||||||
dataIndex: 'isVibration', |
|
||||||
customRender: ({record}) => { |
|
||||||
return ~~record?.isVibration === 0 ? '是' : '否'; |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '是否响铃', |
|
||||||
dataIndex: 'isSound', |
|
||||||
customRender: ({record}) => { |
|
||||||
return ~~record?.isSound === 0 ? '是' : '否'; |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '自定义响铃', |
|
||||||
dataIndex: 'customSound', |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '创建人', |
|
||||||
dataIndex: 'createByName', |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '创建时间', |
|
||||||
dataIndex: 'createTime', |
|
||||||
width: 200 |
|
||||||
} |
|
||||||
]; |
|
||||||
|
|
||||||
/** 搜索表单配置 */ |
|
||||||
export const searchFormSchema: FormSchema[] = [ |
|
||||||
{ |
|
||||||
field: 'enterpName', |
|
||||||
label: '企业名称', |
|
||||||
component: 'Input', |
|
||||||
componentProps: { |
|
||||||
placeholder: '请输入企业名称', |
|
||||||
}, |
|
||||||
colProps: { span: 6 } |
|
||||||
} |
|
||||||
]; |
|
||||||
|
|
||||||
/** 表单配置 */ |
|
||||||
export const formSchema: FormSchema[] = [ |
|
||||||
{ |
|
||||||
field: 'id', |
|
||||||
label: 'ID', |
|
||||||
component: 'Input', |
|
||||||
show: false |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'enterpName', |
|
||||||
label: '企业名称', |
|
||||||
component: 'Input', |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 24 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'thirdPartyId', |
|
||||||
label: '第三方ID', |
|
||||||
component: 'Input', |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'pushTypeId', |
|
||||||
label: '推送类型ID', |
|
||||||
component: 'Input', |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'isVibration', |
|
||||||
label: '是否震动', |
|
||||||
component: 'RadioGroup', |
|
||||||
defaultValue: '0', |
|
||||||
componentProps: { |
|
||||||
options: [ |
|
||||||
{ label: '是', value: '0' }, |
|
||||||
{ label: '否', value: '1' } |
|
||||||
] |
|
||||||
}, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'isSound', |
|
||||||
label: '是否响铃', |
|
||||||
component: 'RadioGroup', |
|
||||||
defaultValue: '0', |
|
||||||
componentProps: { |
|
||||||
options: [ |
|
||||||
{ label: '是', value: '0' }, |
|
||||||
{ label: '否', value: '1' } |
|
||||||
] |
|
||||||
}, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'customSound', |
|
||||||
label: '自定义响铃', |
|
||||||
component: 'Input', |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 24 |
|
||||||
} |
|
||||||
}, |
|
||||||
]; |
|
Loading…
Reference in new issue