handle.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <div class="app-container">
  3. <div v-if="isLoadingStatus" />
  4. <div v-else>
  5. <el-card class="box-card">
  6. <div class="text item">
  7. <el-steps v-if="currentNode.clazz !== undefined && currentNode.clazz !== null && currentNode.clazz !== ''" :active="activeIndex" finish-status="success">
  8. <template v-for="(item, index) in nodeStepList">
  9. <el-step
  10. v-if="item.isHideNode === false ||
  11. item.isHideNode === undefined ||
  12. item.isHideNode == null ||
  13. item.id === processStructureValue.workOrder.current_state"
  14. :key="index"
  15. :title="item.label"
  16. />
  17. </template>
  18. </el-steps>
  19. <div v-else>
  20. <el-alert
  21. show-icon
  22. title="未找到当前工单流程信息,请确认当前工单绑定的流程是否存在。"
  23. type="warning"
  24. />
  25. </div>
  26. </div>
  27. </el-card>
  28. <el-alert
  29. v-if="activeIndex !== nodeStepList.length && processStructureValue.workOrder.is_end===1"
  30. style="margin-top: 15px"
  31. :title="alertMessage"
  32. type="error"
  33. :closable="false"
  34. />
  35. <el-card class="box-card" style="margin-top: 15px">
  36. <div slot="header" class="clearfix">
  37. <span>公共信息</span>
  38. </div>
  39. <div class="text item">
  40. <el-form label-width="100px">
  41. <el-row>
  42. <el-col :span="12">
  43. <el-form-item label="标题:" style="margin-bottom: 5px">
  44. <span>{{ processStructureValue.workOrder.title }}</span>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="12">
  48. <el-form-item label="优先级:" style="margin-bottom: 0">
  49. <span v-if="processStructureValue.workOrder.priority===2">
  50. <el-tag type="warning">紧急</el-tag>
  51. </span>
  52. <span v-else-if="processStructureValue.workOrder.priority===3">
  53. <el-tag type="danger">非常紧急</el-tag>
  54. </span>
  55. <span v-else>
  56. <el-tag type="success">一般</el-tag>
  57. </span>
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. </el-form>
  62. </div>
  63. </el-card>
  64. <el-card class="box-card" style="margin-top: 15px;">
  65. <div slot="header" class="clearfix">
  66. <span>表单信息</span>
  67. </div>
  68. <div class="text item">
  69. <template v-for="(tplItem, tplIndex) in processStructureValue.tpls">
  70. <fm-generate-form
  71. v-show="currentNode.hideTpls===undefined ||
  72. currentNode.hideTpls===null ||
  73. currentNode.hideTpls.indexOf(tplItem.form_structure.id)===-1"
  74. :key="tplIndex"
  75. :ref="'generateForm-'+tplItem.id"
  76. :preview="(currentNode.hideTpls!==undefined &&
  77. currentNode.hideTpls!==null &&
  78. currentNode.hideTpls.indexOf(tplItem.form_structure.id)!==-1) ||
  79. (currentNode.writeTpls===undefined ||
  80. currentNode.writeTpls===null ||
  81. currentNode.writeTpls.indexOf(tplItem.form_structure.id)===-1)||
  82. (isActiveProcessing && currentNode.activeOrder)?true:false"
  83. :remote="remoteFunc"
  84. :value="tplItem.form_data"
  85. :data="tplItem.form_structure"
  86. :organ-list="organList"
  87. />
  88. </template>
  89. </div>
  90. <div v-if="processStructureValue.userAuthority">
  91. <hr style="background-color: #d9d9d9; border:0; height:1px; margin-bottom: 15px">
  92. <div>
  93. <el-input
  94. v-model="remarks"
  95. type="textarea"
  96. placeholder="请输入备注信息"
  97. maxlength="200"
  98. :autosize="{ minRows: 3, maxRows: 99}"
  99. show-word-limit
  100. />
  101. </div>
  102. <div class="text item" style="text-align: center;margin-top:18px">
  103. <div
  104. v-if="isActiveProcessing && currentNode.activeOrder"
  105. >
  106. <el-button
  107. v-permisaction="['process:list:handle:active']"
  108. type="primary"
  109. @click="activeOrderActive"
  110. >
  111. 主动接单
  112. </el-button>
  113. </div>
  114. <div v-else>
  115. <template v-for="(item, index) in processStructureValue.edges">
  116. <el-button
  117. v-if="processStructureValue.workOrder.is_end===0 && item.source===currentNode.id"
  118. :key="index"
  119. type="primary"
  120. @click="submitAction(item)"
  121. >
  122. {{ item.label }}
  123. </el-button>
  124. </template>
  125. </div>
  126. </div>
  127. </div>
  128. </el-card>
  129. <el-card class="box-card" style="margin-top: 15px">
  130. <div slot="header" class="clearfix">
  131. <span>工单流转历史</span>
  132. </div>
  133. <div class="text item">
  134. <el-table
  135. :data="circulationHistoryList"
  136. border
  137. style="width: 100%"
  138. >
  139. <el-table-column
  140. prop="state"
  141. label="节点"
  142. />
  143. <el-table-column
  144. prop="circulation"
  145. label="流转"
  146. />
  147. <el-table-column
  148. prop="processor"
  149. label="处理人"
  150. />
  151. <el-table-column
  152. prop="create_time"
  153. label="处理时间"
  154. />
  155. <el-table-column
  156. prop="remarks"
  157. label="备注"
  158. />
  159. </el-table>
  160. </div>
  161. </el-card>
  162. </div>
  163. </div>
  164. </template>
  165. <script>
  166. import Vue from 'vue'
  167. import {
  168. GenerateForm
  169. } from '@/components/VueFormMaking'
  170. import 'form-making/dist/FormMaking.css'
  171. Vue.component(GenerateForm.name, GenerateForm)
  172. import {
  173. processStructure,
  174. handleWorkOrder,
  175. activeOrder,
  176. queryAllOrgan
  177. } from '@/api/process/work-order'
  178. import { listUser } from '@/api/system/sysuser'
  179. import { mapGetters } from 'vuex'
  180. export default {
  181. data() {
  182. return {
  183. isLoadingStatus: true,
  184. currentNode: {
  185. hideTpls: null,
  186. writeTpls: null
  187. },
  188. isActiveProcessing: false,
  189. tpls: [],
  190. organList: [],
  191. remarks: '', // 备注信息
  192. alertMessage: '',
  193. nodeStepList: [],
  194. circulationHistoryList: [],
  195. activeIndex: 0,
  196. processStructureValue: {
  197. workOrder: { title: '' }
  198. },
  199. ruleForm: {
  200. title: '',
  201. process: '',
  202. classify: '',
  203. state_id: '',
  204. state: '',
  205. source_state: '',
  206. processor: '',
  207. process_method: '',
  208. tpls: [],
  209. tasks: []
  210. },
  211. remoteFunc: {
  212. // 获取用户列表
  213. userList(resolve) {
  214. listUser({
  215. pageSize: 999999
  216. }).then(response => {
  217. const options = response.data.list
  218. resolve(options)
  219. })
  220. }
  221. }
  222. }
  223. },
  224. computed: {
  225. ...mapGetters([
  226. 'userId'
  227. ])
  228. },
  229. created() {
  230. this.getAllOrgan()
  231. this.getProcessNodeList()
  232. },
  233. methods: {
  234. getProcessNodeList() {
  235. processStructure({
  236. processId: this.$route.query.processId,
  237. workOrderId: this.$route.query.workOrderId
  238. }).then(response => {
  239. this.isActiveProcessing = false
  240. this.processStructureValue = response.data
  241. this.circulationHistoryList = this.processStructureValue.circulationHistory
  242. // 获取当前展示节点列表
  243. this.nodeStepList = []
  244. for (var i = 0; i < this.processStructureValue.nodes.length; i++) {
  245. if (this.processStructureValue.nodes[i].id === this.processStructureValue.workOrder.current_state) {
  246. // 当前节点
  247. this.nodeStepList.push(this.processStructureValue.nodes[i])
  248. this.activeIndex = this.nodeStepList.length - 1
  249. if (i + 1 === this.processStructureValue.nodes.length) {
  250. this.activeIndex = this.nodeStepList.length
  251. }
  252. this.currentNode = this.processStructureValue.nodes[i]
  253. } else if (!this.processStructureValue.nodes[i].isHideNode) {
  254. // 非隐藏节点
  255. this.nodeStepList.push(this.processStructureValue.nodes[i])
  256. }
  257. }
  258. // 如果回退到初始节点则可编辑。
  259. if (this.activeIndex === 0 && this.currentNode.clazz === 'start') {
  260. this.currentNode.writeTpls = []
  261. for (var tplTmp of this.processStructureValue.tpls) {
  262. this.currentNode.writeTpls.push(tplTmp.form_structure.id)
  263. }
  264. }
  265. // 判断是否需要主动处理
  266. for (var stateValue of this.processStructureValue.workOrder.state) {
  267. if (this.processStructureValue.workOrder.current_state === stateValue.id && stateValue.processor.length > 1) {
  268. this.isActiveProcessing = true
  269. break
  270. }
  271. }
  272. this.isLoadingStatus = false
  273. this.getAlertMessage()
  274. })
  275. },
  276. submitAction(item) {
  277. var promiseList = []
  278. this.tpls = []
  279. for (var tpl of this.processStructureValue.tpls) {
  280. this.tpls.push({
  281. tplDataId: tpl.id,
  282. tplId: tpl.form_structure.id
  283. })
  284. promiseList.push(this.$refs['generateForm-' + tpl.id][0].getData())
  285. }
  286. Promise.all(promiseList).then(values => {
  287. for (var tplDataIndex in this.tpls) {
  288. this.tpls[tplDataIndex].tplValue = values[tplDataIndex]
  289. }
  290. handleWorkOrder({
  291. tasks: this.processStructureValue.process.task,
  292. source_state: this.processStructureValue.workOrder.current_state,
  293. target_state: item.target,
  294. circulation: item.label,
  295. flow_properties: item.flowProperties === undefined ? 2 : parseInt(item.flowProperties),
  296. work_order_id: parseInt(this.$route.query.workOrderId),
  297. remarks: this.remarks,
  298. tpls: this.tpls
  299. }).then(response => {
  300. if (response.code === 200) {
  301. // this.$router.push({ name: 'upcoming' })
  302. // window.location.reload()
  303. this.getProcessNodeList()
  304. }
  305. })
  306. })
  307. },
  308. // 获取提示消息
  309. getAlertMessage() {
  310. if (this.processStructureValue.workOrder.is_end === 1) {
  311. this.alertMessage = '当前工单已结束。'
  312. }
  313. },
  314. activeOrderActive() {
  315. var jsonData = [{
  316. id: this.nodeStepList[this.activeIndex].id,
  317. label: this.nodeStepList[this.activeIndex].label,
  318. process_method: 'person',
  319. processor: [this.userId]
  320. }]
  321. activeOrder(jsonData, this.$route.query.workOrderId).then(() => {
  322. this.getProcessNodeList()
  323. })
  324. },
  325. getAllOrgan() {
  326. queryAllOrgan().then(res => {
  327. if (res.code == 200) {
  328. this.organList = res.data
  329. }
  330. })
  331. }
  332. }
  333. }
  334. </script>