瀏覽代碼

调整项目管理

Lijy 3 年之前
父節點
當前提交
d3b372b0c5

+ 16 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/router/index.js

@@ -165,6 +165,22 @@ const router = new Router({
   ]
 });
 
+// 解决编程式路由往同一地址跳转时会报错的情况
+const originalPush = Router.prototype.push;
+const originalReplace = Router.prototype.replace;
+
+Router.prototype.push = function push(location, onResolve, onReject) {
+  if (onResolve || onReject)
+    return originalPush.call(this, location, onResolve, onReject);
+  return originalPush.call(this, location).catch(err => err);
+};
+
+Router.prototype.replace = function push(location, onResolve, onReject) {
+  if (onResolve || onReject)
+    return originalReplace.call(this, location, onResolve, onReject);
+  return originalReplace.call(this, location).catch(err => err);
+};
+
 router.beforeEach((to, from, next) => {
     let { title, needLogin } = to.meta;
     let { isLogin } = store.state;

+ 4 - 4
fhKeeper/formulahousekeeper/timesheet_h5/src/views/login/index.vue

@@ -44,7 +44,7 @@
                 this.$axios.post("/user/loginAdmin", this.form)
                 .then(res => {
                     if(res.code == "ok") {
-                        toast.clear();
+                        this.$toast.clear();
                         this.$toast.success('登录成功');
                         let user = res.data;
                         this.$store.commit("updateLogin", true);
@@ -54,10 +54,10 @@
                         //强制刷新,避免index页面中的mounted不执行
                         window.location.reload();
                     } else {
-                        toast.clear();
+                        this.$toast.clear();
                         this.$toast.fail(res.msg);
                     }
-                }).catch(err=> {toast.clear();});
+                }).catch(err=> {this.$toast.clear();});
             },
             
             jumpTo() {
@@ -78,7 +78,7 @@
                                 } else {
                                     this.$toast.fail(res.msg);
                                 }
