index.vue 5.0 KB

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