CarDamageTable.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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
  26. v-if="column.dataIndex == 'carNo' || column.dataIndex == 'distance' || column.dataIndex == 'photo' || column.dataIndex == 'captureTime'">
  27. <div>{{ text ? text : '-' }}</div>
  28. </template>
  29. <template v-if="column.dataIndex == 'type'">
  30. <div>{{ text == '1' ? '风门损坏' : '正常开闭' }}</div>
  31. </template>
  32. <template v-if="column.dataIndex == 'photoC'">
  33. <img :src="text" alt="" class="photo_zp" @click="preViewImg(text)">
  34. </template>
  35. </template>
  36. </a-table>
  37. </div>
  38. <!-- 预览抓拍图像 -->
  39. <a-modal v-model:visible="visiblePhoto" width="850px" :title="titlePhoto" :footer="null" centered destroyOnClose>
  40. <img :src="imgSrc" alt="">
  41. </a-modal>
  42. </div>
  43. </template>
  44. <script setup lang="ts">
  45. import { ref, reactive, onMounted } from 'vue'
  46. import { carColumns, typeList } from '../gate.data'
  47. let props = defineProps({
  48. deviceListApi: {
  49. type: Function,
  50. required: true,
  51. },
  52. gateId: {
  53. type: String,
  54. default: ''
  55. }
  56. })
  57. let type = ref('0')
  58. let dataSource = ref<any[]>([])
  59. //分页参数配置
  60. let pagination = reactive({
  61. current: 1, // 当前页码
  62. pageSize: 10, // 每页显示条数
  63. total: 0, // 总条目数,后端返回
  64. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  65. showSizeChanger: true, // 是否可改变每页显示条数
  66. pageSizeOptions: ['10', '20', '50'], // 可选的每页显示条数
  67. });
  68. let visiblePhoto = ref(false)
  69. let titlePhoto = ref('抓拍图像预览')
  70. let imgSrc = ref('')//抓拍图像路径
  71. //查询列表
  72. async function getCarList() {
  73. let res = await props.deviceListApi({ gateIds: props.gateId, type: type.value, pageNo: pagination.current, pageSize: pagination.pageSize })
  74. const remoteUrl = import.meta.env.DEV ? 'http://182.92.126.35' : 'http://' + window.location.hostname;
  75. dataSource.value = res.records.map(el => {
  76. return {
  77. photoC: `${remoteUrl}:9999/sys/common/static/${el.photo.substring(el.photo.indexOf('/gate_monitor'))}`,
  78. ...el
  79. }
  80. })
  81. pagination.total = res.total
  82. }
  83. function pageChange(val) {
  84. pagination.current = val.current;
  85. pagination.pageSize = val.pageSize;
  86. getCarList()
  87. }
  88. //查询
  89. function getSearch() {
  90. pagination.current = 1
  91. getCarList()
  92. }
  93. //重置
  94. function getReset() {
  95. type.value = '0'
  96. pagination.current = 1
  97. getCarList()
  98. }
  99. //预览抓拍图像
  100. function preViewImg(img) {
  101. visiblePhoto.value = true
  102. imgSrc.value = img
  103. }
  104. onMounted(() => {
  105. getCarList()
  106. })
  107. </script>
  108. <style lang="less" scoped>
  109. .car-damage {
  110. .search-area {
  111. margin: 15px;
  112. .area-item {
  113. display: flex;
  114. align-items: center;
  115. .item-text {
  116. color: #fff;
  117. }
  118. }
  119. }
  120. .zxm-picker,
  121. .zxm-input {
  122. border: 1px solid #3ad8ff77;
  123. background-color: #ffffff00;
  124. color: #fff;
  125. }
  126. .photo_zp {
  127. width: 120px;
  128. cursor: pointer;
  129. }
  130. }
  131. </style>