detail.vue 8.1 KB

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