瀏覽代碼

控件默认时间(当天)

jbb 2 年之前
父節點
當前提交
c13b5bbdff
共有 1 個文件被更改,包括 21 次插入11 次删除
  1. 21 11
      src/views/activiti/form/demoForm2.vue

+ 21 - 11
src/views/activiti/form/demoForm2.vue

@@ -56,6 +56,7 @@
 import pick from 'lodash.pick'
 import todoManageOperation from '../operation/todoManageOperation'
 import { postAction, postFormDataAction } from '@/api/manage'
+ import moment from 'moment'
 export default {
     name: 'DemoForm',
     props: {
@@ -77,7 +78,8 @@ export default {
         isNew: { type: Boolean, default: false, required: false }
     },
     components: {
-        todoManageOperation
+        todoManageOperation,
+        moment
     },
     data () {
         return {
@@ -185,8 +187,7 @@ export default {
                                 this.dynamicData.add = this.add // 新增按钮
                                 // 获取json
                                 this.jsonData = res.result.jsonContent
-                                // this.jsonData.list[8].columns[0].list[0].help = "input_1627377270350,input_1627377316607,-"
-                                // this.jsonData.list[3].help = 'date_1626143660261,-,date_1626143662152'
+                                // this.jsonData.list[2].columns[0].list[0].help = "date_1663752082983,date_1663753163575,hour"
                                 this.cvarr = []
                                 this.cvarr = []
                                 this.fArr =[]
@@ -211,8 +212,8 @@ export default {
             } else {
                 // 获取json
                 this.jsonData = res.result.jsonContent
-                // this.jsonData.list[0].trs[4].tds[1].list[0].help = 'date_1662521249459,date_1662521252212,day'
-                // debugger
+                // this.jsonData.list[0].trs[5].tds[2].list[0].help = 'input_1662521241170,input_1662521240862,-'
+                // this.jsonData.list[0].trs[3].tds[2].list[0].help = 'today'
                  this.cvarr = []
                  this.fArr =[]
                  //遍历help(计算)
@@ -358,6 +359,8 @@ export default {
                             ]
                         //保存多各含有help的数据
                         this.bv.push({bn:this.fArr})
+                       //默认当天时间
+                        this.defualtData()
                     }else if(obj[a].help ==''){
                         this.cvarr.push({model:obj[a].model,key:obj[a].key,type:obj[a].type})
                     }
@@ -365,6 +368,17 @@ export default {
                 }
                 }               
         },
+        defualtData(){
+             this.bv.map(item=>{
+                           if(item.bn[1].label =='today'){
+                               item.bn[0].value =moment(new Date()).format('YYYY-MM-DD')
+                               var that = this
+                               setTimeout(function(){
+                               that.$refs.KFB.setData({[item.bn[0].label]:item.bn[0].value})   
+                                  },0)
+                           }
+                        })
+        },
         // 获取申请人信息
         getApplicant () {
             console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
@@ -411,14 +425,10 @@ export default {
                     if(type == 'date'){
                         if(event.bn[1].value!=='' && event.bn[2].value!==''){
                             var state = ''
-                            if(event.bn[3].label == ''|| !event.bn[3].label){
-                                state ='hour'
-                            }else{
-                                state = event.bn[3].label
-                            }
+                            state = event.bn[3].label
                             event.bn[0].value = this.timeDifference(event.bn[1].value,event.bn[2].value,state)
                         }
-                    }else{
+                       }else{
                         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 =="-"){