detail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="page-detail">
  3. <view class="page-center">
  4. <uni-section title="清单名称" type="line"></uni-section>
  5. <text style="padding-left: 20rpx;">{{version.version_name}}</text>
  6. <!-- 表单数据 -->
  7. <template v-if="formList.length > 0">
  8. <uni-section title="表单数据" type="line"></uni-section>
  9. <uni-forms class="form" label-align="right" :labelWidth="100">
  10. <uni-forms-item v-for="item in formList" :label="item.name" name="email">
  11. <view class="content">{{item.value.join(",")}}</view>
  12. </uni-forms-item>
  13. </uni-forms>
  14. </template>
  15. <!-- 附件信息 -->
  16. <template v-if="excelFileList.length > 0">
  17. <uni-section title="附件信息" type="line"></uni-section>
  18. <view class="attachment" v-for="item in excelFileList" :key="item.id">
  19. <!-- {{item.name}} -->
  20. <previewFile :src="item.url" :name="item.name" />
  21. </view>
  22. </template>
  23. <!-- 审批信息 -->
  24. <uni-section title="审批信息" type="line"></uni-section>
  25. <uni-steps :options="flow.list.FlowNodes" :active="flow.active" direction="column"></uni-steps>
  26. <!-- 清单详情 -->
  27. <uni-section title="清单详情" type="line"></uni-section>
  28. <view class="excel-detail" @click="toExcelDetail">查看详情</view>
  29. <!-- 审批按钮 -->
  30. <view class="btns" v-if="isAuditor">
  31. <button type="primary" @click="showAuditModal">通过</button>
  32. <button type="warn" @click="showRejectModal">拒绝</button>
  33. </view>
  34. </view>
  35. <!-- 审核通过弹窗 -->
  36. <uni-popup ref="popup" type="dialog">
  37. <uni-popup-dialog type="info" mode="base" title="审批" content="是否通过审批" :duration="2000" :before-close="true"
  38. @close="auditClose" @confirm="auditConfirm"></uni-popup-dialog>
  39. </uni-popup>
  40. <!-- 审批拒绝弹窗 -->
  41. <uni-popup ref="rejectPopup" type="dialog">
  42. <uni-popup-dialog mode="input" placeholder="请输入拒绝原因" :duration="2000" :before-close="true"
  43. @close="rejectClose" @confirm="rejectConfirm"></uni-popup-dialog>
  44. </uni-popup>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. queryVersionsList,
  50. queryAttachment,
  51. queryAuditList,
  52. approve,
  53. } from "@/services/bom.js"
  54. import previewFile from "@/components/preview-file/preview-file.vue"
  55. export default {
  56. components: {
  57. previewFile
  58. },
  59. data() {
  60. return {
  61. projectId: 580,
  62. templateNodeId: 0,
  63. versionId: 0,
  64. version: {},
  65. excelFileList: [],
  66. auditMessage: '',
  67. flow: {
  68. active: 0,
  69. active_id: null,
  70. current: 0,
  71. currentNode: {},
  72. list: {
  73. FlowNodes: [],
  74. },
  75. },
  76. isAuditor: false,
  77. };
  78. },
  79. onLoad(options) {
  80. this.templateNodeId = options.templateNodeId
  81. this.versionId = options.versionId
  82. this.projectId = Number(options.projectId)
  83. this.init()
  84. },
  85. methods: {
  86. async init() {
  87. var {
  88. data: {
  89. excel_version_tree: versionList
  90. }
  91. } = await queryVersionsList({
  92. template_node_id: this.templateNodeId
  93. });
  94. var version = versionList.find(v => v.id == this.versionId);
  95. if (version.flow_id) {
  96. this.getFlow(version)
  97. }
  98. this.version = version;
  99. if (version.attachment_id) {
  100. var {
  101. data: {
  102. list: excelFileList
  103. }
  104. } = await queryAttachment({
  105. excel_id: version.attachment_id
  106. })
  107. this.excelFileList = excelFileList.map(item => {
  108. const list = item.url.split('/');
  109. const name = list[list.length - 1];
  110. return {
  111. ...item,
  112. name,
  113. };
  114. })
  115. console.log(this.excelFileList)
  116. }
  117. },
  118. // 显示通过审批弹窗
  119. async showAuditModal() {
  120. this.$refs.popup.open();
  121. },
  122. // 通过审批
  123. async auditConfirm() {
  124. let flow = this.flow;
  125. let flowNode = flow.currentNode
  126. var {
  127. data: newVersion
  128. } = await approve({
  129. id: flow.active_id,
  130. project_id: this.projectId,
  131. audit_status: 3,
  132. flow_id: flowNode.flow_id,
  133. node_id: flowNode.seq,
  134. })
  135. this.version = {
  136. ...this.version,
  137. id: newVersion.id,
  138. }
  139. this.getFlow(this.version)
  140. uni.showToast({
  141. title: "操作成功"
  142. })
  143. this.$refs.popup.close();
  144. },
  145. // 显示拒绝审批弹窗
  146. showRejectModal() {
  147. this.$refs.rejectPopup.open()
  148. },
  149. auditClose() {
  150. this.$refs.popup.close();
  151. },
  152. rejectClose() {
  153. this.$refs.rejectPopup.close();
  154. },
  155. async rejectConfirm(audit_comment) {
  156. const flow = this.flow
  157. const flowNode = flow.currentNode;
  158. var {
  159. data: newVersion
  160. } = await approve({
  161. id: flow.active_id,
  162. project_id: this.projectId,
  163. audit_status: 2,
  164. flow_id: flowNode.flow_id,
  165. node_id: flowNode.seq,
  166. audit_comment,
  167. })
  168. uni.showToast({
  169. title: "操作成功"
  170. })
  171. this.version = {
  172. ...this.version,
  173. id: newVersion.id,
  174. }
  175. this.getFlow(this.version)
  176. this.rejectClose()
  177. },
  178. // 查询审批信息
  179. async getFlow(version) {
  180. const {
  181. data: auditList
  182. } = await queryAuditList({
  183. template_id: version.template_id,
  184. template_node_id: version.template_node_id,
  185. flow_id: version.flow_id,
  186. version_id: version.version_id,
  187. audit_series: version.audit_series,
  188. })
  189. if (auditList.length > 0) {
  190. let item = auditList.find(item => item.list.id == version.flow_id);
  191. if (!item) return;
  192. // 查询当前节点
  193. let current = item.list.FlowNodes.findIndex(node => node.seq == item.active);
  194. item.current = current == -1 ? 0 : current;
  195. // 保存当前所处节点
  196. item.currentNode = item.list.FlowNodes[item.current];
  197. item.list.FlowNodes.forEach(item => {
  198. item.title = item.node
  199. item.desc = item.AuditRoleInfo ?
  200. `审批人:${item?.AuditRoleInfo.Name || '-'}` :
  201. `审批人:${item?.AuditorUser.CName || '-'}`
  202. })
  203. this.flow = item;
  204. // 判断是否含有审批权限
  205. this.isAuditor = false;
  206. if (item.active_audit == 1) {
  207. let user = uni.getStorageSync("user");
  208. if (item.currentNode && item.currentNode.auditor == user.ID) {
  209. this.isAuditor = true;
  210. }
  211. }
  212. }
  213. },
  214. toExcelDetail() {
  215. uni.navigateTo({
  216. url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`
  217. })
  218. }
  219. },
  220. computed: {
  221. formList() {
  222. if (!this.version.ding_schema) return []
  223. try {
  224. const ding_schema = JSON.parse(this.version.ding_schema);
  225. return JSON.parse(ding_schema).formComponentValues || [];
  226. } catch (e) {
  227. return []
  228. }
  229. },
  230. }
  231. }
  232. </script>
  233. <style lang="less" scoped>
  234. .page-detail {
  235. min-height: 100vh;
  236. padding: 20rpx 30rpx 40rpx;
  237. background: url("~@/static/index/bg.png") no-repeat center;
  238. .page-center {
  239. padding: 30rpx;
  240. padding-top: 0;
  241. background-color: #fff;
  242. }
  243. }
  244. .btns {
  245. display: flex;
  246. margin-top: 40rpx;
  247. }
  248. .excel-detail {
  249. color: #2f42ca;
  250. text-decoration: underline;
  251. padding-left: 20rpx;
  252. }
  253. .form {
  254. width: 90%;
  255. margin: 0 auto;
  256. .content {
  257. line-height: 44rpx;
  258. padding: 14rpx;
  259. word-break: break-all;
  260. }
  261. }
  262. .attachment {
  263. padding-left: 20rpx;
  264. margin-bottom: 20rpx;
  265. }
  266. </style>