index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="table_item">
  3. <s-table ref="tableRef" :columns="columns" :data="loadData" :row-key="(record) => record.id">
  4. <template #operator>
  5. <!-- 搜索区域 -->
  6. <div class="table-search">
  7. <div class="table-search-form">
  8. <a-row :gutter="10">
  9. <a-form
  10. ref="searchFormRef"
  11. name="advanced_search"
  12. layout="inline"
  13. :label-col="{ style: { width: '70px', justifyContent: 'end' } }"
  14. :model="searchFormState"
  15. class="ant-advanced-search-form"
  16. >
  17. <a-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8"
  18. ><a-form-item label="点位名称" name="name">
  19. <a-input v-model:value="searchFormState.name" placeholder="请输入点位名称" /> </a-form-item
  20. ></a-col>
  21. </a-form>
  22. </a-row>
  23. </div>
  24. <div class="table-search-buttons">
  25. <a-button type="primary" @click="tableRef.refresh(true)">查询</a-button>
  26. <a-button class="xn-mg08" @click="reset">重置</a-button>
  27. </div>
  28. </div>
  29. <!-- 其他操作区域 -->
  30. <div class="table-head-btn">
  31. <div class="btn-left">
  32. <a-button type="primary" @click="formRef.onOpen()">
  33. <template #icon><plus-outlined /></template>新增
  34. </a-button>
  35. </div>
  36. <div class="btn-right">
  37. <a-button>
  38. <template #icon><download-outlined /></template>导出
  39. </a-button>
  40. </div>
  41. </div>
  42. </template>
  43. <template #bodyCell="{ column, record }">
  44. <template v-if="column.dataIndex === 'modelName'">
  45. {{ $TOOL.dictTypeData('COIDCHAIN', record.modelName) }}
  46. </template>
  47. <template v-if="column.dataIndex === 'action'">
  48. <a-button type="link" size="small" @click="formRef.onOpen(record)">编辑</a-button>
  49. <a-popconfirm title="确定要删除吗?" @confirm="deleteData(record)">
  50. <a-button type="link" danger size="small">删除</a-button>
  51. </a-popconfirm>
  52. </template>
  53. </template>
  54. </s-table>
  55. <Form ref="formRef" @successful="tableRef.refresh(true)" />
  56. </div>
  57. </template>
  58. <script setup>
  59. import tool from '@/utils/tool'
  60. import locationApi from '@/api/basicset/locationApi.js'
  61. import Form from './form.vue'
  62. const formRef = ref()
  63. const searchFormRef = ref()
  64. const searchFormState = ref({})
  65. const tableRef = ref()
  66. const columns = [
  67. {
  68. title: '区域名称',
  69. dataIndex: 'name',
  70. align: 'center',
  71. ellipsis: true
  72. },
  73. {
  74. title: '监控对象',
  75. dataIndex: 'targetName',
  76. align: 'center',
  77. ellipsis: true
  78. },
  79. {
  80. title: '监控设备',
  81. dataIndex: 'modelName',
  82. align: 'center',
  83. ellipsis: true
  84. },
  85. {
  86. title: '传感器编号',
  87. dataIndex: 'sensorCode',
  88. align: 'center',
  89. ellipsis: true
  90. },
  91. {
  92. title: '传感器类型',
  93. dataIndex: 'sensorType',
  94. align: 'center',
  95. ellipsis: true
  96. },
  97. {
  98. title: '传感器路数',
  99. dataIndex: 'sensorRoute',
  100. align: 'center',
  101. ellipsis: true
  102. },
  103. {
  104. title: '报警上限',
  105. dataIndex: 'limitUp',
  106. align: 'center',
  107. ellipsis: true
  108. },
  109. {
  110. title: '报警下限',
  111. dataIndex: 'limitDown',
  112. align: 'center',
  113. ellipsis: true
  114. },
  115. {
  116. title: '操作',
  117. dataIndex: 'action',
  118. align: 'center',
  119. width: 150
  120. }
  121. ]
  122. const loadData = () => {
  123. return locationApi.locationPage(Object.assign(searchFormState.value)).then((res) => {
  124. if (res) {
  125. return res
  126. }
  127. return []
  128. })
  129. }
  130. // 重置
  131. const reset = () => {
  132. searchFormRef.value.resetFields()
  133. tableRef.value.refresh(true)
  134. }
  135. // 删除
  136. const deleteData = (record) => {
  137. let params = [
  138. {
  139. id: record.id
  140. }
  141. ]
  142. locationApi.locationDelete(params).then(() => {
  143. tableRef.value.refresh(true)
  144. reset()
  145. })
  146. }
  147. </script>
  148. <style lang="less" scoped>
  149. .table_item {
  150. padding: 15px 20px;
  151. background-color: #ffffff;
  152. :deep(.ant-table-pagination-right) {
  153. justify-content: center !important;
  154. }
  155. }
  156. </style>