kuaifan 5 years ago
parent
commit
b0800f8cf7

+ 10 - 3
app/Http/Controllers/Api/ProjectController.php

@@ -1101,9 +1101,9 @@ class ProjectController extends Controller
             ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
         $lists = Base::getPageList($lists, $taskid > 0 ? false : true);
         if (intval(Request::input('statistics')) == 1) {
-            $lists['statistics_unfinished'] = $type === '未完成' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('complete', 0)->count();
-            $lists['statistics_overdue'] = $type === '已超期' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('complete', 0)->whereBetween('enddate', [1, Base::time()])->count();
-            $lists['statistics_complete'] = $type === '已完成' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('complete', 1)->count();
+            $lists['statistics_unfinished'] = $type === '未完成' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('archived', 0)->where('complete', 0)->count();
+            $lists['statistics_overdue'] = $type === '已超期' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('archived', 0)->where('complete', 0)->whereBetween('enddate', [1, Base::time()])->count();
+            $lists['statistics_complete'] = $type === '已完成' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('archived', 0)->where('complete', 1)->count();
         }
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的任务', $lists);
@@ -1113,6 +1113,9 @@ class ProjectController extends Controller
             $lists['lists'][$key] = array_merge($info, Users::username2basic($info['username']));
         }
         if ($taskid > 0) {
+            if (count($lists['lists']) == 0) {
+                return Base::retError('未能找到任何相关的任务');
+            }
             return Base::retSuccess('success', $lists['lists'][0]);
         } else {
             return Base::retSuccess('success', $lists);
@@ -1611,6 +1614,10 @@ class ProjectController extends Controller
             DB::table('project_log')->insert($logArray);
         }
         //
+        if (in_array($act, ['complete', 'unfinished'])) {
+            Project::updateNum($task['projectid']);
+        }
+        //
         $task = array_merge($task, $upArray);
         $task['overdue'] = Project::taskIsOverdue($task);
         $task = array_merge($task, Users::username2basic($task['username']));

+ 6 - 4
app/Module/Project.php

