|
|
|
@ -1,6 +1,13 @@ |
|
|
|
|
<template> |
|
|
|
|
<a-form ref="formRef" name="custom-validation" :model="formState" v-bind="layout" @finish="handleFinish" |
|
|
|
|
@validate="handleValidate" @finishFailed="handleFinishFailed"> |
|
|
|
|
<a-form |
|
|
|
|
ref="formRef" |
|
|
|
|
name="custom-validation" |
|
|
|
|
:model="formState" |
|
|
|
|
v-bind="layout" |
|
|
|
|
@finish="handleFinish" |
|
|
|
|
@validate="handleValidate" |
|
|
|
|
@finishFailed="handleFinishFailed" |
|
|
|
|
> |
|
|
|
|
<a-form-item label="名称" name="name"> |
|
|
|
|
<a-input v-model:value="formState.name" /> |
|
|
|
|
</a-form-item> |
|
|
|
@ -17,15 +24,16 @@ |
|
|
|
|
<a-form-item has-feedback label="LOGO" name="logo"> |
|
|
|
|
<j-image-upload v-model:value="formState.logo" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item has-feedback label="banner" name="banner"> |
|
|
|
|
<j-image-upload v-model:value="formState.banner" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item class="h-item" has-feedback label="作品上传路径" name="composition"> |
|
|
|
|
<a-input v-model:value="formState.composition" type="text" autocomplete="off" /> |
|
|
|
|
<a-button :icon="h(FolderOpenOutlined)" |
|
|
|
|
@click="openModal(true, { path: 'sadsad', target: 'composition' })">浏览</a-button> |
|
|
|
|
<a-button :icon="h(FolderOpenOutlined)" @click="openModal(true, { path: 'sadsad', target: 'composition' })">浏览</a-button> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item class="h-item" has-feedback label="比赛证书上传路径" name="certificate"> |
|
|
|
|
<a-input v-model:value="formState.certificate" type="text" autocomplete="off" /> |
|
|
|
|
<a-button :icon="h(FolderOpenOutlined)" |
|
|
|
|
@click="openModal(true, { path: 'sadsad', target: 'certificate' })">浏览</a-button> |
|
|
|
|
<a-button :icon="h(FolderOpenOutlined)" @click="openModal(true, { path: 'sadsad', target: 'certificate' })">浏览</a-button> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item :wrapper-col="{ span: 14, offset: 4 }"> |
|
|
|
|
<a-button type="primary" html-type="submit" @click="submit">保存</a-button> |
|
|
|
@ -36,55 +44,51 @@ |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue'; |
|
|
|
|
import { useModal } from '/@/components/Modal'; |
|
|
|
|
import Modal from './Modal.vue'; |
|
|
|
|
import { PlusOutlined } from '@ant-design/icons-vue'; |
|
|
|
|
import type { UploadProps } from 'ant-design-vue'; |
|
|
|
|
|
|
|
|
|
import { FolderOpenOutlined } from '@ant-design/icons-vue'; |
|
|
|
|
import { reactive, ref, h } from 'vue'; |
|
|
|
|
import type { Rule } from 'ant-design-vue/es/form'; |
|
|
|
|
import type { FormInstance } from 'ant-design-vue'; |
|
|
|
|
import { getDataListApi, updPathApi } from '/@/api/sys/user'; |
|
|
|
|
getDataListApi().then(res => { |
|
|
|
|
import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue'; |
|
|
|
|
import { useModal } from '/@/components/Modal'; |
|
|
|
|
import Modal from './Modal.vue'; |
|
|
|
|
import { PlusOutlined } from '@ant-design/icons-vue'; |
|
|
|
|
import type { UploadProps } from 'ant-design-vue'; |
|
|
|
|
|
|
|
|
|
import { FolderOpenOutlined } from '@ant-design/icons-vue'; |
|
|
|
|
import { reactive, ref, h } from 'vue'; |
|
|
|
|
import type { Rule } from 'ant-design-vue/es/form'; |
|
|
|
|
import type { FormInstance } from 'ant-design-vue'; |
|
|
|
|
import { getDataListApi, updPathApi } from '/@/api/sys/user'; |
|
|
|
|
getDataListApi().then((res) => { |
|
|
|
|
Object.assign(formState, res.records[0]); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const fileList = ref<UploadProps['fileList']>([]); |
|
|
|
|
const fileList = ref<UploadProps['fileList']>([]); |
|
|
|
|
|
|
|
|
|
const handleCancel = () => { |
|
|
|
|
const handleCancel = () => { |
|
|
|
|
previewVisible.value = false; |
|
|
|
|
previewTitle.value = ''; |
|
|
|
|
}; |
|
|
|
|
const handlePreview = async (file: UploadProps['fileList'][number]) => { |
|
|
|
|
}; |
|
|
|
|
const handlePreview = async (file: UploadProps['fileList'][number]) => { |
|
|
|
|
if (!file.url && !file.preview) { |
|
|
|
|
file.preview = (await getBase64(file.originFileObj)) as string; |
|
|
|
|
} |
|
|
|
|
previewImage.value = file.url || file.preview; |
|
|
|
|
previewVisible.value = true; |
|
|
|
|
previewTitle.value = file.name || file.url.substring(file.url.lastIndexOf('/') + 1); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// LOGO upload |
|
|
|
|
function getBase64(file: File) { |
|
|
|
|
// LOGO upload |
|
|
|
|
function getBase64(file: File) { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
const reader = new FileReader(); |
|
|
|
|
reader.readAsDataURL(file); |
|
|
|
|
reader.onload = () => resolve(reader.result); |
|
|
|
|
reader.onerror = error => reject(error); |
|
|
|
|
reader.onerror = (error) => reject(error); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const previewVisible = ref(false); |
|
|
|
|
const previewImage = ref(''); |
|
|
|
|
const previewTitle = ref(''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const previewVisible = ref(false); |
|
|
|
|
const previewImage = ref(''); |
|
|
|
|
const previewTitle = ref(''); |
|
|
|
|
|
|
|
|
|
interface FormState { |
|
|
|
|
interface FormState { |
|
|
|
|
name: string; |
|
|
|
|
logo: any; |
|
|
|
|
newsPage: string; |
|
|
|
@ -92,9 +96,10 @@ interface FormState { |
|
|
|
|
copyright: string; |
|
|
|
|
certificate: string; |
|
|
|
|
composition: string; |
|
|
|
|
} |
|
|
|
|
const formRef = ref<FormInstance>(); |
|
|
|
|
const formState = reactive<FormState>({ |
|
|
|
|
banner: string; |
|
|
|
|
} |
|
|
|
|
const formRef = ref<FormInstance>(); |
|
|
|
|
const formState = reactive<FormState>({ |
|
|
|
|
name: '', |
|
|
|
|
logo: previewImage.value, |
|
|
|
|
newsPage: '', |
|
|
|
@ -102,8 +107,9 @@ const formState = reactive<FormState>({ |
|
|
|
|
copyright: '', |
|
|
|
|
certificate: '', |
|
|
|
|
composition: '', |
|
|
|
|
}); |
|
|
|
|
const checkAge = async (_rule: Rule, value: number) => { |
|
|
|
|
banner: '', |
|
|
|
|
}); |
|
|
|
|
const checkAge = async (_rule: Rule, value: number) => { |
|
|
|
|
if (!value) { |
|
|
|
|
return Promise.reject('Please input the age'); |
|
|
|
|
} |
|
|
|
@ -116,14 +122,16 @@ const checkAge = async (_rule: Rule, value: number) => { |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function submit() { |
|
|
|
|
updPathApi(formState).then(res => { |
|
|
|
|
function submit() { |
|
|
|
|
console.log(formState); |
|
|
|
|
// return |
|
|
|
|
updPathApi(formState).then((res) => { |
|
|
|
|
console.log(res, 'res'); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
const validatePass = async (_rule: Rule, value: string) => { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
const validatePass = async (_rule: Rule, value: string) => { |
|
|
|
|
if (value === '') { |
|
|
|
|
return Promise.reject('Please input the password'); |
|
|
|
|
} else { |
|
|
|
@ -132,8 +140,8 @@ const validatePass = async (_rule: Rule, value: string) => { |
|
|
|
|
} |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
const validatePass2 = async (_rule: Rule, value: string) => { |
|
|
|
|
}; |
|
|
|
|
const validatePass2 = async (_rule: Rule, value: string) => { |
|
|
|
|
if (value === '') { |
|
|
|
|
return Promise.reject('Please input the password again'); |
|
|
|
|
} else if (value !== formState.pass) { |
|
|
|
@ -141,35 +149,33 @@ const validatePass2 = async (_rule: Rule, value: string) => { |
|
|
|
|
} else { |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const layout = { |
|
|
|
|
const layout = { |
|
|
|
|
labelCol: { span: 4 }, |
|
|
|
|
wrapperCol: { span: 14 }, |
|
|
|
|
}; |
|
|
|
|
const handleFinish = (values: FormState) => { |
|
|
|
|
}; |
|
|
|
|
const handleFinish = (values: FormState) => { |
|
|
|
|
console.log(values, formState); |
|
|
|
|
}; |
|
|
|
|
const handleFinishFailed = errors => { |
|
|
|
|
}; |
|
|
|
|
const handleFinishFailed = (errors) => { |
|
|
|
|
console.log(errors); |
|
|
|
|
}; |
|
|
|
|
const resetForm = () => { |
|
|
|
|
}; |
|
|
|
|
const resetForm = () => { |
|
|
|
|
formRef.value.resetFields(); |
|
|
|
|
}; |
|
|
|
|
const handleValidate = (...args) => { |
|
|
|
|
}; |
|
|
|
|
const handleValidate = (...args) => { |
|
|
|
|
console.log(args); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 弹窗 |
|
|
|
|
const [register, { openModal }] = useModal(); |
|
|
|
|
function hanConPat(currentlySelecte, target) { |
|
|
|
|
// 弹窗 |
|
|
|
|
const [register, { openModal }] = useModal(); |
|
|
|
|
function hanConPat(currentlySelecte, target) { |
|
|
|
|
formState[target] = currentlySelecte; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
<style scoped lang="less"> |
|
|
|
|
.h-item { |
|
|
|
|
.h-item { |
|
|
|
|
.ant-input { |
|
|
|
|
width: 90%; |
|
|
|
|
} |
|
|
|
@ -177,5 +183,5 @@ function hanConPat(currentlySelecte, target) { |
|
|
|
|
.ant-btn { |
|
|
|
|
width: 10%; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |