bob
2020-08-13 801770456ae3750a44e0989b0025a98ccbad24e6
src/views/Home.vue
@@ -5,7 +5,7 @@
            <div style="width: 100%;height: 60px;"></div>
            <el-menu
                class="el-menu-vertical-demo"
                :unique-opened="false"
                :unique-opened="true"
                  :default-active="defaultActive"
                @select ="menuSelect"
                @open ="menuSelect"
@@ -42,14 +42,86 @@
        <el-container>
          <el-header style="text-align: right; font-size: 15px;padding-right: 40px;">
               <i class="el-icon-user-solid"></i>
               <span>admin</span>
               <span>{{userName}}</span>
               <el-badge :hidden="badge_drawer == 0" :max="99" :value="badge_drawer" class="item_badge" style="line-height: 32px;">
                  <el-button v-if="drawer_" size="small" type="primary" @click="showDrawer_table">通 知</el-button>
               </el-badge>
               <el-button size="small" type="primary" @click="upPassword">修改密码</el-button>
               <el-button size="small" type="primary" @click="Cancel">退 出</el-button>
          </el-header>
          
          <el-main style="background-color: #f7f8f9;">
               <router-view name="home"></router-view>
               <el-drawer
                 :visible.sync="drawer_table"
                 direction="rtl"
                 size="500px">
                  <el-table
                   v-loading="loading_table3"
                   :data="gridData"
                   :header-cell-style="{'width': '100%', 'text-align': 'center', 'background-color': 'rgb(247, 248, 249)'}"
                   >
                     <el-table-column property="code" label="项目号" width="150" align="center" show-overflow-tooltip :formatter="code_"></el-table-column>
                     <el-table-column property="name" label="项目名称" width="200" show-overflow-tooltip :formatter="name_"></el-table-column>
                        <el-table-column prop="orderNo" label="期次" align="center"></el-table-column>
                        <el-table-column prop="isOverdue" label="是否逾期" align="center" :formatter="isOverdue_"></el-table-column>
                        <el-table-column prop="billTime" label="开票日期" width="180" align="center">
                           <template v-slot="{row}">
                              <div>
                                 <el-date-picker style="width: 160px;" size="mini" v-model="row.billTime" type="date" placeholder="选择日期" @change="moneyChange(row)">
                                 </el-date-picker>
                              </div>
                           </template>
                        </el-table-column>
                        <el-table-column prop="money" label="开票金额" width="160" align="center">
                           <template v-slot="{row}">
                              <div>
                                 <el-input-number size="mini" v-model="row.money" @change="moneyChange(row)"></el-input-number>
                              </div>
                           </template>
                        </el-table-column>
                        <el-table-column prop="gatherTime" label="收款日期" width="180" align="center">
                           <template v-slot="{row}">
                              <div>
                                 <el-date-picker style="width: 160px;" size="mini" v-model="row.gatherTime" type="date" placeholder="选择日期" @change="moneyChange(row)">
                                 </el-date-picker>
                              </div>
                           </template>
                        </el-table-column>
                        <el-table-column fixed="right" label="确认收款" width="140" align="center">
                          <template v-slot="{row}">
                            <el-row>
                              <el-button type="primary" size="mini" @click="confirmPhase(row)">确认收款</el-button>
                            </el-row>
                          </template>
                        </el-table-column>
                   </el-table>
               </el-drawer>
               <router-view @refreshDrawer="getbadge_drawer" name="home"></router-view>
          </el-main>
        </el-container>
      </el-container>
      <el-dialog custom-class="z_master_dialog" v-if="dialog_2_2" title="新增兼职成员" :visible.sync="dialog_2_2" width="400px">
        <el-form ref="ruleForm" label-position="left" :model="ruleForm" status-icon :rules="rules" label-width="90px" class="demo-ruleForm">
            <el-form-item label="原密码" prop="pass_obj">
              <el-input type="password" size="small" v-model="ruleForm.pass_obj"></el-input>
            </el-form-item>
            <el-form-item label="新密码" prop="pass">
            <el-input type="password" size="small" v-model="ruleForm.pass" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="确认密码" prop="checkPass">
            <el-input type="password" size="small" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
         <div slot="footer" class="dialog-footer" style="text-align: right;">
          <el-button type="" size="small" @click="dialog_2_2 = false">取 消</el-button>
          <el-button type="primary" size="small" @click="savePassword">保存并重新登录</el-button>
        </div>
      </el-dialog>
   </div>
