mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 02:25:06 +08:00
feat: uploadImg 组件
This commit is contained in:
@ -12,7 +12,6 @@ export const rules = reactive({
|
||||
clientId: [required],
|
||||
secret: [required],
|
||||
name: [required],
|
||||
logo: [required],
|
||||
status: [required],
|
||||
accessTokenValiditySeconds: [required],
|
||||
refreshTokenValiditySeconds: [required],
|
||||
|
@ -61,7 +61,11 @@
|
||||
v-if="['create', 'update'].includes(actionType)"
|
||||
:schema="allSchemas.formSchema"
|
||||
:rules="rules"
|
||||
/>
|
||||
>
|
||||
<template #logo>
|
||||
<UploadImg :imgs="uploadLogo" :limit="1" />
|
||||
</template>
|
||||
</Form>
|
||||
<!-- 表单:详情 -->
|
||||
<Descriptions
|
||||
v-if="actionType === 'detail'"
|
||||
@ -138,6 +142,7 @@ import { useMessage } from '@/hooks/web/useMessage'
|
||||
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||
import { VxeGridInstance } from 'vxe-table'
|
||||
import { FormExpose } from '@/components/Form'
|
||||
import { UploadImg } from '@/components/UploadFile'
|
||||
// 业务相关的 import
|
||||
import * as ClientApi from '@/api/system/oauth2/client'
|
||||
import { rules, allSchemas } from './client.data'
|
||||
@ -159,7 +164,7 @@ const actionType = ref('') // 操作按钮的类型
|
||||
const actionLoading = ref(false) // 按钮 Loading
|
||||
const formRef = ref<FormExpose>() // 表单 Ref
|
||||
const detailRef = ref() // 详情 Ref
|
||||
|
||||
const uploadLogo = ref('')
|
||||
// 设置标题
|
||||
const setDialogTile = (type: string) => {
|
||||
dialogTitle.value = t('action.' + type)
|
||||
@ -169,6 +174,7 @@ const setDialogTile = (type: string) => {
|
||||
|
||||
// 新增操作
|
||||
const handleCreate = () => {
|
||||
uploadLogo.value = ''
|
||||
setDialogTile('create')
|
||||
}
|
||||
|
||||
@ -177,6 +183,7 @@ const handleUpdate = async (rowId: number) => {
|
||||
setDialogTile('update')
|
||||
// 设置数据
|
||||
const res = await ClientApi.getOAuth2ClientApi(rowId)
|
||||
uploadLogo.value = res.logo
|
||||
unref(formRef)?.setValues(res)
|
||||
}
|
||||
|
||||
@ -202,6 +209,7 @@ const submitForm = async () => {
|
||||
// 提交请求
|
||||
try {
|
||||
const data = unref(formRef)?.formModel as ClientApi.OAuth2ClientVO
|
||||
data.logo = uploadLogo.value
|
||||
if (actionType.value === 'create') {
|
||||
await ClientApi.createOAuth2ClientApi(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
|
Reference in New Issue
Block a user