detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="page-detail">
  3. <view class="page-center">
  4. <uni-section title="清单名称" type="line" style="margin-top: 0;" />
  5. <text style="padding-left: 20rpx;">{{detail.name}}</text>
  6. <!-- 表单数据 -->
  7. <template v-if="formList.length > 0">
  8. <uni-section title="表单数据" type="line" />
  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="attachments.length > 0">
  17. <uni-section title="附件信息" type="line" />
  18. <view class="attachment" v-for="item in attachments" :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" />
  25. <uni-steps :options="auditList" :active="currentStep" direction="column" />
  26. <!-- 清单详情 -->
  27. <!-- <uni-section title="清单详情" type="line" />
  28. <view class="excel-detail" @click="toExcelDetail">查看详情</view> -->
  29. <!-- 审批按钮 -->
  30. <view class="btns" v-if="isAuditor">
  31. <button type="primary" @click="showAuditModal" style="width: 200rpx; height: 45px;">通过</button>
  32. <button type="warn" @click="showRejectModal" style="width: 200rpx; height: 45px;">拒绝</button>
  33. </view>
  34. </view>
  35. <!-- 审核通过弹窗 -->
  36. <uni-popup ref="popup" type="dialog">
  37. <uni-popup-dialog mode="input" placeholder="请输入审批意见" :duration="2000" :before-close="true" @close="auditClose"
  38. @confirm="auditConfirm" />
  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. gerCurrentUser
  50. } from "@/services/user.js"
  51. import previewFile from "@/components/preview-file/preview-file.vue"
  52. import {
  53. audit,
  54. getOAAuditDetail
  55. } from "../../../services/oa";
  56. export default {
  57. components: {
  58. previewFile
  59. },
  60. data() {
  61. return {
  62. id: "",
  63. detail: {},
  64. attachments:[],
  65. auditList: [],
  66. currentStep: 0,
  67. isAuditor: true,
  68. query: {},
  69. excelFileList: []
  70. };
  71. },
  72. onLoad(query) {
  73. if (!uni.getStorageSync('token')) {
  74. uni.setStorageSync("token", query['JWT-TOKEN']);
  75. }
  76. this.id = query.id
  77. this.query = query
  78. this.checkDeviceType()
  79. this.init()
  80. },
  81. methods: {
  82. checkDeviceType() {
  83. const userAgent = navigator.userAgent.toLowerCase();
  84. const mobileKeywords = ['android', 'iphone', 'ipad', 'ipod', 'mobile'];
  85. this.isMobile = mobileKeywords.some(keyword => userAgent.includes(keyword));
  86. return this.isMobile
  87. },
  88. async init() {
  89. var currentUser = await gerCurrentUser();
  90. if (!currentUser) {
  91. return
  92. }
  93. uni.setStorageSync("user", currentUser);
  94. // if (!this.isMobile) {
  95. // // 如果是在电脑上打开,转到PC端的页面去
  96. // window.location.href =
  97. // `http://120.55.44.4:8896/#/bom/home/detail/${version.project_id}/${version.template_id}?version_id=${this.versionId}&JWT-TOKEN=${this.query['JWT-TOKEN']}`
  98. // }
  99. const detail = await getOAAuditDetail(this.id)
  100. this.detail = detail
  101. this.attachments = detail.Files
  102. this.getAuditList(detail.OaAuditList, detail.AuditorInfo)
  103. },
  104. getAuditList(list, currentAuditor) {
  105. // 填充审核人列表
  106. if (list && list.length) {
  107. this.auditList = list.map((item, index) => {
  108. if (currentAuditor.ID === item.auditor) {
  109. this.currentStep = index
  110. }
  111. return {
  112. title: item.seq_name,
  113. desc: `审核人:${item.AuditorUser.CName || '-'}`
  114. }
  115. })
  116. }
  117. },
  118. // 显示通过审批弹窗
  119. async showAuditModal() {
  120. this.$refs.popup.open();
  121. },
  122. // 通过审批
  123. async auditConfirm(audit_comment) {
  124. await audit({
  125. id: this.id,
  126. status: 1,
  127. desc: audit_comment
  128. })
  129. uni.showToast({
  130. title: "操作成功"
  131. })
  132. this.auditClose()
  133. },
  134. auditClose() {
  135. this.$refs.popup.close();
  136. },
  137. // 显示拒绝审批弹窗
  138. showRejectModal() {
  139. this.$refs.rejectPopup.open()
  140. },
  141. async rejectConfirm(audit_comment) {
  142. await audit({
  143. id: this.id,
  144. status: 2,
  145. desc: audit_comment
  146. })
  147. uni.showToast({
  148. title: "操作成功"
  149. })
  150. this.rejectClose()
  151. },
  152. rejectClose() {
  153. this.$refs.rejectPopup.close();
  154. },
  155. toExcelDetail() {
  156. uni.navigateTo({
  157. url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`
  158. })
  159. }
  160. },
  161. computed: {
  162. formList() {
  163. const form = this.detail?.form
  164. if (!form) {
  165. return []
  166. }
  167. try {
  168. const formDatas = JSON.parse(form)
  169. if (formDatas && formDatas.length) {
  170. return formDatas.filter(item=>item.type!=='DIYTable')
  171. }
  172. return []
  173. } catch {
  174. return []
  175. }
  176. },
  177. }
  178. }
  179. </script>
  180. <style lang="less" scoped>
  181. .page-detail {
  182. min-height: 100vh;
  183. padding: 20rpx 30rpx 40rpx;
  184. background: url("~@/static/index/bg.png") no-repeat center;
  185. background-size: cover;
  186. background-attachment: fixed;
  187. .page-center {
  188. padding: 30rpx;
  189. padding-top: 0;
  190. background-color: #fff;
  191. }
  192. }
  193. .btns {
  194. display: flex;
  195. margin-top: 40rpx;
  196. }
  197. .excel-detail {
  198. color: #2f42ca;
  199. text-decoration: underline;
  200. padding-left: 20rpx;
  201. }
  202. .form {
  203. width: 90%;
  204. margin: 0 auto;
  205. .content {
  206. line-height: 44rpx;
  207. padding: 14rpx;
  208. word-break: break-all;
  209. }
  210. }
  211. .attachment {
  212. padding-left: 20rpx;
  213. margin-bottom: 20rpx;
  214. }
  215. </style>