workflowForm.vue.tpl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div>
  3. <el-form :model="formData" label-position="right" label-width="80px">
  4. {{- range .Fields}}
  5. <el-form-item label="{{.FieldDesc}}:">
  6. {{- if eq .FieldType "bool" }}
  7. <el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
  8. {{ end -}}
  9. {{- if eq .FieldType "string" }}
  10. <el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" ></el-input>
  11. {{ end -}}
  12. {{- if eq .FieldType "int" }}
  13. {{- if .DictType}}
  14. <el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
  15. <el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
  16. </el-select>
  17. {{ else -}}
  18. <el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"></el-input>
  19. {{ end -}}
  20. {{ end -}}
  21. {{- if eq .FieldType "time.Time" }}
  22. <el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
  23. {{ end -}}
  24. {{- if eq .FieldType "float64" }}
  25. <el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
  26. {{ end -}}
  27. </el-form-item>
  28. {{ end -}}
  29. <el-form-item>
  30. <el-button v-if="this.wf.clazz == 'start'" @click="start" type="primary">启动</el-button>
  31. <!-- complete传入流转参数 决定下一步会流转到什么位置 此处可以设置多个按钮来做不同的流转 -->
  32. <el-button v-if="canShow" @click="complete('yes')" type="primary">提交</el-button>
  33. <el-button @click="back" type="primary">返回</el-button>
  34. </el-form-item>
  35. </el-form>
  36. </div>
  37. </template>
  38. <script>
  39. import {
  40. startWorkflow,
  41. completeWorkflowMove
  42. } from "@/api/workflowProcess";
  43. import infoList from "@/mixins/infoList";
  44. import { mapGetters } from "vuex";
  45. export default {
  46. name: "{{.StructName}}",
  47. mixins: [infoList],
  48. props:{
  49. business:{
  50. type:Object,
  51. default:function(){return null}
  52. },
  53. wf:{
  54. type:Object,
  55. default:function(){return{}}
  56. },
  57. workflowMoveID:{
  58. type:Number,
  59. default:0
  60. }
  61. },
  62. data() {
  63. return {
  64. {{- range .Fields}}
  65. {{- if .DictType }}
  66. {{ .DictType }}Options:[],
  67. {{ end -}}
  68. {{end -}}
  69. formData: {
  70. {{range .Fields}}
  71. {{- if eq .FieldType "bool" -}}
  72. {{.FieldJson}}:false,
  73. {{ end -}}
  74. {{- if eq .FieldType "string" -}}
  75. {{.FieldJson}}:"",
  76. {{ end -}}
  77. {{- if eq .FieldType "int" -}}
  78. {{.FieldJson}}:0,
  79. {{ end -}}
  80. {{- if eq .FieldType "time.Time" -}}
  81. {{.FieldJson}}:new Date(),
  82. {{ end -}}
  83. {{- if eq .FieldType "float64" -}}
  84. {{.FieldJson}}:0,
  85. {{ end -}}
  86. {{ end }}
  87. }
  88. };
  89. },
  90. computed:{
  91. canShow(){
  92. if(this.wf.assignType == "user"){
  93. if(this.wf.assignValue.indexOf(","+this.userInfo.ID+",")>-1 && this.wf.clazz == 'userTask'){
  94. return true
  95. }else{
  96. return false
  97. }
  98. }else if(this.wf.assign_type == "authority"){
  99. if(this.wf.assignValue.indexOf(","+this.userInfo.authorityId+",")>-1 && this.wf.clazz == 'userTask'){
  100. return true
  101. }else{
  102. return false
  103. }
  104. }
  105. },
  106. ...mapGetters("user", ["userInfo"])
  107. },
  108. methods: {
  109. async start() {
  110. const res = await startWorkflow({
  111. business:this.formData,
  112. wf:{
  113. workflowMoveID:this.workflowMoveID,
  114. businessId:0,
  115. businessType:"{{.Abbreviation}}",
  116. workflowProcessID:this.wf.workflowProcessID,
  117. workflowNodeID:this.wf.id,
  118. promoterID:this.userInfo.ID,
  119. operatorID:this.userInfo.ID,
  120. action:"create",
  121. param:""
  122. }
  123. });
  124. if (res.code == 0) {
  125. this.$message({
  126. type:"success",
  127. message:"启动成功"
  128. })
  129. this.back()
  130. }
  131. },
  132. async complete(param){
  133. const res = await completeWorkflowMove({
  134. business:this.formData,
  135. wf:{
  136. workflowMoveID:this.workflowMoveID,
  137. businessID:this.formData.ID,
  138. businessType:"{{.Abbreviation}}",
  139. workflowProcessID:this.wf.workflowProcessID,
  140. workflowNodeID:this.wf.id,
  141. promoterID:this.userInfo.ID,
  142. operatorID:this.userInfo.ID,
  143. action:"complete",
  144. param:param
  145. }
  146. })
  147. if(res.code == 0){
  148. this.$message({
  149. type:"success",
  150. message:"提交成功"
  151. })
  152. this.back()
  153. }
  154. },
  155. back(){
  156. this.$router.go(-1)
  157. }
  158. },
  159. async created() {
  160. if(this.business){
  161. this.formData = this.business
  162. }
  163. }
  164. };
  165. </script>
  166. <style>
  167. </style>