DispatchForm.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="document-form">
  3. <uv-loading-icon v-if="loading" mode="circle" text="正在加载派驻详情..."></uv-loading-icon>
  4. <template v-else-if="form">
  5. <!-- 基本信息 -->
  6. <CommonSection title="人员派驻信息" :isFirst="true">
  7. <CommonInfoRow label="派遣类型" :value="getDictLabel('disType', form.disType)" />
  8. <CommonInfoRow label="姓名" :value="form.reserName" />
  9. <CommonInfoRow label="性别" :value="form.reserGender === '10' ? '男' : (form.reserGender === '20' ? '女' : '-')" />
  10. <CommonInfoRow :label="form.disType == '10' ? '派遣单位' : '接收单位'" :value="form.disAddress" />
  11. <CommonInfoRow label="手机号" :value="form.reserPhone" />
  12. <CommonInfoRow label="电子邮箱" :value="form.reserEmail" />
  13. <CommonInfoRow label="派遣时间" :value="formatDate(form.disStartTime) + ' 至 ' + formatDate(form.disEndTime)" />
  14. <CommonInfoRow label="项目名称" :value="form.projectName" />
  15. <CommonInfoRow label="工作内容" :value="form.disContent" isColumn />
  16. </CommonSection>
  17. <!-- 附件 -->
  18. <AttachmentList :file="attachment" title="佐证材料" />
  19. </template>
  20. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  21. </view>
  22. </template>
  23. <script setup lang="ts">
  24. import { ref, onMounted, watch, computed } from 'vue';
  25. import { useDict } from '@/hooks/useDict';
  26. import { useDocumentApi } from '@/api/document';
  27. import { formatDate } from '@/utils/date';
  28. import to from 'await-to-js';
  29. import CommonSection from '@/components/ui/CommonSection.vue';
  30. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  31. import AttachmentList from './AttachmentList.vue';
  32. const props = defineProps<{
  33. code: string;
  34. }>();
  35. const { getDictLabel } = useDict('disType');
  36. const documentApi = useDocumentApi();
  37. const form = ref<any>(null);
  38. const loading = ref(false);
  39. const attachment = computed(() => {
  40. if (form.value?.disFile) {
  41. try {
  42. const file = JSON.parse(form.value.disFile);
  43. return {
  44. ...file,
  45. type: '佐证材料'
  46. };
  47. } catch (e) {
  48. return null;
  49. }
  50. }
  51. return null;
  52. });
  53. const fetchData = async () => {
  54. if (!props.code) return;
  55. loading.value = true;
  56. const [err, res] = await to(documentApi.getDispatchById(props.code));
  57. if (!err && res?.data) {
  58. form.value = res.data;
  59. }
  60. loading.value = false;
  61. };
  62. onMounted(() => {
  63. fetchData();
  64. });
  65. watch(() => props.code, () => {
  66. fetchData();
  67. });
  68. </script>
  69. <style lang="scss" scoped>
  70. @import "./common.scss";
  71. </style>