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