taskForm.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. {{ overtimeTypeLabel }}
  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 的 overtimeType 口径一致)
  44. const OVERTIME_TYPE_LABELS = {
  45. WORKDAY: '工作日加班',
  46. RESTDAY: '休息日加班',
  47. LEGAL_HOLIDAY: '法定节假日加班',
  48. };
  49. export default {
  50. components: { fileMain },
  51. props: {
  52. bizType: {
  53. type: String,
  54. default: ''
  55. },
  56. businessId: {
  57. type: String,
  58. default: ''
  59. },
  60. taskId: {
  61. type: String,
  62. default: ''
  63. },
  64. // 流程实例主键(processTask 透传),详情从流程表单变量取
  65. id: {
  66. type: String,
  67. default: ''
  68. },
  69. taskDefinitionKey: {
  70. type: String,
  71. default: ''
  72. },
  73. isUpload: {
  74. type: Boolean,
  75. default: false
  76. },
  77. isInterior: {
  78. type: Boolean,
  79. default: true
  80. },
  81. isIds: {
  82. type: Boolean,
  83. default: false
  84. }
  85. },
  86. data() {
  87. return {
  88. form: {},
  89. startUser: {},
  90. };
  91. },
  92. computed: {
  93. applicantName() {
  94. return this.form.userName || this.form.applicantName || '';
  95. },
  96. overtimeTypeLabel() {
  97. const code = this.form.overtimeType;
  98. if (!code) return '-';
  99. return OVERTIME_TYPE_LABELS[code] || code;
  100. },
  101. durationLabel() {
  102. const minutes = Number(this.form.durationMinutes);
  103. if (!minutes || isNaN(minutes) || minutes <= 0) return '';
  104. const hours = Math.floor(minutes / 60);
  105. const mins = minutes % 60;
  106. if (!hours) return `${mins} 分钟`;
  107. if (!mins) return `${hours} 小时`;
  108. return `${hours} 小时 ${mins} 分钟`;
  109. },
  110. attachmentIds() {
  111. const raw = this.form.attachmentFileIds;
  112. if (!raw) return [];
  113. return String(raw)
  114. .split(',')
  115. .map((item) => item.trim())
  116. .filter(Boolean);
  117. },
  118. },
  119. watch: {
  120. businessId(val) {
  121. if (val) this._getInfo();
  122. }
  123. },
  124. mounted() {
  125. this._getInfo();
  126. },
  127. methods: {
  128. async _getInfo() {
  129. // 审批处理看的是完整表单:待办任务上的 businessId 就是考勤申请业务主键
  130. // (对应 ESS 列表 row.businessId),直接查 /hr/attendance/applications/{businessId};
  131. // 不要拿它去调 /hr/ess/admin/applications/{id}(那个要的是 row.id 索引主键)
  132. if (!this.businessId) return;
  133. try {
  134. this.form =
  135. (await getAttendanceApplicationDetail(this.businessId, false)) || {};
  136. } catch (e) {
  137. console.log("[考勤审批] 审批详情加载失败:", (e && e.message) || e);
  138. }
  139. },
  140. datePart(val) {
  141. const text = String(val || '');
  142. if (!text) return '-';
  143. return text.split('T')[0].split(' ')[0];
  144. },
  145. timePart(val) {
  146. const text = String(val || '');
  147. if (!text) return '-';
  148. const time = text.split('T')[1] || text.split(' ')[1] || '';
  149. return time ? time.slice(0, 5) : '-';
  150. },
  151. getTableValue() {
  152. return {};
  153. }
  154. }
  155. };
  156. </script>
  157. <style lang="scss" scoped>
  158. .task-form-container {
  159. background-color: #fff;
  160. padding-bottom: 40rpx;
  161. }
  162. .attachment-row {
  163. width: 100%;
  164. display: flex;
  165. justify-content: flex-end;
  166. }
  167. </style>