Prechádzať zdrojové kódy

Merge branch 'master' of http://139.196.39.194:9021/chenc/cd-work-flow-web

yuansh 2 rokov pred
rodič
commit
efa852c4aa

+ 5 - 1
src/api/oa/cd-personnel-files.js

@@ -4,9 +4,13 @@ import { getAction, deleteAction, putAction, postAction } from '@/api/manage'
 // 查询分页数据-----人员档案
 const personList = (params) => getAction('/sys/user/list', params)
 
+// 年假
+const annualLeave = (params) => getAction('/sys/user/queryByUsername', params)
+
 // 查询分页数据-----固定资产-转移
 const getFixedZy = (params) => getAction('/oa/assets/getByState', params)
 export {
     personList,
-    getFixedZy
+    getFixedZy,
+    annualLeave
 }

+ 49 - 14
src/views/activiti/form/demoForm2.vue

@@ -65,7 +65,7 @@ import CarSqModal from './carSqModal'
 import MaterialSlModal from './materialSlModal'
 import FixedZyModal from './fixedZyModal'
 import { postAction, postFormDataAction} from '@/api/manage'
-// import {annualLeave} from '@api/oa/cd-personnel-files'
+import {annualLeave} from '@api/oa/cd-personnel-files'
 import moment from 'moment'
 export default {
     name: 'DemoForm',
@@ -103,6 +103,7 @@ export default {
                 formData: {},
                 jsonData: {}
             },
+            leave:0,//剩余年假
             disabled2: false, // 用来取决于表单时不同流程节点填写不同表单信息使用
             jsonData: {}, // 前台任意改变的json
             jsonDataSave: {}, // 保存到数据库的json
@@ -459,11 +460,17 @@ export default {
                                   },0)
                            }else if(item[1].label =='user'){
                               this.$store.getters.userInfo
-                                
                                var that = this
                                setTimeout(function(){
                                that.$refs.KFB.setData({[item[0].label]:that.$store.getters.userInfo.username})   
                                   },0)
+                                  annualLeave({username:that.$store.getters.userInfo.username}).then(res => {
+                                   if (res.success) {
+                                   this.leave = res.result.nannualNowNum
+                                  }else{
+                                   this.$message.error(res.message);
+                                  }
+                                })
                            }
         },
         // 获取申请人信息
@@ -507,16 +514,32 @@ export default {
          specialTerms(value,key){
             var that = this
             //剩余年假
-            // if(key == 'employe_name'){
-            //       annualLeave({username:value}).then(res => {
-            //         if (res.success) {
-            //         //   this.declareElementsData = res.result.records
-            //           //  this.dataSource =res.result.records
-            //         }else{
-            //            this.$message.error(res.message);
-            //         }
-            //     })
-            // }
+            if(key == 'employe_name'){
+                setTimeout(function(){
+                    annualLeave({username:value}).then(res => {
+                    if (res.success) {
+                      //选择姓名获取页面的请假类型和时间间隔
+                      that.leave = res.result.nannualNowNum
+                      var category = that.$refs.KFB.form.getFieldValue('leave_category')
+                      var time1 = that.$refs.KFB.form.getFieldValue('start_date')
+                      var time2 = that.$refs.KFB.form.getFieldValue('end_date')
+                      var timeC=that.timeDifference(time1,time2,'min') //获取时间差
+                      //事假,超过180分钟,年假大于0.5
+                      if(category == 1 &&timeC>180&&that.leave>=0.5){
+                          that.$refs.KFB.setData({unit:'2'})
+                          that.$refs.KFB.setData({leave_category:'2'})
+                        }else if(category == 2 && that.leave<0.5){   //类型为年假,剩余年假小于0.5
+                             that.$refs.KFB.setData({unit:'1'}) 
+                             that.$refs.KFB.setData({leave_category:''})
+                             that.$message.error('剩余年假不足!');
+                        }
+                    }else{
+                       that.$message.error(res.message); 
+                       
+                    }
+                })
+                },0)
+            }
              //请假类型与单位
             //事假
             if(key == 'leave_category' && value == '1'){
@@ -524,7 +547,7 @@ export default {
                 var time1 = that.$refs.KFB.form.getFieldValue('start_date')
                 var time2 = that.$refs.KFB.form.getFieldValue('end_date')
                 var timeC=that.timeDifference(time1,time2,'min') //获取时间差
-                if(timeC>180){
+                if(timeC>180 && that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
                     that.$refs.KFB.setData({unit:'2'})
                     that.$refs.KFB.setData({leave_category:'2'})
                 }else{
@@ -535,6 +558,18 @@ export default {
                 setTimeout(function(){
                  that.$refs.KFB.setData({unit:'1'})   
                 },0)
+            }else if(key == 'leave_category' && value == '2'){//年假
+                 setTimeout(function(){
+                    if(that.leave >=0.5){  //剩余年假大于0.5
+                        that.$refs.KFB.setData({unit:'2'})  
+                    }else{ //剩余年假小于0.5
+                         that.$refs.KFB.setData({unit:'1'}) 
+                         that.$refs.KFB.setData({leave_category:''})
+                         that.$message.error('剩余年假不足!');
+                    }
+
+                },0)
+
             }else if(key == 'leave_category'){
                 setTimeout(function(){
                     that.$refs.KFB.setData({unit:'2'})   
@@ -547,7 +582,7 @@ export default {
                     var time1 = that.$refs.KFB.form.getFieldValue('start_date')
                     var timeC=that.timeDifference(time1,time2,'min')
                     var lx=that.$refs.KFB.form.getFieldValue('leave_category')
-                     if(timeC>180&&lx=='1'){
+                    if(timeC>180&&lx=='1'&&that.leave>=0.5){ //事假,时间差大于180,剩余年假大于0.5
                         that.$refs.KFB.setData({unit:'2'})
                           that.$refs.KFB.setData({leave_category:'2'})
                      }