detail.vue 7.2 KB

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