kuaifan 5 年 前
コミット
33d62107fd

+ 32 - 14
app/Http/Controllers/Api/ProjectController.php

@@ -28,8 +28,12 @@ class ProjectController extends Controller
     /**
      * 项目列表
      *
-     * @apiParam {Number} [page]                当前页,默认:1
-     * @apiParam {Number} [pagesize]            每页显示数量,默认:20,最大:100
+     * @apiParam {String} act           类型
+     * - join: 加入的项目(默认)
+     * - favor: 收藏的项目
+     * - manage: 管理的项目
+     * @apiParam {Number} [page]        当前页,默认:1
+     * @apiParam {Number} [pagesize]    每页显示数量,默认:20,最大:100
      */
     public function lists()
     {
@@ -40,14 +44,28 @@ class ProjectController extends Controller
             $user = $user['data'];
         }
         //
+        $whereArray = [];
+        $whereArray[] = ['project_lists.delete', '=', 0];
+        $whereArray[] = ['project_users.username', '=', $user['username']];
+        switch (Request::input('act')) {
+            case "favor": {
+                $whereArray[] = ['project_users.type', '=', '收藏'];
+                break;
+            }
+            case "manage": {
+                $whereArray[] = ['project_users.type', '=', '成员'];
+                $whereArray[] = ['project_users.isowner', '=', 1];
+                break;
+            }
+            default: {
+                $whereArray[] = ['project_users.type', '=', '成员'];
+                break;
+            }
+        }
         $lists = DB::table('project_lists')
             ->join('project_users', 'project_lists.id', '=', 'project_users.projectid')
-            ->select(['project_lists.*', 'project_users.isowner'])
-            ->where([
-                ['project_lists.delete', 0],
-                ['project_users.type', '成员'],
-                ['project_users.username', $user['username']]
-            ])
+            ->select(['project_lists.*', 'project_users.isowner', 'project_users.indate as uindate'])
+            ->where($whereArray)
             ->orderByDesc('project_lists.id')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
