Ver Fonte

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

fenghaifu há 2 anos atrás
pai
commit
7b4ebc28fa
1 ficheiros alterados com 72 adições e 1 exclusões
  1. 72 1
      src/views/activiti/form/demoForm2.vue

+ 72 - 1
src/views/activiti/form/demoForm2.vue

@@ -103,6 +103,9 @@ export default {
             data: {},
             btndisabled: false,
             ceshi_file: null,
+            fArr:[],//保存含有help的单个表单信息
+            cvarr:[],//保存表单所有的label和key(用来寻找改变字段对应的key)
+            bv:[],//保存所有含有help的表单信息
             dynamicData: {
                 jsonData: {},
                 typeData: [], // 请假类型下拉数据
@@ -182,6 +185,11 @@ export default {
                                 this.dynamicData.add = this.add // 新增按钮
                                 // 获取json
                                 this.jsonData = res.result.jsonContent
+                                this.cvarr = []
+                                this.cvarr = []
+                                this.fArr =[]
+                                //遍历help
+                                this.forHelp(this.jsonData)
                                 this.jsonDataSave = JSON.parse(JSON.stringify(res.result.jsonContent))
                                 // 获取申请人信息
                                 this.getApplicant()
@@ -201,6 +209,10 @@ export default {
             } else {
                 // 获取json
                 this.jsonData = res.result.jsonContent
+                 this.cvarr = []
+                 this.fArr =[]
+                 //遍历help(计算)
+                 this.forHelp(this.jsonData)               
                 // 获取申请人信息
                 this.getApplicant()
                 // 如果是手机端子表初始化子表model
@@ -313,6 +325,44 @@ export default {
                 })
             })
         },
+        //遍历help
+        forHelp(obj){
+            for(var a in obj){
+                if (typeof(obj[a]) == "object"){
+                    if(obj[a].help !=='' && obj[a].help){
+                        //保存每一项的label和key
+                        this.cvarr.push({model:obj[a].model,key:obj[a].key})
+                        obj[a].help = obj[a].help.split(',')
+                        //保存含有help的item中的label和help里的信息
+                        this.fArr=[
+                                  {
+                                   label:obj[a].model,
+                                   value:'',
+                                 },
+                                 {
+                                  label: obj[a].help[0],
+                                  value:'',
+                                 },
+                                {
+                                  label: obj[a].help[2],
+                                  value:'',
+                                 },
+                                {
+                                   label: obj[a].help[1],
+                                   value:''
+                                }
+                            ]
+                        //保存多各含有help的数据
+                        this.bv.push({bn:this.fArr})
+                    }else if(obj[a].help ==''){
+                        this.cvarr.push({model:obj[a].model,key:obj[a].key})
+                    }
+                    this.forHelp(obj[a])
+                }
+                
+                }
+               
+        },
         // 获取申请人信息
         getApplicant () {
             console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
@@ -324,7 +374,28 @@ export default {
             // }
         },
         // 表单字段数值发生改变事件
-        handleChange (value, key) {
+        handleChange (value, key) {  
+            //保存发生改变字段名对应的key 
+            var cc =''
+            this.cvarr.map(item=>{
+                if(item.model ==key){
+                    cc=item.key
+                }
+            })
+            //根据数值改变计算
+            this.bv.map(event =>{
+                event.bn.map((item,index) =>{
+                 if(item.label == cc && index!==0){
+                    item.value = value
+                    if(event.bn[3].label =="+"){
+                      event.bn[0].value = Number(event.bn[1].value)+Number(event.bn[2].value)  
+                    }else if(event.bn[3].label =="-"){
+                      event.bn[0].value = Number(event.bn[1].value)-Number(event.bn[2].value)  
+                    }
+                    this.$refs.KFB.setData({[event.bn[0].label]:event.bn[0].value})
+                }
+                })
+            })       
             // 数据变化时触发
             // 如果开始时间发生变化
             if (key == 'start_time') {