index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. <template v-if="column.dataIndex === 'status'">
  49. <span>
  50. <a-tag :color="record.status == '1' ? '#87d068' : '#cd201f'">
  51. {{ record.status == '1' ? '正常' : '闲置' }}
  52. </a-tag>
  53. </span>
  54. </template>
  55. <template v-if="column.dataIndex === 'action'">
  56. <!-- <a-button type="link" size="small" @click="formRef.onOpen(record)">编辑</a-button> -->
  57. <a-button type="link" size="small" @click="configformRef.onOpen(record)">配置</a-button>
  58. <a-popconfirm title="确定要删除吗?" @confirm="deleteData(record)">
  59. <a-button type="link" danger size="small">删除</a-button>
  60. </a-popconfirm>
  61. </template>
  62. </template>
  63. <!-- <template #expandedRowRender="{ record }">
  64. <a-tabs v-model:activeKey="record.activeKey" size="small" type="card">
  65. <a-tab-pane key="1" tab="基本信息">
  66. <div class="list">
  67. <a-descriptions bordered size="small">
  68. <a-descriptions-item label="设备名称" :span="2">{{ record.deviceName }}</a-descriptions-item>
  69. <a-descriptions-item label="设备编号" :span="2">{{ record.deviceCode }}</a-descriptions-item>
  70. <a-descriptions-item label="设备状态" :span="2">
  71. {{ $TOOL.dictTypeData('COIDCHAIN', record.modelName) }}</a-descriptions-item
  72. >
  73. <a-descriptions-item label="创建时间" :span="2">{{}}</a-descriptions-item>
  74. </a-descriptions>
  75. </div>
  76. </a-tab-pane>
  77. <a-tab-pane key="2" tab="1路">
  78. <div class="list">
  79. <a-descriptions bordered size="small">
  80. <a-descriptions-item label="传感器类型" :span="2">{{ '温度' }}</a-descriptions-item>
  81. <a-descriptions-item label="传感器路数" :span="2">{{ '1' }}</a-descriptions-item>
  82. </a-descriptions>
  83. </div>
  84. </a-tab-pane>
  85. </a-tabs>
  86. </template> -->
  87. </s-table>
  88. <Form ref="formRef" @successful="tableRef.refresh(true)" />
  89. <configForm ref="configformRef" @successful="tableRef.refresh(true)" />
  90. </div>
  91. </template>
  92. <script setup>
  93. import memApi from '@/api/basicset/memApi'
  94. import Form from './form.vue'
  95. import configForm from './configForm.vue'
  96. const formRef = ref()
  97. const configformRef = ref()
  98. const searchFormRef = ref()
  99. const searchFormState = ref({})
  100. const tableRef = ref()
  101. const columns = [
  102. {
  103. title: '设备名称',
  104. dataIndex: 'deviceName',
  105. align: 'center',
  106. ellipsis: true
  107. },
  108. {
  109. title: '设备编号',
  110. dataIndex: 'deviceCode',
  111. align: 'center',
  112. ellipsis: true
  113. },
  114. {
  115. title: '设备型号',
  116. dataIndex: 'typeName',
  117. align: 'center',
  118. ellipsis: true
  119. },
  120. {
  121. title: '最后心跳时间',
  122. dataIndex: 'lastHeartbeatTime',
  123. align: 'center',
  124. ellipsis: true
  125. },
  126. {
  127. title: '设备状态',
  128. dataIndex: 'status',
  129. align: 'center',
  130. ellipsis: true
  131. },
  132. {
  133. title: '传感器路数',
  134. dataIndex: 'sensorCount',
  135. align: 'center',
  136. ellipsis: true
  137. },
  138. {
  139. title: '最近登录时间',
  140. dataIndex: 'lastLoginTime',
  141. align: 'center',
  142. ellipsis: true
  143. },
  144. {
  145. title: '排序码',
  146. dataIndex: 'sortCode',
  147. align: 'center',
  148. ellipsis: true,
  149. sorter: true
  150. },
  151. {
  152. title: '操作',
  153. dataIndex: 'action',
  154. align: 'center',
  155. width: 150
  156. }
  157. ]
  158. const loadData = (parameter) => {
  159. return memApi.memPage(Object.assign(parameter, searchFormState.value)).then((res) => {
  160. return res
  161. })
  162. }
  163. // 重置
  164. const reset = () => {
  165. searchFormRef.value.resetFields()
  166. tableRef.value.refresh(true)
  167. }
  168. // 删除
  169. const deleteData = (record) => {
  170. let params = [
  171. {
  172. id: record.id
  173. }
  174. ]
  175. memApi.memDelete(params).then(() => {
  176. tableRef.value.refresh(true)
  177. reset()
  178. })
  179. }
  180. </script>
  181. <style lang="less" scoped>
  182. .table_item {
  183. padding: 15px 20px;
  184. background-color: #ffffff;
  185. :deep(.ant-table-pagination-right) {
  186. justify-content: center !important;
  187. }
  188. }
  189. .list {
  190. width: 60%;
  191. padding: 10px 20px;
  192. border-radius: 10px;
  193. background-color: #ffffff;
  194. :deep(.ant-descriptions) {
  195. margin-bottom: 10px;
  196. }
  197. :deep(.ant-descriptions-header) {
  198. margin: 0;
  199. padding: 10px;
  200. border: 1px solid #f0f0f0;
  201. border-bottom: none;
  202. }
  203. }
  204. </style>