优化了一些代码

This commit is contained in:
kuaifan 2022-01-28 17:45:48 +08:00
parent 02eb386155
commit 21e618cca2
13 changed files with 86 additions and 178 deletions

View File

@ -623,6 +623,8 @@ class FileController extends AbstractController
'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx' => "code", 'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx' => "code",
'mp3', 'wav', 'mp4', 'flv', 'mp3', 'wav', 'mp4', 'flv',
'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm' => "media", 'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm' => "media",
'xmind' => "xmind",
'rp' => "axure",
default => "", default => "",
}; };
$file = File::createInstance([ $file = File::createInstance([

View File

@ -1328,72 +1328,6 @@ class ProjectController extends AbstractController
return Base::retSuccess('修改成功', $data); return Base::retSuccess('修改成功', $data);
} }
/**
* @api {post} api/project/task/upload 27. 上传文件
*
* @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 28. 创建/获取聊天室 * @api {get} api/project/task/dialog 28. 创建/获取聊天室
* *
@ -1653,7 +1587,7 @@ class ProjectController extends AbstractController
/** /**
* @api {get} api/project/flow/list 33. 工作流列表 * @api {get} api/project/flow/list 33. 工作流列表
* *
* @apiDescription 需要token身份(限:项目负责人) * @apiDescription 需要token身份
* @apiVersion 1.0.0 * @apiVersion 1.0.0
* @apiGroup project * @apiGroup project
* @apiName flow__list * @apiName flow__list
@ -1669,9 +1603,8 @@ class ProjectController extends AbstractController
User::auth(); User::auth();
// //
$project_id = intval(Request::input('project_id')); $project_id = intval(Request::input('project_id'));
$is_filter = intval(Request::input('is_filter',0));
// //
$project = Project::userProject($project_id, true, true, $is_filter); $project = Project::userProject($project_id, true);
// //
$list = ProjectFlow::with(['ProjectFlowItem'])->whereProjectId($project->id)->get(); $list = ProjectFlow::with(['ProjectFlowItem'])->whereProjectId($project->id)->get();
return Base::retSuccess('success', $list); return Base::retSuccess('success', $list);

View File

@ -354,11 +354,10 @@ class Project extends AbstractModel
* 获取项目信息(用于判断会员是否存在项目内) * 获取项目信息(用于判断会员是否存在项目内)
* @param int $project_id * @param int $project_id
* @param null|bool $archived true:仅限未归档, false:仅限已归档, null:不限制 * @param null|bool $archived true:仅限未归档, false:仅限已归档, null:不限制
* @param null $mustOwner true:仅限项目负责人, false:仅限非项目负责人, null:不限制 * @param null|bool $mustOwner true:仅限项目负责人, false:仅限非项目负责人, null:不限制
* @param int $is_filter 是否是用筛选列表
* @return self * @return self
*/ */
public static function userProject($project_id, $archived = true, $mustOwner = null, $is_filter = 0) public static function userProject($project_id, $archived = true, $mustOwner = null)
{ {
$project = self::authData()->where('projects.id', intval($project_id))->first(); $project = self::authData()->where('projects.id', intval($project_id))->first();
if (empty($project)) { if (empty($project)) {
@ -370,10 +369,10 @@ class Project extends AbstractModel
if ($archived === false && $project->archived_at == null) { if ($archived === false && $project->archived_at == null) {
throw new ApiException('项目未归档', [ 'project_id' => $project_id ]); throw new ApiException('项目未归档', [ 'project_id' => $project_id ]);
} }
if ($mustOwner === true && !$project->owner && $is_filter === 0) { if ($mustOwner === true && !$project->owner) {
throw new ApiException('仅限项目负责人操作', [ 'project_id' => $project_id ]); throw new ApiException('仅限项目负责人操作', [ 'project_id' => $project_id ]);
} }
if ($mustOwner === false && $project->owner && $is_filter === 0) { if ($mustOwner === false && $project->owner) {
throw new ApiException('禁止项目负责人操作', [ 'project_id' => $project_id ]); throw new ApiException('禁止项目负责人操作', [ 'project_id' => $project_id ]);
} }
return $project; return $project;

View File

@ -46,9 +46,6 @@ class WebSocketDialogMsg extends AbstractModel
'updated_at', 'updated_at',
]; ];
const MSG_TYPE_TEXT = "text";
const MSG_TYPE_FILE = "file";
/** /**
* 阅读占比 * 阅读占比
* @return int|mixed * @return int|mixed

View File

@ -2263,7 +2263,8 @@ class Base
'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx', 'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx',
'mp3', 'wav', 'mp4', 'flv', 'mp3', 'wav', 'mp4', 'flv',
'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm', 'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm',
'xmind', 'rp', 'xmind',
'rp',
]; ];
break; break;
default: default:

View File

@ -13,15 +13,8 @@
<Input v-if="$Electron && cacheServerUrl" :value="$A.getDomain(cacheServerUrl)" prefix="ios-globe-outline" size="large" readonly clearable @on-clear="clearServerUrl"/> <Input v-if="$Electron && cacheServerUrl" :value="$A.getDomain(cacheServerUrl)" prefix="ios-globe-outline" size="large" readonly clearable @on-clear="clearServerUrl"/>
<Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" /> <Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" />
<Input v-if="loginType=='login'"
v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" <Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" size="large" @on-enter="onLogin" />
size="large"
@on-enter="onLogin" />
<Poptip v-else :content="$L('密码必须包含数字字母大小写或者特殊字符的组合长度在6~32位之间')" :transfer="true">
<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password"
size="large"
@on-enter="onLogin" />
</Poptip>
<Input v-if="loginType=='reg'" v-model="password2" prefix="ios-lock-outline" :placeholder="$L('输入确认密码')" type="password" size="large" @on-enter="onLogin" /> <Input v-if="loginType=='reg'" v-model="password2" prefix="ios-lock-outline" :placeholder="$L('输入确认密码')" type="password" size="large" @on-enter="onLogin" />
<Input v-if="loginType=='reg' && needInvite" v-model="invite" class="login-code" :placeholder="$L('请输入注册邀请码')" type="text" size="large" @on-enter="onLogin"><span slot="prepend">&nbsp;{{$L('邀请码')}}&nbsp;</span></Input> <Input v-if="loginType=='reg' && needInvite" v-model="invite" class="login-code" :placeholder="$L('请输入注册邀请码')" type="text" size="large" @on-enter="onLogin"><span slot="prepend">&nbsp;{{$L('邀请码')}}&nbsp;</span></Input>
@ -252,7 +245,7 @@ export default {
} }
if (this.loginType == 'reg') { if (this.loginType == 'reg') {
if (this.password != this.password2) { if (this.password != this.password2) {
$A.noticeError("确认密码输入不一致"); $A.messageWarning("确认密码输入不一致");
return; return;
} }
} }
@ -276,10 +269,7 @@ export default {
}); });
}).catch(({data, msg}) => { }).catch(({data, msg}) => {
this.loadIng--; this.loadIng--;
$A.noticeError({ $A.modalError(msg);
desc: msg,
duration: 10
});
if (data.code === 'need') { if (data.code === 'need') {
this.reCode(); this.reCode();
this.codeNeed = true; this.codeNeed = true;

View File

@ -451,6 +451,12 @@ export default {
}, 5000) }, 5000)
}, },
workReportShow(show) {
if (show) {
this.getReportUnread(0);
}
},
unreadTotal: { unreadTotal: {
handler(num) { handler(num) {
if (this.$Electron) { if (this.$Electron) {
@ -550,7 +556,6 @@ export default {
if (this.reportUnreadNumber > 0) { if (this.reportUnreadNumber > 0) {
this.reportTabs = "receive"; this.reportTabs = "receive";
} }
this.getReportUnread(0);
this.workReportShow = true; this.workReportShow = true;
return; return;
case 'clearCache': case 'clearCache':

View File

@ -35,13 +35,17 @@
<li v-if="dialogData.hasMorePages" class="history" @click="loadNextPage">{{$L('加载历史消息')}}</li> <li v-if="dialogData.hasMorePages" class="history" @click="loadNextPage">{{$L('加载历史消息')}}</li>
<li v-else-if="dialogData.loading > 0 && dialogMsgList.length === 0" class="loading"><Loading/></li> <li v-else-if="dialogData.loading > 0 && dialogMsgList.length === 0" class="loading"><Loading/></li>
<li v-else-if="dialogMsgList.length === 0" class="nothing">{{$L('暂无消息')}}</li> <li v-else-if="dialogMsgList.length === 0" class="nothing">{{$L('暂无消息')}}</li>
<DialogList <li
v-for="item in dialogMsgList" v-for="item in dialogMsgList"
:dialogMsg="item" :id="'view_' + item.id"
:topId="topId"
:key="item.id" :key="item.id"
:dialogData="dialogData" :class="{self:item.userid == userId, 'history-tip': topId == item.id}">
/> <em v-if="topId == item.id" class="history-text">{{$L('历史消息')}}</em>
<div class="dialog-avatar">
<UserAvatar :userid="item.userid" :tooltipDisabled="item.userid == userId" :size="30"/>
</div>
<DialogView :msg-data="item" :dialog-type="dialogData.type"/>
</li>
<li <li
v-for="item in tempMsgList" v-for="item in tempMsgList"
:id="'tmp_' + item.id" :id="'tmp_' + item.id"
@ -108,12 +112,11 @@ import ScrollerY from "../../../components/ScrollerY";
import {mapState} from "vuex"; import {mapState} from "vuex";
import DialogView from "./DialogView"; import DialogView from "./DialogView";
import DialogUpload from "./DialogUpload"; import DialogUpload from "./DialogUpload";
import DialogList from "./DialogList";
import {Store} from "le5le-store"; import {Store} from "le5le-store";
export default { export default {
name: "DialogWrapper", name: "DialogWrapper",
components: {DialogList, DialogUpload, DialogView, ScrollerY, DragInput}, components: {DialogUpload, DialogView, ScrollerY, DragInput},
props: { props: {
dialogId: { dialogId: {
type: Number, type: Number,

View File

@ -72,20 +72,15 @@
<div class="project-subbox"> <div class="project-subbox">
<div class="project-subtitle">{{projectData.desc}}</div> <div class="project-subtitle">{{projectData.desc}}</div>
<div class="project-switch"> <div class="project-switch">
<div v-if="completedCount > 0" class="project-checkbox">
<Checkbox :value="projectParameter('completedTask')" @on-change="toggleCompleted">{{$L('显示已完成')}}</Checkbox>
</div>
<div v-if="flowList && flowList.length > 0" class="project-select"> <div v-if="flowList && flowList.length > 0" class="project-select">
<div class="title">{{$L('进度')}}</div> <Select v-model="flowId" :placeholder="this.$L('进度')">
<Select
v-model="flowId"
style="width:100%"
:placeholder="this.$L('全部')"
>
<Option value="0">{{this.$L('全部')}}</Option> <Option value="0">{{this.$L('全部')}}</Option>
<Option v-for="item in flowList" :value="item.id" :key="item.id">{{ item.name }}</Option> <Option v-for="item in flowList" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select> </Select>
</div> </div>
<div v-if="completedCount > 0" class="project-checkbox">
<Checkbox :value="projectParameter('completedTask')" @on-change="toggleCompleted">{{$L('显示已完成')}}</Checkbox>
</div>
<div :class="['project-switch-button', !projectParameter('card') ? 'menu' : '']" @click="$store.dispatch('toggleProjectParameter', 'card')"> <div :class="['project-switch-button', !projectParameter('card') ? 'menu' : '']" @click="$store.dispatch('toggleProjectParameter', 'card')">
<div><i class="taskfont">&#xe60c;</i></div> <div><i class="taskfont">&#xe60c;</i></div>
<div><i class="taskfont">&#xe66a;</i></div> <div><i class="taskfont">&#xe66a;</i></div>
@ -507,8 +502,9 @@ export default {
archivedTaskShow: false, archivedTaskShow: false,
projectDialogSubscribe: null, projectDialogSubscribe: null,
flowId: 0,
flowList: [], flowList: [],
flowId: 0
} }
}, },
@ -572,23 +568,21 @@ export default {
}, },
panelTask() { panelTask() {
const {searchText,flowId} = this; const {searchText, flowId} = this;
return function (list) { return function (list) {
if (!this.projectParameter('completedTask')) { if (!this.projectParameter('completedTask')) {
list = list.filter(({complete_at}) => { list = list.filter(({complete_at}) => {
return !complete_at; return !complete_at;
}); });
} }
if (flowId > 0) {
list = list.filter(({flow_item_id}) => flow_item_id === flowId);
}
if (searchText) { if (searchText) {
list = list.filter(({name, desc}) => { list = list.filter(({name, desc}) => {
return $A.strExists(name, searchText) || $A.strExists(desc, searchText); return $A.strExists(name, searchText) || $A.strExists(desc, searchText);
}); });
} }
if(flowId > 0){
list = list.filter(({flow_item_id}) => {
return flow_item_id === flowId;
});
}
return list; return list;
} }
}, },
@ -624,7 +618,7 @@ export default {
})).sort((a, b) => { })).sort((a, b) => {
let at1 = $A.Date(a.complete_at), let at1 = $A.Date(a.complete_at),
at2 = $A.Date(b.complete_at); at2 = $A.Date(b.complete_at);
if(at1 || at2){ if (at1 || at2) {
return at1 - at2; return at1 - at2;
} }
if (a.sort != b.sort) { if (a.sort != b.sort) {
@ -691,14 +685,14 @@ export default {
if (task.project_id != projectId || task.parent_id > 0) { if (task.project_id != projectId || task.parent_id > 0) {
return false; return false;
} }
if (flowId > 0 && task.flow_item_id !== flowId) {
return false;
}
if (searchText) { if (searchText) {
if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) { if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) {
return false; return false;
} }
} }
if(task.flow_item_id !== flowId && flowId > 0){
return false;
}
return !task.complete_at; return !task.complete_at;
}); });
return array.sort((a, b) => { return array.sort((a, b) => {
@ -725,14 +719,14 @@ export default {
if (task.project_id != projectId || task.parent_id > 0) { if (task.project_id != projectId || task.parent_id > 0) {
return false; return false;
} }
if (flowId > 0 && task.flow_item_id !== flowId) {
return false;
}
if (searchText) { if (searchText) {
if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) { if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) {
return false; return false;
} }
} }
if(task.flow_item_id !== flowId && flowId > 0){
return false;
}
return task.complete_at; return task.complete_at;
}); });
return array.sort((a, b) => { return array.sort((a, b) => {
@ -762,10 +756,11 @@ export default {
}, },
projectId: { projectId: {
handler(val) { handler(val) {
if (val) { if (val > 0) {
this.getFlowData(); this.getFlowData();
} }
}, },
immediate: true,
}, },
}, },
@ -1158,21 +1153,20 @@ export default {
taskIsHidden(task) { taskIsHidden(task) {
const {name, desc, complete_at} = task; const {name, desc, complete_at} = task;
const {searchText,flowId} = this; const {searchText, flowId} = this;
if (!this.projectParameter('completedTask')) { if (!this.projectParameter('completedTask')) {
if (complete_at) { if (complete_at) {
return true; return true;
} }
} }
if (flowId > 0 && task.flow_item_id !== flowId) {
return false;
}
if (searchText) { if (searchText) {
if (!($A.strExists(name, searchText) || $A.strExists(desc, searchText))) { if (!($A.strExists(name, searchText) || $A.strExists(desc, searchText))) {
return true; return true;
} }
} }
if(task.flow_item_id !== flowId && flowId > 0){
return true;
}
return false; return false;
}, },
@ -1200,6 +1194,22 @@ export default {
}); });
}, },
getFlowData() {
this.$store.dispatch("call", {
url: 'project/flow/list',
data: {
project_id: this.projectId,
},
}).then(({data}) => {
let flowList = data.map(({project_flow_item}) => project_flow_item);
if (flowList) {
this.flowList = flowList[0];
}
}).catch(() => {
this.flowList = [];
});
},
inviteCopy() { inviteCopy() {
if (!this.inviteData.url) { if (!this.inviteData.url) {
return; return;
@ -1253,14 +1263,14 @@ export default {
return false; return false;
} }
} }
if (this.flowId > 0 && task.flow_item_id !== this.flowId) {
return false;
}
if (this.searchText) { if (this.searchText) {
if (!$A.strExists(task.name, this.searchText) && !$A.strExists(task.desc, this.searchText)) { if (!$A.strExists(task.name, this.searchText) && !$A.strExists(task.desc, this.searchText)) {
return false; return false;
} }
} }
if(task.flow_item_id !== this.flowId && this.flowId > 0){
return false;
}
return task.owner; return task.owner;
}, },
@ -1276,37 +1286,20 @@ export default {
return false; return false;
} }
} }
if (this.flowId > 0 && task.flow_item_id !== this.flowId) {
return false;
}
if (this.searchText) { if (this.searchText) {
if (!$A.strExists(task.name, this.searchText) && !$A.strExists(task.desc, this.searchText)) { if (!$A.strExists(task.name, this.searchText) && !$A.strExists(task.desc, this.searchText)) {
return false; return false;
} }
} }
if(task.flow_item_id !== this.flowId && this.flowId > 0){
return false;
}
return task.task_user && task.task_user.find(({userid, owner}) => userid == this.userId && owner == 0); return task.task_user && task.task_user.find(({userid, owner}) => userid == this.userId && owner == 0);
}, },
expiresFormat(date) { expiresFormat(date) {
return $A.countDownFormat(date, this.nowTime) return $A.countDownFormat(date, this.nowTime)
}, },
getFlowData() {
this.$store.dispatch("call", {
url: 'project/flow/list',
data: {
project_id: this.projectId,
is_filter: 1
},
}).then(({data}) => {
let flowList = data.map(item => {
return item.project_flow_item;
});
this.flowList = flowList[0];
}).catch(({msg}) => {
this.flowList = [];
return false;
});
},
} }
} }
</script> </script>

View File

@ -103,16 +103,10 @@ export default {
if (this.id > 0) { if (this.id > 0) {
this.getDetail(val); this.getDetail(val);
}else{ }else{
this.userInputShow = false;
this.reportData.offset = 0; this.reportData.offset = 0;
this.reportData.type = "weekly"; this.reportData.type = "weekly";
this.reportData.receive = []; this.reportData.receive = [];
this.getTemplate(); this.getTemplate();
setTimeout(() => {
//
// UserInput
this.userInputShow = true;
}, 50)
} }
}, },
}, },

View File

@ -473,10 +473,6 @@ export default {
return; return;
} }
this.loadIng++; this.loadIng++;
//
if ( this.addData.cascader.length > 0 ) {
this.addData.column_id = this.addData.cascader[1];
}
this.$store.dispatch("taskAdd", this.addData).then(({msg}) => { this.$store.dispatch("taskAdd", this.addData).then(({msg}) => {
this.loadIng--; this.loadIng--;
$A.messageSuccess(msg); $A.messageSuccess(msg);

View File

@ -417,7 +417,8 @@ export default {
'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx', 'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx',
'mp3', 'wav', 'mp4', 'flv', 'mp3', 'wav', 'mp4', 'flv',
'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm', 'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm',
'xmind', 'rp', 'xmind',
'rp',
], ],
uploadAccept: '', uploadAccept: '',
maxSize: 204800, maxSize: 204800,

View File

@ -136,14 +136,18 @@
box-shadow: none; box-shadow: none;
} }
} }
.project-select{ .project-select {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 14px; margin-right: 14px;
opacity: 0.9; .ivu-select-single {
z-index: 1000; .ivu-select-selection {
.title{ height: 30px;
width:50px; .ivu-select-selected-value {
height: 28px;
line-height: 28px;
}
}
} }
} }
.project-switch-button { .project-switch-button {
@ -957,16 +961,6 @@
.project-switch { .project-switch {
margin-left: 0; margin-left: 0;
justify-content: flex-end; justify-content: flex-end;
.project-select{
display: flex;
align-items: center;
margin-right: 14px;
opacity: 0.9;
z-index: 1000;
.title{
width:50px;
}
}
} }
} }
} }