fix: 移动端无法上传任务文件的问题
This commit is contained in:
parent
886baa427b
commit
08372facd7
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
|
||||||
use App\Exceptions\ApiException;
|
use App\Exceptions\ApiException;
|
||||||
use App\Models\AbstractModel;
|
use App\Models\AbstractModel;
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
|
@ -1274,72 +1274,6 @@ class ProjectController extends AbstractController
|
|||||||
return Base::retSuccess('修改成功', $data);
|
return Base::retSuccess('修改成功', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @api {post} api/project/task/upload 26. 上传文件
|
|
||||||
*
|
|
||||||
* @apiDescription 需要token身份(限:项目、任务负责人)
|
|
||||||
* @apiVersion 1.0.0
|
|
||||||
* @apiGroup project
|
|
||||||
* @apiName task__upload
|
|
||||||
*
|
|
||||||
* @apiParam {Number} task_id 任务ID
|
|
||||||
* @apiParam {String} [filename] post-文件名称
|
|
||||||
* @apiParam {String} [image64] post-base64图片(二选一)
|
|
||||||
* @apiParam {File} [files] post-文件对象(二选一)
|
|
||||||
*
|
|
||||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
|
||||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
|
||||||
* @apiSuccess {Object} data 返回数据
|
|
||||||
*/
|
|
||||||
public function task__upload()
|
|
||||||
{
|
|
||||||
$user = User::auth();
|
|
||||||
//
|
|
||||||
$task_id = Base::getPostInt('task_id');
|
|
||||||
//
|
|
||||||
$task = ProjectTask::userTask($task_id, true, true);
|
|
||||||
//
|
|
||||||
$path = "uploads/task/" . $task->id . "/";
|
|
||||||
$image64 = Base::getPostValue('image64');
|
|
||||||
$fileName = Base::getPostValue('filename');
|
|
||||||
if ($image64) {
|
|
||||||
$data = Base::image64save([
|
|
||||||
"image64" => $image64,
|
|
||||||
"path" => $path,
|
|
||||||
"fileName" => $fileName,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$data = Base::upload([
|
|
||||||
"file" => Request::file('files'),
|
|
||||||
"type" => 'file',
|
|
||||||
"path" => $path,
|
|
||||||
"fileName" => $fileName,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if (Base::isError($data)) {
|
|
||||||
return Base::retError($data['msg']);
|
|
||||||
} else {
|
|
||||||
$fileData = $data['data'];
|
|
||||||
$file = ProjectTaskFile::createInstance([
|
|
||||||
'project_id' => $task->project_id,
|
|
||||||
'task_id' => $task->id,
|
|
||||||
'name' => $fileData['name'],
|
|
||||||
'size' => $fileData['size'] * 1024,
|
|
||||||
'ext' => $fileData['ext'],
|
|
||||||
'path' => $fileData['path'],
|
|
||||||
'thumb' => Base::unFillUrl($fileData['thumb']),
|
|
||||||
'userid' => $user->userid,
|
|
||||||
]);
|
|
||||||
$file->save();
|
|
||||||
//
|
|
||||||
$file = ProjectTaskFile::find($file->id);
|
|
||||||
$task->addLog("上传文件:" . $file->name);
|
|
||||||
$task->pushMsg('upload', $file);
|
|
||||||
return Base::retSuccess("上传成功", $file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/project/task/dialog 27. 创建/获取聊天室
|
* @api {get} api/project/task/dialog 27. 创建/获取聊天室
|
||||||
*
|
*
|
||||||
|
@ -30,9 +30,6 @@ class VerifyCsrfToken extends Middleware
|
|||||||
// 修改任务
|
// 修改任务
|
||||||
'api/project/task/update/',
|
'api/project/task/update/',
|
||||||
|
|
||||||
// 上传任务问题
|
|
||||||
'api/project/task/upload/',
|
|
||||||
|
|
||||||
// 聊天发文件
|
// 聊天发文件
|
||||||
'api/dialog/msg/sendfile/',
|
'api/dialog/msg/sendfile/',
|
||||||
|
|
||||||
|
@ -216,12 +216,21 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
'$route': {
|
'$route': {
|
||||||
handler (route) {
|
handler (route) {
|
||||||
if (route.query && route.query.sendmsg && this.msgText == '') {
|
if ($A.isJson(window.__sendDialogMsg) && window.__sendDialogMsg.time > $A.Time()) {
|
||||||
|
const {msgFile, msgText} = window.__sendDialogMsg;
|
||||||
|
window.__sendDialogMsg = null;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
||||||
|
this.sendFileMsg(msgFile);
|
||||||
|
} else if (msgText) {
|
||||||
|
this.sendMsg(msgText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (route.query && route.query._) {
|
||||||
let query = $A.cloneJSON(route.query);
|
let query = $A.cloneJSON(route.query);
|
||||||
delete query.sendmsg;
|
delete query._;
|
||||||
this.goForward({query}, true);
|
this.goForward({query}, true);
|
||||||
this.msgText = route.query.sendmsg;
|
|
||||||
this.$nextTick(this.sendMsg);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
|
@ -347,7 +347,7 @@
|
|||||||
</EDropdown>
|
</EDropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<TaskUpload ref="upload" class="upload"/>
|
<TaskUpload ref="upload" class="upload" @on-select-file="onSelectFile"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="taskDetail.id > 0" class="task-dialog" :style="dialogStyle">
|
<div v-show="taskDetail.id > 0" class="task-dialog" :style="dialogStyle">
|
||||||
<template v-if="hasOpenDialog">
|
<template v-if="hasOpenDialog">
|
||||||
@ -1030,8 +1030,14 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.windowMax768) {
|
if (this.windowMax768) {
|
||||||
this.goForward({path: '/manage/messenger', query: {sendmsg: this.msgText}});
|
window.__sendDialogMsg = {
|
||||||
|
time: $A.Time() + 10,
|
||||||
|
msgText: this.msgText,
|
||||||
|
msgFile: this.msgFile
|
||||||
|
};
|
||||||
|
this.msgFile = [];
|
||||||
this.msgText = "";
|
this.msgText = "";
|
||||||
|
this.goForward({path: '/manage/messenger', query: {_: $A.randomString(6)}});
|
||||||
$A.setStorage("messenger::dialogId", data.dialog_id)
|
$A.setStorage("messenger::dialogId", data.dialog_id)
|
||||||
this.$store.state.dialogOpenId = data.dialog_id;
|
this.$store.state.dialogOpenId = data.dialog_id;
|
||||||
this.$store.dispatch('openTask', 0);
|
this.$store.dispatch('openTask', 0);
|
||||||
@ -1061,9 +1067,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
msgPasteDrag(e, type) {
|
msgPasteDrag(e, type) {
|
||||||
if (this.windowMax768) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const files = type === 'drag' ? e.dataTransfer.files : e.clipboardData.files;
|
const files = type === 'drag' ? e.dataTransfer.files : e.clipboardData.files;
|
||||||
this.msgFile = Array.prototype.slice.call(files);
|
this.msgFile = Array.prototype.slice.call(files);
|
||||||
if (this.msgFile.length > 0) {
|
if (this.msgFile.length > 0) {
|
||||||
@ -1093,6 +1096,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSelectFile(file) {
|
||||||
|
this.msgFile = [file];
|
||||||
|
this.msgDialog()
|
||||||
|
},
|
||||||
|
|
||||||
deleteFile(file) {
|
deleteFile(file) {
|
||||||
this.$set(file, '_deling', false);
|
this.$set(file, '_deling', false);
|
||||||
this.$store.dispatch("forgetTaskFile", file.id)
|
this.$store.dispatch("forgetTaskFile", file.id)
|
||||||
@ -1110,9 +1118,7 @@ export default {
|
|||||||
|
|
||||||
openMenu(task) {
|
openMenu(task) {
|
||||||
const el = this.$refs[`taskMenu_${task.id}`];
|
const el = this.$refs[`taskMenu_${task.id}`];
|
||||||
if (el) {
|
el && el.handleClick()
|
||||||
el.handleClick()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
openNewWin() {
|
openNewWin() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user