flowDetail.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div class="hui-flex">
  3. <div class="hui-flex-box">
  4. <div class="hui-detail">
  5. <div class="hui-detail-box">
  6. <div class="hui-detail-title">基础信息</div>
  7. <property-flow-detail v-if="detail.flowType === 1" :formData="detail"></property-flow-detail>
  8. <change-flow-detail v-if="detail.flowType === 2" :formData="detail"></change-flow-detail>
  9. <depreciation-flow-detail v-if="detail.flowType === 3"
  10. :formData="detail"></depreciation-flow-detail>
  11. <inventory-flow-detail v-if="detail.flowType === 4" :formData="detail"></inventory-flow-detail>
  12. <device-flow-detail v-if="detail.flowType === 5" :formData="detail"></device-flow-detail>
  13. </div>
  14. <div class="hui-detail-box">
  15. <div class="hui-detail-title">附件抄送</div>
  16. <div class="hui-detail-content">
  17. <div class="hui-detail-item">
  18. <div class="hui-detail-label">流程附件</div>
  19. <div class="hui-detail-value">
  20. <upload ref="upload" :list="detail.attachment ? JSON.parse(detail.attachment) : []"
  21. type="preview">
  22. </upload>
  23. </div>
  24. </div>
  25. <div class="hui-detail-item">
  26. <div class="hui-detail-label">抄送人</div>
  27. <div class="hui-detail-value">
  28. <cc :ccList="detail.receiver ? JSON.parse(detail.receiver) : []"></cc>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="hui-detail-box">
  34. <div class="hui-detail-title">审核流程</div>
  35. <div class="hui-detail-content">
  36. <flow :flowlist="flowUserList"></flow>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="hui-drawer-submit" v-if="activeList.length>0">
  42. <el-button size="small" type="primary" v-for="item in activeList" :key="item.id" @click="action(item)">
  43. {{item.viewName}}
  44. </el-button>
  45. </div>
  46. <el-dialog :close-on-click-modal="false" :title="actionData.viewName" :visible.sync="dialogVisible" width="60%"
  47. :append-to-body="true">
  48. <flow-action v-if="dialogVisible" :action="actionData" :projectFlowId="detail.projectFlowId"
  49. @callback="callback" @updateFlowState="updateFlowState">
  50. </flow-action>
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. const upload = () => import('@/components/common/upload');
  56. const flowAction = () => import('@/components/flow/flowAction');
  57. const flow = () => import('@/components/flow/flow');
  58. const cc = () => import('@/components/common/cc');
  59. const propertyFlowDetail = () => import('@/components/work/property/propertyFlowDetail');
  60. const changeFlowDetail = () => import('@/components/work/property/changeFlowDetail');
  61. const depreciationFlowDetail = () => import('@/components/work/property/depreciationFlowDetail');
  62. const inventoryFlowDetail = () => import('@/components/work/property/inventoryFlowDetail');
  63. import {
  64. getFlowById,
  65. generationFlow,
  66. updateFlow,
  67. getFlowApprove,
  68. getUserFlowAction,
  69. insertDevice,
  70. updateDevice
  71. } from '@/api/property'
  72. export default {
  73. props: ['detailId'],
  74. data() {
  75. return {
  76. detail: {},
  77. activeList: [],
  78. dialogVisible: false,
  79. actionData: {},
  80. flowUserList: [],
  81. receiver: ''
  82. }
  83. },
  84. mounted() {
  85. if (this.detailId) this.init();
  86. },
  87. methods: {
  88. init() {
  89. getFlowById(this.detailId).then(res => {
  90. if (res.state) {
  91. let flowData = JSON.parse(res.data.flowData);
  92. this.detail = Object.assign(res.data, flowData);
  93. let flowUserList = this.detail.flowUserList ? JSON.parse(this.detail.flowUserList) : [];
  94. if (this.detail.projectFlowId) {
  95. this.initFlow(flowUserList);
  96. } else {
  97. this.flowUserList = flowUserList;
  98. }
  99. if (!this.detail.projectFlowId && this.detail.createdByUserId === this.$store.getters.user
  100. .userId) this.activeList = [{
  101. id: -1,
  102. viewName: '生成流程'
  103. }]
  104. }
  105. })
  106. },
  107. initFlow(flowUserList) {
  108. getUserFlowAction(this.detail.projectFlowId).then(res => {
  109. if (res.state) {
  110. this.activeList = res.data.filter(node => {
  111. if (node.viewName == '提交') return this.detail.createdByUserId === this.$store
  112. .getters.user.userId;
  113. return node.viewName != '查看'
  114. });
  115. }
  116. });
  117. getFlowApprove(this.detail.projectFlowId).then(res => {
  118. if (res.state) {
  119. let approverList = res.data.approverList;
  120. let submiterId = res.data.submiter && res.data.submiter.userId;
  121. //提交者
  122. let activityList = []
  123. if (res.data.statusStr != '待提交') {
  124. activityList = res.data.activityList.filter(node => node.activityUser.userId ===
  125. submiterId).map(node => {
  126. let comment = JSON.parse(node.activityComment) || {};
  127. return {
  128. id: node.id,
  129. name: node.activityUser.userName,
  130. partName: "提交审核",
  131. portrait: node.activityUser.portrait,
  132. status: 1,
  133. remark: comment.text,
  134. file: comment.enclosure,
  135. date: this.$dayjs(node.activityDate).format('YYYY-MM-DD')
  136. }
  137. });
  138. }
  139. let list = flowUserList.map((node, index) => {
  140. let item = approverList[index];
  141. let comment = JSON.parse(item.comment) || {};
  142. node['status'] = item.status;
  143. node['remark'] = comment.text;
  144. node['file'] = comment.enclosure;
  145. if (comment.text) node['date'] = this.$dayjs(item.statusDate).format(
  146. 'YYYY-MM-DD');
  147. return node;
  148. })
  149. this.flowUserList = activityList.length === 0 ? list : [activityList[activityList.length -
  150. 1]].concat(list);
  151. let noList = this.flowUserList.filter(node => !node.status);
  152. if (noList.length === 0) return;
  153. this.receiver = noList[0].id;
  154. }
  155. });
  156. },
  157. action(item) {
  158. if (item.id === -1) return this.flowOperation();
  159. this.actionData = item;
  160. this.dialogVisible = true;
  161. },
  162. callback(type) {
  163. this.dialogVisible = false;
  164. if (type === 'init') this.init();
  165. },
  166. flowOperation() {
  167. if (JSON.parse(this.detail.flowUserList).length === 0) return this.$message.warning('未设置审核人');
  168. this.$confirm('生成流程后不允许再修改数据,确定生成?', () => {
  169. this.$loading();
  170. generationFlow(this.returnSubmitData()).then(res => {
  171. if (res.state) {
  172. updateFlow({
  173. id: this.detail.id,
  174. projectFlowId: res.data.id
  175. }).then(node => {
  176. this.updateFlowState(1);
  177. this.$message.success('操作成功');
  178. this.init();
  179. });
  180. }
  181. this.$loading.close();
  182. });
  183. });
  184. },
  185. updateFlowState(state, operation) {
  186. updateFlow({
  187. id: this.detail.id,
  188. state: state
  189. }).then(node => {
  190. if (node.state) {
  191. if (state === 3) this.passFlow();
  192. if (this.receiver && operation != '退回') {
  193. let postMessageData = {
  194. operation: operation + '了',
  195. receiver: this.receiver,
  196. messageType: 2, //流程类型-2
  197. dataType: this.detail.flowType, //1.资产登记/设备流程
  198. dataId: this.detail.id
  199. }
  200. this.$msg.sendFlowMessage(this.detail, postMessageData);
  201. let ccList = this.detail.receiver ? JSON.parse(this.detail.receiver) : [];
  202. if (ccList.length > 0) {
  203. postMessageData['receiver'] = ccList.join(',');
  204. postMessageData['isCC'] = 1;
  205. this.$msg.sendFlowMessage(this.detail, postMessageData);
  206. }
  207. }
  208. this.$emit('callback', 'init');
  209. }
  210. });
  211. },
  212. passFlow() {
  213. let flowData = JSON.parse(this.detail.flowData);
  214. if (this.detail.flowType === 1) {
  215. flowData['attachment'] = JSON.stringify(this.detail.attachment);
  216. flowData['document'] = JSON.stringify(this.detail.document);
  217. insertDevice(flowData)
  218. }
  219. if (this.detail.flowType === 2) {
  220. flowData['id'] = this.detail.deviceId;
  221. delete flowData.remark;
  222. updateDevice(flowData)
  223. }
  224. },
  225. returnSubmitData() {
  226. let organization = this.$store.getters.organization;
  227. let userList = JSON.parse(this.detail.flowUserList).map((item, index) => {
  228. let obj = {
  229. organizedName: organization.name,
  230. organizationId: organization.id,
  231. userId: item.id,
  232. userName: item.name,
  233. partName: item.partName,
  234. portrait: item.portrait
  235. }
  236. return {
  237. flowUsers: [obj],
  238. sequence: (index + 1),
  239. status: 0
  240. }
  241. })
  242. let flowName = this.$msg.messageType[0].dataType.filter(node => node.id === this.detail.flowType)[0].title;
  243. return {
  244. flowUserList: JSON.stringify([{
  245. name: organization.name,
  246. organizationId: organization.id,
  247. flowUserList: JSON.stringify(userList)
  248. }]),
  249. coment: '{}',
  250. submiter: this.$store.getters.user.id,
  251. subscribers: [],
  252. flowName: flowName + '流程'
  253. }
  254. }
  255. },
  256. components: {
  257. upload,
  258. flow,
  259. flowAction,
  260. cc,
  261. propertyFlowDetail,
  262. changeFlowDetail,
  263. depreciationFlowDetail,
  264. inventoryFlowDetail
  265. },
  266. }
  267. </script>
  268. <style lang="scss">
  269. </style>