taskForm.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. // durationMinutes 现按小时口径提交/存储(如 2 = 2 小时)
  109. const hours = Number(this.form.durationMinutes);
  110. if (!hours || isNaN(hours) || hours <= 0) return '';
  111. return `${hours} 小时`;
  112. },
  113. attachmentIds() {
  114. const raw = this.form.attachmentFileIds;
  115. if (!raw) return [];
  116. return String(raw)
  117. .split(',')
  118. .map((item) => item.trim())
  119. .filter(Boolean);
  120. },
  121. },
  122. watch: {
  123. businessId(val) {
  124. if (val) this._getInfo();
  125. }
  126. },
  127. mounted() {
  128. this._getInfo();
  129. },
  130. methods: {
  131. async _getInfo() {
  132. // 审批处理看的是完整表单:待办任务上的 businessId 就是考勤申请业务主键
  133. // (对应 ESS 列表 row.businessId),直接查 /hr/attendance/applications/{businessId};
  134. // 不要拿它去调 /hr/ess/admin/applications/{id}(那个要的是 row.id 索引主键)
  135. if (!this.businessId) return;
  136. try {
  137. this.form =
  138. (await getAttendanceApplicationDetail(this.businessId, false)) || {};
  139. } catch (e) {
  140. console.log("[考勤审批] 审批详情加载失败:", (e && e.message) || e);
  141. }
  142. },
  143. datePart(val) {
  144. const text = String(val || '');
  145. if (!text) return '-';
  146. return text.split('T')[0].split(' ')[0];
  147. },
  148. timePart(val) {
  149. const text = String(val || '');
  150. if (!text) return '-';
  151. const time = text.split('T')[1] || text.split(' ')[1] || '';
  152. return time ? time.slice(0, 5) : '-';
  153. },
  154. getTableValue() {
  155. return {};
  156. }
  157. }
  158. };
  159. </script>
  160. <style lang="scss" scoped>
  161. .task-form-container {
  162. background-color: #fff;
  163. padding-bottom: 40rpx;
  164. }
  165. .attachment-row {
  166. width: 100%;
  167. display: flex;
  168. justify-content: flex-end;
  169. }
  170. </style>