@@ -41,10 +41,12 @@ class Project
      */
     public static function updateNum($projectid)
     {
-        DB::table('project_lists')->where('id', $projectid)->update([
-            'unfinished' => DB::table('project_task')->where('projectid', $projectid)->where('complete', 0)->where('delete', 0)->count(),
-            'complete' => DB::table('project_task')->where('projectid', $projectid)->where('complete', 1)->where('delete', 0)->count(),
-        ]);
+        if ($projectid > 0) {
+            DB::table('project_lists')->where('id', $projectid)->update([
+                'unfinished' => DB::table('project_task')->where('projectid', $projectid)->where('complete', 0)->where('delete', 0)->count(),
+                'complete' => DB::table('project_task')->where('projectid', $projectid)->where('complete', 1)->where('delete', 0)->count(),
+            ]);
+        }
     }
 
     /**

+ 33 - 1
resources/assets/js/main/components/project/archived.vue

@@ -18,6 +18,7 @@
 </style>
 <script>
     import DrawerTabsContainer from "../DrawerTabsContainer";
+    import Task from "../../mixins/task";
     export default {
         name: 'ProjectArchived',
         components: {DrawerTabsContainer},
@@ -30,6 +31,9 @@
                 default: true
             },
         },
+        mixins: [
+            Task
+        ],
         data () {
             return {
                 loadYet: false,
@@ -48,7 +52,34 @@
             this.columns = [{
                 "title": "任务名称",
                 "key": 'title',
-                "minWidth": 100,
+                "minWidth": 120,
+                render: (h, params) => {
+                    return this.renderTaskTitle(h, params, (act, detail) => {
+                        switch (act) {
+                            case "delete":      // 删除任务
+                            case "unarchived":  // 取消归档
+                                this.lists.some((task, i) => {
+                                    if (task.id == detail.id) {
+                                        this.lists.splice(i, 1);
+                                        return true;
+                                    }
+                                });
+                                break;
+
+                            case "archived":    // 归档
+                                let has = false;
+                                this.lists.some((task) => {
+                                    if (task.id == detail.id) {
+                                        return has = true;
+                                    }
+                                });
+                                if (!has) {
+                                    this.lists.unshift(detail);
+                                }
+                                break;
+                        }
+                    });
+                }
             }, {
                 "title": "创建人",
                 "key": 'createuser',
@@ -171,6 +202,7 @@
                         if (res.ret === 1) {
                             this.lists = res.data.lists;
                             this.listTotal = res.data.total;
+                            this.noDataText = "没有相关的数据";
                         } else {
                             this.lists = [];
                             this.listTotal = 0;

+ 53 - 1
resources/assets/js/main/components/project/statistics.vue

@@ -123,6 +123,7 @@
 </style>
 <script>
     import DrawerTabsContainer from "../DrawerTabsContainer";
+    import Task from "../../mixins/task";
     export default {
         name: 'ProjectStatistics',
         components: {DrawerTabsContainer},
@@ -135,6 +136,9 @@
                 default: true
             },
         },
+        mixins: [
+            Task
+        ],
         data () {
             return {
                 loadYet: false,
@@ -159,7 +163,54 @@
             this.columns = [{
                 "title": "任务名称",
                 "key": 'title',
-                "minWidth": 100,
+                "minWidth": 120,
+                render: (h, params) => {
+                    return this.renderTaskTitle(h, params, (act, detail) => {
+                        switch (act) {
+                            case "delete":      // 删除任务
+                            case "archived":    // 归档
+                                this.lists.some((task, i) => {
+                                    if (task.id == detail.id) {
+                                        this.lists.splice(i, 1);
+                                        if (task.complete) {
+                                            this.statistics_complete--;
+                                        } else {
+                                            this.statistics_unfinished++;
+                                        }
+                                        return true;
+                                    }
+                                });
+                                break;
+
+                            case "unarchived":  // 取消归档
+                                let has = false;
+                                this.lists.some((task) => {
+                                    if (task.id == detail.id) {
+                                        if (task.complete) {
+                                            this.statistics_complete++;
+                                        } else {
+                                            this.statistics_unfinished--;
+                                        }
+                                        return has = true;
+                                    }
+                                });
+                                if (!has) {
+                                    this.lists.unshift(detail);
+                                }
+                                break;
+
+                            case "complete":    // 标记完成
+                                this.statistics_complete++;
+                                this.statistics_unfinished--;
+                                break;
+
+                            case "unfinished":  // 标记未完成
+                                this.statistics_complete--;
+                                this.statistics_unfinished++;
+                                break;
+                        }
+                    });
+                }
             }, {
                 "title": "创建人",
                 "key": 'createuser',
@@ -246,6 +297,7 @@
                         if (res.ret === 1) {
                             this.lists = res.data.lists;
                             this.listTotal = res.data.total;
+                            this.noDataText = "没有相关的数据";
                         } else {
                             this.lists = [];
                             this.listTotal = 0;

+ 2 - 1
resources/assets/js/main/components/project/task/detail/detail.vue

@@ -240,7 +240,8 @@
                 $A.aAjax({
                     url: 'project/task/lists',
                     data: {
-                        taskid: this.taskid
+                        taskid: this.taskid,
+                        archived: '全部'
                     },
                     error: () => {
                         alert(this.$L('网络繁忙,请稍后再试!'));

+ 21 - 5
resources/assets/js/main/components/project/task/lists.vue

@@ -64,8 +64,9 @@
 </style>
 
 <script>
-
     import DrawerTabsContainer from "../../DrawerTabsContainer";
+    import Task from "../../../mixins/task";
+
     export default {
         name: 'ProjectTaskLists',
         components: {DrawerTabsContainer},
@@ -81,6 +82,9 @@
                 type: Array,
             },
         },
+        mixins: [
+            Task
+        ],
         data() {
             return {
                 keys: {},
@@ -103,9 +107,10 @@
             this.columns = [{
                 "title": "任务名称",
                 "key": 'title',
-                "minWidth": 100,
-                "tooltip": true,
-                "sortable": true,
+                "minWidth": 120,
+                render: (h, params) => {
+                    return this.renderTaskTitle(h, params);
+                }
             }, {
                 "title": "阶段",
                 "key": 'labelid',
@@ -123,7 +128,18 @@
                 "align": "center",
                 "sortable": true,
                 render: (h, params) => {
-                    return h('span', params.row.enddate ? $A.formatDate("Y-m-d H:i:s", params.row.enddate) : '-');
+                    if (!params.row.startdate && !params.row.enddate) {
+                        return h('span', '-');
+                    }
+                    return h('div', {
+                        style: {
+                            fontSize: '12px',
+                            lineHeight: '14px'
+                        }
+                    }, [
+                        h('div', params.row.startdate ? $A.formatDate("Y-m-d H:i:s", params.row.startdate) : '-'),
+                        h('div', params.row.enddate ? $A.formatDate("Y-m-d H:i:s", params.row.enddate) : '-'),
+                    ]);
                 }
             }, {
                 "title": "负责人",

+ 25 - 48
resources/assets/js/main/components/project/todo/attention.vue

@@ -50,55 +50,20 @@
             this.columns = [{
                 "title": "任务名称",
                 "key": 'title',
-                "minWidth": 100,
+                "minWidth": 120,
                 render: (h, params) => {
-                    return h('div', [
-                        h('Icon', {
-                            props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
-                            style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
-                            on: {
-                                click: () => {
-                                    this.taskComplete(params.row, !params.row.complete, (detail) => {
-                                        this.$emit("change", detail.complete ? 'complete' : 'unfinished', detail);
-                                    });
-                                }
-                            }
-                        }),
-                        h('span', {
-                            style: {cursor: 'pointer'},
-                            on: {
-                                click: () => {
-                                    let taskDetail = params.row;
-                                    this.taskDetail(taskDetail, (act, detail) => {
-                                        for (let key in detail) {
-                                            if (detail.hasOwnProperty(key)) {
-                                                this.$set(taskDetail, key, detail[key])
-                                            }
-                                        }
-                                        //
-                                        switch (act) {
-                                            case "username":    // 负责人
-                                            case "delete":      // 删除任务
-                                            case "archived":    // 归档
-                                                this.lists.some((task, i) => {
-                                                    if (task.id == detail.id) {
-                                                        this.lists.splice(i, 1);
-                                                        return true;
-                                                    }
-                                                });
-                                                break;
-
-                                            case "unarchived":  // 取消归档
-                                                this.lists.unshift(detail);
-                                                break;
-                                        }
-                                        //
-                                        this.$emit("change", act, detail);
-                                    });
-                                }
-                            }
-                        }, params.row.title)
-                    ]);
+                    return this.renderTaskTitle(h, params, (act, detail) => {
+                        switch (act) {
+                            case "delete":      // 删除任务
+                                this.lists.some((task, i) => {
+                                    if (task.id == detail.id) {
+                                        this.lists.splice(i, 1);
+                                        return true;
+                                    }
+                                });
+                                break;
+                        }
+                    });
                 }
             }, {
                 "title": "创建人",
@@ -109,6 +74,18 @@
                 "key": 'username',
                 "minWidth": 80,
             }, {
+                "title": "完成",
+                "minWidth": 70,
+                render: (h, params) => {
+                    return h('span', params.row.complete ? '√' : '-');
+                }
+            }, {
+                "title": "归档",
+                "minWidth": 70,
+                render: (h, params) => {
+                    return h('span', params.row.archived ? '√' : '-');
+                }
+            }, {
                 "title": "添加时间",
                 "width": 160,
                 render: (h, params) => {

+ 2 - 48
resources/assets/js/main/components/project/todo/complete.vue

@@ -50,55 +50,9 @@
             this.columns = [{
                 "title": "任务名称",
                 "key": 'title',
-                "minWidth": 100,
+                "minWidth": 120,
                 render: (h, params) => {
-                    return h('div', [
-                        h('Icon', {
-                            props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
-                            style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
-                            on: {
-                                click: () => {
-                                    this.taskComplete(params.row, !params.row.complete, (detail) => {
-                                        this.$emit("change", detail.complete ? 'complete' : 'unfinished', detail);
-                                    });
-                                }
-                            }
-                        }),
-                        h('span', {
-                            style: {cursor: 'pointer'},
-                            on: {
-                                click: () => {
-                                    let taskDetail = params.row;
-                                    this.taskDetail(taskDetail, (act, detail) => {
-                                        for (let key in detail) {
-                                            if (detail.hasOwnProperty(key)) {
-                                                this.$set(taskDetail, key, detail[key])
-                                            }
-                                        }
-                                        //
-                                        switch (act) {
-                                            case "username":    // 负责人
-                                            case "delete":      // 删除任务
-                                            case "archived":    // 归档
-                                                this.lists.some((task, i) => {
-                                                    if (task.id == detail.id) {
-                                                        this.lists.splice(i, 1);
-                                                        return true;
-                                                    }
-                                                });
-                                                break;
-
-                                            case "unarchived":  // 取消归档
-                                                this.lists.unshift(detail);
-                                                break;
-                                        }
-                                        //
-                                        this.$emit("change", act, detail);
-                                    });
-                                }
-                            }
-                        }, params.row.title)
-                    ]);
+                    return this.renderTaskTitle(h, params);
                 }
             }, {
                 "title": "创建人",

+ 63 - 0
resources/assets/js/main/mixins/task.js

@@ -30,5 +30,68 @@ export default {
                 }
             });
         },
+
+        renderTaskTitle(h, params, callback) {
+            let taskDetail = params.row;
+            return h('div', [
+                h('Icon', {
+                    props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
+                    style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
+                    on: {
+                        click: () => {
+                            this.taskComplete(params.row, !params.row.complete, (detail) => {
+                                this.$emit("change", detail.complete ? 'complete' : 'unfinished', detail);
+                                typeof callback === "function" && callback(detail.complete ? 'complete' : 'unfinished', detail);
+                            });
+                        }
+                    }
+                }),
+                h('span', {
+                    style: {cursor: 'pointer'},
+                    on: {
+                        click: () => {
+                            this.taskDetail(taskDetail, (act, detail) => {
+                                for (let key in detail) {
+                                    if (detail.hasOwnProperty(key)) {
+                                        this.$set(taskDetail, key, detail[key])
+                                    }
+                                }
+                                //
+                                if (typeof callback === "function") {
+                                    callback(act, detail);
+                                } else {
+                                    switch (act) {
+                                        case "username":    // 负责人
+                                        case "delete":      // 删除任务
+                                        case "archived":    // 归档
+                                            this.lists.some((task, i) => {
+                                                if (task.id == detail.id) {
+                                                    this.lists.splice(i, 1);
+                                                    return true;
+                                                }
+                                            });
+                                            break;
+
+                                        case "unarchived":  // 取消归档
+                                            let has = false;
+                                            this.lists.some((task) => {
+                                                if (task.id == detail.id) {
+                                                    return has = true;
+                                                }
+                                            });
+                                            if (!has) {
+                                                this.lists.unshift(detail);
+                                            }
+                                            break;
+                                    }
+                                }
+                                //
+                                this.$emit("change", act, detail);
+                            });
+                        }
+                    }
+                }, taskDetail.title)
+            ]);
+        }
     }
 }

+ 27 - 4
resources/assets/js/main/pages/project.vue

@@ -26,7 +26,7 @@
         <w-content>
             <!-- 列表 -->
             <ul class="project-list">
-                <li v-for="(item, index) in lists">
+                <li v-for="item in lists">
                     <div class="project-item">
                         <div class="project-head">
                             <div v-if="item.loadIng === true" class="project-loading">
@@ -54,7 +54,7 @@
                         </div>
                         <div class="project-bottom">
                             <div class="project-iconbtn" @click.stop="handleProject('archived', item)">
-                                <Icon class="project-iconbtn-icon1" type="md-checkmark-circle-outline" size="24" />
+                                <Icon class="project-iconbtn-icon1" type="md-filing" size="24" />
                                 <div class="project-iconbtn-text">已归档任务</div>
                             </div>
                             <div class="project-iconbtn" @click.stop="handleProject('member', item)">
@@ -109,13 +109,13 @@
         <Drawer v-model="projectDrawerShow" width="75%">
             <Tabs v-if="projectDrawerShow" v-model="projectDrawerTab">
                 <TabPane :label="$L('已归档任务')" name="archived">
-                    <project-archived :canload="projectDrawerShow && projectDrawerTab == 'archived'" :projectid="handleProjectId"></project-archived>
+                    <project-archived :canload="projectDrawerShow && projectDrawerTab == 'archived'" :projectid="handleProjectId" @change="changeTaskProcess"></project-archived>
                 </TabPane>
                 <TabPane :label="$L('成员管理')" name="member">
                     <project-users :canload="projectDrawerShow && projectDrawerTab == 'member'" :projectid="handleProjectId"></project-users>
                 </TabPane>
                 <TabPane :label="$L('项目统计')" name="statistics">
-                    <project-statistics :canload="projectDrawerShow && projectDrawerTab == 'statistics'" :projectid="handleProjectId"></project-statistics>
+                    <project-statistics :canload="projectDrawerShow && projectDrawerTab == 'statistics'" :projectid="handleProjectId" @change="changeTaskProcess"></project-statistics>
                 </TabPane>
             </Tabs>
         </Drawer>
@@ -648,6 +648,29 @@
                     },
                 });
             },
+
+            changeTaskProcess(act, detail) {
+                switch (act) {
+                    case "complete":    // 标记完成
+                        this.lists.some((item) => {
+                            if (item.id == detail.projectid) {
+                                item.complete++;
+                                item.unfinished--;
+                                return true;
+                            }
+                        })
+                        break;
+                    case "unfinished":  // 标记未完成
+                        this.lists.some((item) => {
+                            if (item.id == detail.projectid) {
+                                item.complete--;
+                                item.unfinished++;
+                                return true;
+                            }
+                        })
+                        break;
+                }
+            }
         },
     }
 </script>