6 changed files with 259 additions and 259 deletions
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
width="720px" |
||||
@register="registerModal" |
||||
> |
||||
<BasicForm @register="registerForm"/> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { ref } from 'vue'; |
||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||
import { formSchema } from './concern.data'; |
||||
import { getPushConcernFan } from '/@/api/platform/common/controller/pushConcernFan'; |
||||
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 }; |
||||
props.title = '查看关注用户'; |
||||
await setFieldsValue(await getPushConcernFan(refId)); |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
</script> |
@ -1,79 +0,0 @@
@@ -1,79 +0,0 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
width="720px" |
||||
@register="registerModal" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm"/> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
/** |
||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||
* author entfrm开发团队-王翔 |
||||
*/ |
||||
import { ref, unref } from 'vue'; |
||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||
import { formSchema } from './userManage.data'; |
||||
import { addPushUserManage, editPushUserManage, getPushUserManage } from '/@/api/platform/common/controller/pushUserManage'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
|
||||
/** 通用变量统一声明区域 */ |
||||
const tag = ref<Nullable<string>>(''); |
||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||
const emit = defineEmits(['success', 'register']); |
||||
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||
labelWidth: 100, |
||||
schemas: formSchema, |
||||
showActionButtonGroup: false, |
||||
baseColProps: { span: 24 } |
||||
}); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||
// 处理清除脏数据 |
||||
await resetFields(); |
||||
await clearValidate(); |
||||
// 处理设置数据 |
||||
tag.value = data._tag; |
||||
const refId = data.record?.id; |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
// 采用tag标签区分操作 |
||||
switch (unref(tag)) { |
||||
case 'add': |
||||
props.title = '新增推送'; |
||||
break; |
||||
case 'edit': |
||||
props.title = '编辑推送'; |
||||
await setFieldsValue(await getPushUserManage(refId)); |
||||
break; |
||||
} |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
/** 处理弹出框提交 */ |
||||
async function handleSubmit() { |
||||
try { |
||||
// 提取验证数据 |
||||
const formData = await validate(); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
// 采用tag标签区分操作 |
||||
switch (unref(tag)) { |
||||
case 'add': |
||||
await addPushUserManage(formData); |
||||
break; |
||||
case 'edit': |
||||
await editPushUserManage(formData); |
||||
break; |
||||
} |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
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: 'nickName' |
||||
}, |
||||
{ |
||||
title: '性别', |
||||
dataIndex: 'sex', |
||||
width: 80, |
||||
customRender: ({ record }) => { |
||||
const sex = record.sex; |
||||
const enable = ~~sex === 0; |
||||
const color = enable ? 'green' : 'red'; |
||||
const text = enable ? '男' : '女'; |
||||
return h(Tag, { color: color }, () => text); |
||||
} |
||||
}, |
||||
{ |
||||
title: '手机号', |
||||
dataIndex: 'phone' |
||||
}, |
||||
{ |
||||
title: '邮箱', |
||||
dataIndex: 'email' |
||||
}, |
||||
{ |
||||
title: '所属部门', |
||||
dataIndex: 'deptName' |
||||
}, |
||||
{ |
||||
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', |
||||
componentProps: { |
||||
disabled: true |
||||
} |
||||
}, |
||||
{ |
||||
field: 'deptName', |
||||
label: '所属部门', |
||||
component: 'Input', |
||||
colProps: { |
||||
span: 12 |
||||
}, |
||||
componentProps: { |
||||
disabled: true |
||||
} |
||||
}, |
||||
{ |
||||
field: 'sex', |
||||
label: '性别', |
||||
component: 'Select', |
||||
colProps: { |
||||
span: 12 |
||||
}, |
||||
componentProps: { |
||||
disabled: true, |
||||
options: [ |
||||
{ label: '男', value: '0' }, |
||||
{ label: '女', value: '1' } |
||||
] |
||||
}, |
||||
}, |
||||
{ |
||||
field: 'phone', |
||||
label: '手机号', |
||||
component: 'Input', |
||||
componentProps: { |
||||
disabled: true |
||||
} |
||||
}, |
||||
{ |
||||
field: 'email', |
||||
label: '邮箱', |
||||
component: 'Input', |
||||
componentProps: { |
||||
disabled: true |
||||
} |
||||
}, |
||||
]; |
@ -1,132 +0,0 @@
@@ -1,132 +0,0 @@
|
||||
import { BasicColumn } from '/@/components/Table'; |
||||
import { FormSchema } from '/@/components/Table'; |
||||
|
||||
/** 表格列配置 */ |
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '名称', |
||||
dataIndex: 'userName' |
||||
}, |
||||
{ |
||||
title: '是否播放声音', |
||||
dataIndex: 'playSound', |
||||
customRender: ({record}) => { |
||||
return ~~record?.playSound === 0 ? '是' : '否'; |
||||
} |
||||
}, |
||||
{ |
||||
title: '是否震动', |
||||
dataIndex: 'playVibrate', |
||||
customRender: ({record}) => { |
||||
return ~~record?.playVibrate === 0 ? '是' : '否'; |
||||
} |
||||
}, |
||||
{ |
||||
title: '是否闪光', |
||||
dataIndex: 'playLights', |
||||
customRender: ({record}) => { |
||||
return ~~record?.playLights === 0 ? '是' : '否'; |
||||
} |
||||
}, |
||||
{ |
||||
title: '创建人', |
||||
dataIndex: 'createByName' |
||||
}, |
||||
{ |
||||
title: '创建时间', |
||||
dataIndex: 'createTime', |
||||
width: 200 |
||||
} |
||||
]; |
||||
|
||||
/** 搜索表单配置 */ |
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'userName', |
||||
label: '名称', |
||||
component: 'Input', |
||||
componentProps: { |
||||
placeholder: '请输入名称', |
||||
}, |
||||
colProps: { span: 6 } |
||||
} |
||||
]; |
||||
|
||||
/** 表单配置 */ |
||||
export const formSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'id', |
||||
label: 'ID', |
||||
component: 'Input', |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'toUserId', |
||||
label: '对方用户id', |
||||
component: 'Input', |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'fromUserId', |
||||
label: '发送方用户id', |
||||
component: 'Input', |
||||
show: false |
||||
}, |
||||
{ |
||||
field: 'userName', |
||||
label: '名称', |
||||
component: 'Input', |
||||
required: true, |
||||
componentProps: { |
||||
disabled: true |
||||
}, |
||||
}, |
||||
{ |
||||
field: 'playSound', |
||||
label: '是否播放声音', |
||||
component: 'RadioGroup', |
||||
required: true, |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '是', value: '0' }, |
||||
{ label: '否', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'playVibrate', |
||||
label: '是否震动', |
||||
component: 'RadioGroup', |
||||
required: true, |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '是', value: '0' }, |
||||
{ label: '否', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
{ |
||||
field: 'playLights', |
||||
label: '是否闪光', |
||||
component: 'RadioGroup', |
||||
required: true, |
||||
defaultValue: '0', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '是', value: '0' }, |
||||
{ label: '否', value: '1' } |
||||
] |
||||
}, |
||||
colProps: { |
||||
span: 12 |
||||
} |
||||
}, |
||||
]; |
Loading…
Reference in new issue