index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div class="layout-pd">
  3. <el-row>
  4. <!--操作-->
  5. <el-col :xs="24">
  6. <el-card class="mt8" shadow="hover">
  7. <el-form :model="Data.Filter" @submit.stop.prevent>
  8. <el-form-item prop="name" style="width: 100%">
  9. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  10. <el-form-item label="省份">
  11. <el-input v-model="Data.Filter.province" placeholder="请输入省份" clearable></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  15. <el-form-item label="油站名称">
  16. <el-input v-model="Data.Filter.name" placeholder="请输入油站名称" clearable></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  20. <el-form-item label="油站类型">
  21. <el-select v-model="Data.Filter.type" placeholder="请选择油站类型">
  22. <el-option label="所有" :value="''"></el-option>
  23. <el-option v-for="(value, key) in type" :key="key" :label="value" :value="key" />
  24. </el-select>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  28. <el-form-item label="选择时间">
  29. <el-date-picker
  30. v-model="Data.Filter.createTimeRange"
  31. type="datetimerange"
  32. value-format="YYYY-MM-DD HH:mm:ss"
  33. range-separator="To"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. />
  37. </el-form-item>
  38. </el-col>
  39. </el-form-item>
  40. </el-form>
  41. <hr>
  42. <!-- 按钮 -->
  43. <el-row justify="space-between" class="submit-button" style="margin-bottom:-7px">
  44. <el-row>
  45. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  46. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  47. </el-row>
  48. </el-row>
  49. </el-card>
  50. </el-col>
  51. <!--表格-->
  52. <el-col :xs="24">
  53. <el-card class="my-fill mt8" shadow="hover">
  54. <el-table ref="multipleTableRef" v-loading="Data.loading" stripe :data="Data.tableModel" row-key="id"
  55. style="width: 100%">
  56. <el-table-column v-for="column in Data.dynamicColumns" :key="column.prop" :prop="column.prop"
  57. :label="column.label" />
  58. <el-table-column label="站长及联系方式">
  59. <template #default="scope">
  60. {{ scope.row.contact }}{{ scope.row.phone }}
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <div class="my-flex my-flex-end" style="margin-top: 20px">
  65. <el-pagination v-model:currentPage="pageState.pageInput.currentPage" v-model:page-size="pageState.pageInput.pageSize"
  66. :total="Data.total" :page-sizes="[10, 15, 20, 50, 100]" small background @size-change="onSizeChange"
  67. @current-change="onCurrentChange" layout="total, sizes, prev, pager, next, jumper" />
  68. </div>
  69. </el-card>
  70. </el-col>
  71. </el-row>
  72. </div>
  73. </template>
  74. <script setup lang="ts" name="authorize/fuelingsdk">
  75. import { onMounted, reactive, ref, watch } from "vue";
  76. import { ElTable } from 'element-plus'
  77. import { gasStationFilterModel_SearchFilter, gasStationFilterModel, PageInputgasStationFilterModel } from "/@/api/admin/reportManagement/gasStation/gasStationDto";
  78. import { gasStationApi } from "/@/api/admin/reportManagement/gasStation/gasStationApi";
  79. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  80. // 使用组合式函数获取分页状态
  81. const pageState = useDynamicPageSize(10, 15);
  82. /**引入组件*/
  83. // 安装日期假数据
  84. const value1 = ref('')
  85. /**页面对象 */
  86. const Data = reactive({
  87. time: '',
  88. /**加载显示 */
  89. loading: false,
  90. /**条件查询模块 */
  91. Filter: {
  92. city:"",
  93. contact:"",
  94. phone:"",
  95. alarmTime:"",
  96. /**省份 */
  97. province: "",
  98. /**加油站名称 */
  99. name: "",
  100. // 油站类型
  101. type:"",
  102. startDate:null,
  103. endDate:null,
  104. } as gasStationFilterModel_SearchFilter,
  105. /**表格信息 */
  106. tableModel: [] as Array<gasStationFilterModel>,
  107. /**动态表头 */
  108. dynamicColumns: [
  109. { prop: 'province', label: '省份' },
  110. { prop: 'city', label: '城市' },
  111. { prop: 'name', label: '油站名称' },
  112. { prop: 'type', label: '油站类型' },
  113. { prop: 'address', label: '油站地址' },
  114. { prop: 'dispensersTotal', label: '油机数量' },
  115. { prop: 'nozzleControlsTotal', label: '油枪数量' },
  116. { prop: 'alarmTime', label: '启用时间(安装时间)' },
  117. ],
  118. /**分页标识 */
  119. pageInput: {
  120. currentPage: 1,
  121. pageSize: 10,
  122. } as PageInputgasStationFilterModel,
  123. /**分页总数 */
  124. total: 0,
  125. })
  126. // 油站类型
  127. enum type {
  128. 中石油="中石油",
  129. 中石化="中石化",
  130. 社会站="社会站"
  131. }
  132. /**初始化 */
  133. const init = async () => {
  134. Data.loading = true
  135. const res: any = await new gasStationApi().getPage({ ...Data.pageInput, filter: Data.Filter })
  136. Data.tableModel = res?.data.list ?? []
  137. Data.total = res?.data.total ?? 0
  138. Data.loading = false
  139. }
  140. onMounted(() => {
  141. // 初始化分页大小
  142. Data.pageInput.pageSize = pageState.pageInput.pageSize;
  143. init()
  144. })
  145. /**条件查询 */
  146. const onQuery = () => {
  147. init()
  148. }
  149. /**重置查询条件 */
  150. const resetQuery = () => {
  151. Data.Filter.name = ''
  152. Data.Filter.province = ''
  153. Data.pageInput.pageSize = 10
  154. Data.pageInput.currentPage = 1
  155. }
  156. /**重置 */
  157. const onReset = () => {
  158. resetQuery()
  159. init()
  160. }
  161. /**
  162. * 页条变化
  163. * @param val
  164. */
  165. const onSizeChange = (val: number) => {
  166. Data.pageInput.pageSize = val
  167. init()
  168. }
  169. /**
  170. * 页数 变化
  171. * @param val
  172. */
  173. const onCurrentChange = (val: number) => {
  174. Data.pageInput.currentPage = val
  175. init()
  176. }
  177. watch(
  178. () => Data.Filter.createTimeRange,
  179. (newVal) => {
  180. if (newVal && newVal.length === 2) {
  181. Data.Filter.startDate = newVal[0]; // yyyy-MM-dd 格式
  182. Data.Filter.endDate = newVal[1];
  183. } else {
  184. Data.Filter.startDate = null;
  185. Data.Filter.endDate = null;
  186. }
  187. }
  188. );
  189. </script>
  190. <style scoped lang="scss">
  191. .el-input,
  192. .el-select {
  193. width: 240px;
  194. }
  195. /* 输入框标签固定四个字符宽度 */
  196. ::v-deep .el-form-item__label {
  197. // 字体大小14,4个字符,12px右间距
  198. width: 14*4px+12px;
  199. justify-content: start;
  200. }
  201. /* 数据表头 设置灰色样式 */
  202. ::v-deep .el-table th.el-table__cell {
  203. background-color: #F6F6F6;
  204. }
  205. </style>