detail.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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.current" 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" @close="rejectClose"
  43. @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. queryVersionDetail,
  54. } from "@/services/bom.js"
  55. import {
  56. gerCurrentUser
  57. } from "@/services/user.js"
  58. import previewFile from "@/components/preview-file/preview-file.vue"
  59. export default {
  60. components: {
  61. previewFile
  62. },
  63. data() {
  64. return {
  65. projectId: 580,
  66. templateNodeId: 0,
  67. versionId: 0,
  68. version: {},
  69. excelFileList: [],
  70. auditMessage: '',
  71. flow: {
  72. active: 0,
  73. active_id: null,
  74. current: 0,
  75. currentNode: {},
  76. list: {
  77. FlowNodes: [],
  78. },
  79. },
  80. isAuditor: false,
  81. options: {}
  82. };
  83. },
  84. onLoad(options) {
  85. this.templateNodeId = options.templateNodeId
  86. this.versionId = options.versionId
  87. this.projectId = Number(options.projectId)
  88. if (!uni.getStorageSync('token')) {
  89. uni.setStorageSync("token", options['JWT-TOKEN']);
  90. }
  91. this.options = options
  92. this.init()
  93. },
  94. methods: {
  95. async init() {
  96. var currentUser = await gerCurrentUser();
  97. console.log(currentUser);
  98. if(!currentUser){
  99. return
  100. }
  101. uni.setStorageSync("user", currentUser);
  102. // var {
  103. // data: {
  104. // excel_version_tree: versionList
  105. // }
  106. // } = await queryVersionsList({
  107. // template_node_id: this.templateNodeId
  108. // });
  109. // var version = versionList.find(v => v.id == this.versionId);
  110. var version = await queryVersionDetail({userID: currentUser.ID, versionID: this.versionId})
  111. if (version.flow_id) {
  112. this.getFlow(version)
  113. }
  114. this.version = version;
  115. if (version.attachment_id) {
  116. var {
  117. data: {
  118. list: excelFileList
  119. }
  120. } = await queryAttachment({
  121. excel_id: version.attachment_id
  122. })
  123. this.excelFileList = excelFileList.map(item => {
  124. const list = item.url.split('/');
  125. const name = list[list.length - 1];
  126. return {
  127. ...item,
  128. name,
  129. };
  130. })
  131. console.log(this.excelFileList)
  132. }
  133. },
  134. // 显示通过审批弹窗
  135. async showAuditModal() {
  136. this.$refs.popup.open();
  137. },
  138. // 通过审批
  139. async auditConfirm() {
  140. let flow = this.flow;
  141. let flowNode = flow.currentNode
  142. var {
  143. data: newVersion
  144. } = await approve({
  145. id: flow.active_id,
  146. project_id: this.projectId,
  147. audit_status: 3,
  148. flow_id: flowNode.flow_id,
  149. node_id: flowNode.seq,
  150. })
  151. this.version = {
  152. ...this.version,
  153. id: newVersion.id,
  154. }
  155. this.getFlow(this.version)
  156. uni.showToast({
  157. title: "操作成功"
  158. })
  159. this.$refs.popup.close();
  160. },
  161. // 显示拒绝审批弹窗
  162. showRejectModal() {
  163. this.$refs.rejectPopup.open()
  164. },
  165. auditClose() {
  166. this.$refs.popup.close();
  167. },
  168. rejectClose() {
  169. this.$refs.rejectPopup.close();
  170. },
  171. async rejectConfirm(audit_comment) {
  172. const flow = this.flow
  173. const flowNode = flow.currentNode;
  174. var {
  175. data: newVersion
  176. } = await approve({
  177. id: flow.active_id,
  178. project_id: this.projectId,
  179. audit_status: 2,
  180. flow_id: flowNode.flow_id,
  181. node_id: flowNode.seq,
  182. audit_comment,
  183. })
  184. uni.showToast({
  185. title: "操作成功"
  186. })
  187. this.version = {
  188. ...this.version,
  189. id: newVersion.id,
  190. }
  191. this.getFlow(this.version)
  192. this.rejectClose()
  193. },
  194. // 查询审批信息
  195. async getFlow(version) {
  196. const {
  197. data: auditList
  198. } = await queryAuditList({
  199. template_id: version.template_id,
  200. template_node_id: version.template_node_id,
  201. flow_id: version.flow_id,
  202. version_id: version.version_id,
  203. audit_series: version.audit_series,
  204. })
  205. if (auditList.length > 0) {
  206. let item = auditList.find(item => item.list.id == version.flow_id);
  207. if (!item) return;
  208. // 查询当前节点
  209. debugger
  210. let current = item.list.FlowNodes.findIndex(node => node.seq == item.active);
  211. item.current = current == -1 ? 0 : current;
  212. // 保存当前所处节点
  213. item.currentNode = item.list.FlowNodes[item.current];
  214. item.list.FlowNodes.forEach(item => {
  215. item.title = item.node
  216. item.desc = item.AuditRoleInfo ?
  217. `审批人:${item?.AuditRoleInfo.Name || '-'}` :
  218. `审批人:${item?.AuditorUser.CName || '-'}`
  219. })
  220. this.flow = item;
  221. // 判断是否含有审批权限
  222. this.isAuditor = false;
  223. if (item.active_audit == 1) {
  224. let user = uni.getStorageSync("user");
  225. if (item.currentNode && item.currentNode.auditor == user.ID) {
  226. this.isAuditor = true;
  227. }
  228. }
  229. }
  230. },
  231. toExcelDetail() {
  232. uni.navigateTo({
  233. url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`
  234. })
  235. }
  236. },
  237. computed: {
  238. formList() {
  239. if (!this.version.ding_schema) return []
  240. try {
  241. const ding_schema = JSON.parse(this.version.ding_schema);
  242. return JSON.parse(ding_schema).formComponentValues || [];
  243. } catch (e) {
  244. return []
  245. }
  246. },
  247. }
  248. }
  249. </script>
  250. <style lang="less" scoped>
  251. .page-detail {
  252. min-height: 100vh;
  253. padding: 20rpx 30rpx 40rpx;
  254. background: url("~@/static/index/bg.png") no-repeat center;
  255. .page-center {
  256. padding: 30rpx;
  257. padding-top: 0;
  258. background-color: #fff;
  259. }
  260. }
  261. .btns {
  262. display: flex;
  263. margin-top: 40rpx;
  264. }
  265. .excel-detail {
  266. color: #2f42ca;
  267. text-decoration: underline;
  268. padding-left: 20rpx;
  269. }
  270. .form {
  271. width: 90%;
  272. margin: 0 auto;
  273. .content {
  274. line-height: 44rpx;
  275. padding: 14rpx;
  276. word-break: break-all;
  277. }
  278. }
  279. .attachment {
  280. padding-left: 20rpx;
  281. margin-bottom: 20rpx;
  282. }
  283. </style>