AirportForm.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <el-form :model="formData" inline class="airport-form">
  3. <el-form-item :prop="formData.startDate" style="width: 172px">
  4. <el-date-picker
  5. v-model="formData.startDate"
  6. type="datetime"
  7. format="YYYY-MM-DD HH:mm"
  8. value-format="YYYY-MM-DD HH:mm"
  9. size="default"
  10. :prefix-icon="datePreTitle('开始')"
  11. :clearable="false"
  12. />
  13. </el-form-item>
  14. <el-form-item :prop="formData.endDate" style="width: 172px">
  15. <el-date-picker
  16. v-model="formData.endDate"
  17. type="datetime"
  18. format="YYYY-MM-DD HH:mm"
  19. value-format="YYYY-MM-DD HH:mm"
  20. :default-time="new Date('2000-01-01 23:59:59')"
  21. :disabled-date="disabledEndTime"
  22. size="default"
  23. :prefix-icon="datePreTitle('结束')"
  24. :clearable="false"
  25. />
  26. </el-form-item>
  27. <el-form-item :prop="formData.flightState" style="width: 134px">
  28. <el-select
  29. v-model="formData.flightState"
  30. size="default"
  31. :clearable="false"
  32. >
  33. <el-option
  34. v-for="option in flightStateOptions"
  35. :key="option.value"
  36. :label="option.label"
  37. :value="option.value"
  38. />
  39. </el-select>
  40. </el-form-item>
  41. <!-- <el-form-item :prop="formData.flightWarning" style="width: 104px">
  42. <el-select
  43. v-model="formData.flightWarning"
  44. size="default"
  45. :clearable="false"
  46. >
  47. <el-option
  48. v-for="option in flightWarningOptions"
  49. :key="option.value"
  50. :label="option.label"
  51. :value="option.value"
  52. />
  53. </el-select>
  54. </el-form-item> -->
  55. <!-- <el-form-item
  56. v-if="name.includes('International')"
  57. :prop="formData.waybillType"
  58. style="width: 104px"
  59. >
  60. <el-select
  61. v-model="formData.waybillType"
  62. size="default"
  63. :clearable="false"
  64. >
  65. <el-option
  66. v-for="option in waybillTypeOptions"
  67. :key="option.value"
  68. :label="option.label"
  69. :value="option.value"
  70. />
  71. </el-select>
  72. </el-form-item> -->
  73. </el-form>
  74. </template>
  75. <script setup lang="tsx">
  76. import { parseTime } from '@/utils/validate'
  77. import { ElMessage } from 'element-plus'
  78. import { CommonData } from '~/common'
  79. const props = defineProps({
  80. name: {
  81. type: String,
  82. required: true,
  83. },
  84. })
  85. const emit = defineEmits(['formDataChange'])
  86. const defaultStartTime = `${parseTime(new Date(), '{y}-{m}-{d}')} 00:00`
  87. const defaultEndTime = `${parseTime(new Date(), '{y}-{m}-{d}')} 23:59`
  88. const formData = reactive({
  89. startDate: defaultStartTime,
  90. endDate: defaultEndTime,
  91. flightState: '',
  92. flightWarning: '',
  93. waybillType: '',
  94. })
  95. watchEffect(() => {
  96. if (!formData.startDate || !formData.endDate) {
  97. return
  98. }
  99. const start = new Date(formData.startDate + ':00').getTime()
  100. const end = new Date(formData.endDate + ':59').getTime()
  101. if (start > end) {
  102. ElMessage.warning('开始时间不能晚于结束时间')
  103. formData.endDate = ''
  104. return
  105. }
  106. if (start <= end - 2 * 24 * 60 * 60 * 1000) {
  107. ElMessage.warning('间隔不能超过2天')
  108. formData.endDate = ''
  109. return
  110. }
  111. const formattedFormData: CommonData = {}
  112. Object.entries(formData).forEach(([key, value]) => {
  113. formattedFormData[key] = value === '' ? null : value
  114. })
  115. formattedFormData.startDate = formData.startDate + ':00'
  116. formattedFormData.endDate = formData.endDate + ':59'
  117. emit('formDataChange', formattedFormData)
  118. })
  119. const disabledEndTime = endDate => {
  120. const start = new Date(formData.startDate + ':00').getTime()
  121. const end = new Date(endDate + ':59').getTime()
  122. return start > end || start <= end - 2 * 24 * 60 * 60 * 1000
  123. }
  124. const datePreTitle = (title: string) => {
  125. return <div class="date-pre-title">{title}:</div>
  126. }
  127. const flightStateOptions = ref([
  128. {
  129. label: '全部航班',
  130. value: '',
  131. },
  132. {
  133. label: props.name.includes('Departure') ? '已起飞' : '已降落',
  134. value: props.name.includes('Departure') ? 'hasTakenOff' : 'hasLanded',
  135. },
  136. {
  137. label: props.name.includes('Departure') ? '未起飞' : '未降落',
  138. value: props.name.includes('Departure') ? 'hasNotTakenOff' : 'hasNotLanded',
  139. },
  140. {
  141. label: '取消',
  142. value: 'canceled',
  143. },
  144. ])
  145. onMounted(() => {
  146. if (props.name.includes('International')) {
  147. flightStateOptions.value.push({
  148. label: '机场代理操作',
  149. value: 'groundService',
  150. })
  151. }
  152. if (props.name === 'ArrivalAirport') {
  153. flightStateOptions.value.push(
  154. {
  155. label: '深航地服',
  156. value: 'groundServiceSZ',
  157. },
  158. {
  159. label: '机场地服',
  160. value: 'groundService',
  161. }
  162. )
  163. }
  164. })
  165. const flightWarningOptions = ref([
  166. {
  167. label: '全部航班',
  168. value: '',
  169. },
  170. {
  171. label: '正常航班',
  172. value: 'normal',
  173. },
  174. {
  175. label: '预警航班',
  176. value: 'warning',
  177. },
  178. {
  179. label: '告警航班',
  180. value: 'alarm',
  181. },
  182. ])
  183. const waybillTypeOptions = ref([
  184. {
  185. label: '全部运单',
  186. value: '',
  187. },
  188. {
  189. label: '国际普货',
  190. value: 'normal',
  191. },
  192. // {
  193. // label: '国际快件',
  194. // value: 'fast',
  195. // },
  196. ])
  197. </script>
  198. <style scoped lang="scss">
  199. .airport-form :deep {
  200. .el-form-item {
  201. margin: 0;
  202. &:not(:last-of-type) {
  203. margin-right: 8px;
  204. }
  205. .el-input__inner {
  206. font-size: 14px;
  207. font-family: DIN, Microsoft YaHei;
  208. color: #303133;
  209. }
  210. .el-date-editor {
  211. .el-input__prefix {
  212. flex-basis: 28px;
  213. padding: 0 8px;
  214. .date-pre-title {
  215. font-style: normal;
  216. font-size: 14px;
  217. font-family: Microsoft YaHei;
  218. color: #303133;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </style>