@@ -59,8 +77,8 @@ class ProjectController extends Controller
     /**
      * 添加项目
      *
-     * @apiParam {String} title     项目名称
-     * @apiParam {Array} labels     流程,格式[流程1, 流程2]
+     * @apiParam {String} title         项目名称
+     * @apiParam {Array} labels         流程,格式[流程1, 流程2]
      */
     public function add()
     {
@@ -129,7 +147,7 @@ class ProjectController extends Controller
     /**
      * 收藏项目
      *
-     * @apiParam {String} act
+     * @apiParam {String} act           类型
      * - cancel: 取消收藏
      * - else: 添加收藏
      * @apiParam {Number} projectid     项目ID
@@ -415,9 +433,9 @@ class ProjectController extends Controller
     /**
      * 项目成员-列表
      *
-     * @apiParam {Number} projectid             项目ID
-     * @apiParam {Number} [page]                当前页,默认:1
-     * @apiParam {Number} [pagesize]            每页显示数量,默认:20,最大:100
+     * @apiParam {Number} projectid     项目ID
+     * @apiParam {Number} [page]        当前页,默认:1
+     * @apiParam {Number} [pagesize]    每页显示数量,默认:20,最大:100
      */
     public function users__lists()
     {

+ 143 - 0
resources/assets/js/main/components/project/my/favor.vue

@@ -0,0 +1,143 @@
+<template>
+    <div class="project-complete">
+        <!-- 列表 -->
+        <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
+        <!-- 分页 -->
+        <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
+    </div>
+</template>
+
+<style lang="scss" scoped>
+    .project-complete {
+        .tableFill {
+            margin: 12px 12px 20px;
+        }
+    }
+</style>
+<script>
+    import Project from "../../../mixins/project";
+
+    export default {
+        name: 'ProjectMyFavor',
+        props: {
+            canload: {
+                type: Boolean,
+                default: true
+            },
+        },
+        mixins: [
+            Project
+        ],
+        data () {
+            return {
+                loadYet: false,
+
+                loadIng: 0,
+
+                columns: [],
+
+                lists: [],
+                listPage: 1,
+                listTotal: 0,
+                noDataText: "数据加载中.....",
+            }
+        },
+        created() {
+            this.columns = [{
+                "title": "项目名称",
+                "key": 'title',
+                "minWidth": 100,
+            }, {
+                "title": "收藏时间",
+                "minWidth": 160,
+                render: (h, params) => {
+                    return h('span', $A.formatDate("Y-m-d H:i:s", params.row.uindate));
+                }
+            }, {
+                "title": "操作",
+                "key": 'action',
+                "width": 80,
+                "align": 'center',
+                render: (h, params) => {
+                    return h('Button', {
+                        props: {
+                            type: 'primary',
+                            size: 'small'
+                        },
+                        on: {
+                            click: () => {
+                                this.$Modal.confirm({
+                                    title: '取消收藏',
+                                    content: '你确定要取消收藏此项目吗?',
+                                    loading: true,
+                                    onOk: () => {
+                                        this.favorProject('cancel', params.row.id, () => {
+                                            this.getLists();
+                                        });
+                                    }
+                                });
+                            }
+                        }
+                    }, '取消');
+                }
+            }];
+        },
+        mounted() {
+            if (this.canload) {
+                this.loadYet = true;
+                this.getLists(true);
+            }
+        },
+
+        watch: {
+            canload(val) {
+                if (val && !this.loadYet) {
+                    this.loadYet = true;
+                    this.getLists(true);
+                }
+            }
+        },
+
+        methods: {
+            setPage(page) {
+                this.listPage = page;
+                this.getLists();
+            },
+
+            setPageSize(size) {
+                if (Math.max($A.runNum(this.listPageSize), 10) != size) {
+                    this.listPageSize = size;
+                    this.getLists();
+                }
+            },
+
+            getLists(resetLoad) {
+                if (resetLoad === true) {
+                    this.listPage = 1;
+                }
+                this.loadIng++;
+                $A.aAjax({
+                    url: 'project/lists',
+                    data: {
+                        act: 'favor',
+                        page: Math.max(this.listPage, 1),
+                        pagesize: Math.max($A.runNum(this.listPageSize), 10),
+                    },
+                    complete: () => {
+                        this.loadIng--;
+                    },
+                    success: (res) => {
+                        if (res.ret === 1) {
+                            this.lists = res.data.lists;
+                            this.listTotal = res.data.total;
+                        } else {
+                            this.lists = [];
+                            this.listTotal = 0;
+                            this.noDataText = res.msg;
+                        }
+                    }
+                });
+            },
+        }
+    }
+</script>

+ 136 - 0
resources/assets/js/main/components/project/my/join.vue

@@ -0,0 +1,136 @@
+<template>
+    <div class="project-complete">
+        <!-- 列表 -->
+        <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
+        <!-- 分页 -->
+        <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
+    </div>
+</template>
+
+<style lang="scss" scoped>
+    .project-complete {
+        .tableFill {
+            margin: 12px 12px 20px;
+        }
+    }
+</style>
+<script>
+    import Project from '../../../mixins/project'
+
+    export default {
+        name: 'ProjectMyJoin',
+        props: {
+            canload: {
+                type: Boolean,
+                default: true
+            },
+        },
+        mixins: [
+            Project
+        ],
+        data () {
+            return {
+                loadYet: false,
+
+                loadIng: 0,
+
+                columns: [],
+
+                lists: [],
+                listPage: 1,
+                listTotal: 0,
+                noDataText: "数据加载中.....",
+            }
+        },
+        created() {
+            this.columns = [{
+                "title": "项目名称",
+                "key": 'title',
+                "minWidth": 100,
+            }, {
+                "title": "加入时间",
+                "minWidth": 160,
+                render: (h, params) => {
+                    return h('span', $A.formatDate("Y-m-d H:i:s", params.row.uindate));
+                }
+            }, {
+                "title": "操作",
+                "key": 'action',
+                "width": 80,
+                "align": 'center',
+                render: (h, params) => {
+                    return h('Button', {
+                        props: {
+                            type: 'primary',
+                            size: 'small'
+                        },
+                        on: {
+                            click: () => {
+                                this.outProject(params.row.id, () => {
+                                    this.getLists();
+                                });
+                            }
+                        }
+                    }, '退出');
+                }
+            }];
+        },
+        mounted() {
+            if (this.canload) {
+                this.loadYet = true;
+                this.getLists(true);
+            }
+        },
+
+        watch: {
+            canload(val) {
+                if (val && !this.loadYet) {
+                    this.loadYet = true;
+                    this.getLists(true);
+                }
+            }
+        },
+
+        methods: {
+            setPage(page) {
+                this.listPage = page;
+                this.getLists();
+            },
+
+            setPageSize(size) {
+                if (Math.max($A.runNum(this.listPageSize), 10) != size) {
+                    this.listPageSize = size;
+                    this.getLists();
+                }
+            },
+
+            getLists(resetLoad) {
+                if (resetLoad === true) {
+                    this.listPage = 1;
+                }
+                this.loadIng++;
+                $A.aAjax({
+                    url: 'project/lists',
+                    data: {
+                        act: 'join',
+                        page: Math.max(this.listPage, 1),
+                        pagesize: Math.max($A.runNum(this.listPageSize), 10),
+                    },
+                    complete: () => {
+                        this.loadIng--;
+                    },
+                    success: (res) => {
+                        if (res.ret === 1) {
+                            this.lists = res.data.lists;
+                            this.listTotal = res.data.total;
+                        } else {
+                            this.lists = [];
+                            this.listTotal = 0;
+                            this.noDataText = res.msg;
+                        }
+                    }
+                });
+            },
+        }
+    }
+</script>

+ 136 - 0
resources/assets/js/main/components/project/my/manage.vue

@@ -0,0 +1,136 @@
+<template>
+    <div class="project-complete">
+        <!-- 列表 -->
+        <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
+        <!-- 分页 -->
+        <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total transfer></Page>
+    </div>
+</template>
+
+<style lang="scss" scoped>
+    .project-complete {
+        .tableFill {
+            margin: 12px 12px 20px;
+        }
+    }
+</style>
+<script>
+    import Project from "../../../mixins/project";
+
+    export default {
+        name: 'ProjectMyManage',
+        props: {
+            canload: {
+                type: Boolean,
+                default: true
+            },
+        },
+        mixins: [
+            Project
+        ],
+        data () {
+            return {
+                loadYet: false,
+
+                loadIng: 0,
+
+                columns: [],
+
+                lists: [],
+                listPage: 1,
+                listTotal: 0,
+                noDataText: "数据加载中.....",
+            }
+        },
+        created() {
+            this.columns = [{
+                "title": "项目名称",
+                "key": 'title',
+                "minWidth": 100,
+            }, {
+                "title": "创建时间",
+                "minWidth": 160,
+                render: (h, params) => {
+                    return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
+                }
+            }, {
+                "title": "操作",
+                "key": 'action',
+                "width": 80,
+                "align": 'center',
+                render: (h, params) => {
+                    return h('Button', {
+                        props: {
+                            type: 'primary',
+                            size: 'small'
+                        },
+                        on: {
+                            click: () => {
+                                this.deleteProject(params.row.id, () => {
+                                    this.getLists();
+                                });
+                            }
+                        }
+                    }, '删除');
+                }
+            }];
+        },
+        mounted() {
+            if (this.canload) {
+                this.loadYet = true;
+                this.getLists(true);
+            }
+        },
+
+        watch: {
+            canload(val) {
+                if (val && !this.loadYet) {
+                    this.loadYet = true;
+                    this.getLists(true);
+                }
+            }
+        },
+
+        methods: {
+            setPage(page) {
+                this.listPage = page;
+                this.getLists();
+            },
+
+            setPageSize(size) {
+                if (Math.max($A.runNum(this.listPageSize), 10) != size) {
+                    this.listPageSize = size;
+                    this.getLists();
+                }
+            },
+
+            getLists(resetLoad) {
+                if (resetLoad === true) {
+                    this.listPage = 1;
+                }
+                this.loadIng++;
+                $A.aAjax({
+                    url: 'project/lists',
+                    data: {
+                        act: 'manage',
+                        page: Math.max(this.listPage, 1),
+                        pagesize: Math.max($A.runNum(this.listPageSize), 10),
+                    },
+                    complete: () => {
+                        this.loadIng--;
+                    },
+                    success: (res) => {
+                        if (res.ret === 1) {
+                            this.lists = res.data.lists;
+                            this.listTotal = res.data.total;
+                        } else {
+                            this.lists = [];
+                            this.listTotal = 0;
+                            this.noDataText = res.msg;
+                        }
+                    }
+                });
+            },
+        }
+    }
+</script>

+ 84 - 0
resources/assets/js/main/mixins/project.js

@@ -0,0 +1,84 @@
+export default {
+    methods: {
+        outProject(projectid, successCallback) {
+            this.$Modal.confirm({
+                title: '退出项目',
+                content: '你确定要退出此项目吗?',
+                loading: true,
+                onOk: () => {
+                    $A.aAjax({
+                        url: 'project/out?projectid=' + projectid,
+                        error: () => {
+                            this.$Modal.remove();
+                            this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
+                        },
+                        success: (res) => {
+                            this.$Modal.remove();
+                            setTimeout(() => {
+                                if (res.ret === 1) {
+                                    this.$Message.success(res.msg);
+                                    typeof successCallback === "function" && successCallback();
+                                }else{
+                                    this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
+                                }
+                            }, 350);
+                        }
+                    });
+                }
+            });
+        },
+
+        favorProject(act, projectid, successCallback) {
+            $A.aAjax({
+                url: 'project/favor',
+                data: {
+                    act: act,
+                    projectid: projectid,
+                },
+                error: () => {
+                    this.$Modal.remove();
+                    this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
+                },
+                success: (res) => {
+                    this.$Modal.remove();
+                    setTimeout(() => {
+                        if (res.ret === 1) {
+                            this.$Message.success(res.msg);
+                            typeof successCallback === "function" && successCallback();
+                        }else{
+                            this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
+                        }
+                    }, 350);
+                }
+            });
+        },
+
+        deleteProject(projectid, successCallback) {
+            this.$Modal.confirm({
+                title: '删除项目',
+                content: '你确定要删除此项目吗?',
+                loading: true,
+                onOk: () => {
+                    $A.aAjax({
+                        url: 'project/delete?projectid=' + projectid,
+                        error: () => {
+                            this.$Modal.remove();
+                            this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
+                        },
+                        success: (res) => {
+                            this.$Modal.remove();
+                            setTimeout(() => {
+                                if (res.ret === 1) {
+                                    this.$Message.success(res.msg);
+                                    typeof successCallback === "function" && successCallback();
+                                }else{
+                                    this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
+                                }
+                            }, 350);
+                        }
+                    });
+                }
+            });
+        }
+    }
+}

+ 32 - 90
resources/assets/js/main/pages/project.vue

@@ -12,9 +12,9 @@
                 </div>
                 <div class="w-nav-flex"></div>
                 <div class="w-nav-right">
-                    <span class="ft hover" @click="handleProject('myfavor', null)"><i class="ft icon">&#xE720;</i> {{$L('收藏的项目')}}</span>
                     <span class="ft hover" @click="handleProject('myjoin', null)"><i class="ft icon">&#xE75E;</i> {{$L('参与的项目')}}</span>
-                    <span class="ft hover" @click="handleProject('mycreate', null)"><i class="ft icon">&#xE764;</i> {{$L('我创建的项目')}}</span>
+                    <span class="ft hover" @click="handleProject('myfavor', null)"><i class="ft icon">&#xE720;</i> {{$L('收藏的项目')}}</span>
+                    <span class="ft hover" @click="handleProject('mycreate', null)"><i class="ft icon">&#xE764;</i> {{$L('我管理的项目')}}</span>
                 </div>
             </div>
         </div>
@@ -115,11 +115,17 @@
             </Tabs>
         </Drawer>
 
-        <Drawer v-model="projectListDrawerShow" width="75%">
+        <Drawer v-model="projectListDrawerShow" width="50%">
             <Tabs v-model="projectListDrawerTab">
-                <TabPane :label="$L('收藏的项目')" name="myfavor"></TabPane>
-                <TabPane :label="$L('参与的项目')" name="myjoin"></TabPane>
-                <TabPane :label="$L('创建的项目')" name="mycreate"></TabPane>
+                <TabPane :label="$L('参与的项目')" name="myjoin">
+                    <project-my-join :canload="projectListDrawerShow && projectListDrawerTab == 'myjoin'"></project-my-join>
+                </TabPane>
+                <TabPane :label="$L('收藏的项目')" name="myfavor">
+                    <project-my-favor :canload="projectListDrawerShow && projectListDrawerTab == 'myfavor'"></project-my-favor>
+                </TabPane>
+                <TabPane :label="$L('管理的项目')" name="mycreate">
+                    <project-my-manage :canload="projectListDrawerShow && projectListDrawerTab == 'mycreate'"></project-my-manage>
+                </TabPane>
             </Tabs>
         </Drawer>
     </div>
@@ -259,8 +265,18 @@
     import ProjectComplete from "../components/project/complete";
     import ProjectUsers from "../components/project/users";
     import ProjectStatistics from "../components/project/statistics";
+    import ProjectMyFavor from "../components/project/my/favor";
+    import ProjectMyJoin from "../components/project/my/join";
+    import ProjectMyManage from "../components/project/my/manage";
+    import Project from "../mixins/project";
     export default {
-        components: {ProjectStatistics, ProjectUsers, ProjectComplete, WLoading, WContent, WHeader},
+        components: {
+            ProjectMyManage,
+            ProjectMyJoin,
+            ProjectMyFavor, ProjectStatistics, ProjectUsers, ProjectComplete, WLoading, WContent, WHeader},
+        mixins: [
+            Project
+        ],
         data () {
             return {
                 loadIng: 0,
@@ -292,7 +308,7 @@
                 projectDrawerTab: 'complete',
 
                 projectListDrawerShow: false,
-                projectListDrawerTab: 'myfavor',
+                projectListDrawerTab: 'myjoin',
 
                 handleProjectId: 0,
             }
@@ -425,7 +441,7 @@
                 }
                 switch (event) {
                     case 'favor': {
-                        this.favorProject(item);
+                        this.favorProject('add', item.id);
                         break;
                     }
                     case 'rename': {
@@ -437,11 +453,15 @@
                         break;
                     }
                     case 'delete': {
-                        this.deleteProject(item);
+                        this.deleteProject(item.id, () => {
+                            this.getLists();
+                        });
                         break;
                     }
                     case 'out': {
-                        this.outProject(item);
+                        this.outProject(item.id, () => {
+                            this.getLists();
+                        });
                         break;
                     }
 
@@ -455,8 +475,8 @@
                         this.projectDrawerTab = event;
                         break;
                     }
-                    case 'myfavor':
                     case 'myjoin':
+                    case 'myfavor':
                     case 'mycreate': {
                         this.projectListDrawerShow = true;
                         this.projectListDrawerTab = event;
@@ -465,26 +485,6 @@
                 }
             },
 
-            favorProject(item) {
-                this.$set(item, 'loadIng', true);
-                $A.aAjax({
-                    url: 'project/favor',
-                    data: {
-                        id: item.id,
-                    },
-                    complete: () => {
-                        this.$set(item, 'loadIng', false);
-                    },
-                    success: (res) => {
-                        if (res.ret === 1) {
-                            this.$Message.success(res.msg);
-                        }else{
-                            this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
-                        }
-                    }
-                });
-            },
-
             renameProject(item) {
                 this.renameValue = "";
                 this.$Modal.confirm({
@@ -609,64 +609,6 @@
                     },
                 });
             },
-
-            deleteProject(item) {
-                this.$Modal.confirm({
-                    title: '删除项目',
-                    content: '你确定要删除此项目吗?',
-                    loading: true,
-                    onOk: () => {
-                        $A.aAjax({
-                            url: 'project/delete?projectid=' + item.id,
-                            error: () => {
-                                this.$Modal.remove();
-                                this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
-                            },
-                            success: (res) => {
-                                this.$Modal.remove();
-                                setTimeout(() => {
-                                    if (res.ret === 1) {
-                                        this.$Message.success(res.msg);
-                                        //
-                                        this.getLists();
-                                    }else{
-                                        this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
-                                    }
-                                }, 350);
-                            }
-                        });
-                    }
-                });
-            },
-
-            outProject(item) {
-                this.$Modal.confirm({
-                    title: '退出项目',
-                    content: '你确定要退出此项目吗?',
-                    loading: true,
-                    onOk: () => {
-                        $A.aAjax({
-                            url: 'project/out?projectid=' + item.id,
-                            error: () => {
-                                this.$Modal.remove();
-                                this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
-                            },
-                            success: (res) => {
-                                this.$Modal.remove();
-                                setTimeout(() => {
-                                    if (res.ret === 1) {
-                                        this.$Message.success(res.msg);
-                                        //
-                                        this.getLists();
-                                    }else{
-                                        this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
-                                    }
-                                }, 350);
-                            }
-                        });
-                    }
-                });
-            }
         },
     }
 </script>