-
zhangwei
2025-01-23 e5a77d6a551d13e4cf74624b31b0fa3e328b304d
src/pages/mine/index.vue
@@ -1,6 +1,6 @@
<template>
   <view class="container">
      <view class="header">
      <view :class="identity=='enterprise'?'header-hide':'header'">
         <view class="header-img">
            <view class="header-image-left" @click='tologin'>
               <up-avatar :src="userInfo.avatar" shape="circle" size='60'></up-avatar>
@@ -12,7 +12,7 @@
               <text class='iconfont icon-qiehuan chuany-font28'></text>
            </view>
         </view>
         <view class="num-box">
         <view class="num-box" v-if="identity!=='enterprise'">
            <view @tap="goWallet" class="num-item" data-ptpid="ef57-17f4-bbea-280f">
               <view class="num-bold">{{ balance }}元</view>
               <view class="num-text">
@@ -28,13 +28,13 @@
               企业服务
            </view>
            <view class="tool_content">
               <view class="tool_item" @click="toRelease">
               <view class="tool_item" @click="toRelease" v-if="isAdmin">
                  <image src="@/static/image/fabu.png" mode="aspectFit" class="item_img"></image>
                  <view class="tool_label">
                     发布职位
                  </view>
               </view>
               <view class="tool_item" @click="toOrder">
               <view class="tool_item" @click="toOrder" v-if="isAdmin">
                  <image src="@/static/image/guanli.png" mode="aspectFit" class="item_img"></image>
                  <view class="tool_label">
                     职位管理
@@ -46,18 +46,18 @@
                     我的企业
                  </view>
               </view>
               <view class="tool_item" @click="toWorkerRecord">
               <view class="tool_item" @click="toWorkerRecord" v-if="isAdmin">
                  <image src="@/static/image/record.png" mode="aspectFit" class="item_img"></image>
                  <view class="tool_label">
                     打卡记录
                     工资审核
                  </view>
               </view>
               <!-- <view class="tool_item" @click="toPage('/otherPages/member/sendCompany/sendCompany')">
                  <image src="@/static/image/server.png" mode="aspectFit" class="item_img"></image>
               <view class="tool_item" @click="toSalary" v-if="isAdmin">
                  <image src="@/static/image/salary.png" mode="aspectFit" class="item_img"></image>
                  <view class="tool_label">
                     服务中心
                     工资查询
                  </view>
               </view> -->
               </view>
            </view>
         </view>
      </view>
@@ -80,16 +80,74 @@
            </view>
        </view> -->
      <view class="nav-box" v-if="identity=='enterprise'">
         <view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
            v-for="(item, index) in navList" :key="item.name">
            <view class="nav-title">
               <view :class="'iconfont ' + item.icon"></view>
               {{ item.name }}
            </view>
         <view class="" v-if="isAdmin">
            <view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
               v-for="(item, index) in navList" :key="item.name">
               <view class="nav-title">
                  <view :class="'iconfont ' + item.icon"></view>
                  {{ item.name }}
               </view>
            <view class="nav-icon">
               <view v-if="item.num || item.num === 0">{{ item.num }}</view>
               <view class="iconfont iconarrow"></view>
               <view class="nav-icon">
                  <view v-if="item.num || item.num === 0">{{ item.num }}</view>
                  <view class="iconfont iconarrow"></view>
               </view>
            </view>
         </view>
         <view class="" v-if="isWorker">
            <view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
               v-for="(item, index) in workerList" :key="item.name">
               <view class="nav-title">
                  <view :class="'iconfont ' + item.icon"></view>
                  {{ item.name }}
               </view>
               <view class="nav-icon">
                  <view v-if="item.num || item.num === 0">{{ item.num }}</view>
                  <view class="iconfont iconarrow"></view>
               </view>
            </view>
         </view>
         <view class="" v-if="Isbaoxiaojingli">
            <view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
               v-for="(item, index) in jingLiList" :key="item.name">
               <view class="nav-title">
                  <view :class="'iconfont ' + item.icon"></view>
                  {{ item.name }}
               </view>
               <view class="nav-icon">
                  <view v-if="item.num || item.num === 0">{{ item.num }}</view>
                  <view class="iconfont iconarrow"></view>
               </view>
            </view>
         </view>
         <view class="" v-if="IsBaoxiaozhuguan">
            <view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
               v-for="(item, index) in zhuGuanList" :key="item.name">
               <view class="nav-title">
                  <view :class="'iconfont ' + item.icon"></view>
                  {{ item.name }}
               </view>
               <view class="nav-icon">
                  <view v-if="item.num || item.num === 0">{{ item.num }}</view>
                  <view class="iconfont iconarrow"></view>
               </view>
            </view>
         </view>
         <view class="" v-if="IsCaiWu">
            <view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
               v-for="(item, index) in CaiWuList" :key="item.name">
               <view class="nav-title">
                  <view :class="'iconfont ' + item.icon"></view>
                  {{ item.name }}
               </view>
               <view class="nav-icon">
                  <view v-if="item.num || item.num === 0">{{ item.num }}</view>
                  <view class="iconfont iconarrow"></view>
               </view>
            </view>
         </view>
      </view>
