chenc 3 years ago
parent
commit
f59f087170
1 changed files with 55 additions and 48 deletions
  1. 55 48
      src/views/activiti/form/demoForm2.vue

+ 55 - 48
src/views/activiti/form/demoForm2.vue

@@ -87,7 +87,8 @@ export default {
         jsonData: {}
         jsonData: {}
       },
       },
       disabled2: false, //用来取决于表单时不同流程节点填写不同表单信息使用
       disabled2: false, //用来取决于表单时不同流程节点填写不同表单信息使用
-      jsonData: {},
+      jsonData: {},//前台任意改变的json
+      jsonDataSave: {},//保存到数据库的json
       url: {
       url: {
         getForm: '/actBusiness/getForm',
         getForm: '/actBusiness/getForm',
         addApply: '/actBusiness/add',
         addApply: '/actBusiness/add',
@@ -138,16 +139,10 @@ export default {
     this.getAction('/tbTableInfo/query', {
     this.getAction('/tbTableInfo/query', {
       businessTable: this.processData.businessTable,
       businessTable: this.processData.businessTable,
       taskNodeId: this.processData.key,
       taskNodeId: this.processData.key,
-      tableId: this.processData.tableId
+      tableId: this.processData.tableId,
+      type: '1'
     }).then(res => {
     }).then(res => {
-      // this.$refs.KFB.setData({aaa:null,bbb:null,name:"123"})
-      // this.$refs.KFB.getData().then(res => {
-      //   console.log('aaa',res)
-      // })
-
       var jsonString = JSON.stringify(res.result.jsonContent)
       var jsonString = JSON.stringify(res.result.jsonContent)
-      
-      // var jsonString='123d"dynamicKey":"666"'
       var index = 1
       var index = 1
 
 
       var dynamicKeyValueList = []
       var dynamicKeyValueList = []
@@ -168,12 +163,6 @@ export default {
           index = ihEnd + 1
           index = ihEnd + 1
         }
         }
       }
       }
-      //循环动态数据源表示获取数据
-      // if(dynamicKeyValueList.length>0){
-      //   dynamicKeyValueList.forEach(async element => {
-      //      await this.getDataListByName(element);
-      //   });
-      // }
       console.log(dynamicKeyValueList)
       console.log(dynamicKeyValueList)
       if (dynamicKeyValueList.length > 0) {
       if (dynamicKeyValueList.length > 0) {
         //获取数据字典数据源
         //获取数据字典数据源
@@ -192,8 +181,9 @@ export default {
                 this.dynamicData.add = this.add //新增按钮
                 this.dynamicData.add = this.add //新增按钮
                 //获取json
                 //获取json
                 this.jsonData = res.result.jsonContent
                 this.jsonData = res.result.jsonContent
+                this.jsonDataSave = JSON.parse(JSON.stringify(res.result.jsonContent))
                 //获取申请人信息
                 //获取申请人信息
-                this.getApplicant();
+                this.getApplicant()
                 //如果是手机端子表初始化子表model
                 //如果是手机端子表初始化子表model
                 this.listUpdateModel()
                 this.listUpdateModel()
                 if (!this.isNew) {
                 if (!this.isNew) {
@@ -211,7 +201,7 @@ export default {
         //获取json
         //获取json
         this.jsonData = res.result.jsonContent
         this.jsonData = res.result.jsonContent
         //获取申请人信息
         //获取申请人信息
-        this.getApplicant();
+        this.getApplicant()
         //如果是手机端子表初始化子表model
         //如果是手机端子表初始化子表model
         this.listUpdateModel()
         this.listUpdateModel()
         // window.jsonData=this.jsonData;
         // window.jsonData=this.jsonData;
@@ -270,46 +260,61 @@ export default {
     init() {
     init() {
       this.btndisabled = true
       this.btndisabled = true
       var r = this.processData
       var r = this.processData
-
       this.getAction(this.url.getForm, {
       this.getAction(this.url.getForm, {
         tableId: r.tableId,
         tableId: r.tableId,
         tableName: r.tableName
         tableName: r.tableName
       }).then(res => {
       }).then(res => {
-        if (res.success) {
-          let formData = res.result
-          formData.tableName = r.tableName
-          this.data = formData
-          //如果表单是手机端的子表则
-          if (this.isSJ) {
-            var formModelList = _.keys(this.data)
-              .join(',')
-              .split(',')
-            var itemList = []
-            formModelList.forEach(element => {
-              if (element.indexOf('child&') != -1) {
-                itemList = JSON.parse(JSON.stringify(this.data[element]))
-                delete this.data[element]
+        //第一次调接口根据子表数据渲染子表前台效果
+        //只有手机端才执行
+        if (this.isSJ) {
+          _.keys(res.result).forEach((e, i) => {
+            if (e.indexOf('child&') != -1) {
+              if (i > 0) {
+                this.add()
               }
               }
-            })
-            //子表字段名
-            //子表数据model和值组装
-            itemList.forEach((item, index) => {
-              this.itemModelNameList.forEach(itemModelName => {
-                this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
+            }
+          })
+        }
+        this.getAction(this.url.getForm, {
+          tableId: r.tableId,
+          tableName: r.tableName
+        }).then(res => {
+          if (res.success) {
+            let formData = res.result
+            formData.tableName = r.tableName
+            this.data = formData
+            //如果表单是手机端的子表则
+            if (this.isSJ) {
+              var formModelList = _.keys(this.data)
+                .join(',')
+                .split(',')
+              var itemList = []
+              formModelList.forEach(element => {
+                if (element.indexOf('child&') != -1) {
+                  itemList = JSON.parse(JSON.stringify(this.data[element]))
+                  delete this.data[element]
+                }
               })
               })
-            })
+              //子表字段名
+              //子表数据model和值组装
+              itemList.forEach((item, index) => {
+                this.itemModelNameList.forEach(itemModelName => {
+                  this.data[itemModelName + '@' + (index + 1)] = item[itemModelName]
+                })
+              })
+            }
+            //赋值
+            this.$refs.KFB.setData(this.data)
+            this.btndisabled = false
+          } else {
+            this.$message.error(res.message)
           }
           }
-          //赋值
-          this.$refs.KFB.setData(this.data)
-          this.btndisabled = false
-        } else {
-          this.$message.error(res.message)
-        }
+        })
       })
       })
     },
     },
     //获取申请人信息
     //获取申请人信息
     getApplicant() {
     getApplicant() {
-      console.log("aa",this.$refs.KFB.form.getFieldValue('applicant'))
+      console.log('aa', this.$refs.KFB.form.getFieldValue('applicant'))
       // if (this.$refs.KFB.form.getFieldValue('applicant')) {
       // if (this.$refs.KFB.form.getFieldValue('applicant')) {
       //   alert(1)
       //   alert(1)
       //   this.$refs.KFB.setData({
       //   this.$refs.KFB.setData({
@@ -436,7 +441,8 @@ export default {
             }
             }
           })
           })
           //如果手机端子表得则需要修改json
           //如果手机端子表得则需要修改json
-          var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
           if (!this.isSJ && this.isNew) {
           if (!this.isSJ && this.isNew) {
             jsonPamats = null
             jsonPamats = null
           }
           }
@@ -553,7 +559,8 @@ export default {
             }
             }
           })
           })
           //如果手机端子表得则需要修改json
           //如果手机端子表得则需要修改json
-          var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          // var jsonPamats = JSON.parse(JSON.stringify(this.jsonData))
+          var jsonPamats = JSON.parse(JSON.stringify(this.jsonDataSave))
           if (!this.isSJ && this.isNew) {
           if (!this.isSJ && this.isNew) {
             jsonPamats = null
             jsonPamats = null
           }
           }