submit.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <el-drawer
  3. :title="title"
  4. :modal-append-to-body="false"
  5. :modal="false"
  6. :wrapper-closable="false"
  7. size="99%"
  8. :visible.sync="dialogVisible"
  9. >
  10. <div class="content-container">
  11. <vuescroll :ops="ops" style="height: calc(100vh - 300px)">
  12. <el-form ref="ruleForm" :model="formData" :rules="rules" label-width="210px">
  13. <el-form-item label="标题" prop="exampleTitle">
  14. <el-input v-model="formData.exampleTitle" />
  15. </el-form-item>
  16. <el-form-item label="描述" prop="exampleDesc">
  17. <el-input v-model="formData.exampleDesc" type="textarea" :rows="4" placeholder="描述" />
  18. </el-form-item>
  19. <el-form-item label="附件" prop="attachList">
  20. <FileUpload
  21. :is-multiple="true"
  22. :file-type="1"
  23. :delault-file-list="formData.attachList"
  24. @fileListChange="attchListChange"
  25. />
  26. </el-form-item>
  27. <p style="color: #FFFFFF">下一关:评审任务</p>
  28. <el-form-item label="执行人" prop="accountIdTo">
  29. <user-selector :default-val="formData.accountIdTo" @setUserInfo="handleSelectUser" />
  30. </el-form-item>
  31. <el-form-item label="说明" prop="actionRemark">
  32. <el-input v-model="formData.actionRemark" type="textarea" :rows="4" placeholder="说明" />
  33. </el-form-item>
  34. </el-form>
  35. </vuescroll>
  36. <el-row>
  37. <el-button
  38. v-for="(item,index) in flowData.taskIns.actionList"
  39. :key="index"
  40. type="primary"
  41. @click="submitForm('ruleForm', item.actionId, item.actionCode)"
  42. >{{ item.actionTitle }} </el-button>
  43. <el-button class="cancel-btn" @click="dialogVisible = false">取 消</el-button>
  44. </el-row>
  45. </div>
  46. </el-drawer>
  47. </template>
  48. <script>
  49. import { startWfExample, submitWfExample, getWfExampleById } from '@/api/system/wfExampleApi'
  50. import FileUpload from '@/components/FileUpload/index'
  51. import UserSelector from '@/components/UserSelector/index'
  52. import Vuescroll from 'vuescroll'
  53. export default {
  54. name: 'SubmitTask',
  55. components: { Vuescroll, FileUpload, UserSelector },
  56. props: {
  57. title: {
  58. type: String,
  59. default: ''
  60. }
  61. },
  62. data() {
  63. return {
  64. ops: {
  65. bar: {
  66. keepShow: false,
  67. background: 'rgba(144, 147, 153, 0.4)',
  68. onlyShowBarOnScroll: false
  69. }
  70. },
  71. dialogVisible: false,
  72. formData: {
  73. exampleId: undefined,
  74. exampleTitle: '', // 预警标题
  75. exampleDesc: '', // 描述
  76. wfDefId: undefined,
  77. wfInsId: undefined,
  78. taskDefId: undefined,
  79. taskInsId: undefined,
  80. taskCode: '',
  81. actionId: undefined,
  82. actionCode: '',
  83. groupIdTo: undefined,
  84. positionIdTo: undefined,
  85. accountIdTo: undefined, // 执行人
  86. actionRemark: '', // 说明
  87. attachList: []
  88. },
  89. flowData: {
  90. taskIns: {
  91. actionList: []
  92. }
  93. },
  94. rules: {
  95. exampleTitle: [
  96. { required: true, message: '请输入标题', trigger: 'blur' }
  97. ],
  98. groupId: [
  99. { required: true, message: '请输入所在部门', trigger: 'blur' }
  100. ],
  101. accountIdTo: [
  102. { required: true, message: '请选择执行人', trigger: 'blur' }
  103. ]
  104. }
  105. }
  106. },
  107. mounted() {
  108. },
  109. methods: {
  110. // 附件
  111. attchListChange(dataList) {
  112. this.formData.attachList = dataList
  113. },
  114. // Task Start View
  115. start() {
  116. this.resetFormData()
  117. this.dialogVisible = true
  118. startWfExample().then((resp) => {
  119. const { code, data, msg } = resp
  120. if (code === 0) {
  121. this.flowData = data
  122. this.formData.wfDefId = data.wfDefId
  123. this.formData.wfInsId = data.wfInsId
  124. this.formData.taskDefId = data.taskIns.taskDefId
  125. this.formData.taskInsId = data.taskIns.taskInsId
  126. this.formData.taskCode = data.taskIns.taskCode
  127. } else {
  128. this.$message.error(msg)
  129. }
  130. }).catch((error) => {
  131. console.log(error)
  132. })
  133. },
  134. // Task Handling View
  135. handle(exampleId) {
  136. this.resetFormData()
  137. this.dialogVisible = true
  138. getWfExampleById(exampleId).then((resp) => {
  139. const { code, data, msg } = resp
  140. if (code === 0) {
  141. this.formData = data.data
  142. const flow = data.flow
  143. this.flowData = flow
  144. this.formData.wfDefId = flow.wfDefId
  145. this.formData.wfInsId = flow.wfInsId
  146. this.formData.taskDefId = flow.taskIns.taskDefId
  147. this.formData.taskInsId = flow.taskIns.taskInsId
  148. this.formData.taskCode = flow.taskIns.taskCode
  149. } else {
  150. this.$message.error(msg)
  151. }
  152. }).catch((error) => {
  153. console.log(error)
  154. })
  155. },
  156. // Select User
  157. handleSelectUser(item) {
  158. this.formData.accountIdTo = item.accountId
  159. this.formData.groupIdTo = item.groupId
  160. this.formData.positionIdTo = item.positionId
  161. },
  162. // Reset Form Data
  163. resetFormData() {
  164. this.formData = {
  165. exampleId: undefined,
  166. exampleTitle: '', // 预警标题
  167. exampleDesc: '', // 描述
  168. actionRemark: '', // 说明
  169. accountIdTo: undefined, // 执行人
  170. groupIdTo: undefined, // 执行人班组
  171. positionIdTo: undefined // 执行人岗位
  172. }
  173. },
  174. // Submit Flow
  175. submitForm(formName, actionId, actionCode) {
  176. this.formData.actionId = actionId
  177. this.formData.actionCode = actionCode
  178. this.$refs[formName].validate((valid) => {
  179. if (valid) {
  180. submitWfExample(this.formData).then((resp) => {
  181. const { code, msg } = resp
  182. if (code === 0) {
  183. this.dialogVisible = false
  184. this.formSuccess()
  185. this.$message.success(msg)
  186. } else {
  187. this.$message.error(msg)
  188. }
  189. }).catch((error) => {
  190. console.log(error)
  191. })
  192. } else {
  193. console.log('error submit!!')
  194. return false
  195. }
  196. })
  197. },
  198. formSuccess() {
  199. this.$emit('formSuccess')
  200. },
  201. resetForm(formName) {
  202. this.$refs[formName].resetFields()
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. </style>
  209. <style lang="scss" scoped>
  210. .content-container {
  211. position: relative;
  212. height: calc(100% - 15px);
  213. .thisform {
  214. margin: 0 100px;
  215. }
  216. .btn-group {
  217. width: 100%;
  218. text-align: center;
  219. .el-button {
  220. margin: 0 15px;
  221. }
  222. .cancel-btn {
  223. background: #004F7B;
  224. border-color: #004F7B;
  225. color: #FFF;
  226. &:hover {
  227. background: #026197;
  228. border-color: #026197;
  229. }
  230. }
  231. }
  232. }
  233. </style>