ExportModal.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <el-dialog v-model="props.visible" width="500px" :show-close="false" :close-on-click-modal="false" top="10vh"
  3. class="exportModal">
  4. <template #header="{ titleId, titleClass }">
  5. <div class="flex justify-between items-center border-b pb-3">
  6. <h4 :id="titleId" :class="titleClass">导出任务</h4>
  7. <div>
  8. <el-button type="primary" :loading="['2'].includes(props.saveLoading)" @click="submit()">
  9. 导出
  10. </el-button>
  11. <el-button @click="closeVisible()">取消</el-button>
  12. </div>
  13. </div>
  14. </template>
  15. <div class="mt-5">
  16. <el-form ref="formRef" :model="form" label-width="6em" class="flex flex-wrap form">
  17. <el-form-item label="优先级:">
  18. <el-select v-model="form.priority" placeholder="请选择" clearable>
  19. <el-option v-for="item in PRIORITY " :key="item.value" :value="item.value" :label="item.label" />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="执行人:">
  23. <el-select v-model="form.executorId" placeholder="请选择" clearable multiple filterable>
  24. <el-option v-for="item in executorValueData" :key="item.id" :value="item.id" :label="item.name" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="开始时间:" class="w50">
  28. <el-date-picker v-model="form.startDate" type="date" placeholder="选择日期" value-format="YYYY-MM-DD" />
  29. </el-form-item>
  30. <el-form-item label="截止时间:" class="w50">
  31. <el-date-picker v-model="form.endDate" type="date" placeholder="选择日期" value-format="YYYY-MM-DD" />
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. </el-dialog>
  36. </template>
  37. <script lang="ts" setup>
  38. import { ref, watch } from 'vue';
  39. import { defalutExportForm, PRIORITY, ALL_USERS } from './api';
  40. import { post } from '@/utils/request';
  41. import { Emits, Props } from './type';
  42. import { dayjs } from 'element-plus';
  43. const props = defineProps<Props>();
  44. const emits = defineEmits<Emits>();
  45. watch(() => props.visible, (val) => {
  46. if (val) {
  47. form.value = { ...defalutExportForm }
  48. post(ALL_USERS, {}).then(({ data }) => {
  49. executorValueData.value = data;
  50. })
  51. }
  52. })
  53. const formRef = ref();
  54. const form = ref<any>({})
  55. const executorValueData = ref<any>([])
  56. function closeVisible() {
  57. emits("close")
  58. }
  59. function submit() {
  60. const { executorId, startDate, endDate, ...rest } = form.value;
  61. const data = {
  62. ...rest,
  63. startDate: startDate && dayjs(startDate).format('YYYY-MM-DD 00:00:00'),
  64. endDate: endDate && dayjs(endDate).format('YYYY-MM-DD 23:59:59'),
  65. executorId: executorId.join(','),
  66. }
  67. emits("submit", data)
  68. }
  69. </script>
  70. <style lang="scss">
  71. .el-form-item {
  72. width: 100%;
  73. }
  74. .form {
  75. .w50 {
  76. @apply w-1/2;
  77. }
  78. }
  79. </style>