commonSearch.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="table-page-search-wrapper">
  3. <a-form :model="queryParams" ref="queryForm" layout="inline">
  4. <a-row :gutter="24">
  5. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  6. <a-form-item label="区域" prop="spaceId">
  7. <j-tree-select
  8. ref="treeSelect"
  9. placeholder="请选择上级"
  10. v-model="queryParams.spaceId"
  11. dict="base_space,name,id"
  12. pidField="parentid"
  13. pidValue="0"
  14. hasChildField="has_child"
  15. >
  16. </j-tree-select>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :xl="6" :lg="7" :md="8" :sm="24" v-if="type !== 'nodate'">
  20. <a-form-item label="日期" prop="date">
  21. <a-range-picker
  22. v-if="type === 'daterange'"
  23. v-model="queryParams.date"
  24. format="YYYY-MM"
  25. :placeholder="['开始月份', '结束月份']"
  26. >
  27. </a-range-picker>
  28. <a-date-picker
  29. v-if="type === 'month'"
  30. v-model="queryParams.yearMonth"
  31. :editable="false"
  32. :clearable="false"
  33. value-format="yyyy-MM"
  34. type="month"
  35. placeholder="选择月"
  36. >
  37. </a-date-picker>
  38. <a-date-picker
  39. v-if="type === 'day'"
  40. v-model="queryParams.day"
  41. :editable="false"
  42. :clearable="false"
  43. value-format="yyyy-MM-dd"
  44. type="date"
  45. placeholder="选择日期"
  46. >
  47. </a-date-picker>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  51. <a-button type="primary" icon="search" @click="handleQuery">搜索</a-button>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. </template>
  57. <script>
  58. import { httpAction, getAction } from '@/api/manage'
  59. export default {
  60. name: '',
  61. props: {
  62. type: {
  63. type: String,
  64. default: null,
  65. },
  66. hasAreaSearch: {
  67. type: Boolean,
  68. default: false,
  69. },
  70. },
  71. data() {
  72. return {
  73. showSearch: false,
  74. queryParams: {
  75. spaceId: '288348631531521',
  76. beginTime: null, // 只有能耗总览不需要
  77. endTime: null, // 只有能耗总览不需要
  78. date: [],
  79. yearMonth: null, // 节能分析
  80. day: null, // 分项能耗
  81. },
  82. params: {
  83. column: 'createTime',
  84. order: 'desc',
  85. hasQuery: 'false',
  86. field: 'id,parentid,name',
  87. pageNo: '1',
  88. pageSize: '100',
  89. },
  90. url: {},
  91. }
  92. },
  93. created() {
  94. this.getNowDate()
  95. },
  96. mounted() {},
  97. methods: {
  98. /**
  99. * 查询当天日期
  100. */
  101. getNowDate() {
  102. const nowTime = new Date()
  103. const year = nowTime.getFullYear()
  104. let month = nowTime.getMonth() + 1
  105. let day = nowTime.getDate()
  106. month = month < 10 ? '0' + month : month
  107. day = day < 10 ? '0' + day : day
  108. // const NOW_MONTHS_AGO = `${year}-${month}`
  109. this.queryParams.beginTime = `${year}-01`
  110. this.queryParams.endTime = `${year}-${month}`
  111. this.queryParams.date = [`${year}-01`, `${year}-${month}`]
  112. this.queryParams.yearMonth = `${year}-${month}`
  113. this.queryParams.day = `${year}-${month}-${day}`
  114. },
  115. changeShow() {
  116. this.showSearch = !this.showSearch
  117. },
  118. /** 搜索按钮操作 */
  119. handleQuery() {
  120. // console.log(this.queryParams)
  121. this.queryParams.beginTime = this.queryParams.date[0]
  122. this.queryParams.endTime = this.queryParams.date[1]
  123. this.$emit('search', this.queryParams)
  124. },
  125. /** 重置按钮操作 */
  126. resetQuery() {
  127. this.resetForm('queryForm')
  128. this.date = []
  129. this.handleQuery()
  130. },
  131. },
  132. }
  133. </script>
  134. <style lang="less" scoped>
  135. .search-compoments {
  136. position: relative;
  137. .search-icon {
  138. position: absolute;
  139. top: -10px;
  140. right: -10px;
  141. width: 20px;
  142. height: 20px;
  143. font-size: 20px;
  144. color: #fff;
  145. background-color: #1890ff;
  146. }
  147. .search-container {
  148. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  149. padding-top: 12px;
  150. margin-bottom: 10px;
  151. .a-form-item--small.a-form-item {
  152. margin-bottom: 14px;
  153. }
  154. }
  155. .item-echarts {
  156. min-height: calc(100vh - 174px);
  157. padding: 10px;
  158. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  159. }
  160. }
  161. </style>