index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. <a-button type="link" size="small" @click="leaveFor('/biz/monitor/trendchart', record)">详情</a-button>
  65. </template>
  66. </template>
  67. </s-table>
  68. <Form ref="formRef" @successful="tableRef.refresh(true)" />
  69. </div>
  70. </template>
  71. <script setup>
  72. import locationApi from '@/api/basicset/locationApi.js'
  73. import { useRoute } from 'vue-router'
  74. import router from '@/router'
  75. import Form from './form.vue'
  76. const formRef = ref()
  77. const searchFormRef = ref()
  78. const searchFormState = ref({})
  79. const tableRef = ref()
  80. const Route = useRoute()
  81. const columns = [
  82. {
  83. title: '序号',
  84. dataIndex: 'index',
  85. align: 'center',
  86. width: 50
  87. },
  88. {
  89. title: '点位名称',
  90. dataIndex: 'name',
  91. align: 'center',
  92. ellipsis: true,
  93. resizable: true
  94. },
  95. {
  96. title: '监测冰箱',
  97. dataIndex: 'targetName',
  98. align: 'center',
  99. ellipsis: true,
  100. resizable: true
  101. },
  102. {
  103. title: '冷链设备名称',
  104. dataIndex: 'deviceName',
  105. align: 'center',
  106. ellipsis: true,
  107. resizable: true
  108. },
  109. {
  110. title: '冷链设备编号',
  111. dataIndex: 'sensorCode',
  112. align: 'center',
  113. ellipsis: true,
  114. resizable: true
  115. },
  116. {
  117. title: '传感器类型',
  118. dataIndex: 'sensorType',
  119. align: 'center',
  120. ellipsis: true,
  121. resizable: true
  122. },
  123. {
  124. title: '传感器路数',
  125. dataIndex: 'sensorRoute',
  126. align: 'center',
  127. ellipsis: true,
  128. resizable: true
  129. },
  130. {
  131. title: '离线预警',
  132. dataIndex: 'deviceOfflineAlarm',
  133. align: 'center',
  134. ellipsis: true,
  135. resizable: true,
  136. customRender({ value }) {
  137. return value ? '是' : '否'
  138. }
  139. },
  140. {
  141. title: '创建时间',
  142. dataIndex: 'createTime',
  143. align: 'center',
  144. ellipsis: true,
  145. resizable: true
  146. },
  147. {
  148. title: '操作',
  149. dataIndex: 'action',
  150. align: 'center',
  151. width: 150
  152. }
  153. ]
  154. // 可伸缩列
  155. const handleResizeColumn = (w, col) => {
  156. col.width = w
  157. }
  158. const queryId = ref() //监控对象冰箱的id
  159. onBeforeMount(() => {
  160. if (Route.query.id) {
  161. queryId.value = Route.query.id
  162. }
  163. })
  164. // 返回上一页
  165. const goBack = () => {
  166. router.go(-1)
  167. }
  168. const loadData = (parameter) => {
  169. if (queryId.value) {
  170. parameter.monitorTargetId = queryId.value
  171. return locationApi.locationPage(Object.assign(parameter, searchFormState.value)).then((res) => {
  172. return res
  173. })
  174. }
  175. }
  176. // 重置
  177. const reset = () => {
  178. searchFormRef.value.resetFields()
  179. tableRef.value.refresh(true)
  180. }
  181. // 删除
  182. const deleteData = (record) => {
  183. let params = [
  184. {
  185. id: record.id
  186. }
  187. ]
  188. locationApi.locationDelete(params).then(() => {
  189. tableRef.value.refresh(true)
  190. reset()
  191. })
  192. }
  193. // 跳转到趋势图界面
  194. const leaveFor = (url, record) => {
  195. router.push({
  196. path: url,
  197. query: {
  198. id: record.monitorDeviceId,
  199. roads: record.sensorRoute
  200. }
  201. })
  202. }
  203. </script>
  204. <style lang="less" scoped>
  205. .table_item {
  206. padding: 15px 20px;
  207. background-color: #ffffff;
  208. :deep(.ant-table-pagination-right) {
  209. justify-content: center !important;
  210. }
  211. :deep .ant-page-header-back {
  212. margin-right: 8px;
  213. }
  214. }
  215. </style>