index.vue 4.3 KB

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