index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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="deviceName">
  19. <a-input v-model:value="searchFormState.deviceName" placeholder="请输入设备名称" /> </a-form-item
  20. ></a-col>
  21. <a-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
  22. <a-form-item label="设备编号" name="deviceCode">
  23. <a-input v-model:value="searchFormState.deviceCode" placeholder="请输入设备编号" /> </a-form-item
  24. ></a-col>
  25. </a-form>
  26. </a-row>
  27. </div>
  28. <div class="table-search-buttons">
  29. <a-button type="primary" @click="tableRef.refresh(true)">查询</a-button>
  30. <a-button class="xn-mg08" @click="reset">重置</a-button>
  31. </div>
  32. </div>
  33. <!-- 其他操作区域 -->
  34. <div class="table-head-btn">
  35. <div class="btn-left">
  36. <a-button type="primary" @click="formRef.onOpen()">
  37. <template #icon><plus-outlined /></template>新增
  38. </a-button>
  39. </div>
  40. <div class="btn-right">
  41. <a-button>
  42. <template #icon><download-outlined /></template>导出
  43. </a-button>
  44. </div>
  45. </div>
  46. </template>
  47. <template #bodyCell="{ column, record }">
  48. <!-- -->
  49. <template v-if="column.dataIndex === 'modelName'">
  50. {{ $TOOL.dictTypeData('COIDCHAIN', record.modelName) }}
  51. </template>
  52. <template v-if="column.dataIndex === 'status'">
  53. <span>
  54. <a-tag :color="record.status == '1' ? '#87d068' : '#cd201f'">
  55. {{ record.status == '1' ? '正常' : '闲置' }}
  56. </a-tag>
  57. </span>
  58. </template>
  59. <template v-if="column.dataIndex === 'action'">
  60. <a-button type="link" size="small" @click="configformRef.onOpen(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">记录</a-button>
  65. </template>
  66. </template>
  67. <template #expandedRowRender="{ record }">
  68. <a-tabs v-model:activeKey="record.activeKey" size="small" type="card">
  69. <a-tab-pane key="1" tab="基本信息">
  70. <div class="list">
  71. <a-descriptions bordered size="small">
  72. <a-descriptions-item label="设备名称" :span="2">{{ record.deviceName }}</a-descriptions-item>
  73. <a-descriptions-item label="设备编号" :span="2">{{ record.deviceCode }}</a-descriptions-item>
  74. <a-descriptions-item label="设备状态" :span="2">
  75. {{ $TOOL.dictTypeData('COIDCHAIN', record.modelName) }}</a-descriptions-item
  76. >
  77. <a-descriptions-item label="创建时间" :span="2">{{}}</a-descriptions-item>
  78. </a-descriptions>
  79. </div>
  80. </a-tab-pane>
  81. <a-tab-pane key="2" tab="1路">
  82. <div class="list">
  83. <a-descriptions bordered size="small">
  84. <a-descriptions-item label="传感器类型" :span="2">{{ '温度' }}</a-descriptions-item>
  85. <a-descriptions-item label="传感器路数" :span="2">{{ '1' }}</a-descriptions-item>
  86. </a-descriptions>
  87. </div>
  88. </a-tab-pane>
  89. </a-tabs>
  90. </template>
  91. </s-table>
  92. <Form ref="formRef" @successful="tableRef.refresh(true)" />
  93. <configForm ref="configformRef" @successful="tableRef.refresh(true)" />
  94. </div>
  95. </template>
  96. <script setup>
  97. import memApi from '@/api/basicset/memApi'
  98. import Form from './form.vue'
  99. import configForm from './configForm.vue'
  100. const formRef = ref()
  101. const configformRef = ref()
  102. const searchFormRef = ref()
  103. const searchFormState = ref({})
  104. const tableRef = ref()
  105. const columns = [
  106. {
  107. title: '设备名称',
  108. dataIndex: 'deviceName',
  109. align: 'center',
  110. ellipsis: true
  111. },
  112. {
  113. title: '设备编号',
  114. dataIndex: 'deviceCode',
  115. align: 'center',
  116. ellipsis: true
  117. },
  118. {
  119. title: '设备型号',
  120. dataIndex: 'modelName',
  121. align: 'center',
  122. ellipsis: true
  123. },
  124. {
  125. title: '最后心跳时间',
  126. dataIndex: 'lastHeartbeatTime',
  127. align: 'center',
  128. ellipsis: true
  129. },
  130. {
  131. title: '设备状态',
  132. dataIndex: 'status',
  133. align: 'center',
  134. ellipsis: true
  135. },
  136. {
  137. title: '传感器路数',
  138. dataIndex: 'sensorCount',
  139. align: 'center',
  140. ellipsis: true
  141. },
  142. {
  143. title: '最近登录时间',
  144. dataIndex: 'lastLoginTime',
  145. align: 'center',
  146. ellipsis: true
  147. },
  148. {
  149. title: '排序码',
  150. dataIndex: 'sortCode',
  151. align: 'center',
  152. ellipsis: true,
  153. sorter: true
  154. },
  155. {
  156. title: '操作',
  157. dataIndex: 'action',
  158. align: 'center',
  159. width: 150
  160. }
  161. ]
  162. const loadData = (parameter) => {
  163. return memApi.memPage(Object.assign(parameter, searchFormState.value)).then((res) => {
  164. return res
  165. })
  166. }
  167. // 重置
  168. const reset = () => {
  169. searchFormRef.value.resetFields()
  170. tableRef.value.refresh(true)
  171. }
  172. // 删除
  173. const deleteData = (record) => {
  174. let params = [
  175. {
  176. id: record.id
  177. }
  178. ]
  179. memApi.memDelete(params).then(() => {
  180. tableRef.value.refresh(true)
  181. reset()
  182. })
  183. }
  184. </script>
  185. <style lang="less" scoped>
  186. .table_item {
  187. padding: 15px 20px;
  188. background-color: #ffffff;
  189. :deep(.ant-table-pagination-right) {
  190. justify-content: center !important;
  191. }
  192. }
  193. .list {
  194. width: 60%;
  195. padding: 10px 20px;
  196. border-radius: 10px;
  197. background-color: #ffffff;
  198. :deep(.ant-descriptions) {
  199. margin-bottom: 10px;
  200. }
  201. :deep(.ant-descriptions-header) {
  202. margin: 0;
  203. padding: 10px;
  204. border: 1px solid #f0f0f0;
  205. border-bottom: none;
  206. }
  207. }
  208. </style>