liuying
2024-05-09 f4078b75fe80f03e58af3217bf642d0de118d1c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
  <a-modal
    title="发起流程"
    :visible="visible"
    width="1000px"
    :destroyOnClose="true"
    @ok="handleOk"
    @cancel="handleCancel">
    <k-form-build ref="kfb" :value="jsonData" />
  </a-modal>
</template>
 
<script>
import 'k-form-design/styles/k-form-design.less'
import { formEntity } from '@/api/modular/system/formDesignmanage'
import { startWorkflow } from '@/api/modular/system/workflowManage'
export default {
  name: 'StartWorkflow',
  components: {
    porpsWorkflowDefinitionId: {
      type: Number,
      default: null
    },
    porpsVersion: {
      type: Number,
      default: null
    },
    porpsFormId: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      visible: false,
      workflowdefinitionId: null,
      version: null,
      jsonData: {}
    }
  },
  methods: {
    // 初始化
    init(workflowdefinitionid, version, formId) {
      this.visible = true
      this.workflowdefinitionId = workflowdefinitionid
      this.version = version
      formEntity(Object.assign({ id: formId })).then(res => {
        console.log(res)
        this.jsonData = JSON.parse(res.data.formJson)
      })
    },
    // 提交
    handleOk() {
      this.$refs.kfb.getData().then(values => {
        var data = {
          id: this.workflowdefinitionId,
          version: this.version,
          inputs: values
        }
        startWorkflow(data).then(res => {
          if (res.success === true) {
            this.$message.success('发起流程成功!')
            this.handleCancel()
          } else {
             this.$message.error(res.message)
          }
        })
      }).catch(() => {
        console.log('验证未通过,获取失败')
      })
    },
    // 取消
    handleCancel() {
      this.visible = false
    }
  }
}
</script>
 
<style>
 
</style>