</template>
@@ -60,47 +132,330 @@
     navigationItem
   },
  data() {
      var validatePass = (rule, value, callback) => {
         if (value === '' || !(/^[A-Za-z0-9]{6,10}$/).test(value) || value.length<6 || value.length>10) {
            callback(new Error('请输入密码,由字母和数字组成且长度在6~10之间'));
         } else {
            if (this.ruleForm.checkPass !== '') {
               this.$refs.ruleForm.validateField('checkPass');
            }
            callback();
         }
      };
      var validatePass2 = (rule, value, callback) => {
         if (value === '') {
            callback(new Error('请再次输入密码'));
         } else if (value !== this.ruleForm.pass) {
            callback(new Error('两次输入密码不一致!'));
         } else {
            callback();
         }
      };
      return {
         breadcrumbItems:[],
         defaultActive: "",
         navList:[
            {
               title:"首页", path:"mine",children:[]
            },
           {
             title:"项目管理", path:"0_1",children:[
               {title:"信息广场", path:"project2",children:[]},
               {title:"项目总览", path:"Overview",children:[]},
               {title:"项目分析", path:"project3",children:[]},
               {title:"归档报告", path:"project4",children:[]},
             ]
           },
           {
             title:"任务管理", path:"0_2",children:[
               {title:"任务列表", path:"calendarTask",children:[]},
             ]
           }
         ],
         navList:[],
         dialog_2_2: false,
         ruleForm: {},
         badge_drawer: 0,
         drawer_:false,
         drawer_table: false,
         loading_table3: false,
         gridData: [],
         timer: null,
         rules: {
            pass_obj: [
               {required: true, message: '请输入原密码', trigger: ['blur', 'change']}
            ],
            pass: [
               {required: true, validator: validatePass, trigger: ['blur', 'change']}
            ],
            checkPass: [
               {required: true, validator: validatePass2, trigger: ['blur', 'change']}
            ]
         },
      }
  },
   created() {
      let userId_ = localStorage.getItem('userId');
      if (!userId_) {
         this.$router.push('/login');
      //let userId_ = localStorage.getItem('userId');
      let userId_ = this.$cookies.get('userId');
      this.userName = this.$cookies.get('userName');
      let departId = this.$cookies.get('departId');
      //this.userName = localStorage.getItem('userName');
      //let departId = localStorage.getItem('departId');
      if (!userId_ || !departId) {
         this.$router.push('/login').catch(err => {err});
      }
      else {
         this.defaultActive = "mine";
         this.$router.push('/mine');
         this.$router.push('/mine').catch(err => {err});
         let type;
         if(departId) {
            type = departId;
            this.$cookies.set('assign', false);
            // localStorage.setItem('assign', false);
         }else {
            type = "all";
            this.$cookies.set('assign', false);
            //localStorage.setItem('assign', true);
         }
         this.getMenu(type);
      }
      if (departId == "300") {
         this.drawer_ = true;
         this.getbadge_drawer();
         this.timer = setInterval(()=>{
            this.getbadge_drawer()
         },1000 * 60 * 5);
      }
   },
   
   beforeDestroy() {//在Vue实例的生命周期结束前执行
     clearInterval(this.timer);
   },
  methods: {
      getMenu(userType) {
         let DayDatas = {
             all: [
               {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
               {'id': "111", 'title': "项目管理", 'path': "0_111"}, //返回的数组字段
               {'id': "112", 'title': "任务管理", 'path': "0_112"},
               {'id': "113", 'title': "财务管理", 'path': "0_113"},
               {'id': "111_1", 'title': "信息广场", 'path': 'square', 'parentId': "111"}, //
               {'id': "111_2", 'title': "项目总览", 'path': 'list', 'parentId': "111"}, //
               {'id': "111_3", 'title': "项目分析", 'path': 'Overview', 'parentId': "111"}, //
               // {'id': "111_4", 'title': "归档报告", 'path': 'project4', 'parentId': "111"}, //
               {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
               {'id': "112_2", 'title': "任务总览", 'path': 'taskOverview', 'parentId': "112"}, //
               {'id': "113_1", 'title': "实际支付费用", 'path': 'actualPayment', 'parentId': "113"}, //
               {'id': "113_2", 'title': "合同完成统计", 'path': 'completeStatistics', 'parentId': "113"}, //
               {'id': "113_3", 'title': "兼职支付确认", 'path': 'partTimeExpenses', 'parentId': "113"}, //
            //   {'id': "113_4", 'title': "成本核算", 'path': 'costAccounting', 'parentId': "113"}, //
               {'id': "113_5", 'title': "已回款统计", 'path': 'collectionStatistics', 'parentId': "113"}, //
            ],
            100: [
                  {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
                  {'id': "111", 'title': "项目管理", 'path': "0_111"}, //返回的数组字段
                  {'id': "112", 'title': "任务管理", 'path': "0_112"},
                  {'id': "111_1", 'title': "信息广场", 'path': 'square', 'parentId': "111"}, //
                  //{'id': "111_2", 'title': "项目总览", 'path': 'list', 'parentId': "111"}, //
                  //{'id': "111_3", 'title': "项目分析", 'path': 'Overview', 'parentId': "111"}, //
                  {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
                  {'id': "112_2", 'title': "任务总览", 'path': 'taskOverview', 'parentId': "112"}, //
               ],
            300:[
               {'id': "113", 'title': "财务管理", 'path': "0_113"},
               {'id': "113_1", 'title': "实际支付费用", 'path': 'actualPayment', 'parentId': "113"}, //
                  {'id': "113_2", 'title': "合同完成统计", 'path': 'completeStatistics', 'parentId': "113"}, //
                  {'id': "113_3", 'title': "兼职支付确认", 'path': 'partTimeExpenses', 'parentId': "113"}, //
                  {'id': "113_5", 'title': "已回款统计", 'path': 'collectionStatistics', 'parentId': "113"}, //
            ],
            400: [
               {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
               {'id': "112", 'title': "任务管理", 'path': "0_112"},
               {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
               {'id': "112_2", 'title': "任务总览", 'path': 'taskOverview', 'parentId': "112"}, //
            ],
            500: [
               {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
               {'id': "112", 'title': "任务管理", 'path': "0_112"},
               {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
               {'id': "112_2", 'title': "任务总览", 'path': 'taskOverview', 'parentId': "112"}, //
            ],
         };
         let list = [];
         if (!userType || userType=='undefined') {
            list = DayDatas['all'];
         }
         else {
            list = DayDatas[userType];
         }
         let parId = "";
         let obj = {};
         let result = [];
         list.map(el => {
             obj[el.id] = el;
         })
         for(let i=0, len = list.length; i < len; i++) {
             let id = list[i].parentId;
             //设置显示字段
             list[i].title = list[i].title;
             if(id == parId || !id) {
                 if(!obj[list[i].id].children) {
                   obj[list[i].id].children = [];
                 }
                 result.push(list[i]);
                 continue;
             }
             if(obj[id].children) {
                 obj[id].children.push(list[i]);
             } else {
                 obj[id].children = [list[i]];
             }
         }
         this.navList = result;
      },
      upPassword() {
         this.ruleForm = {};
         this.dialog_2_2 = true;
      },
      savePassword() {
         let me = this;
         let is_null1 = true;
         this.$refs.ruleForm.validate((valid) => {
            if (!valid) {
               is_null1 = false;
            }
         });
         if (is_null1) {
            let url_ = "/api/user/changePass/" + this.$cookies.get('userId');
            let params_ = {
               prePass: this.ruleForm.pass_obj,
               newPass: this.ruleForm.checkPass,
            };
            this.$axios.get(url_,{
              params: params_
            }).then(data_ => {
               window.console.log(data_);
               if (data_.data.status == "1009") {
                  me.$message.error("保存失败!" + data_.data.message);
               }
               else {
                  me.$router.push('/login').catch(err => {err});
               }
               //me.$cookies.set('userId', null);
            }).catch(error =>{
            })
         }
      },
      Cancel() {
         //localStorage.setItem('userId', null);
         this.$cookies.set('userId', null);
         this.$router.push('/login').catch(err => {err});
      },
      menuSelect(index, a){
       let isPage = index.substring(0,2);
       if (isPage != "0_") {
         this.$router.push('/'+ index);
         this.$router.push('/'+ index).catch(err => {err});
       }
      },
      getbadge_drawer() {
         let me = this;
         let url = "/api/scheme/bill/notice/count";
         me.badge_drawer = 0;
         this.getUrl(url, null, function(data_) {
            if (data_.data.data) {
               me.badge_drawer = data_.data.data;
            }
         })
      },
      showDrawer_table() {
         this.drawer_table = true;
         this.getGridData();
      },
      getGridData() {
         let me = this;
         let url = "/api/scheme/bill/notice";
         me.loading_table3 = true;
         me.gridData = [];
         this.getUrl(url, null, function(data_) {
            me.loading_table3 = false;
            if (data_.data.data) {
               me.gridData = data_.data.data;
            }
            else {
               me.gridData = [];
            }
         })
      },
      confirmPhase(row) {
         let me = this;
         let url = "/api/scheme/bill/check/" + row.id;
         let params = {
            checkUser: this.$cookies.get('userId'),
            money: row.money
         }
         this.getUrl(url, params, function(data_) {
            me.getGridData();
         })
      },
      moneyChange(row) {
         let me = this;
         let url = "/api/scheme/bill/addOrUpdate";
         let params = {...row};
         params.parentId = me.tableData2[0].id;
         this.postUrl(url, params, function(data_) {
         })
      },
      code_(row, colum, val ,index){
         return row.scheme.code;
      },
      name_(row, colum, val ,index){
         return row.scheme.name;
      },
      isOverdue_(row, colum, val ,index){
         let gatherTime_ = row.gatherTime;
         if (new Date() > new Date(gatherTime_)) {
            return "是";
         }
         else{
            return "否";
         }
      },
      getUrl(url, params, callback){
        let me = this;
        this.$axios.get(url,{
          params: params
        }).then(data_ => {
          //console.log(data_);
          if (callback) {
            callback(data_);
          }
        })
        .catch(error =>{
          //console.log(error);
        })
      },
      postUrl(url, params, callback){
        let me = this;
        this.$axios.post(url,params)
        .then(data_ => {
          //console.log(data_);
          if (callback) {
            callback(data_);
          }
        })
        .catch(error =>{
          //console.log(error);
        })
      },
      
     /* handleSelect(key, keyPath){
@@ -133,4 +488,11 @@
  .el-aside {
    color: #333;
  }
   .class_form_z1 .el-form-item{
      margin-bottom: 5px
   }
   .z_master_dialog .el-dialog__body{
      padding-top: 0px;
   }
</style>