detail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. if (query["JWT-TOKEN"]) {
  102. uni.setStorageSync("token", query["JWT-TOKEN"]);
  103. }
  104. }
  105. this.id = query.id;
  106. this.query = query;
  107. this.checkDeviceType();
  108. this.init();
  109. },
  110. methods: {
  111. checkDeviceType() {
  112. const userAgent = navigator.userAgent.toLowerCase();
  113. const mobileKeywords = ["android", "iphone", "ipad", "ipod", "mobile"];
  114. this.isMobile = mobileKeywords.some((keyword) =>
  115. userAgent.includes(keyword)
  116. );
  117. return this.isMobile;
  118. },
  119. async init() {
  120. var currentUser = await gerCurrentUser();
  121. if (!currentUser) {
  122. return;
  123. }
  124. uni.setStorageSync("user", currentUser);
  125. // if (!this.isMobile) {
  126. // // 如果是在电脑上打开,转到PC端的页面去
  127. // window.location.href =
  128. // `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']}`
  129. // }
  130. const detail = await getOAAuditDetail(this.id);
  131. // 如果传入链接是已完成审批的,则重定向到已审批详情中
  132. if (detail.audit_status === 3) {
  133. uni.redirectTo({
  134. url: `/pages/approved/detail?id=${this.id}`,
  135. });
  136. }
  137. this.detail = detail;
  138. this.attachments = detail.Files;
  139. this.getAuditList(detail.OaAuditList, detail.AuditorInfo);
  140. },
  141. getAuditList(list, currentAuditor) {
  142. // 填充审核人列表
  143. if (list && list.length) {
  144. this.auditList = list.map((item, index) => {
  145. if (currentAuditor.ID === item.auditor) {
  146. this.currentStep = index;
  147. }
  148. return {
  149. title: item.seq_name,
  150. desc: `审核人:${item.AuditorUser.CName || "-"}`,
  151. };
  152. });
  153. }
  154. },
  155. // 显示通过审批弹窗
  156. async showAuditModal() {
  157. this.$refs.popup.open();
  158. },
  159. // 通过审批
  160. async auditConfirm(audit_comment) {
  161. await audit({
  162. id: this.id,
  163. status: 1,
  164. desc: audit_comment,
  165. });
  166. uni.showToast({
  167. title: "操作成功",
  168. });
  169. this.auditClose();
  170. uni.redirectTo({
  171. url: `/pages/approved/detail?id=${this.id}`,
  172. });
  173. },
  174. auditClose() {
  175. this.$refs.popup.close();
  176. },
  177. // 显示拒绝审批弹窗
  178. showRejectModal() {
  179. this.$refs.rejectPopup.open();
  180. },
  181. async rejectConfirm(audit_comment) {
  182. await audit({
  183. id: this.id,
  184. status: 2,
  185. desc: audit_comment,
  186. });
  187. uni.showToast({
  188. title: "操作成功",
  189. });
  190. this.rejectClose();
  191. },
  192. rejectClose() {
  193. this.$refs.rejectPopup.close();
  194. },
  195. toExcelDetail() {
  196. uni.navigateTo({
  197. url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`,
  198. });
  199. },
  200. },
  201. computed: {
  202. formList() {
  203. const form = this.detail?.form;
  204. if (!form) {
  205. return [];
  206. }
  207. try {
  208. const formDatas = JSON.parse(form);
  209. if (formDatas && formDatas.length) {
  210. return formDatas.filter((item) => item.type !== "DIYTable");
  211. }
  212. return [];
  213. } catch {
  214. return [];
  215. }
  216. },
  217. },
  218. };
  219. </script>
  220. <style lang="less" scoped>
  221. .page-detail {
  222. min-height: 100vh;
  223. padding: 20rpx 30rpx 40rpx;
  224. background: url("~@/static/index/bg.png") no-repeat center;
  225. background-size: cover;
  226. background-attachment: fixed;
  227. .page-center {
  228. padding: 30rpx;
  229. padding-top: 0;
  230. background-color: #fff;
  231. }
  232. }
  233. .btns {
  234. display: flex;
  235. margin-top: 40rpx;
  236. }
  237. .excel-detail {
  238. color: #2f42ca;
  239. text-decoration: underline;
  240. padding-left: 20rpx;
  241. }
  242. .form {
  243. width: 90%;
  244. margin: 0 auto;
  245. .content {
  246. line-height: 44rpx;
  247. padding: 14rpx;
  248. word-break: break-all;
  249. }
  250. }
  251. .attachment {
  252. padding-left: 20rpx;
  253. margin-bottom: 20rpx;
  254. }
  255. </style>