添加上传图片两张

This commit is contained in:
wangyilin 2025-01-03 11:44:48 +08:00
parent d153b4fb45
commit 311b25aa48
2 changed files with 7 additions and 7 deletions

View File

@ -9,7 +9,7 @@
/> />
<a-button class="btn-success" @click="selectFile">{{ btnLabel }}</a-button> <a-button class="btn-success" @click="selectFile">{{ btnLabel }}</a-button>
<input :id="id" type="file" style="display: none" ref="fileInput" /> <input :idFile="idFile" type="file" style="display: none" ref="fileInput" />
</div> </div>
</template> </template>
@ -34,7 +34,7 @@ const props = withDefaults(
width?: string | number; width?: string | number;
height?: string | number; height?: string | number;
btnLabel?: string; btnLabel?: string;
id: string; idFile?: string | any;
}>(), }>(),
{ {
parentDir: "", parentDir: "",
@ -43,7 +43,7 @@ const props = withDefaults(
width: "150px", width: "150px",
height: "150px", height: "150px",
btnLabel: "选择图片", btnLabel: "选择图片",
id: "myFileInput", idFile: "myFileInput",
} }
); );
@ -54,7 +54,7 @@ const uploadUrl = ref();
const fileInput = ref(null); const fileInput = ref(null);
const selectFile = () => { const selectFile = () => {
document.getElementById(props.id)?.click(); document.getElementById(props.idFile)?.click();
}; };
async function inputFileListener(this: HTMLInputElement) { async function inputFileListener(this: HTMLInputElement) {
@ -107,13 +107,13 @@ const fileDelete = () => {
}; };
onMounted(() => { onMounted(() => {
document document
.getElementById(props.id) .getElementById(props.idFile)
?.addEventListener("change", inputFileListener); ?.addEventListener("change", inputFileListener);
}); });
onUnmounted(() => { onUnmounted(() => {
document document
.getElementById(props.id) .getElementById(props.idFile)
?.removeEventListener("change", inputFileListener); ?.removeEventListener("change", inputFileListener);
}); });
defineExpose({ fileDelete }); defineExpose({ fileDelete });

View File

@ -61,7 +61,7 @@
<SingleImageFileUpload <SingleImageFileUpload
v-model:value="formDate.securityServiceLicence" v-model:value="formDate.securityServiceLicence"
ref="permitUpload" ref="permitUpload"
id="securityServiceLicenceInput" id-file="securityServiceLicenceInput"
></SingleImageFileUpload> ></SingleImageFileUpload>
<div style="color: red; text-align: left"> <div style="color: red; text-align: left">
自行招用单位备案证或保安许可证 自行招用单位备案证或保安许可证