hookehuyr

fix 上传相关组件默认值和只读问题处理

<!--
* @Date: 2022-08-31 16:16:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-02-10 11:17:21
* @LastEditTime: 2024-06-13 16:07:24
* @FilePath: /data-table/src/components/FileUploaderField/index.vue
* @Description: 文件上传控件
-->
......@@ -16,6 +16,7 @@
v-html="item.component_props.note"
style="font-size: 0.9rem; margin-left: 1rem; color: gray; padding-bottom: 0.5rem; padding-top: 0.25rem; white-space: pre-wrap;"
/>
<div v-if="!item.component_props.readonly" class="upload-wrapper">
<div>
<p
v-for="(file, index) in fileList"
......@@ -52,6 +53,17 @@
</div>
<van-divider />
</div>
<div v-else style="padding: 1rem;">
<a
v-for="(item, index) in default_file" :key="index"
:href="item.url"
:download="item.name"
style="color: #000; font-size: 0.9rem; text-decoration: underline; margin-right: 0.5rem;"
>
{{ item.name }}
</a>
</div>
</div>
<van-overlay :show="loading">
<div class="wrapper" @click.stop>
......@@ -86,6 +98,7 @@ const HideShow = computed(() => {
})
const emit = defineEmits(["active"]);
const show_empty = ref(false);
const default_file = ref(props.item.component_props.default)
// 文件类型中文页面显示
const type_text = computed(() => {
......
<!--
* @Date: 2022-08-31 16:16:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-06-06 16:50:41
* @LastEditTime: 2024-06-13 16:40:11
* @FilePath: /data-table/src/components/ImageUploaderField/index.vue
* @Description: 图片上传控件
-->
......@@ -41,10 +41,12 @@
<van-image
v-for="(item, index) in default_list" :key="index"
@click="onImgClick(index)"
width="100"
height="100"
width="80"
height="80"
fit="contain"
position="center"
:src="item"
style="margin-right: 0.5rem; margin-block-end: 0.25rem;"
style="margin-right: 0.5rem; margin-block-end: 0.25rem; border: 1px solid #eee; padding: 0.5rem;"
/>
</div>
<van-divider />
......@@ -83,20 +85,13 @@ const HideShow = computed(() => {
return !props.item.component_props.disabled
});
// 默认图片列表
const default_tmp = [{
name : "92C3D730-CB73-40DD-AB1F-E86A159D2F11.png",
url : "https://cdn.ipadbiz.cn/uploadForm/kibnjo/91b15c62bc3d002fb1c2dd2023648376.png"
}, {
name : "92C3D730-CB73-40DD-AB1F-E86A159D2F11.png",
url : "https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
}];
const default_tmp = ref(props.item.component_props.default)
const default_list = ref([]);
onMounted(() => {
// TODO: 没有默认的default字段
if (default_tmp.length) {
default_list.value = default_tmp.map(item => item.url)
console.log("🚀 ~ file: index.vue:97 ~ onMounted ~ default_list.value :", default_list.value );
// 默认图片显示
if (default_tmp.value.length) {
default_list.value = default_tmp.value.map(item => item.url)
}
})
......@@ -361,10 +356,11 @@ const validImageUploader = () => {
// 预览只读图片
const onImgClick = (i) => {
showImagePreview({
images: default_list.value,
startPosition: i,
});
// showImagePreview({
// images: default_list.value,
// startPosition: i,
// className: "my-image-preview",
// });
}
defineExpose({ validImageUploader });
......