no message

This commit is contained in:
kuaifan 2021-06-10 18:54:11 +08:00
parent 351648990f
commit 4ef713a0bf
6 changed files with 187 additions and 41 deletions

View File

@ -55,7 +55,41 @@ class ProjectController extends AbstractController
} }
/** /**
* 项目详情 * 单个项目信息
*
* @apiParam {Number} project_id 项目ID
*/
public function one()
{
$user = User::authE();
if (Base::isError($user)) {
return $user;
} else {
$user = User::IDE($user['data']);
}
//
$project_id = intval(Request::input('project_id'));
//
$project = Project::with(['projectColumn' => function($query) {
$query->with(['projectTask' => function($taskQuery) {
$taskQuery->with(['taskUser', 'taskTag'])->where('parent_id', 0);
}]);
}, 'projectUser'])
->select($this->projectSelect)
->join('project_users', 'projects.id', '=', 'project_users.project_id')
->where('projects.id', $project_id)
->where('project_users.userid', $user->userid)
->first();
if ($project) {
$owner_user = $project->projectUser->where('owner', 1)->first();
$project->owner_userid = $owner_user ? $owner_user->userid : 0;
}
//
return Base::retSuccess('success', $project);
}
/**
* 单个项目详情(比"单个项目信息"多)
* *
* @apiParam {Number} project_id 项目ID * @apiParam {Number} project_id 项目ID
*/ */

View File

