Преглед на файлове

弹框 动态数据源配置

chenc преди 3 години
родител
ревизия
666de64609

+ 1 - 1
src/views/activiti/applyList.vue

@@ -186,7 +186,7 @@
       </div>
     </a-drawer>
     <!--流程表单-->
-    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
       <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                  :processData="lcModa.processData" :isNew = "lcModa.isNew"
                  @afterSubmit="afterSub" @close="lcModa.visible=false,lcModa.disabled = false"></component>

+ 1 - 1
src/views/activiti/doneManage.vue

@@ -114,7 +114,7 @@
       </div>
     </a-modal>
     <!--流程表单-->
-    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
       <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                  :processData="lcModa.processData" :isNew = "lcModa.isNew"
                  @close="lcModa.visible=false,lcModa.disabled = false"></component>

+ 85 - 5
src/views/activiti/form/demoForm2.vue

@@ -54,6 +54,7 @@
 <script>
 import pick from 'lodash.pick'
 import todoManageOperation from '../operation/todoManageOperation'
+import { postAction } from '@/api/manage'
 
 export default {
   name: 'demoForm',
@@ -109,7 +110,7 @@ export default {
   created() {
     console.log('流程数据', this.processData)
     //加载一些下拉选择数据等
-    this.getDataList()
+    // this.getDataList()
     let businessTable = ''
     //如果没有值则在另一个属性上有值
     if (!this.processData.businessTable) {
@@ -119,22 +120,95 @@ export default {
       businessTable: this.processData.businessTable,
       taskNodeId: this.processData.key
     }).then(res => {
-      this.jsonData = res.result.jsonContent
       // 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='123d"dynamicKey":"666"'
+      var index = 1
+
+      var dynamicKeyValueList = []
+      for (var index = 1; index !== -1; ) {
+        //动态字符位置
+        index = jsonString.indexOf('"dynamicKey"', index)
+        if (index !== -1) {
+          //从指定字符的周后一个字符后开始找(")
+          var ihStart = jsonString.indexOf('"', index + 12)
+          //再从 (") 后面位置还是找下一个 (")
+          var ihEnd = jsonString.indexOf('"', ihStart + 1)
+          //获取引号之间的字符
+          var dynamicKeyValue = jsonString.substring(ihStart + 1, ihEnd)
+          //如果动态表示不为空则获取
+          if (dynamicKeyValue != '') {
+            dynamicKeyValueList.push(dynamicKeyValue)
+          }
+          index = ihEnd + 1
+        }
+      }
+      //循环动态数据源表示获取数据
+      // if(dynamicKeyValueList.length>0){
+      //   dynamicKeyValueList.forEach(async element => {
+      //      await this.getDataListByName(element);
+      //   });
+      // }
+      console.log(dynamicKeyValueList)
+      if (dynamicKeyValueList.length > 0) {
+        //获取数据字典数据源
+        postAction('/sys/dict/getDictItems/getDictList', dynamicKeyValueList).then(dictData => {
+          if (dictData.success) {
+            this.dynamicData = dictData.result.dicList
+
+            //获取用户下拉数据
+            this.getAction('/sys/user/list').then(userData => {
+              if (res.success) {
+                userData.result.records.forEach(user => {
+                  user.label = user.realname
+                  user.value = user.username
+                })
+                //存到动态数据源中
+                this.dynamicData.userList = userData.result.records
+                //获取json
+                this.jsonData = res.result.jsonContent
+                if (!this.isNew) {
+                  this.init()
+                }
+              } else {
+                this.$message.error(userData.message)
+              }
+            })
+          } else {
+            this.$message.error(dictData.message)
+          }
+        })
+      } else {
+        //获取json
+        this.jsonData = res.result.jsonContent
+        if (!this.isNew) {
+          this.init()
+        }
+      }
+
       //后台检测到流程节点有关联表单且前台处于我的待办界面打开表单详情
       if (res.result.isSave && this.processData.isSuspended != undefined) {
         this.disabled = false
         this.btndisabled = false
       }
-      if (!this.isNew) {
-        this.init()
-      }
     })
   },
   methods: {
+    //根据字典名字获取数据源
+    getDataListByName(name) {
+      this.getAction(this.url.leaveType + '/' + name).then(res => {
+        if (res.success) {
+          this.dynamicData[name] = res.result
+          console.log(111)
+        } else {
+          this.$message.error(res.message)
+        }
+      })
+    },
     //获取获取下拉数据等
     getDataList() {
       //获取请假类型下拉数据
@@ -225,6 +299,12 @@ export default {
       //通过函数获取数据
       this.$refs.KFB.getData()
         .then(res => {
+          //清除为空的表单数据
+          _.keys(res).forEach(r => {
+            if (!res[r]) {
+              delete res[r]
+            }
+          })
           // 获取数据成功
           let formData = JSON.parse(JSON.stringify(res))
           console.log(formData)

+ 1 - 1
src/views/activiti/processFinishManage.vue

@@ -140,7 +140,7 @@
       </div>
     </a-modal>
     <!--流程表单-->
-    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
       <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                  :processData="lcModa.processData" :isNew = "lcModa.isNew"
                  @close="lcModa.visible=false,lcModa.disabled = false"></component>

+ 1 - 1
src/views/activiti/processInsManage.vue

@@ -135,7 +135,7 @@
       </div>
     </a-modal>
     <!--流程表单-->
-    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
       <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                  :processData="lcModa.processData" :isNew = "lcModa.isNew"
                  @close="lcModa.visible=false,lcModa.disabled = false"></component>

+ 1 - 1
src/views/activiti/todoManage.vue

@@ -116,7 +116,7 @@
       </div>
     </a-modal>
     <!--流程表单-->
-    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
       <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                  :processData="lcModa.processData" :isNew = "lcModa.isNew"
                  @close="lcModa.visible=false,lcModa.disabled = false" @getDataList="getDataList"></component>

+ 1 - 1
src/views/dashboard/IndexOa.vue

@@ -38,7 +38,7 @@
     </a-row>
     
     <!--流程表单-->
-    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
       <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                  :processData="lcModa.processData" :isNew = "lcModa.isNew"
                  @afterSubmit="afterSub" @close="lcModa.visible=false,lcModa.disabled = false"></component>