taskForm.vue 4.1 KB

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