添加的任务排到列表最前面
This commit is contained in:
parent
b6cbb66ae3
commit
e0ea6e8303
@ -503,6 +503,7 @@ class ProjectController extends AbstractController
|
||||
'name' => $name,
|
||||
'color' => $color,
|
||||
]);
|
||||
$column->sort = intval(ProjectColumn::whereProjectId($project->id)->orderByDesc('sort')->value('sort')) + 1;
|
||||
$column->save();
|
||||
return Base::retSuccess('添加成功', $column);
|
||||
}
|
||||
@ -546,7 +547,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* {post}添加任务
|
||||
* {post} 添加任务
|
||||
*
|
||||
* @apiParam {Number} project_id 项目ID
|
||||
* @apiParam {Number} [column_id] 列表ID,留空取第一个
|
||||
@ -555,6 +556,7 @@ class ProjectController extends AbstractController
|
||||
* @apiParam {Array} [times] 计划时间(格式:开始时间,结束时间;如:2020-01-01 00:00,2020-01-01 23:59)
|
||||
* @apiParam {Number} [owner] 负责人,留空为自己
|
||||
* @apiParam {Array} [subtasks] 子任务(格式:[{name,owner,times}])
|
||||
* @apiParam {Number} [top] 添加的任务排到列表最前面
|
||||
*/
|
||||
public function task__add()
|
||||
{
|
||||
@ -574,6 +576,7 @@ class ProjectController extends AbstractController
|
||||
$p_level = Base::getPostValue('p_level');
|
||||
$p_name = Base::getPostValue('p_name');
|
||||
$p_color = Base::getPostValue('p_color');
|
||||
$top = Base::getPostInt('top');
|
||||
// 项目
|
||||
$project = Project::select($this->projectSelect)
|
||||
->join('project_users', 'projects.id', '=', 'project_users.project_id')
|
||||
@ -617,6 +620,7 @@ class ProjectController extends AbstractController
|
||||
'p_level' => $p_level,
|
||||
'p_name' => $p_name,
|
||||
'p_color' => $p_color,
|
||||
'top' => $top,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class Project extends AbstractModel
|
||||
*/
|
||||
public function projectColumn(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(projectColumn::class, 'project_id', 'id')->orderBy('id');
|
||||
return $this->hasMany(projectColumn::class, 'project_id', 'id')->orderBy('sort')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,20 +12,27 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property int $id
|
||||
* @property int|null $project_id 项目ID
|
||||
* @property string|null $name 列表名称
|
||||
* @property int|null $inorder 排序(ASC)
|
||||
* @property string|null $color 颜色
|
||||
* @property int|null $sort 排序(ASC)
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectTask[] $projectTask
|
||||
* @property-read int|null $project_task_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|ProjectColumn onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereColor($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereInorder($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereProjectId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectColumn whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|ProjectColumn withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|ProjectColumn withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ProjectColumn extends AbstractModel
|
||||
@ -37,7 +44,7 @@ class ProjectColumn extends AbstractModel
|
||||
*/
|
||||
public function projectTask(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(projectTask::class, 'column_id', 'id')->orderByDesc('id');
|
||||
return $this->hasMany(projectTask::class, 'column_id', 'id')->orderBy('sort')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property int|null $p_level 优先级
|
||||
* @property string|null $p_name 优先级名称
|
||||
* @property string|null $p_color 优先级颜色
|
||||
* @property int|null $sort 排序(ASC)
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
@ -57,6 +58,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask wherePName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereParentId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereProjectId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereStartAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereUserid($value)
|
||||
@ -224,6 +226,7 @@ class ProjectTask extends AbstractModel
|
||||
$p_level = intval($params['p_level']);
|
||||
$p_name = $params['p_name'];
|
||||
$p_color = $params['p_color'];
|
||||
$top = intval($params['top']);
|
||||
//
|
||||
$retPre = $parent_id ? '子任务' : '任务';
|
||||
$task = self::createInstance();
|
||||
@ -263,6 +266,12 @@ class ProjectTask extends AbstractModel
|
||||
}
|
||||
// 创建人
|
||||
$task->userid = User::token2userid();
|
||||
// 排序位置
|
||||
if ($top) {
|
||||
$task->sort = intval(self::whereColumnId($task->column_id)->orderBy('sort')->value('sort')) - 1;
|
||||
} else {
|
||||
$task->sort = intval(self::whereColumnId($task->column_id)->orderByDesc('sort')->value('sort')) + 1;
|
||||
}
|
||||
//
|
||||
return AbstractModel::transaction(function() use ($subtasks, $content, $owner, $task) {
|
||||
$task->save();
|
||||
|
@ -77,16 +77,16 @@
|
||||
</ul>
|
||||
</div>
|
||||
</Poptip>
|
||||
<Icon type="md-add" @click="addBefore(column)" />
|
||||
<Icon type="md-add" @click="addTop(column)" />
|
||||
</div>
|
||||
</div>
|
||||
<ul class="overlay-y" :ref="'column_' + column.id">
|
||||
<li v-if="column.addBefore===true" class="task-add">
|
||||
<li v-if="column.addTop===true" class="task-add">
|
||||
<TaskAddSimple
|
||||
:column-id="column.id"
|
||||
:project-id="projectDetail.id"
|
||||
:add-before="true"
|
||||
@on-close="column.addBefore=false"
|
||||
:add-top="true"
|
||||
@on-close="column.addTop=false"
|
||||
@on-priority="addOpen"
|
||||
auto-active/>
|
||||
</li>
|
||||
@ -550,8 +550,8 @@ export default {
|
||||
this.addShow = true;
|
||||
},
|
||||
|
||||
addBefore(column) {
|
||||
this.$set(column, 'addBefore', true);
|
||||
addTop(column) {
|
||||
this.$set(column, 'addTop', true);
|
||||
this.$refs['column_' + column.id][0].scrollTop = 0;
|
||||
},
|
||||
|
||||
|
@ -43,7 +43,7 @@ export default {
|
||||
columnId: {
|
||||
default: ''
|
||||
},
|
||||
addBefore: {
|
||||
addTop: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
@ -99,9 +99,7 @@ export default {
|
||||
this.addData.project_id = this.projectId;
|
||||
this.addData.column_id = this.columnId;
|
||||
this.addData.owner = [this.userId];
|
||||
if (this.addBefore) {
|
||||
this.addData.add_before = true;
|
||||
}
|
||||
this.addData.top = this.addTop ? 1 : 0;
|
||||
return $A.cloneJSON(this.addData);
|
||||
},
|
||||
|
||||
|
1
resources/assets/sass/project-list.scss
vendored
1
resources/assets/sass/project-list.scss
vendored
@ -166,6 +166,7 @@
|
||||
color: #888888;
|
||||
cursor: pointer;
|
||||
background-color: #F2F3F5;
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
color: #777777;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user