detail.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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"></uni-section>
  9. <uni-forms class="form" label-align="right" :labelWidth="100">
  10. <uni-forms-item v-for="item in formList" :label="item.name" name="email">
  11. <view class="content">{{item.value.join(",")}}</view>
  12. </uni-forms-item>
  13. </uni-forms>
  14. </template>
  15. <!-- 附件信息 -->
  16. <template v-if="excelFileList.length > 0">
  17. <uni-section title="附件信息" type="line"></uni-section>
  18. <view class="attachment" v-for="item in excelFileList" :key="item.id">
  19. <!-- {{item.name}} -->
  20. <previewFile :src="item.url" :name="item.name" />
  21. </view>
  22. </template>
  23. <!-- 审批信息 -->
  24. <uni-section title="审批信息" type="line"></uni-section>
  25. <uni-steps :options="auditList" :active="currentStep" direction="column" />
  26. <!-- 清单详情 -->
  27. <uni-section title="清单详情" type="line"></uni-section>
  28. <view class="excel-detail" @click="toExcelDetail">查看详情</view>
  29. <!-- 审批按钮 -->
  30. <view class="btns" v-if="isAuditor">
  31. <button type="primary" @click="showAuditModal">通过</button>
  32. <button type="warn" @click="showRejectModal">拒绝</button>
  33. </view>
  34. </view>
  35. <!-- 审核通过弹窗 -->
  36. <uni-popup ref="popup" type="dialog">
  37. <uni-popup-dialog mode="input" placeholder="请输入审批意见" :duration="2000" :before-close="true" @close="auditClose"
  38. @confirm="auditConfirm" />
  39. </uni-popup>
  40. <!-- 审批拒绝弹窗 -->
  41. <uni-popup ref="rejectPopup" type="dialog">
  42. <uni-popup-dialog mode="input" placeholder="请输入拒绝原因" :duration="2000" :before-close="true" @close="rejectClose"
  43. @confirm="rejectConfirm"></uni-popup-dialog>
  44. </uni-popup>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. gerCurrentUser
  50. } from "@/services/user.js"
  51. import previewFile from "@/components/preview-file/preview-file.vue"
  52. import {
  53. audit,
  54. getOAAuditDetail
  55. } from "../../../services/oa";
  56. export default {
  57. components: {
  58. previewFile
  59. },
  60. data() {
  61. return {
  62. id: "",
  63. detail: {},
  64. auditList: [],
  65. currentStep: 0,
  66. isAuditor: true,
  67. query: {},
  68. excelFileList: []
  69. };
  70. },
  71. onLoad(query) {
  72. if (!uni.getStorageSync('token')) {
  73. uni.setStorageSync("token", query['JWT-TOKEN']);
  74. }
  75. this.id = query.id
  76. this.query = query
  77. this.init()
  78. },
  79. methods: {
  80. async init() {
  81. var currentUser = await gerCurrentUser();
  82. if (!currentUser) {
  83. return
  84. }
  85. uni.setStorageSync("user", currentUser);
  86. const detail = await getOAAuditDetail(this.id)
  87. this.detail = detail
  88. this.getAuditList(detail.OaAuditList, detail.AuditorInfo)
  89. },
  90. getAuditList(list, currentAuditor) {
  91. // 填充审核人列表
  92. if (list && list.length) {
  93. this.auditList = list.map((item, index) => {
  94. if (currentAuditor.ID === item.auditor) {
  95. this.currentStep = index
  96. }
  97. return {
  98. title: item.seq_name,
  99. desc: `审核人:${item.AuditorUser.CName || '-'}`
  100. }
  101. })
  102. }
  103. },
  104. // 显示通过审批弹窗
  105. async showAuditModal() {
  106. this.$refs.popup.open();
  107. },
  108. // 通过审批
  109. async auditConfirm(audit_comment) {
  110. await audit({
  111. id: this.id,
  112. status: 1,
  113. desc: audit_comment
  114. })
  115. uni.showToast({
  116. title: "操作成功"
  117. })
  118. this.auditClose()
  119. },
  120. auditClose() {
  121. this.$refs.popup.close();
  122. },
  123. // 显示拒绝审批弹窗
  124. showRejectModal() {
  125. this.$refs.rejectPopup.open()
  126. },
  127. async rejectConfirm(audit_comment) {
  128. await audit({
  129. id: this.id,
  130. status: 2,
  131. desc: audit_comment
  132. })
  133. uni.showToast({
  134. title: "操作成功"
  135. })
  136. this.rejectClose()
  137. },
  138. rejectClose() {
  139. this.$refs.rejectPopup.close();
  140. },
  141. toExcelDetail() {
  142. uni.navigateTo({
  143. url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`
  144. })
  145. }
  146. },
  147. computed: {
  148. formList() {
  149. const form = this.detail?.form
  150. if (!form) {
  151. return []
  152. }
  153. console.log(form);
  154. try {
  155. const formDatas = JSON.parse(form)
  156. console.log(formDatas);
  157. if (formDatas && formDatas.length) {
  158. return formDatas
  159. }
  160. return []
  161. } catch {
  162. return []
  163. }
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="less" scoped>
  169. .page-detail {
  170. min-height: 100vh;
  171. padding: 20rpx 30rpx 40rpx;
  172. background: url("~@/static/index/bg.png") no-repeat center;
  173. background-size: cover;
  174. background-attachment: fixed;
  175. .page-center {
  176. padding: 30rpx;
  177. padding-top: 0;
  178. background-color: #fff;
  179. }
  180. }
  181. .btns {
  182. display: flex;
  183. margin-top: 40rpx;
  184. }
  185. .excel-detail {
  186. color: #2f42ca;
  187. text-decoration: underline;
  188. padding-left: 20rpx;
  189. }
  190. .form {
  191. width: 90%;
  192. margin: 0 auto;
  193. .content {
  194. line-height: 44rpx;
  195. padding: 14rpx;
  196. word-break: break-all;
  197. }
  198. }
  199. .attachment {
  200. padding-left: 20rpx;
  201. margin-bottom: 20rpx;
  202. }
  203. </style>