@ -33,9 +33,28 @@
</li> </li>
<li class="menu-project"> <li class="menu-project">
<ul> <ul>
<li v-for="(item, key) in projectList" :key="key" @click="toggleRoute('project/' + item.id)" :class="classNameRoute('project/' + item.id)"> <li
<div class="title">{{item.name}}</div> v-for="(item, key) in projectList"
<div v-if="item.task_my_num > 0" class="num">{{item.task_my_num}}</div> :key="key"
:class="classNameRoute('project/' + item.id, openMenu[item.id])"
@click="toggleRoute('project/' + item.id)">
<div class="project-h1">
<em @click.stop="toggleOpenMenu(item.id)"></em>
<div class="title">{{item.name}}</div>
<div v-if="item.task_my_num > 0" class="num">{{item.task_my_num}}</div>
</div>
<div class="project-h2">
<p>
<em>{{$L('我的')}}:</em>
<span>{{item.task_my_complete}}/{{item.task_my_num}}</span>
<Progress :percent="item.task_my_percent" :stroke-width="6" />
</p>
<p>
<em>{{$L('全部')}}:</em>
<span>{{item.task_complete}}/{{item.task_num}}</span>
<Progress :percent="item.task_percent" :stroke-width="6" />
</p>
</div>
</li> </li>
</ul> </ul>
<Loading v-if="loadIng > 0"/> <Loading v-if="loadIng > 0"/>
@ -122,7 +141,9 @@ export default {
path: 'priority', path: 'priority',
name: '任务等级' name: '任务等级'
} }
] ],
openMenu: {}
} }
}, },
@ -168,6 +189,10 @@ export default {
this.goForward({path: '/manage/' + path}); this.goForward({path: '/manage/' + path});
}, },
toggleOpenMenu(id) {
this.$set(this.openMenu, id, !this.openMenu[id])
},
settingRoute(path) { settingRoute(path) {
if (path === 'signout') { if (path === 'signout') {
$A.modalConfirm({ $A.modalConfirm({
@ -182,9 +207,10 @@ export default {
this.toggleRoute('setting/' + path); this.toggleRoute('setting/' + path);
}, },
classNameRoute(path) { classNameRoute(path, openMenu) {
return { return {
"active": $A.leftExists(this.curPath, '/manage/' + path) "active": $A.leftExists(this.curPath, '/manage/' + path),
"open-menu": openMenu === true,
}; };
}, },

View File

@ -607,7 +607,6 @@ export default {
success: ({ret, data, msg}) => { success: ({ret, data, msg}) => {
if (ret === 1) { if (ret === 1) {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.addTaskSuccess(data)
this.addShow = false; this.addShow = false;
this.addData = { this.addData = {
owner: 0, owner: 0,
@ -618,6 +617,8 @@ export default {
p_name: '', p_name: '',
p_color: '', p_color: '',
}; };
this.$store.commit('getProjectOne', data.project_id);
this.addTaskSuccess(data)
} else { } else {
$A.modalError(msg); $A.modalError(msg);
} }

View File

@ -161,7 +161,6 @@ export default {
success: ({ret, data, msg}) => { success: ({ret, data, msg}) => {
if (ret === 1) { if (ret === 1) {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$emit("on-success", data)
this.active = false; this.active = false;
this.addData = { this.addData = {
owner: 0, owner: 0,
@ -172,6 +171,8 @@ export default {
p_name: '', p_name: '',
p_color: '', p_color: '',
} }
this.$store.commit('getProjectOne', data.project_id);
this.$emit("on-success", data)
} else { } else {
$A.modalError(msg); $A.modalError(msg);
} }

View File

@ -109,6 +109,31 @@ export default {
* @param state * @param state
* @param project_id * @param project_id
*/ */
getProjectOne(state, project_id) {
if (state.method.runNum(project_id) === 0) {
return;
}
$A.apiAjax({
url: 'project/one',
data: {
project_id: project_id,
},
success: ({ret, data, msg}) => {
if (ret === 1) {
let index = state.projectList.findIndex(({id}) => id === data.id);
if (index > -1) {
state.projectList.splice(index, 1, data);
}
}
}
});
},
/**
* 获取项目详情
* @param state
* @param project_id
*/
getProjectDetail(state, project_id) { getProjectDetail(state, project_id) {
if (state.method.runNum(project_id) === 0) { if (state.method.runNum(project_id) === 0) {
return; return;
@ -135,11 +160,19 @@ export default {
}, },
success: ({ret, data, msg}) => { success: ({ret, data, msg}) => {
if (ret === 1) { if (ret === 1) {
state.cacheProject[project_id] = data; state.cacheProject[data.id] = data;
if (state.projectDetail.id === project_id) { if (state.projectDetail.id === data.id) {
state.projectDetail = data; state.projectDetail = data;
} }
state.method.setStorage("cacheProject", state.cacheProject); state.method.setStorage("cacheProject", state.cacheProject);
//
let index = state.projectList.findIndex(({id}) => id === data.id);
if (index > -1) {
const project = $A.cloneJSON(data);
delete project.project_column;
delete project.project_user;
state.projectList.splice(index, 1, project);
}
} else { } else {
$A.modalError(msg); $A.modalError(msg);
} }

View File

@ -109,40 +109,91 @@
> ul { > ul {
width: 100%; width: 100%;
> li { > li {
position: relative;
list-style: none;
padding: 0 8px 0 30px;
margin: 4px auto;
border-radius: 4px;
display: flex; display: flex;
align-items: center; flex-direction: column;
justify-content: space-between; margin: 4px auto;
&:before { list-style: none;
content: ""; .project-h1 {
position: absolute; position: relative;
top: 50%; display: flex;
left: 8px; align-items: center;
transform: translateY(-50%); justify-content: space-between;
width: 12px; padding: 0 8px 0 30px;
height: 12px; border-radius: 4px;
background: url("data:image/svg+xml;base64,PHN2ZyB0PSIxNjIyMzkwODExNTQxIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI0OTk3IiB3aWR0aD0iNDgiIGhlaWdodD0iNDgiPjxwYXRoIGQ9Ik0zNjYuMTgyNCAxMDguMjM2OEw4MTIuMDMyIDQyOC4wMzJhMTAyLjQgMTAyLjQgMCAwIDEgMCAxNjYuNTAyNEwzNjYuMTgyNCA5MTQuMzI5NmExMDIuNCAxMDIuNCAwIDAgMS0xNjIuMDk5Mi04My4yNTEyVjE5MS40ODhhMTAyLjQgMTAyLjQgMCAwIDEgMTYyLjA5OTItODMuMjUxMnoiIHAtaWQ9IjI0OTk4IiBmaWxsPSIjOTk5OTk5Ij48L3BhdGg+PC9zdmc+") no-repeat center center; > em {
background-size: contain; position: absolute;
top: 50%;
left: 2px;
width: 24px;
height: 24px;
cursor: pointer;
transform: translateY(-50%);
display: flex;
align-items: center;
justify-content: center;
&:before {
content: "";
width: 12px;
height: 12px;
background: url("data:image/svg+xml;base64,PHN2ZyB0PSIxNjIyMzkwODExNTQxIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI0OTk3IiB3aWR0aD0iNDgiIGhlaWdodD0iNDgiPjxwYXRoIGQ9Ik0zNjYuMTgyNCAxMDguMjM2OEw4MTIuMDMyIDQyOC4wMzJhMTAyLjQgMTAyLjQgMCAwIDEgMCAxNjYuNTAyNEwzNjYuMTgyNCA5MTQuMzI5NmExMDIuNCAxMDIuNCAwIDAgMS0xNjIuMDk5Mi04My4yNTEyVjE5MS40ODhhMTAyLjQgMTAyLjQgMCAwIDEgMTYyLjA5OTItODMuMjUxMnoiIHAtaWQ9IjI0OTk4IiBmaWxsPSIjOTk5OTk5Ij48L3BhdGg+PC9zdmc+") no-repeat center center;
background-size: contain;
transition: transform 0.2s;
}
}
.title {
flex: 1;
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 38px;
line-height: 38px;
}
.num {
font-size: 12px;
padding-left: 16px;
}
} }
.title { .project-h2 {
flex: 1; display: none;
color: #333333; margin: 16px 4px;
overflow: hidden; padding: 0 8px 0 26px;
text-overflow: ellipsis; > p {
white-space: nowrap; display: flex;
height: 38px; align-items: center;
line-height: 38px; padding: 4px 0;
} height: 36px;
.num { em,
font-size: 12px; span {
padding-left: 16px; font-style: normal;
font-size: 12px;
flex-shrink: 0;
padding-right: 6px;
}
.ivu-progress {
margin-right: -26px;
.ivu-progress-inner {
background-color: #e4e4e4;
}
}
}
} }
&.active { &.active {
background-color: #ffffff; .project-h1 {
background-color: #ffffff;
}
}
&.open-menu {
.project-h1 {
> em {
&:before {
transform: rotate(90deg);
}
}
}
.project-h2 {
display: block;
}
} }
} }
} }