workflowForm.vue.tpl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. return false
  106. },
  107. ...mapGetters("user", ["userInfo"])
  108. },
  109. methods: {
  110. async start() {
  111. const res = await startWorkflow({
  112. business:this.formData,
  113. wf:{
  114. workflowMoveID:this.workflowMoveID,
  115. businessId:0,
  116. businessType:"{{.Abbreviation}}",
  117. workflowProcessID:this.wf.workflowProcessID,
  118. workflowNodeID:this.wf.id,
  119. promoterID:this.userInfo.ID,
  120. operatorID:this.userInfo.ID,
  121. action:"create",
  122. param:""
  123. }
  124. });
  125. if (res.code == 0) {
  126. this.$message({
  127. type:"success",
  128. message:"启动成功"
  129. })
  130. this.back()
  131. }
  132. },
  133. async complete(param){
  134. const res = await completeWorkflowMove({
  135. business:this.formData,
  136. wf:{
  137. workflowMoveID:this.workflowMoveID,
  138. businessID:this.formData.ID,
  139. businessType:"{{.Abbreviation}}",
  140. workflowProcessID:this.wf.workflowProcessID,
  141. workflowNodeID:this.wf.id,
  142. promoterID:this.userInfo.ID,
  143. operatorID:this.userInfo.ID,
  144. action:"complete",
  145. param:param
  146. }
  147. })
  148. if(res.code == 0){
  149. this.$message({
  150. type:"success",
  151. message:"提交成功"
  152. })
  153. this.back()
  154. }
  155. },
  156. back(){
  157. this.$router.go(-1)
  158. }
  159. },
  160. async created() {
  161. if(this.business){
  162. this.formData = this.business
  163. }
  164. }
  165. };
  166. </script>
  167. <style>
  168. </style>