From 07b5dcb4905a15d0b39a51219d51c57fbd5ca4d1 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期四, 28 十一月 2024 13:35:04 +0800 Subject: [PATCH] 1. 新增登录页面 2. 新增登录接口 3. 新增stores/userToken.js 保存登录状态登录和退出登录 和 stores/activeCheck.js 保存登录超时和延时函数 4. components/core/Header完善退出登录点击事件 5. 新增cookie工具类 6. 新增登录工具类 --- src/components/FYImageSelectDialog.vue | 212 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 139 insertions(+), 73 deletions(-) diff --git a/src/components/FYImageSelectDialog.vue b/src/components/FYImageSelectDialog.vue index 744b866..04bc1b3 100644 --- a/src/components/FYImageSelectDialog.vue +++ b/src/components/FYImageSelectDialog.vue @@ -1,64 +1,71 @@ <template> <el-dialog :model-value="dialogVisible" - @opened="$emit('update:dialogVisible', true)" - @closed="$emit('update:dialogVisible', false)" - width="66%" - title="浠绘剰鍥剧墖" + @opened="handleOpen" + @closed="handleClose" + top="5vh" + width="68%" destroy-on-close + :close-on-press-escape="false" > - <div class="main"> - <el-row justify="end" v-if="!readonly"> - <el-text size="small" type="info" class="m-r-8" - >鏈�澶氶�夋嫨{{ maxSelect }}寮犲浘鐗�</el-text - > - <el-button - size="small" - type="primary" - @click="handleSubmit" - :disabled="selectedImgUrlList.length == 0" - >纭畾</el-button - > - <el-button size="small" type="primary" @click="handleCancel" - >鍙栨秷</el-button - > - </el-row> + <!-- <div class="main"> --> + <el-row justify="end" v-if="!readonly"> + <el-text size="small" type="info" class="m-r-8" + >鏈�澶氶�夋嫨{{ maxSelect }}寮犲浘鐗�</el-text + > + <el-button + size="small" + type="primary" + @click="handleSubmit" + :disabled="selectedImgUrlList.length == 0" + >纭畾</el-button + > + <el-button size="small" type="primary" @click="handleCancel" + >鍙栨秷</el-button + > + </el-row> - <div class="center"> - <el-tabs v-if="typeList.length > 0" v-model="activeId" type="card"> - <el-tab-pane - v-for="item in typeList" - :key="item.typeId" - :label=" - item.typeName + ' (' + typeImgMap.get(activeId).length + ')' - " - :name="item.typeId" - > - </el-tab-pane> - </el-tabs> - <el-scrollbar + <div class="center"> + <el-tabs v-if="typeList.length > 0" v-model="activeId" type="card"> + <el-tab-pane + v-for="item in typeList" + :key="item.typeId" + :label=" + item.typeName + ' (' + typeImgMap.get(item.typeId).length + ')' + " + :name="item.typeId" + > + </el-tab-pane> + </el-tabs> + <el-scrollbar height="70vh"> + <div v-if="typeImgMap.get(activeId) && typeImgMap.get(activeId).length > 0" class="imgs" > <el-image + v-loading="img.loading" v-for="(img, i) in typeImgMap.get(activeId)" :key="i" :class="[img.isSelect ? 'selected' : 'noActive', 'image']" fit="cover" :src="img.url" - lazy + :preview-src-list="readonly ? typeImgMap.get(activeId).map((v) => v.url) : []" + :initial-index="i" @click="onSelect(img, i)" + @load="onOneImgLoadSuccess(img)" + @error="onOneImgLoadError(img)" /> - </el-scrollbar> + </div> <el-row v-else justify="space-between"> <el-empty description="鏆傛棤璁板綍" /> </el-row> - </div> + </el-scrollbar> </div> + <!-- </div> --> </el-dialog> </template> <script setup> -import { ref, watch } from 'vue'; +import { ref, watch, computed, onMounted, onUnmounted } from 'vue'; const props = defineProps({ dialogVisible: Boolean, @@ -96,6 +103,34 @@ // const typeImgMap = ref(new Map()); const selectedImgUrlList = ref([]); +let loadedImgCount = ref(0); +// 鍔犺浇鐘舵�� +const loading = computed(() => { + if (activeId.value == '') { + return false; + } + // 淇濊瘉鏈�寮�濮嬫槸鍔犺浇鐘舵�侊紝涓夊垎涔嬩竴鍔犺浇涔嬪悗鍋滄灞曠ず鍔犺浇鐘舵�� + return !( + props.typeImgMap.get(activeId.value).length / 3 <= + loadedImgCount.value + ); +}); +function onOneImgLoadError(img) { + img.loading = false; + loadedImgCount.value++; +} +function onOneImgLoadSuccess(img) { + img.loading = false; + loadedImgCount.value++; +} +watch( + () => activeId.value, + (nV, oV) => { + loadedImgCount.value = 0; + }, + { immediate: true } +); + function onSelect(img, i) { if (props.readonly) { return; @@ -122,7 +157,28 @@ img.isSelect = false; } } - +function handleOpen() { + // if (props.typeImgMap.get(activeId.value) == undefined) { + // return; + // } + // props.typeImgMap.get(activeId.value).forEach((i) => { + // if (i.isSelect == true) { + // return; + // } + // props.defaultFile.forEach((imgItem) => { + // if (imgItem.url == i.url) { + // i.isSelect = true; + // selectedImgUrlList.value.push(i); + // } + // }); + // }); + emit('update:dialogVisible', true); +} +function handleClose() { + selectedImgUrlList.value.forEach((item) => (item.isSelect = false)); + selectedImgUrlList.value = []; + emit('update:dialogVisible', false); +} function handleSubmit() { emit('submit', selectedImgUrlList.value); emit('update:dialogVisible', false); @@ -142,27 +198,47 @@ }, { immediate: true } ); +// watch( +// () => props.defaultFile, +// (nV, oV) => { +// if (props.typeImgMap.get(activeId.value) == undefined) { +// return; +// } +// props.typeImgMap.get(activeId.value).forEach((i) => { +// if (i.isSelect == true) { +// return; +// } +// nV.forEach((imgItem) => { +// if (imgItem.url == i.url) { +// i.isSelect = true; +// selectedImgUrlList.value.push(i); +// } +// }); +// }); +// }, +// { deep: true, immediate: true } +// ); -watch( - () => props.typeImgMap, - (newMap, oldMap) => { - if (newMap.get(activeId.value) == undefined) { - return; - } - newMap.get(activeId.value).forEach((i) => { - if (i.isSelect == true) { - return; - } - props.defaultFile.forEach((imgItem) => { - if (imgItem.url == i.url) { - i.isSelect = true; - selectedImgUrlList.value.push(i); - } - }); - }); - }, - { immediate: true } -); +// watch( +// () => props.typeImgMap, +// (newMap, oldMap) => { +// if (newMap.get(activeId.value) == undefined) { +// return; +// } +// newMap.get(activeId.value).forEach((i) => { +// if (i.isSelect == true) { +// return; +// } +// props.defaultFile.forEach((imgItem) => { +// if (imgItem.url == i.url) { +// i.isSelect = true; +// selectedImgUrlList.value.push(i); +// } +// }); +// }); +// }, +// { immediate: true } +// ); </script> <style scoped> .center { @@ -175,15 +251,13 @@ } .main { - margin: 0 auto; /* 浣跨埗鍏冪礌灞呬腑 */ - height: 100%; - width: 100%; + /* 浣跨埗鍏冪礌灞呬腑 */ + /* margin: 0 auto; */ + /* width: 100%; */ } .imgs { - height: 50vh; width: 100%; - min-height: 100px !important; /* border-style:solid; border-radius: 1px; */ /* height: 100%; */ @@ -197,16 +271,9 @@ .image { margin: 5px; - height: 210px; - width: 200px; + height: 250px; + width: 240px; border-radius: 4px; -} - -.active { - padding: 5px; - width: 20%; - height: 200px; - border: 0.5rem outset rgb(52, 155, 4); } .selected { @@ -252,7 +319,6 @@ } ::v-deep .el-dialog__body { - height: 60vh; padding: 10px calc(var(--el-dialog-padding-primary) + 10px) !important; } </style> -- Gitblit v1.9.3