CarDamageTable.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="car-damage">
  3. <div class="search-area">
  4. <a-row>
  5. <a-col :span="4">
  6. <div class="area-item">
  7. <div class="item-text">风门状态:</div>
  8. <a-select ref="select" v-model:value="type" style="width: 240px" placeholder="请选择风门状态">
  9. <a-select-option v-for="(item, index) in typeList" :key="item.value" :value="item.value">{{
  10. item.label }}</a-select-option>
  11. </a-select>
  12. </div>
  13. </a-col>
  14. <a-col :span="4">
  15. <a-button type="primary" preIcon="ant-design:search-outlined" style="margin-left: 10px"
  16. @click="getSearch">查询</a-button>
  17. <a-button preIcon="ant-design:sync-outlined" style="margin: 0px 15px" @click="getReset">重置</a-button>
  18. </a-col>
  19. </a-row>
  20. </div>
  21. <div class="content-area">
  22. <a-table size="small" :dataSource="dataSource" :columns="carColumns" :pagination="pagination"
  23. :scroll="{ y: 200, }" @change="pageChange">
  24. <template #bodyCell="{ column, text }">
  25. <template v-if="column.dataIndex == 'type'">
  26. <div>{{ text == '1' ? '风门损坏' : '正常开闭' }}</div>
  27. </template>
  28. </template>
  29. </a-table>
  30. </div>
  31. </div>
  32. </template>
  33. <script setup lang="ts">
  34. import { ref, reactive, onMounted } from 'vue'
  35. import { carColumns, typeList } from '../gate.data'
  36. let props = defineProps({
  37. deviceListApi: {
  38. type: Function,
  39. required: true,
  40. },
  41. gateId: {
  42. type: String,
  43. default: ''
  44. }
  45. })
  46. let type = ref('0')
  47. let dataSource = ref<any[]>([])
  48. //分页参数配置
  49. let pagination = reactive({
  50. current: 1, // 当前页码
  51. pageSize: 10, // 每页显示条数
  52. total: 0, // 总条目数,后端返回
  53. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  54. showSizeChanger: true, // 是否可改变每页显示条数
  55. pageSizeOptions: ['10', '20', '50'], // 可选的每页显示条数
  56. });
  57. //查询列表
  58. async function getCarList() {
  59. let res = await props.deviceListApi({ gateIds: props.gateId, type: type.value, pageNo: pagination.current, pageSize: pagination.pageSize })
  60. dataSource.value = res.records || []
  61. pagination.total = res.total
  62. }
  63. function pageChange(val) {
  64. pagination.current = val.current;
  65. pagination.pageSize = val.pageSize;
  66. getCarList()
  67. }
  68. //查询
  69. function getSearch() {
  70. pagination.current = 1
  71. getCarList()
  72. }
  73. //重置
  74. function getReset() {
  75. type.value = '0'
  76. pagination.current = 1
  77. getCarList()
  78. }
  79. onMounted(() => {
  80. getCarList()
  81. })
  82. </script>
  83. <style lang="less" scoped>
  84. .car-damage {
  85. .search-area {
  86. margin: 15px;
  87. .area-item {
  88. display: flex;
  89. align-items: center;
  90. .item-text {
  91. color: #fff;
  92. }
  93. }
  94. }
  95. .zxm-picker,
  96. .zxm-input {
  97. border: 1px solid #3ad8ff77;
  98. background-color: #ffffff00;
  99. color: #fff;
  100. }
  101. }
  102. </style>