Skip to content

Commit 30febd4

Browse files
author
Taois
committed
feat:优化文件夹选择
1 parent cd69e92 commit 30febd4

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

dashboard/src/components/actions/MultiInputAction.vue

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
}"
9393
format="YYYY-MM-DD"
9494
@change="handleDateChange(index, $event)"
95-
:popup-container="'body'"
9695
/>
9796
</div>
9897
</div>
@@ -1293,24 +1292,43 @@ export default {
12931292
12941293
// 文件夹选择处理
12951294
const handleFolderSelect = (index) => {
1295+
// 创建一个隐藏的文件夹选择器
12961296
const input = document.createElement('input')
12971297
input.type = 'file'
12981298
input.webkitdirectory = true
1299+
input.multiple = true
12991300
input.style.position = 'absolute'
13001301
input.style.left = '-9999px'
1302+
input.style.opacity = '0'
13011303
document.body.appendChild(input)
13021304
13031305
input.addEventListener('change', (e) => {
1304-
if (e.target.files && e.target.files[0]) {
1305-
// 获取文件夹路径(去掉文件名)
1306-
const path = e.target.files[0].webkitRelativePath
1307-
const folderPath = path.substring(0, path.lastIndexOf('/'))
1308-
inputValues.value[index] = folderPath || e.target.files[0].name
1306+
if (e.target.files && e.target.files.length > 0) {
1307+
// 从第一个文件的路径中提取文件夹路径
1308+
const firstFile = e.target.files[0]
1309+
const relativePath = firstFile.webkitRelativePath
1310+
1311+
if (relativePath) {
1312+
// 获取文件夹名称(第一级目录)
1313+
const folderName = relativePath.split('/')[0]
1314+
inputValues.value[index] = folderName
1315+
} else {
1316+
// 如果没有相对路径,使用文件名去掉扩展名
1317+
const fileName = firstFile.name
1318+
const folderName = fileName.substring(0, fileName.lastIndexOf('.')) || fileName
1319+
inputValues.value[index] = folderName
1320+
}
1321+
13091322
validateInput(index)
13101323
}
13111324
document.body.removeChild(input)
13121325
})
13131326
1327+
// 添加取消事件监听
1328+
input.addEventListener('cancel', () => {
1329+
document.body.removeChild(input)
1330+
})
1331+
13141332
input.click()
13151333
}
13161334
@@ -1862,9 +1880,26 @@ export default {
18621880
18631881
/* 确保日期选择器面板正确显示 */
18641882
.date-picker-modern :deep(.arco-picker-dropdown) {
1865-
z-index: 9999;
1883+
z-index: 9999 !important;
1884+
}
1885+
1886+
/* 修复日期选择器弹出层样式 */
1887+
.date-picker-modern :deep(.arco-picker-panel) {
1888+
z-index: 9999 !important;
18661889
}
18671890
1891+
.date-picker-modern :deep(.arco-picker-popup) {
1892+
z-index: 9999 !important;
1893+
}
1894+
1895+
/* 确保日期选择器容器不被遮挡 */
1896+
.date-picker-modern :deep(.arco-picker-container) {
1897+
position: relative;
1898+
z-index: 1;
1899+
}
1900+
1901+
1902+
18681903
/* 输入操作按钮 */
18691904
.input-actions {
18701905
display: flex;

0 commit comments

Comments
 (0)