-                            }).catch(err=> {toast.clear();});
+                            }).catch(err=> {this.$toast.clear();});
             },
             bindIfNessary() {
                 let href = window.location.href;

+ 98 - 23
fhKeeper/formulahousekeeper/timesheet_h5/src/views/project/index.vue

@@ -3,7 +3,7 @@
         <van-nav-bar title="项目管理" left-text="返回" @click-left="back" :right-text="projectAdd?'新增项目':''" @click-right="openDialog(-1)" fixed left-arrow/>
         
         <div class="login_form">
-            <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
+            <!-- <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
                 <van-list v-model="loading" :finished="finished" finished-text="没有更多了" :error.sync="error" error-text="请求失败,点击重新加载" @load="getProject">
                     <van-swipe-cell v-for="(item,index) in list" :key="index">
                         <van-cell :border="false" :title="item.projectName" :value="item.projectCode"/>
@@ -13,6 +13,17 @@
                         </template>
                     </van-swipe-cell> 
                 </van-list>
+            </van-pull-refresh> -->
+            <van-pull-refresh v-model="isDownLoading" @refresh="onDownRefresh">
+                <van-list v-model="isUpLoading" :finished="upFinished" :immediate-check="false" :offset="10" finished-text="我是有底线的" @load="onLoadList">
+                    <van-swipe-cell v-for="(item,index) in list" :key="index">
+                        <van-cell :border="false" :title="item.projectName" :value="item.projectCode"/>
+                        <template slot="right" v-if="projectManagement || item.creatorId == user.id">
+                            <van-button square type="info" text="编辑" @click="openDialog(index)"/>
+                            <van-button square type="danger" text="删除" @click="delPro(index)"/>
+                        </template>
+                    </van-swipe-cell> 
+                </van-list>
             </van-pull-refresh>
 
             <van-dialog v-model="show" :title="title" show-cancel-button :beforeClose="chargeBtn">
@@ -79,6 +90,13 @@
                 ause: [],
                 projectAdd: false, // 新增项目
                 projectManagement: false, // 管理项目
+                 isDownLoading: false, // 下拉刷新
+                isUpLoading: false, // 上拉加载
+                upFinished: false, // 上拉加载完毕
+                offset: 100, // 滚动条与底部距离小于 offset 时触发load事件
+                pageSize: 25, // 每页条数
+                pageIndex: 1, // 页码
+                dpp: false,
             };
         },
         created() {
@@ -201,35 +219,91 @@
 
             // 获取项目
             getProject() {
-                if (this.refreshing) {
-                    this.list = [];
-                    this.refreshing = false;
-                }
-                if(this.total == this.list.length && this.list.length != 0) {
-                    this.loading = false;
-                    this.finished = true;
-                    return false;
-                }
+                // if (this.refreshing) {
+                //     this.list = [];
+                //     this.refreshing = false;
+                // }
+                // if(this.total == this.list.length && this.list.length != 0) {
+                //     this.loading = false;
+                //     this.finished = true;
+                //     return false;
+                // }
+                // this.$axios.post("/project/getProjectPage", {
+                //     pageIndex: this.page,
+                //     pageSize: this.size,
+                // })
+                // .then(res => {
+                //     if(res.code == "ok") {
+                //         this.loading = false;
+                //         if (this.list.length == 0) {
+                //             this.finished = true;
+                //         }
+                //         this.list = [];
+                //         for(var i in res.data.records) {
+                //             this.list.push(res.data.records[i])
+                //         }
+                //         this.total = res.data.total;
+                //         this.page++;
+                //     } else {
+                //         this.$toast.fail('获取失败:'+res.msg);
+                //     }
+                // }).catch(err=> {toast.clear();});
+
                 this.$axios.post("/project/getProjectPage", {
-                    pageIndex: this.page,
-                    pageSize: this.size,
+                    pageIndex: this.pageIndex,
+                    pageSize: this.pageSize,
                 })
                 .then(res => {
                     if(res.code == "ok") {
-                        this.loading = false;
-                        if (this.list.length == 0) {
-                            this.finished = true;
-                        }
-                        this.list = [];
-                        for(var i in res.data.records) {
-                            this.list.push(res.data.records[i])
+                        this.isDownLoading = false
+                        this.isUpLoading = false
+                        this.total = res.data.total
+                        var datas = res.data.records
+                        if(res.data.records.length <= 0) {
+                            this.total = 0,
+                            this.list = []
+                            this.$toast('已全部加载完成');
+                            return
+                        } else {
+                            console.log(this.dpp)
+                            if(this.dpp) this.list = []
+                            if(this.list.length == 0) {
+                                this.list = datas
+                            } else {
+                                for(var i in datas) {
+                                    this.list.push(datas[i])
+                                }
+                            }
                         }
-                        this.total = res.data.total;
-                        this.page++;
                     } else {
-                        this.$toast.fail('获取失败:'+res.msg);
+                        this.$toast.fail('获取失败');
+                        this.isDownLoading = false
+                        this.isUpLoading = false
                     }
-                }).catch(err=> {toast.clear();});
+                }).catch(err=> {
+                    toast.clear();
+                    this.isDownLoading = false
+                    this.isUpLoading = false
+                });
+            },
+            onDownRefresh() {
+                console.log(123)
+                this.dpp = true
+                this.pageIndex = 1
+                this.upFinished = false // 不写这句会导致你上拉到底过后在下拉刷新将不能触发下拉加载事件
+                this.getProject()
+            },
+            onLoadList() {
+                console.log('出发没')
+                if(this.total <= this.list.length) {
+                    this.$toast('已全部加载完成');
+                    this.upFinished = false
+                    this.isUpLoading = false
+                    return
+                }
+                this.pageIndex = +this.pageIndex + 1
+                this.dpp = false
+                this.getProject()
             },
 
             onRefresh() {
@@ -389,6 +463,7 @@
         mounted() {
             this.getUsers();
             this.yanjiuzx()
+            this.getProject()
             // this.canEdit = (this.user.role==1||this.user.role==2||this.user.role==5);
             var list = this.user.functionList
             for(var i in list) {