You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
5.7 KiB

  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 v-if="showSelfNode" @click="complete('')" type="primary">确认</el-button>
  34. <el-button @click="back" type="primary">返回</el-button>
  35. </el-form-item>
  36. </el-form>
  37. </div>
  38. </template>
  39. <script>
  40. import {
  41. startWorkflow,
  42. completeWorkflowMove
  43. } from "@/api/workflowProcess";
  44. import infoList from "@/mixins/infoList";
  45. import { mapGetters } from "vuex";
  46. export default {
  47. name: "{{.StructName}}",
  48. mixins: [infoList],
  49. props:{
  50. business:{
  51. type:Object,
  52. default:function(){return null}
  53. },
  54. wf:{
  55. type:Object,
  56. default:function(){return{}}
  57. },
  58. move:{
  59. type:Object,
  60. default:function(){return{}}
  61. },
  62. workflowMoveID:{
  63. type:[Number,String],
  64. default:0
  65. }
  66. },
  67. data() {
  68. return {
  69. {{- range .Fields}}
  70. {{- if .DictType }}
  71. {{ .DictType }}Options:[],
  72. {{ end -}}
  73. {{end -}}
  74. formData: {
  75. {{range .Fields}}
  76. {{- if eq .FieldType "bool" -}}
  77. {{.FieldJson}}:false,
  78. {{ end -}}
  79. {{- if eq .FieldType "string" -}}
  80. {{.FieldJson}}:"",
  81. {{ end -}}
  82. {{- if eq .FieldType "int" -}}
  83. {{.FieldJson}}:0,
  84. {{ end -}}
  85. {{- if eq .FieldType "time.Time" -}}
  86. {{.FieldJson}}:new Date(),
  87. {{ end -}}
  88. {{- if eq .FieldType "float64" -}}
  89. {{.FieldJson}}:0,
  90. {{ end -}}
  91. {{ end }}
  92. }
  93. };
  94. },
  95. computed:{
  96. showSelfNode(){
  97. if(this.wf.assignType == "self" && this.move.promoterID == this.userInfo.ID){
  98. return true
  99. }else{
  100. return false
  101. }
  102. },
  103. canShow(){
  104. if(this.wf.assignType == "user"){
  105. if(this.wf.assignValue.indexOf(","+this.userInfo.ID+",")>-1 && this.wf.clazz == 'userTask'){
  106. return true
  107. }else{
  108. return false
  109. }
  110. }else if(this.wf.assign_type == "authority"){
  111. if(this.wf.assignValue.indexOf(","+this.userInfo.authorityId+",")>-1 && this.wf.clazz == 'userTask'){
  112. return true
  113. }else{
  114. return false
  115. }
  116. }
  117. },
  118. ...mapGetters("user", ["userInfo"])
  119. },
  120. methods: {
  121. async start() {
  122. const res = await startWorkflow({
  123. business:this.formData,
  124. wf:{
  125. workflowMoveID:this.workflowMoveID,
  126. businessId:0,
  127. businessType:"{{.Abbreviation}}",
  128. workflowProcessID:this.wf.workflowProcessID,
  129. workflowNodeID:this.wf.id,
  130. promoterID:this.userInfo.ID,
  131. operatorID:this.userInfo.ID,
  132. action:"create",
  133. param:""
  134. }
  135. });
  136. if (res.code == 0) {
  137. this.$message({
  138. type:"success",
  139. message:"启动成功"
  140. })
  141. this.back()
  142. }
  143. },
  144. async complete(param){
  145. const res = await completeWorkflowMove({
  146. business:this.formData,
  147. wf:{
  148. workflowMoveID:this.workflowMoveID,
  149. businessID:this.formData.ID,
  150. businessType:"{{.Abbreviation}}",
  151. workflowProcessID:this.wf.workflowProcessID,
  152. workflowNodeID:this.wf.id,
  153. promoterID:this.userInfo.ID,
  154. operatorID:this.userInfo.ID,
  155. action:"complete",
  156. param:param
  157. }
  158. })
  159. if(res.code == 0){
  160. this.$message({
  161. type:"success",
  162. message:"提交成功"
  163. })
  164. this.back()
  165. }
  166. },
  167. back(){
  168. this.$router.go(-1)
  169. }
  170. },
  171. async created() {
  172. if(this.business){
  173. this.formData = this.business
  174. }
  175. }
  176. };
  177. </script>
  178. <style>
  179. </style>