detail.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. uni.setStorageSync("token", query["JWT-TOKEN"]);
  82. }
  83. this.query = query;
  84. this.checkDeviceType();
  85. this.getDetail();
  86. },
  87. methods: {
  88. checkDeviceType() {
  89. const userAgent = navigator.userAgent.toLowerCase();
  90. const mobileKeywords = ["android", "iphone", "ipad", "ipod", "mobile"];
  91. this.isMobile = mobileKeywords.some((keyword) =>
  92. userAgent.includes(keyword)
  93. );
  94. if (!this.isMobile) {
  95. // 如果是在电脑上打开,转到PC端的页面去https://work.greentech.com.cn/profile/detail?id=852
  96. window.location.href = `https://work.greentech.com.cn/profile/detail?id=${this.id}&JWT-TOKEN=${this.query["JWT-TOKEN"]}`;
  97. }
  98. return this.isMobile;
  99. },
  100. getDetail() {
  101. getOAAuditDetail(this.id)
  102. .then((result) => {
  103. this.detail = result;
  104. this.getAuditList(result.OaAuditList, result.AuditorInfo);
  105. })
  106. .catch((err) => {
  107. console.log(err);
  108. });
  109. },
  110. getAuditList(list, currentAuditor) {
  111. // 填充审核人列表
  112. if (list && list.length) {
  113. this.auditList = list.map((item, index) => {
  114. if (currentAuditor.ID === item.auditor) {
  115. this.currentStep = index;
  116. }
  117. return {
  118. title: item.seq_name,
  119. desc: `审核人:${item.AuditorUser.CName || "-"}`,
  120. };
  121. });
  122. }
  123. },
  124. },
  125. };
  126. </script>
  127. <style lang="less" scoped>
  128. .page-detail {
  129. min-height: 100vh;
  130. padding: 20rpx 30rpx 40rpx;
  131. background: url("~@/static/index/bg.png") no-repeat center;
  132. background-size: cover;
  133. background-attachment: fixed;
  134. .page-center {
  135. padding: 30rpx;
  136. padding-top: 0;
  137. background-color: #fff;
  138. }
  139. }
  140. .btns {
  141. display: flex;
  142. margin-top: 40rpx;
  143. }
  144. .excel-detail {
  145. color: #2f42ca;
  146. text-decoration: underline;
  147. padding-left: 20rpx;
  148. }
  149. .form {
  150. width: 90%;
  151. margin: 0 auto;
  152. .content {
  153. line-height: 44rpx;
  154. padding: 14rpx;
  155. word-break: break-all;
  156. }
  157. }
  158. .attachment {
  159. padding-left: 20rpx;
  160. margin-bottom: 20rpx;
  161. }
  162. </style>