Skip to content

Commit

Permalink
初步完成复制移动
Browse files Browse the repository at this point in the history
  • Loading branch information
WangNingkai committed Nov 6, 2018
1 parent 343ed5f commit c4e230f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 59 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/ManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ public function deleteItem($sign)
*/
public function copyItem(Request $request)
{
$itemId = $request->get('source');
$parentItemId = $request->get('target');
$itemId = $request->get('source_id');
$parentItemId = $request->get('target_id');
$response = $this->od->copy($itemId, $parentItemId);
return $response; // 返回复制进度链接
}
Expand All @@ -298,8 +298,8 @@ public function copyItem(Request $request)
*/
public function moveItem(Request $request)
{
$itemId = $request->get('source');
$parentItemId = $request->get('target');
$itemId = $request->get('source_id');
$parentItemId = $request->get('target_id');
$response = $this->od->move($itemId, $parentItemId);
return $response;
}
Expand Down
102 changes: 71 additions & 31 deletions resources/views/admin/other.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<label for="action">操作:</label>
<select class="custom-select" id="action" name="action">
<option value="">请选择操作</option>
<option value="copy">复制</option>
<option value="move">移动</option>
<option value="copy">复制</option>
</select>
</div>
<div class="form-group">
Expand All @@ -17,6 +17,7 @@
<span class="input-group-text">od://</span>
</div>
<input type="text" class="form-control" name="source" id="source">
<input type="hidden" name="source_id" id="source_id">
</div>
<span class="form-text text-danger">填写完整地址(包括文件名)</span>
</div>
Expand All @@ -29,8 +30,9 @@
<span class="input-group-text">od://</span>
</div>
<input type="text" class="form-control" name="target" id="target">
<input type="hidden" name="target_id" id="target_id">
</div>
<span class="form-text text-danger">移动文件请填写完整文件地址(包括文件名)不填默认为根目录</span>
<span class="form-text text-danger">移动文件请填写完整文件地址</span>
</div>
</div>
<div class="form-group invisible">
Expand All @@ -46,58 +48,96 @@
let action = $("#action").val();
let source = $("#source").val();
let target = $("#target").val();
// 移动
// 复制
// source_id = getItemId(source);
getItemId(target);
return;
if (action === '' || source === '' || target === '') {
if (source === target) {
swal('提示', '请确保源地址与目标不一致', 'warning');
return false;
}
if (action === 'move') {
// 移动
fetchItemId(source, "source_id");
fetchItemId(target, "target_id");
setTimeout(function () {
let source_id = $("#source_id").val();
let target_id = $("#target_id").val();
move(source_id, target_id);
}, 2000);
} else if (action === 'copy') {
// 复制
if (source === '' || target === '') {
swal('提示', '源地址与目标地址错误', 'warning');
return false;
}
fetchItemId(source, "source_id");
fetchItemId(target, "target_id");
setTimeout(function () {
let source_id = $("#source_id").val();
let target_id = $("#target_id").val();
copy(source_id, target_id);
}, 2000);
} else {
swal('提示', '请确保提交内容完整', 'warning');
return false;
}
url = (action === 'copy' ? Config.routes.copy : Config.routes.move);
axios.post(url, {
source: source,
target: target,
_token: Config._token
})
});
/*function getStatus(url) {
axios.get(url)
.then(function (response) {
if (response.status === 200) {
console.log(response);
// url = response.data.data.url;
// setInterval("getStatus(url)", 2000);
}
console.log(response);
})
.catch(function (error) {
console.log(error);
});
});
}*/
});
function getStatus(url) {
axios.get(url)
function fetchItemId(path, to) {
axios.post(Config.routes.path2id, {
path: path,
_token: Config._token
})
.then(function (response) {
let res = response.data;
$("#" + to).val(res.data.id);
})
.catch(function (error) {
console.log(error);
swal('提示', '源地址无效', 'warning');
});
}
function move(source_id, target_id) {
axios.post(Config.routes.move, {
source_id: source_id,
target_id: target_id,
_token: Config._token
})
.then(function (response) {
console.log(response.data);
let res = response.data;
console.log(res);
swal('移动成功');
setTimeout(window.location.reload(), 1000);
})
.catch(function (error) {
console.log(error);
swal('提示', '移动出现问题,请检查文件是否存在', 'warning');
});
}
function getItemId(path) {
axios.post(Config.routes.path2id, {
path: path,
function copy(source_id, target_id) {
axios.post(Config.routes.copy, {
source_id: source_id,
target_id: target_id,
_token: Config._token
})
.then(function (response) {
console.log(response.data);
let res = response.data;
console.log(res);
swal('复制成功');
setTimeout(window.location.reload(), 1000);
})
.catch(function (error) {
console.log(error);
swal('提示', '复制出现问题,请检查文件是否存在', 'warning');
});
}
</script>
Expand Down
32 changes: 8 additions & 24 deletions resources/views/one.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class="fa fa-plus-circle"></i> 添加
@if(!blank($path_array))
<li class="list-group-item list-group-item-action"><a
href="{{ route('home',\App\Helpers\Tool::handleUrl(\App\Helpers\Tool::getParentUrl($path_array))) }}"><i
class="fa fa-arrow-left"></i> 返回上一层</a></li>
class="fa fa-level-up"></i> 返回上一层</a></li>
@endif
@foreach($items as $item)
<li class="list-group-item list-group-item-action">
Expand Down Expand Up @@ -160,16 +160,11 @@ class="pull-right">{{ array_has($item,'folder')? '-' : \App\Helpers\Tool::conver
</div>
<div class="col">
<span class="pull-right">
@if(array_has($item,'folder'))
<a href="javascript:void(0)"
data-clipboard-text="{{ route('home',\App\Helpers\Tool::handleUrl($origin_path ? $origin_path.'/'.$item['name'] : $item['name'])) }}"
class="clipboard" title="已复制" data-toggle="tooltip"
data-placement="right"><i class="fa fa-clipboard"></i></a>&nbsp;&nbsp;
@else
@if(array_has($item,'image')))
<a href="{{ route('view',\App\Helpers\Tool::handleUrl($origin_path ? $origin_path.'/'.$item['name'] : $item['name'])) }}"
data-fancybox="image-list"><i
class="fa fa-eye" title="查看"></i></a>&nbsp;&nbsp;
@if(!array_has($item,'folder'))
@if(array_has($item,'image'))
<a href="{{ route('view',\App\Helpers\Tool::handleUrl($origin_path ? $origin_path.'/'.$item['name'] : $item['name'])) }}"
data-fancybox="image-list"><i
class="fa fa-eye" title="查看"></i></a>&nbsp;&nbsp;
@endif
@if(session()->has('LogInfo') && \App\Helpers\Tool::canEdit($item) )
<a href="{{ route('file.update',$item['id']) }}"><i
Expand All @@ -178,11 +173,6 @@ class="fa fa-pencil"></i></a>&nbsp;&nbsp;
<a href="{{ route('download',\App\Helpers\Tool::handleUrl($origin_path ? $origin_path.'/'.$item['name'] : $item['name'])) }}"><i
class="fa fa-download"
title="下载"></i></a>&nbsp;&nbsp;
<a href="javascript:void(0)"
data-clipboard-text="{{ route('download',\App\Helpers\Tool::handleUrl($origin_path ? $origin_path.'/'.$item['name'] : $item['name'])) }}"
class="clipboard"
title="已复制" data-toggle="tooltip"
data-placement="right"><i class="fa fa-clipboard"></i></a>&nbsp;&nbsp;
@endif
@if (session()->has('LogInfo'))
<a onclick="deleteItem('{{ encrypt($item['id'] . '.' . encrypt($item['eTag'])) }}')"
Expand Down Expand Up @@ -256,14 +246,8 @@ function deleteItem($sign) {
}).then((result) => {
if (result.value) {
window.open('/item/delete/' + $sign, '_blank');
} else if (
result.dismiss === swal.DismissReason.cancel
) {
swal(
'已取消',
'文件安全 :)',
'error'
)
} else if (result.dismiss === swal.DismissReason.cancel) {
swal('已取消', '文件安全 :)', 'error');
}
})
}
Expand Down

0 comments on commit c4e230f

Please sign in to comment.