taskForm.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="task-form-container">
  3. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth="180rpx">
  4. <u-form-item label="申请人" borderBottom>
  5. {{ applicantName || '-' }}
  6. </u-form-item>
  7. <u-form-item label="所属部门" borderBottom>
  8. {{ form.deptName || '-' }}
  9. </u-form-item>
  10. <u-form-item label="补卡类型" borderBottom>
  11. {{ repairTypeLabel }}
  12. </u-form-item>
  13. <u-form-item label="补卡日期" borderBottom>
  14. {{ datePart(punchTime) }}
  15. </u-form-item>
  16. <u-form-item label="补卡时间" borderBottom>
  17. {{ timePart(punchTime) }}
  18. </u-form-item>
  19. <u-form-item label="申请事由" borderBottom>
  20. {{ form.reason || '-' }}
  21. </u-form-item>
  22. <u-form-item label="附件" borderBottom>
  23. <view v-if="attachmentIds.length" class="attachment-row">
  24. <fileMain :value="attachmentIds" type="view"></fileMain>
  25. </view>
  26. <text v-else>-</text>
  27. </u-form-item>
  28. </u--form>
  29. </view>
  30. </template>
  31. <script>
  32. import { getAttendanceApplicationDetail } from '@/api/hr/attendanceApply';
  33. import fileMain from '@/pages/doc/index.vue';
  34. // 补卡类型枚举(与 /hr/attendance/applications 的 repairType 口径一致)
  35. const REPAIR_TYPE_LABELS = {
  36. MISSING_IN: '上班漏打卡',
  37. MISSING_OUT: '下班漏打卡',
  38. LATE: '迟到补卡',
  39. EARLY: '早退补卡',
  40. ABSENT: '缺勤补卡',
  41. NORMAL: '正常补卡',
  42. OTHER: '其他补卡',
  43. };
  44. export default {
  45. components: { fileMain },
  46. props: {
  47. bizType: {
  48. type: String,
  49. default: ''
  50. },
  51. businessId: {
  52. type: String,
  53. default: ''
  54. },
  55. taskId: {
  56. type: String,
  57. default: ''
  58. },
  59. // 流程实例主键(processTask 透传),详情从流程表单变量取
  60. id: {
  61. type: String,
  62. default: ''
  63. },
  64. taskDefinitionKey: {
  65. type: String,
  66. default: ''
  67. },
  68. isUpload: {
  69. type: Boolean,
  70. default: false
  71. },
  72. isInterior: {
  73. type: Boolean,
  74. default: true
  75. },
  76. isIds: {
  77. type: Boolean,
  78. default: false
  79. }
  80. },
  81. data() {
  82. return {
  83. form: {},
  84. startUser: {},
  85. };
  86. },
  87. computed: {
  88. applicantName() {
  89. return this.form.userName || this.form.applicantName || '';
  90. },
  91. repairTypeLabel() {
  92. const code = this.form.repairType;
  93. if (!code) return '-';
  94. return REPAIR_TYPE_LABELS[code] || code;
  95. },
  96. // 补卡以补卡打卡时间为主,缺失时退回开始时间
  97. punchTime() {
  98. return this.form.repairPunchTime || this.form.startTime || '';
  99. },
  100. attachmentIds() {
  101. const raw = this.form.attachmentFileIds;
  102. if (!raw) return [];
  103. return String(raw)
  104. .split(',')
  105. .map((item) => item.trim())
  106. .filter(Boolean);
  107. },
  108. },
  109. watch: {
  110. businessId(val) {
  111. if (val) this._getInfo();
  112. }
  113. },
  114. mounted() {
  115. this._getInfo();
  116. },
  117. methods: {
  118. async _getInfo() {
  119. // 审批处理看的是完整表单:待办任务上的 businessId 就是考勤申请业务主键
  120. // (对应 ESS 列表 row.businessId),直接查 /hr/attendance/applications/{businessId};
  121. // 不要拿它去调 /hr/ess/admin/applications/{id}(那个要的是 row.id 索引主键)
  122. if (!this.businessId) return;
  123. try {
  124. this.form =
  125. (await getAttendanceApplicationDetail(this.businessId, false)) || {};
  126. } catch (e) {
  127. console.log("[考勤审批] 审批详情加载失败:", (e && e.message) || e);
  128. }
  129. },
  130. datePart(val) {
  131. const text = String(val || '');
  132. if (!text) return '-';
  133. return text.split('T')[0].split(' ')[0];
  134. },
  135. timePart(val) {
  136. const text = String(val || '');
  137. if (!text) return '-';
  138. const time = text.split('T')[1] || text.split(' ')[1] || '';
  139. return time ? time.slice(0, 5) : '-';
  140. },
  141. getTableValue() {
  142. return {};
  143. }
  144. }
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .task-form-container {
  149. background-color: #fff;
  150. padding-bottom: 40rpx;
  151. }
  152. .attachment-row {
  153. width: 100%;
  154. display: flex;
  155. justify-content: flex-end;
  156. }
  157. </style>