Form.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <el-form :inline="true" class="searchBox">
  3. <el-form-item label="合同日期:" class="form">
  4. <el-date-picker
  5. v-model="queryParams.date"
  6. type="date"
  7. placeholder="请选择月份"
  8. :clearable="false"
  9. />
  10. </el-form-item>
  11. <el-form-item label="合同编号" class="form">
  12. <el-input v-model="queryParams.code" clearable />
  13. </el-form-item>
  14. <el-form-item label="合同名称" class="form project-name">
  15. <el-input v-model="queryParams.name" clearable />
  16. </el-form-item>
  17. <el-form-item class="search-button">
  18. <el-button type="primary" :icon="Search" @click="onSearchHandle">查询</el-button>
  19. </el-form-item>
  20. </el-form>
  21. </template>
  22. <script lang="ts" setup>
  23. /**
  24. * @description 查询表单
  25. */
  26. import { Search } from '@element-plus/icons-vue'
  27. import moment from 'moment'
  28. import PubsubService from '@/utils/PubsubService'
  29. interface IProps {
  30. pageKey: string // 页面的唯一标识
  31. }
  32. const { pageKey } = defineProps<IProps>()
  33. interface IQuery {
  34. date: string // 合同日期
  35. code: string // 合同编号
  36. name: string // 合同名称
  37. }
  38. const queryParams = reactive<IQuery>({
  39. date: moment().format('YYYY-MM-DD'),
  40. code: '',
  41. name: ''
  42. })
  43. // 查询
  44. const onSearchHandle: () => void = () => {
  45. queryParams.date = moment(queryParams.date).format('YYYY-MM-DD')
  46. const params = { ...queryParams }
  47. // 发布查询事件
  48. PubsubService.publish(pageKey, params)
  49. // onSearch?.(queryParams)
  50. }
  51. </script>
  52. <style scoped lang="scss">
  53. .project-name {
  54. width: 400px !important;
  55. }
  56. .search-button {
  57. display: flex;
  58. margin: 5px 0;
  59. align-items: center;
  60. flex-shrink: 0;
  61. }
  62. </style>