5 changed files with 216 additions and 114 deletions
@ -0,0 +1,76 @@ |
|||||||
|
<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 './ringtone.data'; |
||||||
|
import { addPushRingtone, editPushRingtone, getPushRingtone } from '/@/api/platform/common/controller/pushRingtone'; |
||||||
|
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 = '编辑铃声'; |
||||||
|
let ringtone = await getPushRingtone(refId); |
||||||
|
ringtone.ringtone = String(ringtone.ringtone).split(','); |
||||||
|
await setFieldsValue(await getPushRingtone(refId)); |
||||||
|
break; |
||||||
|
} |
||||||
|
// 尾部:设置处理后的最终配置数据 |
||||||
|
setModalProps(props); |
||||||
|
}); |
||||||
|
|
||||||
|
/** 处理弹出框提交 */ |
||||||
|
async function handleSubmit() { |
||||||
|
try { |
||||||
|
// 提取验证数据 |
||||||
|
const formData = await validate(); |
||||||
|
formData.ringtone = Array(formData.ringtone).join(','); |
||||||
|
// 处理提交之前逻辑 |
||||||
|
setModalProps({ confirmLoading: true }); |
||||||
|
// 采用tag标签区分操作 |
||||||
|
switch (unref(tag)) { |
||||||
|
case 'add': |
||||||
|
await addPushRingtone(formData); |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
await editPushRingtone(formData); |
||||||
|
break; |
||||||
|
} |
||||||
|
// 处理提交完成之后逻辑 |
||||||
|
closeModal(); |
||||||
|
emit('success'); |
||||||
|
} finally { |
||||||
|
setModalProps({ confirmLoading: false }); |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
@ -1,56 +0,0 @@ |
|||||||
/** |
|
||||||
* @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,94 @@ |
|||||||
|
import { BasicColumn } from '/@/components/Table'; |
||||||
|
import { FormSchema } from '/@/components/Table'; |
||||||
|
import { h } from 'vue'; |
||||||
|
import { Tag } from 'ant-design-vue'; |
||||||
|
import { commonUpload } from '/@/api/platform/core/controller/upload'; |
||||||
|
|
||||||
|
/** 表格列配置 */ |
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: '铃声名称', |
||||||
|
dataIndex: 'name' |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '铃声地址', |
||||||
|
dataIndex: 'ringtone' |
||||||
|
}, |
||||||
|
{ |
||||||
|
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: 12 |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'ringtone', |
||||||
|
label: '上传铃声', |
||||||
|
component: 'Upload', |
||||||
|
required: true, |
||||||
|
componentProps: { |
||||||
|
multiple: false, |
||||||
|
maxSize: 20, |
||||||
|
maxNumber: 1, |
||||||
|
showUploadSaveBtn: true, |
||||||
|
showPreviewNumber: true, |
||||||
|
emptyHidePreview: true, |
||||||
|
api: commonUpload, |
||||||
|
accept: ['audio/*'] |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '备注', |
||||||
|
field: 'remarks', |
||||||
|
component: 'InputTextArea', |
||||||
|
componentProps: { |
||||||
|
rows: 6 |
||||||
|
}, |
||||||
|
colProps: { |
||||||
|
span: 24 |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
||||||
|
|
Loading…
Reference in new issue