Skip to content

Commit

Permalink
perf: 任务等级支持设置0天表示默认不限时
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 28, 2021
1 parent 739d1f2 commit d7f1246
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/SystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function priority()
return Base::retError('参数错误');
}
foreach ($list AS $item) {
if (empty($item['name']) || empty($item['color']) || empty($item['days']) || empty($item['priority'])) {
if (empty($item['name']) || empty($item['color']) || empty($item['priority'])) {
continue;
}
$array[] = [
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/SettingsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function run()
'id' => 2,
'name' => 'priority',
'desc' => '',
'setting' => '[{"name":"\\u91cd\\u8981\\u4e14\\u7d27\\u6025","color":"#ED4014","days":1,"priority":1},{"name":"\\u91cd\\u8981\\u4e0d\\u7d27\\u6025","color":"#F16B62","days":3,"priority":2},{"name":"\\u7d27\\u6025\\u4e0d\\u91cd\\u8981","color":"#19C919","days":5,"priority":3},{"name":"\\u4e0d\\u91cd\\u8981\\u4e0d\\u7d27\\u6025","color":"#2D8CF0","days":7,"priority":4}]',
'setting' => '[{"name":"\\u91cd\\u8981\\u4e14\\u7d27\\u6025","color":"#ED4014","days":1,"priority":1},{"name":"\\u91cd\\u8981\\u4e0d\\u7d27\\u6025","color":"#F16B62","days":3,"priority":2},{"name":"\\u7d27\\u6025\\u4e0d\\u91cd\\u8981","color":"#19C919","days":5,"priority":3},{"name":"\\u4e0d\\u91cd\\u8981\\u4e0d\\u7d27\\u6025","color":"#2D8CF0","days":0,"priority":4}]',
'created_at' => seeders_at('2021-07-01 08:04:30'),
'updated_at' => seeders_at('2021-07-01 09:20:26'),
),
Expand Down
19 changes: 16 additions & 3 deletions resources/assets/js/pages/manage/components/TaskAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<Button :class="{advanced: advanced}" @click="advanced=!advanced">{{$L('高级选项')}}</Button>
<ul class="advanced-priority">
<li v-for="(item, key) in taskPriority" :key="key">
<ETooltip :content="item.name + ' (' + item.days + $L('天') + ')'">
<ETooltip :content="taskPriorityContent(item)">
<i
class="taskfont"
:style="{color:item.color}"
Expand Down Expand Up @@ -369,10 +369,23 @@ export default {
}
},
taskPriorityContent(item) {
let days = $A.runNum(item.days);
if (days <= 0) {
return item.name + ' (' + this.$L('无时间限制') + ')';
}
return item.name + ' (' + days + this.$L('') + ')';
},
choosePriority(item) {
let start = new Date();
let end = new Date(new Date().setDate(start.getDate() + $A.runNum(item.days)));
this.$set(this.addData, 'times', $A.date2string([start, end]))
let days = $A.runNum(item.days);
if (days > 0) {
let end = new Date(new Date().setDate(start.getDate() + days));
this.$set(this.addData, 'times', $A.date2string([start, end]))
} else {
this.$set(this.addData, 'times', [])
}
this.$set(this.addData, 'p_level', item.priority)
this.$set(this.addData, 'p_name', item.name)
this.$set(this.addData, 'p_color', item.color)
Expand Down

0 comments on commit d7f1246

Please sign in to comment.