|
|
|
@ -1,90 +1,94 @@ |
|
|
|
|
<template> |
|
|
|
|
<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> |
|
|
|
|
<a-form-item label="新闻首页" name="newsPage"> |
|
|
|
|
<a-input v-model:value="formState.newsPage" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="备案号" name="recordNumber"> |
|
|
|
|
<a-textarea v-model:value="formState.recordNumber" placeholder="Basic usage" :rows="4" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="版权信息" name="copyright"> |
|
|
|
|
<a-textarea v-model:value="formState.copyright" placeholder="Basic usage" :rows="4" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
<a-form-item has-feedback label="LOGO" name="logo"> |
|
|
|
|
<j-image-upload v-model:value="formState.logo" /> |
|
|
|
|
</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-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-form-item> |
|
|
|
|
<a-form-item :wrapper-col="{ span: 14, offset: 4 }"> |
|
|
|
|
<a-button type="primary" html-type="submit" @click="submit">保存</a-button> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-form> |
|
|
|
|
<div class="px-10"> |
|
|
|
|
<Modal @register="register" @confirmPath="hanConPat" /> |
|
|
|
|
</div> |
|
|
|
|
<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> |
|
|
|
|
<a-form-item label="新闻首页" name="newsPage"> |
|
|
|
|
<a-input v-model:value="formState.newsPage" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="备案号" name="recordNumber"> |
|
|
|
|
<a-textarea v-model:value="formState.recordNumber" placeholder="Basic usage" :rows="4" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="版权信息" name="copyright"> |
|
|
|
|
<a-textarea v-model:value="formState.copyright" placeholder="Basic usage" :rows="4" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
<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-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-form-item> |
|
|
|
|
<a-form-item :wrapper-col="{ span: 14, offset: 4 }"> |
|
|
|
|
<a-button type="primary" html-type="submit" @click="submit">保存</a-button> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-form> |
|
|
|
|
<div class="px-10"> |
|
|
|
|
<Modal @register="register" @confirmPath="hanConPat" /> |
|
|
|
|
</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; |
|
|
|
|
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); |
|
|
|
|
const reader = new FileReader(); |
|
|
|
|
reader.readAsDataURL(file); |
|
|
|
|
reader.onload = () => resolve(reader.result); |
|
|
|
|
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,80 +107,81 @@ 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'); |
|
|
|
|
return Promise.reject('Please input the age'); |
|
|
|
|
} |
|
|
|
|
if (!Number.isInteger(value)) { |
|
|
|
|
return Promise.reject('Please input digits'); |
|
|
|
|
return Promise.reject('Please input digits'); |
|
|
|
|
} else { |
|
|
|
|
if (value < 18) { |
|
|
|
|
return Promise.reject('Age must be greater than 18'); |
|
|
|
|
} else { |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
if (value < 18) { |
|
|
|
|
return Promise.reject('Age must be greater than 18'); |
|
|
|
|
} else { |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function submit() { |
|
|
|
|
updPathApi(formState).then(res => { |
|
|
|
|
console.log(res, 'res'); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
const validatePass = async (_rule: Rule, value: string) => { |
|
|
|
|
function submit() { |
|
|
|
|
console.log(formState); |
|
|
|
|
// return |
|
|
|
|
updPathApi(formState).then((res) => { |
|
|
|
|
console.log(res, 'res'); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
const validatePass = async (_rule: Rule, value: string) => { |
|
|
|
|
if (value === '') { |
|
|
|
|
return Promise.reject('Please input the password'); |
|
|
|
|
return Promise.reject('Please input the password'); |
|
|
|
|
} else { |
|
|
|
|
if (formState.checkPass !== '') { |
|
|
|
|
formRef.value.validateFields('checkPass'); |
|
|
|
|
} |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
if (formState.checkPass !== '') { |
|
|
|
|
formRef.value.validateFields('checkPass'); |
|
|
|
|
} |
|
|
|
|
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'); |
|
|
|
|
return Promise.reject('Please input the password again'); |
|
|
|
|
} else if (value !== formState.pass) { |
|
|
|
|
return Promise.reject("Two inputs don't match!"); |
|
|
|
|
return Promise.reject("Two inputs don't match!"); |
|
|
|
|
} else { |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
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%; |
|
|
|
|
width: 90%; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.ant-btn { |
|
|
|
|
width: 10%; |
|
|
|
|
width: 10%; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|