94 lines
3.7 KiB
HTML
94 lines
3.7 KiB
HTML
<link rel="stylesheet" href="{__METE__CSS__}/style.css">
|
|
<link rel="stylesheet" href="{__METE__}/layui/css/layui.css" />
|
|
<script src="{__METE__}/layui/layui.js"></script>
|
|
|
|
<!-- 主体 -->
|
|
<div class="create-folder">
|
|
<div class="layui-form layui-row layui-col-space16">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">当前数据id</label>
|
|
<div class="layui-input-block">
|
|
<input type="text" name="id" class="layui-input" id="current-image-id" disabled>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">单行选择框</label>
|
|
<div class="layui-input-block">
|
|
<select name="name" lay-filter="aihao">
|
|
<option value="">请选择</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="btnbar">
|
|
<button type="button" class="layui-btn" id="movefolder">移动图片</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 主体 -->
|
|
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
// 获取URL中的imageId参数
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const currentImageIds = urlParams.get('imageIds');
|
|
|
|
// 将获取到的ID赋值给输入框
|
|
document.getElementById('current-image-id').value = currentImageIds;
|
|
|
|
|
|
fetch('/picbed/index/getpicbedfolder')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.code === 0) {
|
|
const select = document.querySelector('select[name="name"]');
|
|
select.innerHTML = '<option value="">请选择</option>';
|
|
data.data.forEach(folder => {
|
|
const option = document.createElement('option');
|
|
option.value = folder.id;
|
|
option.textContent = folder.name;
|
|
select.appendChild(option);
|
|
});
|
|
layui.form.render('select');
|
|
} else {
|
|
layui.layer.msg(data.msg);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
layui.layer.msg('获取相册数据失败,请稍后重试。');
|
|
});
|
|
});
|
|
|
|
document.getElementById('movefolder').onclick = function (event) {
|
|
event.preventDefault(); // 阻止默认表单提交
|
|
const folderId = document.querySelector('select[name="name"]').value; // 获取相册ID
|
|
const imageIds = document.getElementById('current-image-id').value.split(','); // 从输入框获取多个图片的ID
|
|
|
|
fetch('/picbed/index/movefolder', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ folder: folderId, ids: imageIds }) // 提交相册ID和图片ID
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
// 处理成功响应
|
|
if (data.code === 0) {
|
|
layui.layer.msg(data.msg);
|
|
setTimeout(function () { // 添加延时关闭
|
|
var index = parent.layer.getFrameIndex(window.name);
|
|
parent.layer.close(index);
|
|
location.reload(); // 刷新界面
|
|
}, 1000); // 1秒后关闭
|
|
} else {
|
|
layui.layer.msg(data.msg);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
// 处理错误
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
</script> |