taskForm.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. {{ leaveTypeLabel }}
  12. </u-form-item>
  13. <u-form-item label="开始日期" borderBottom>
  14. {{ datePart(form.startTime) }}
  15. </u-form-item>
  16. <u-form-item label="开始时间" borderBottom>
  17. {{ timePart(form.startTime) }}
  18. </u-form-item>
  19. <u-form-item label="结束日期" borderBottom>
  20. {{ datePart(form.endTime) }}
  21. </u-form-item>
  22. <u-form-item label="结束时间" borderBottom>
  23. {{ timePart(form.endTime) }}
  24. </u-form-item>
  25. <u-form-item v-if="durationLabel" label="申请时长" borderBottom>
  26. {{ durationLabel }}
  27. </u-form-item>
  28. <u-form-item label="申请事由" borderBottom>
  29. {{ form.reason || '-' }}
  30. </u-form-item>
  31. <u-form-item label="附件" borderBottom>
  32. <view v-if="attachmentIds.length" class="attachment-row">
  33. <fileMain :value="attachmentIds" type="view"></fileMain>
  34. </view>
  35. <text v-else>-</text>
  36. </u-form-item>
  37. </u--form>
  38. </view>
  39. </template>
  40. <script>
  41. import { getAttendanceApplicationDetail } from '@/api/hr/attendanceApply';
  42. import fileMain from '@/pages/doc/index.vue';
  43. // 请假类型枚举(与 /hr/attendance/applications 的 leaveType 口径一致)
  44. const LEAVE_TYPE_LABELS = {
  45. ANNUAL: '年假',
  46. PERSONAL: '事假',
  47. SICK: '病假',
  48. COMPENSATORY: '调休假',
  49. MARRIAGE: '婚假',
  50. MATERNITY: '产假',
  51. PATERNITY: '陪产假',
  52. BEREAVEMENT: '丧假',
  53. OTHER: '其他',
  54. };
  55. export default {
  56. components: { fileMain },
  57. props: {
  58. bizType: {
  59. type: String,
  60. default: ''
  61. },
  62. businessId: {
  63. type: String,
  64. default: ''
  65. },
  66. taskId: {
  67. type: String,
  68. default: ''
  69. },
  70. // 流程实例主键(processTask 透传),详情从流程表单变量取
  71. id: {
  72. type: String,
  73. default: ''
  74. },
  75. taskDefinitionKey: {
  76. type: String,
  77. default: ''
  78. },
  79. isUpload: {
  80. type: Boolean,
  81. default: false
  82. },
  83. isInterior: {
  84. type: Boolean,
  85. default: true
  86. },
  87. isIds: {
  88. type: Boolean,
  89. default: false
  90. }
  91. },
  92. data() {
  93. return {
  94. form: {},
  95. startUser: {},
  96. };
  97. },
  98. computed: {
  99. applicantName() {
  100. return this.form.userName || this.form.applicantName || '';
  101. },
  102. leaveTypeLabel() {
  103. const code = this.form.leaveType;
  104. if (!code) return '-';
  105. return LEAVE_TYPE_LABELS[code] || code;
  106. },
  107. durationLabel() {
  108. const minutes = Number(this.form.durationMinutes);
  109. if (!minutes || isNaN(minutes) || minutes <= 0) return '';
  110. const hours = Math.floor(minutes / 60);
  111. const mins = minutes % 60;
  112. if (!hours) return `${mins} 分钟`;
  113. if (!mins) return `${hours} 小时`;
  114. return `${hours} 小时 ${mins} 分钟`;
  115. },
  116. attachmentIds() {
  117. const raw = this.form.attachmentFileIds;
  118. if (!raw) return [];
  119. return String(raw)
  120. .split(',')
  121. .map((item) => item.trim())
  122. .filter(Boolean);
  123. },
  124. },
  125. watch: {
  126. businessId(val) {
  127. if (val) this._getInfo();
  128. }
  129. },
  130. mounted() {
  131. this._getInfo();
  132. },
  133. methods: {
  134. async _getInfo() {
  135. // 审批处理看的是完整表单:待办任务上的 businessId 就是考勤申请业务主键
  136. // (对应 ESS 列表 row.businessId),直接查 /hr/attendance/applications/{businessId};
  137. // 不要拿它去调 /hr/ess/admin/applications/{id}(那个要的是 row.id 索引主键)
  138. if (!this.businessId) return;
  139. try {
  140. this.form =
  141. (await getAttendanceApplicationDetail(this.businessId, false)) || {};
  142. } catch (e) {
  143. console.log("[考勤审批] 审批详情加载失败:", (e && e.message) || e);
  144. }
  145. },
  146. datePart(val) {
  147. const text = String(val || '');
  148. if (!text) return '-';
  149. return text.split('T')[0].split(' ')[0];
  150. },
  151. timePart(val) {
  152. const text = String(val || '');
  153. if (!text) return '-';
  154. const time = text.split('T')[1] || text.split(' ')[1] || '';
  155. return time ? time.slice(0, 5) : '-';
  156. },
  157. getTableValue() {
  158. return {};
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .task-form-container {
  165. background-color: #fff;
  166. padding-bottom: 40rpx;
  167. }
  168. .attachment-row {
  169. width: 100%;
  170. display: flex;
  171. justify-content: flex-end;
  172. }
  173. </style>