detail.vue 4.3 KB

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