detail.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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
  11. v-for="item in formList"
  12. :label="item.name"
  13. name="email"
  14. >
  15. <view class="content">{{ item.value.join(",") }}</view>
  16. </uni-forms-item>
  17. </uni-forms>
  18. </template>
  19. <!-- 附件信息 -->
  20. <template v-if="attachments.length > 0">
  21. <uni-section title="附件信息" type="line" />
  22. <view class="attachment" v-for="item in attachments" :key="item.id">
  23. <!-- {{item.name}} -->
  24. <previewFile :src="item.url" :name="item.name" />
  25. </view>
  26. </template>
  27. <!-- 审批信息 -->
  28. <uni-section title="审批信息" type="line" />
  29. <uni-steps
  30. :options="auditList"
  31. :active="currentStep"
  32. direction="column"
  33. />
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { getOAAuditDetail } from "@/services/oa";
  39. export default {
  40. computed: {
  41. formList() {
  42. const form = this.detail?.form;
  43. if (!form) {
  44. return [];
  45. }
  46. try {
  47. const formDatas = JSON.parse(form);
  48. if (formDatas && formDatas.length) {
  49. return formDatas.filter((item) => item.type !== "DIYTable");
  50. }
  51. return [];
  52. } catch {
  53. return [];
  54. }
  55. },
  56. attachments() {
  57. if (this.detail?.Files?.length) {
  58. return this.detail.Files;
  59. }
  60. return [];
  61. },
  62. },
  63. data() {
  64. return {
  65. id: -1,
  66. detail: {},
  67. auditList: [],
  68. currentStep: 0,
  69. isMobile: true,
  70. };
  71. },
  72. onLoad(query) {
  73. if (query?.id !== undefined) {
  74. this.id = Number(query.id);
  75. } else {
  76. return;
  77. }
  78. if (!uni.getStorageSync("token")) {
  79. uni.setStorageSync("token", query["JWT-TOKEN"]);
  80. }
  81. this.query = query;
  82. this.checkDeviceType();
  83. this.getDetail();
  84. },
  85. methods: {
  86. checkDeviceType() {
  87. const userAgent = navigator.userAgent.toLowerCase();
  88. const mobileKeywords = ["android", "iphone", "ipad", "ipod", "mobile"];
  89. this.isMobile = mobileKeywords.some((keyword) =>
  90. userAgent.includes(keyword)
  91. );
  92. if (!this.isMobile) {
  93. // 如果是在电脑上打开,转到PC端的页面去https://work.greentech.com.cn/profile/detail?id=852
  94. window.location.href = `https://work.greentech.com.cn/profile/detail?id=${this.id}&JWT-TOKEN=${this.query["JWT-TOKEN"]}`;
  95. }
  96. return this.isMobile;
  97. },
  98. getDetail() {
  99. getOAAuditDetail(this.id)
  100. .then((result) => {
  101. this.detail = result;
  102. this.getAuditList(result.OaAuditList, result.AuditorInfo);
  103. })
  104. .catch((err) => {
  105. console.log(err);
  106. });
  107. },
  108. getAuditList(list, currentAuditor) {
  109. // 填充审核人列表
  110. if (list && list.length) {
  111. this.auditList = list.map((item, index) => {
  112. if (currentAuditor.ID === item.auditor) {
  113. this.currentStep = index;
  114. }
  115. return {
  116. title: item.seq_name,
  117. desc: `审核人:${item.AuditorUser.CName || "-"}`,
  118. };
  119. });
  120. }
  121. },
  122. },
  123. };
  124. </script>
  125. <style lang="less" scoped>
  126. .page-detail {
  127. min-height: 100vh;
  128. padding: 20rpx 30rpx 40rpx;
  129. background: url("~@/static/index/bg.png") no-repeat center;
  130. background-size: cover;
  131. background-attachment: fixed;
  132. .page-center {
  133. padding: 30rpx;
  134. padding-top: 0;
  135. background-color: #fff;
  136. }
  137. }
  138. .btns {
  139. display: flex;
  140. margin-top: 40rpx;
  141. }
  142. .excel-detail {
  143. color: #2f42ca;
  144. text-decoration: underline;
  145. padding-left: 20rpx;
  146. }
  147. .form {
  148. width: 90%;
  149. margin: 0 auto;
  150. .content {
  151. line-height: 44rpx;
  152. padding: 14rpx;
  153. word-break: break-all;
  154. }
  155. }
  156. .attachment {
  157. padding-left: 20rpx;
  158. margin-bottom: 20rpx;
  159. }
  160. </style>