index.vue 3.8 KB

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