detail.vue 6.7 KB

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