From 31a48e3a3c7d4e37a05ef43fa4b65c84989cc353 Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期四, 29 八月 2024 09:26:25 +0800
Subject: [PATCH] select role
---
src/components/upload/index.vue | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue
index e0c517e..3600546 100644
--- a/src/components/upload/index.vue
+++ b/src/components/upload/index.vue
@@ -5,23 +5,69 @@
:limit="limit"
:action="action"
@change="handleChange"
+ @before-remove="beforeRemove"
image-preview
/>
</template>
<script setup>
- import { ref } from 'vue';
+ import { computed, ref, onMounted, watch, watchEffect } from 'vue';
+ import { useUserStore } from '@/store';
+
+ const userStore = useUserStore();
const props = defineProps({
limit: {
type: Number,
default: 1,
},
action: String, // 涓婁紶鐨勬湇鍔″櫒鍦板潃
+ url: String, //鍥炴樉鐨勬枃浠跺湴鍧�
});
- const emit = defineEmits(['update:fileList', 'success']);
+ const emit = defineEmits(['update:fileList', 'success', 'handleRemove']);
+ const urls = computed(() => props.url);
const fileList = ref([]);
+ watch(
+ () => props.url,
+ (newVal) => {
+ if (newVal) {
+ fileList.value = newVal.split(',').map((item) => ({
+ uid: item,
+ name: item,
+ status: 'done',
+ url: item,
+ }));
+ }
+ },
+ {
+ deep: true, // 寮�鍚繁搴︾洃鍚�
+ }
+ );
+
+ onMounted(() => {
+ if (urls.value) {
+ fileList.value = urls.value.split(',').map((item) => ({
+ uid: item,
+ name: item,
+ status: 'done',
+ url: item,
+ }));
+ }
+
+ // console.log(
+ // window.location.origin,
+ // import.meta.env.VITE_API_BASE_URL,
+ // 8988
+ // );
+ });
+
+ // console.log(urls.value, 8988);
+ const beforeRemove = (file) => {
+ emit('handleRemove');
+ fileList.value = [];
+ };
+
const handleChange = (fileList) => {
emit('update:fileList', fileList);
const successFiles = fileList.filter((item) => item.status === 'done');
--
Gitblit v1.8.0