@@ -113,24 +171,84 @@
</template>
<script>
   var app = getApp();
   import {
      mapActions,
      mapGetters,
      mapMutations
   } from 'vuex'
   export default {
      data() {
         return {
            identity: '',
            navList: [
               //    {
               //    icon: 'icon-huabanfuben',
               //    name: '工人打卡记录',
               //    cb: function() {
               //       uni.navigateTo({
               //          url: '/pages/company/index'
               //       });
               //    }
               // },
            navList: [{
               icon: 'icon-huabanfuben',
               name: '员工管理',
               cb: function() {
                  uni.navigateTo({
                     url: '/pages/company/staff'
                  });
               }
            }],
            workerList: [{
               icon: 'icon-baoxiaoshenqing',
               name: '费用报销申请',
               cb: function() {
                  uni.navigateTo({
                     url: '/pages/reimbursement/index'
                  });
               }
            },{
               icon: 'icon-baoxiao',
               name: '我的费用报销',
               cb: function() {
                  uni.navigateTo({
                     url: '/pages/reimbursement/myreim'
                  });
               }
            }],
            CaiWuList:[
               {
                  icon: 'icon-baoxiaodan',
                  name: '费用报销',
                  cb: function() {
                     uni.navigateTo({
                        url: '/pages/reimbursement/reimbursement'
                     });
                  }
               }
            ],
            navList1: [{
            zhuGuanList:[
               {
                  icon: 'icon-shenpicaigoudan',
                  name: '主管列表',
                  cb: function() {
                     uni.navigateTo({
                        url: '/pages/reimbursement/examine?role=zhuGuan'
                     });
                  }
               }
            ],
            jingLiList:[
               {
                  icon: 'icon-shenpi',
                  name: '经理列表',
                  cb: function() {
                     uni.navigateTo({
                        url: '/pages/reimbursement/examine?role=jingLi'
                     });
                  }
               }
            ],
            navList2: [{
                  icon: 'icon-dingdan',
                  name: '上班打卡',
                  cb: this.toMyWork
               },
               {
                  icon: 'icon-fuwutuandui',
                  name: '工作记录',
                  cb: this.toMyRecord
               },
               {
                  icon: 'icon-wanshanxinxi',
                  name: '完善资料',
                  cb: function() {
@@ -139,9 +257,10 @@
                     });
                  }
               },
               {
            ],
            navList3: [{
                  icon: 'icon-dingdan',
                  name: '我的工作',
                  name: '上班打卡',
                  cb: this.toMyWork
               },
               {
@@ -149,42 +268,89 @@
                  name: '工作记录',
                  cb: this.toMyRecord
               },
               {
                  icon: 'icon-wanshanxinxi',
                  name: '修改资料',
                  cb: function() {
                     uni.navigateTo({
                        url: '/pages/mine/apply'
                     });
                  }
               },
            ],
            isLogin: false,
            userInfo: {},
            balance: '0.00'
            token: this.$db.get('userToken') || ''
         };
      },
      onLoad: function() {
      },
      onShow: function() {
         let that = this
         this.userInfo = this.$db.get('userInfo') ? JSON.parse(this.$db.get('userInfo')) : {}
         this.token = this.$db.get('userToken') ? this.$db.get('userToken') : ''
         uni.getStorage({
            key: 'identity',
            success: function(res) {
               that.identity = res.data
               if (res.data == 'worker') {
                  if (that.userInfo.userWorker) {
                     that.balance = that.$common.moneySub(that.userInfo.userWorker.tiXianZonge, that
                        .userInfo.userWorker.yiTiXianJine)
                  }
         this.getUserInfo()
      },
      computed: {
         ...mapGetters(['userInfo', 'identity']),
         isAdmin() {
            return this.userInfo.userCompany ? this.userInfo.userCompany.isAdmin : false
         },
         // 是否是员工
         isWorker() {
            if (this.userInfo.oaPermissions) {
               return this.userInfo.oaPermissions.memberId ? true : false
            }
            return false
         },
         // 是否为报销主管
         IsBaoxiaozhuguan() {
            if (this.userInfo.oaPermissions) {
               return this.userInfo.oaPermissions.bF_IsBaoxiaozhuguan ? true : false
            }
            return false
         },
         // 是否为报销经理
         Isbaoxiaojingli() {
            if (this.userInfo.oaPermissions) {
               return this.userInfo.oaPermissions.bF_Isbaoxiaojingli ? true : false
            }
            return false
         },
         // 财务
         IsCaiWu() {
            if (this.userInfo.oaPermissions) {
               return this.userInfo.oaPermissions.bF_IsCaiWu ? true : false
            }
            return false
         },
         navList1() {
            return this.userInfo.userWorker ? this.navList3 : this.navList2
         },
         isLogin() {
            return this.token ? true : false;
         },
         balance() {
            if (this.identity == 'worker') {
               if (this.userInfo.userWorker) {
                  return this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
                     .userWorker
                     .yiTiXianJine)
               } else {
                  if (that.userInfo.userCompany) {
                     that.balance = that.userInfo.userCompany.chongZhiYue ? that.userInfo
                        .userCompany.chongZhiYue : '0.00'
                  }
                  return '0.00'
               }
            } else {
               if (this.userInfo.userCompany) {
                  return this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
                     .chongZhiYue :
                     '0.00'
               } else {
                  return '0.00'
               }
            }
         });
         // this.userInfo = this.$db.get('userInfo') ? JSON.parse(this.$db.get('userInfo')) : {}
         // this.token = this.$db.get('userToken') ? this.$db.get('userToken') : ''
         this.isLogin = this.token ? true : false;
         }
      },
      methods: {
         ...mapActions([
            'getUserInfo'
         ]),
         ...mapMutations(['setIdentity']),
         tologin() {
            if (this.isLogin) {
               uni.navigateTo({
@@ -198,6 +364,9 @@
         },
         toOrder() {
            if (!this.userInfo.userCompany) {
               uni.navigateTo({
                  url: '/pages/enterprise/enterprise'
               });
               this.$util.showToast({
                  title: '请先完善企业资料!'
               })
@@ -209,6 +378,9 @@
         },
         toRelease() {
            if (!this.userInfo.userCompany) {
               uni.navigateTo({
                  url: '/pages/enterprise/enterprise'
               });
               this.$util.showToast({
                  title: '请先完善企业资料!'
               })
@@ -225,6 +397,9 @@
         },
         toWorkerRecord() {
            if (!this.userInfo.userCompany) {
               uni.navigateTo({
                  url: '/pages/enterprise/enterprise'
               });
               this.$util.showToast({
                  title: '请先完善企业资料!'
               })
@@ -234,8 +409,25 @@
               url: '/pages/company/index'
            });
         },
         toSalary() {
            if (!this.userInfo.userCompany) {
               uni.navigateTo({
                  url: '/pages/enterprise/enterprise'
               });
               this.$util.showToast({
                  title: '请先完善企业资料!'
               })
               return
            }
            uni.navigateTo({
               url: '/pages/worker/salary'
            });
         },
         toMyWork() {
            if (!this.userInfo.userWorker) {
               uni.navigateTo({
                  url: '/pages/mine/apply'
               });
               this.$util.showToast({
                  title: '请先完善资料!'
               })
@@ -245,8 +437,11 @@
               url: '/pages/order/myorder'
            });
         },
         toMyRecord(){
         toMyRecord() {
            if (!this.userInfo.userWorker) {
               uni.navigateTo({
                  url: '/pages/mine/apply'
               });
               this.$util.showToast({
                  title: '请先完善资料!'
               })
@@ -257,23 +452,25 @@
            });
         },
         changRole() {
            this.identity = this.identity === 'enterprise' ? 'worker' : 'enterprise'
            console.log(this.identity, 'this.identity');
            uni.setStorage({
               key: 'identity',
               data: this.identity,
            });
            if (this.identity == 'worker') {
               if (this.userInfo.userWorker) {
                  this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo.userWorker
                     .yiTiXianJine)
               }
            } else {
               if (this.userInfo.userCompany) {
                  this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany.chongZhiYue :
                     '0.00'
               }
            }
            this.$store.commit('setIdentity', this.identity === 'enterprise' ? 'worker' : 'enterprise')
            // this.$db.set('identity', this.identity === 'enterprise' ? 'worker' : 'enterprise')
            // this.identity = this.identity === 'enterprise' ? 'worker' : 'enterprise'
            console.log(this.identity, this.$db.get('identity'), 'this.identity');
            // uni.setStorage({
            //    key: 'identity',
            //    data: this.identity,
            // });
            // if (this.identity == 'worker') {
            //    if (this.userInfo.userWorker) {
            //       this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo.userWorker
            //          .yiTiXianJine)
            //    }
            // } else {
            //    if (this.userInfo.userCompany) {
            //       this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany.chongZhiYue :
            //          '0.00'
            //    }
            // }
         },
         goWallet() {
            uni.navigateTo({
@@ -455,6 +652,7 @@
         .tool_content {
            display: flex;
            justify-content: space-between;
            padding: 30rpx 0;
            .tool_item {
@@ -463,7 +661,7 @@
               flex-direction: column;
               height: 120rpx;
               justify-content: center;
               margin: 0 50rpx 0 0;
               // margin: 0 50rpx 0 0;
               width: 120rpx;
               &:nth-child(4n) {