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