flowPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div>
  3. <el-tabs type="border-card">
  4. <el-tab-pane :label="formTitle">
  5. <!--<bidding-view v-if="formType==='BIDDING'" :bid-id="formId" />-->
  6. <!--<contract-view v-if="formType==='CONTRACT'" :contract-id="formId" />-->
  7. </el-tab-pane>
  8. <el-tab-pane label="流程图及意见">
  9. <el-card>
  10. <el-image v-if="processInstanceId" :src="$constant.BASE_URI + '/ActivitiController/readByPid?processInstanceId=' + processInstanceId " fit="scale-down" />
  11. <el-image v-if="!processInstanceId && taskId" :src="$constant.BASE_URI + '/ActivitiController/readByTid?taskId=' + taskId + '&isHistoric=' + taskHistoric + '&type=image'" fit="scale-down" />
  12. <!--<img v-if="taskId" :src="'/webServer/ActivitiController/read?taskId=' + taskId + '&isHistoric=' + taskHistoric + '&type=image'" style="height: 100%">-->
  13. </el-card>
  14. <el-card class="space-top">
  15. <el-table :data="CommentData" stripe>
  16. <el-table-column type="index" width="60" />
  17. <el-table-column label="节点名称" prop="activityName" />
  18. <el-table-column label="处理人" prop="commitUserName" />
  19. <el-table-column label="处理意见" prop="comments" />
  20. <el-table-column label="处理时间" prop="commitTime" />
  21. </el-table>
  22. </el-card>
  23. </el-tab-pane>
  24. </el-tabs>
  25. <el-card v-if="flowType=='OPERA'" class="space-top">
  26. <el-form ref="commitForm" :model="commitForm" style="width: 100%;padding: 5px" :rules="commitRules">
  27. <el-row class="col-self">
  28. <el-col :span="4" class="col-txt"><span>当前节点</span></el-col>
  29. <el-col :span="19" class="col-input col-bg">
  30. <span>{{ nodeName }}</span>
  31. </el-col>
  32. </el-row>
  33. <el-row>
  34. <el-col :span="4" class="col-txt"><span>处理意见</span></el-col>
  35. <el-col :span="19" class="col-input">
  36. <el-form-item prop="comments">
  37. <el-input v-model="commitForm.comments" type="textarea" />
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. </el-form>
  42. </el-card>
  43. <div class="el-dialog__footer">
  44. <el-button type="info" @click="handleClose()">关闭</el-button>
  45. <!--<el-button v-if="flowType=='OPERA'" type="danger" @click="handleBack()">退回</el-button>-->
  46. <el-button v-if="flowType=='OPERA'" type="primary" @click="handleSubmit()">{{ submitTxt }}</el-button>
  47. </div>
  48. <el-dialog title="选择用户" :visible.sync="dialogUserSelectVisible" width="50%" top="30px" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body>
  49. <auditor-select
  50. v-if="dialogUserSelectVisible"
  51. :data-roles="TaskGroup"
  52. :dept-id="formDeptId"
  53. @handleUserSelectClose="handleUserSelectClose"
  54. @handleUserSelectCommit="handleUserSelectCommit"
  55. />
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. import Base from '@/views/base/base'
  61. // import BiddingView from '../zj/bidding/biddingView'
  62. // import ContractView from '../zj/contract/contractView'
  63. import AuditorSelect from './auditorSelect'
  64. export default {
  65. name: 'FlowPage',
  66. components: {
  67. // BiddingView,
  68. // ContractView,
  69. AuditorSelect
  70. },
  71. mixins: [Base],
  72. props: {
  73. flowType: { // 流程类型
  74. type: String,
  75. default: 'OPERA' // OPERA, VIEW
  76. },
  77. formTitle: { // 表单名称
  78. type: String,
  79. default: ''
  80. },
  81. formType: { // 表单类型
  82. type: String,
  83. default: 'BIDDING' // BIDDING, CONTRACT
  84. },
  85. formId: { // 表单主键ID
  86. type: String,
  87. default: ''
  88. },
  89. taskId: { // 任务ID
  90. type: String,
  91. default: ''
  92. },
  93. taskHistoric: { // 选择部门
  94. type: Boolean,
  95. default: false
  96. },
  97. processInstanceId: { // 流程实例ID
  98. type: String,
  99. default: ''
  100. }
  101. },
  102. data() {
  103. return {
  104. CommentData: [],
  105. commitForm: {
  106. comments: ''
  107. },
  108. commitRules: {
  109. comments: [{ required: true, trigger: 'blur', message: '请输入处理意见' }]
  110. },
  111. // 节点信息
  112. lastNode: '',
  113. isLastNode: false,
  114. nodeName: '审批',
  115. submitTxt: '提交下一步',
  116. formDeptId: '',
  117. TaskGroup: [],
  118. dialogUserSelectVisible: false
  119. }
  120. },
  121. mounted() {
  122. this.$nextTick(() => {
  123. this.initFlowDeptId(this.formId, this.formType)
  124. if (this.processInstanceId) {
  125. this.initCommentsByPid(this.processInstanceId)
  126. } else if (this.taskId) {
  127. this.initFlowInfo(this.taskId)
  128. this.initCommentsByTid(this.taskId)
  129. this.initNodeState(this.taskId)
  130. }
  131. })
  132. },
  133. methods: {
  134. initFlowInfo: function(_taskId) {
  135. const _this = this
  136. this.flowRequest('nextTaskGroups', { taskId: _taskId, isHistoric: this.taskHistoric }).then(res => {
  137. if (res.data) {
  138. _this.TaskGroup = res.data.data
  139. console.log('_this.TaskGroup', res.data)
  140. }
  141. })
  142. },
  143. initFlowDeptId: function(_formId, _formType) {
  144. const _this = this
  145. if (_formType === 'BIDDING') {
  146. this.lastNode = 'ZJ_AUDIT'
  147. this.bidRequest('getById', { id: _formId }).then((res) => {
  148. if (res.data) {
  149. _this.formDeptId = res.data.agentConstructionCompany
  150. // console.log('BIDDING_this.formDeptId', res.data)
  151. }
  152. })
  153. } else if (_formType === 'CONTRACT') {
  154. this.lastNode = 'ZJ_AUDIT'
  155. this.ctrRequest('getById', { id: _formId }).then((res) => {
  156. if (res.data) {
  157. _this.formDeptId = res.data.agentConstructionCompany
  158. // console.log('CONTRACT_this.formDeptId', res.data)
  159. }
  160. })
  161. }
  162. },
  163. initCommentsByTid: function(_taskId) {
  164. const _this = this
  165. _this.CommentData = []
  166. this.flowRequest('getCommentsByTid', { taskId: _taskId, isHistoric: this.taskHistoric }).then((res) => {
  167. if (res.data.data) {
  168. res.data.data.forEach(function(item) {
  169. item.commitTime = _this.$common.transServDate(item.commitTime)
  170. _this.CommentData.push(item)
  171. })
  172. }
  173. })
  174. },
  175. initCommentsByPid: function(_processInstanceId) {
  176. const _this = this
  177. _this.CommentData = []
  178. this.flowRequest('getCommentsByPid', { processInstanceId: _processInstanceId }).then((res) => {
  179. if (res.data.data) {
  180. res.data.data.forEach(function(item) {
  181. item.commitTime = _this.$common.transServDate(item.commitTime)
  182. _this.CommentData.push(item)
  183. })
  184. }
  185. })
  186. },
  187. initNodeState: function(_taskId) {
  188. const _this = this
  189. this.flowRequest('getCurrentFlowNode', { taskId: _taskId }).then((res) => {
  190. console.log(res)
  191. if (res.data.data) {
  192. const data = res.data.data
  193. _this.nodeName = data.name
  194. _this.isLastNode = data.candidateGroups.includes(_this.lastNode)
  195. if (_this.isLastNode) {
  196. _this.submitTxt = '通过并结束'
  197. } else {
  198. _this.submitTxt = '提交下一步'
  199. }
  200. console.log(_this.nodeName, _this.isLastNode)
  201. }
  202. })
  203. },
  204. handleUserSelectClose: function() {
  205. this.dialogUserSelectVisible = false
  206. },
  207. handleUserSelectCommit: function(_selectRole, _selectUserInfo) {
  208. const flowData = {
  209. taskId: this.taskId,
  210. dataRole: _selectRole,
  211. comments: this.commitForm.comments
  212. }
  213. if (_selectUserInfo) {
  214. flowData.id = _selectUserInfo.id
  215. flowData.truename = _selectUserInfo.label
  216. }
  217. // console.log('flowData', flowData)
  218. this.flowRequest('runTask', flowData).then(res => {
  219. if (res.data) {
  220. this.$message('流程处理成功')
  221. const submitData = {
  222. formType: this.formType,
  223. formId: this.formId,
  224. selectRole: _selectRole
  225. }
  226. this.$emit('handleSubmit', submitData)
  227. this.dialogUserSelectVisible = false
  228. } else {
  229. this.$alert('流程处理失败')
  230. }
  231. })
  232. },
  233. handleClose: function() {
  234. this.$emit('handleClose')
  235. },
  236. handleBack: function() {
  237. this.confirm('是否确认退回?').then(() => {
  238. this.flowRequest('jump', { taskId: this.taskId }).then(res => {
  239. if (res.data) {
  240. this.$message('流程回退成功')
  241. this.$emit('handleBack')
  242. } else {
  243. this.$alert('流程回退失败:' + res.data)
  244. }
  245. })
  246. })
  247. },
  248. handleSubmit: function() {
  249. this.$refs.commitForm.validate(valid => {
  250. if (valid) {
  251. let info = '是否确认提交下一步'
  252. if (this.isLastNode) {
  253. info = '是否通过审批并结束流程'
  254. }
  255. this.confirm(info).then(() => {
  256. if (this.isLastNode) {
  257. this.handleUserSelectCommit(this.$constant.FLOW.APPROVE, '')
  258. } else {
  259. this.dialogUserSelectVisible = true
  260. }
  261. })
  262. } else {
  263. console.log('error submit!!')
  264. return false
  265. }
  266. })
  267. },
  268. // Request
  269. flowRequest(opUrl, postData) {
  270. return this.$channel.globleRequest('ActivitiController', opUrl, postData, 'Flow Controller')
  271. },
  272. bidRequest(opUrl, postData) {
  273. return this.$channel.globleRequest('ProjectBiddingManageController', opUrl, postData, 'bid')
  274. },
  275. ctrRequest(opUrl, postData) {
  276. return this.$channel.globleRequest('ProjectContractManageController', opUrl, postData, 'ctr')
  277. }
  278. }
  279. }
  280. </script>
  281. <style scoped>
  282. </style>