1.上传附件接口联调

sws 2024-08-16
v1.0.0
sws 2024-08-16 15:38:08 +08:00
parent 51b2d54925
commit ebc83554ac
3 changed files with 38 additions and 17 deletions

View File

@ -13,7 +13,7 @@
</template>
</el-image>
</div>
<div class="flex-row align-c gap-10 size-12">
<div v-if="src !== ''" class="flex-row align-c gap-10 size-12">
{{ src }}
<div class="copy" @click="clipboard_event"></div>
</div>
@ -42,10 +42,14 @@ const qrCodeUrl = ref('');
const generateQRCode = async (text: string, margin: number) => {
try {
const dataUrl = await QRCode.toDataURL(text, { margin });
let new_text = text.trim();
if (!text) {
new_text = '请先选择分组';
}
const dataUrl = await QRCode.toDataURL(new_text, { margin });
qrCodeUrl.value = dataUrl;
} catch (error) {
console.error('Error generating QR code:', error);
console.error('生成二维码时出错:', error);
}
};
const clipboard_event = async () => {
@ -59,13 +63,15 @@ const clipboard_event = async () => {
watch(
() => props.src,
(newValue) => {
generateQRCode(newValue.trim(), 2);
if (newValue !== '') {
generateQRCode(newValue, 2);
}
}
);
//
onMounted(() => {
generateQRCode(props.src.trim(), 2);
generateQRCode(props.src, 2);
});
</script>
<style lang="scss" scoped>

View File

@ -75,7 +75,7 @@
</template>
<template v-else-if="upload_type == 'file'">
<div class="bg-f5 img flex-row jc-c align-c radius h w">
<icon :name="ext_file_name_list_map.filter((ext) => ext.type == item.type).length > 0 && ext_file_name_list_map.filter((ext) => ext.type == item.type)[0].type == item.type ? ext_file_name_list_map.filter((ext) => ext.type == item.type)[0].icon : 'file'" size="42" color="9"></icon>
<icon :name="ext_file_name_list_map.filter((ext) => ext.type == item.ext).length > 0 && ext_file_name_list_map.filter((ext) => ext.type == item.ext)[0].type == item.ext ? ext_file_name_list_map.filter((ext) => ext.type == item.ext)[0].icon : 'file'" size="42" color="9"></icon>
</div>
</template>
<template v-else>
@ -296,6 +296,7 @@ const all_tree = {
id: '',
pid: '',
name: '全部',
items: [],
path: '',
is_enable: 1,
sort: '',
@ -338,9 +339,11 @@ const upload_category_confirm = () => {
};
const category_id = ref('');
//
const tree_node_event = (data: any) => {
const tree_node_event = (data: any, a: any, b: any) => {
//
// if (data.is_enable == 0) return;
//
if (data.items.length > 0) return;
category_id.value = data.id;
get_attachment_list();
};

View File

@ -12,7 +12,7 @@
<el-radio-group v-model="form.type" @change="upload_type_change">
<el-radio value="loc">本地上传</el-radio>
<el-radio value="scan">扫码上传</el-radio>
<el-radio v-if="upload_type !== 'file'" value="web"></el-radio>
<el-radio v-if="type !== 'file'" value="web"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="上传至分组" prop="category_id">
@ -105,13 +105,27 @@
<div class="table-body">
<div v-for="(item, index) in scan_file_list" :key="index" class="table-row">
<div class="table-cell">
<el-image :src="item.url" class="preview-img radius-sm" fit="contain">
<template #error>
<template v-if="type == 'video'">
<div class="preview-img radius-sm">
<icon name="video" size="12" color="9"></icon>
</div>
</template>
<template v-else-if="type == 'file'">
<div class="preview-img radius-sm">
<div class="bg-f5 img flex-row jc-c align-c radius h w">
<icon name="error-img" size="12"></icon>
<icon :name="ext_file_name_list_map.filter((ext) => ext.type == item.ext).length > 0 && ext_file_name_list_map.filter((ext) => ext.type == item.ext)[0].type == item.ext ? ext_file_name_list_map.filter((ext) => ext.type == item.ext)[0].icon : 'file'" size="12" color="9"></icon>
</div>
</template>
</el-image>
</div>
</template>
<template v-else>
<el-image :src="item.url" class="preview-img radius-sm" fit="contain">
<template #error>
<div class="bg-f5 img flex-row jc-c align-c radius h w">
<icon name="error-img" size="12"></icon>
</div>
</template>
</el-image>
</template>
<div class="desc">{{ item.title }}</div>
</div>
<div class="table-cell">{{ annex_size_to_unit(item.size) }}</div>
@ -173,11 +187,9 @@ const props = defineProps({
},
});
const dialogVisible = defineModel({ type: Boolean, default: false });
//
const upload_type = ref(props.type);
// name
const upload_type_name = computed(() => {
return upload_type.value === 'img' ? '图片' : upload_type.value === 'video' ? '视频' : '文件';
return props.type === 'img' ? '图片' : props.type === 'video' ? '视频' : '文件';
});
//
const exts_text = ref(props.exts.join(','));
@ -199,7 +211,7 @@ const form = ref<formData>({
type: 'loc',
category_id: [],
file: [],
qrcode: '******',
qrcode: '',
web_image: '',
});
const rules = reactive<FormRules>({