subDevice.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <template>
  2. <div class="system-dic-container">
  3. <el-dialog title="子设备详情" v-model="isShowSubDeviceDialog" width="80%">
  4. <div class="content">
  5. <div class="cont_box">
  6. <div class="title">设备:{{ detail.name }}</div>
  7. <div class="pro-status"><span :class="developer_status == 2 ? 'on' : 'off'"></span>{{ developer_status == 2 ? '在线' : '离线' }}</div>
  8. <!-- <div class="pro-option" @click="CkOption">{{ developer_status == 2 ? '下线' : '上线' }}</div> -->
  9. </div>
  10. </div>
  11. <div class="content-box">
  12. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  13. <el-tab-pane label="运行状态" name="3">
  14. <div style="display: flex; padding: 10px; flex-wrap: wrap">
  15. <div class="ant-card">
  16. <div class="ant-card-body">
  17. <div class="cardflex">
  18. <div>设备状态</div>
  19. <div @click="getrunData()" style="cursor: pointer">
  20. <el-icon style="font-size: 18px">
  21. <ele-Refresh />
  22. </el-icon>
  23. </div>
  24. </div>
  25. <div class="statusname" v-if="areaData.status == 0">未启用</div>
  26. <div class="statusname" v-if="areaData.status == 1">离线</div>
  27. <div class="statusname" v-if="areaData.status == 2">在线</div>
  28. <div class="cardflex comtest">
  29. <div>数据时间</div>
  30. <div>{{ areaData.lastOnlineTime || '未启用' }}</div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="ant-card" v-for="(item, index) in areaData.properties" :key="index">
  35. <div class="ant-card-body">
  36. <div class="cardflex">
  37. <div>{{ item.name }}</div>
  38. <div style="cursor: pointer">
  39. <el-icon style="font-size: 18px" @click="getrunData()">
  40. <ele-Refresh />
  41. </el-icon>
  42. <el-icon style="font-size: 18px; margin-left: 10px" @click="onOpenListDetail(item)">
  43. <ele-Expand />
  44. </el-icon>
  45. </div>
  46. </div>
  47. <div class="statusname">{{ item.value }}{{ item.unit }}</div>
  48. <div class="">
  49. <devantd :json="item.list" :antdid="item.key" v-if="item.type == 'int' || item.type == 'float'" />
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </el-tab-pane>
  55. <el-tab-pane label="设备信息" name="1">
  56. <div class="pro-box">
  57. <div class="protitle">设备信息</div>
  58. <div>
  59. <el-button type="primary" v-auth="'edit'" @click="onOpenEditDic(detail)">编辑</el-button>
  60. </div>
  61. </div>
  62. <div class="ant-descriptions-view">
  63. <table>
  64. <tbody>
  65. <tr class="ant-descriptions-row">
  66. <th class="ant-descriptions-item-label ant-descriptions-item-colon">设备标识</th>
  67. <td class="ant-descriptions-item-content" colspan="1">{{ detail.key }}</td>
  68. <th class="ant-descriptions-item-label ant-descriptions-item-colon">设备名称</th>
  69. <td class="ant-descriptions-item-content" colspan="1">{{ detail.name }}</td>
  70. <th class="ant-descriptions-item-label ant-descriptions-item-colon">所属产品</th>
  71. <td class="ant-descriptions-item-content" colspan="1">{{ detail.productName }}</td>
  72. </tr>
  73. <tr class="ant-descriptions-row">
  74. <th class="ant-descriptions-item-label ant-descriptions-item-colon">消息协议</th>
  75. <td class="ant-descriptions-item-content" colspan="1">{{ prodetail.messageProtocol }}</td>
  76. <th class="ant-descriptions-item-label ant-descriptions-item-colon">链接协议</th>
  77. <td class="ant-descriptions-item-content" colspan="1">{{ prodetail.transportProtocol }}</td>
  78. <th class="ant-descriptions-item-label ant-descriptions-item-colon">设备类型</th>
  79. <td class="ant-descriptions-item-content" colspan="1">{{ prodetail.deviceType }}</td>
  80. </tr>
  81. <tr class="ant-descriptions-row">
  82. <th class="ant-descriptions-item-label ant-descriptions-item-colon">固件版本</th>
  83. <td class="ant-descriptions-item-content" colspan="1">{{ prodetail.version }}</td>
  84. <th class="ant-descriptions-item-label ant-descriptions-item-colon">注册时间</th>
  85. <td class="ant-descriptions-item-content" colspan="1">{{ detail.updatedAt }}</td>
  86. <th class="ant-descriptions-item-label ant-descriptions-item-colon">最后上线时间</th>
  87. <td class="ant-descriptions-item-content" colspan="1">{{ detail.lastOnlineTime || '' }}</td>
  88. </tr>
  89. <tr class="ant-descriptions-row">
  90. <th class="ant-descriptions-item-label ant-descriptions-item-colon">说明</th>
  91. <td class="ant-descriptions-item-content" colspan="5">{{ detail.desc }}</td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. </div>
  96. </el-tab-pane>
  97. <el-tab-pane label="物模型" name="2">
  98. <div class="wu-box">
  99. <el-tabs type="border-card" v-model="activetab" @tab-click="wuhandleClick">
  100. <el-tab-pane label="属性定义" name="attr">
  101. <div class="wu-title">
  102. <div class="title">属性定义</div>
  103. <div>
  104. <el-button type="primary" @click="onOpenEditAttr()">添加</el-button>
  105. </div>
  106. </div>
  107. <el-table style="width: 100%" :data="tableData.data" v-if="activetab == 'attr'">
  108. <el-table-column label="属性标识" align="center" prop="key" />
  109. <el-table-column label="属性名称" prop="name" show-overflow-tooltip />
  110. <el-table-column prop="valueType" label="数据类型" width="100" align="center">
  111. <template #default="scope">
  112. <span>{{ scope.row.valueType?.type }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column prop="decimals" label="精度" width="60" align="center">
  116. <template #default="scope">
  117. <span>{{ scope.row.valueType.decimals }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column prop="unit" label="单位" width="60" align="center">
  121. <template #default="scope">
  122. <span>{{ scope.row.valueType.unit }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column prop="accessMode" label="是否只读" width="120" align="center">
  126. <template #default="scope">
  127. <el-tag type="info" size="small" v-if="scope.row.accessMode">只读</el-tag>
  128. <el-tag type="success" size="small" v-else>读写</el-tag>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="说明" prop="desc" show-overflow-tooltip />
  132. <el-table-column label="操作" width="300" align="center" fixed="right">
  133. <template #default="scope">
  134. <el-button size="small" text type="warning" @click="onEditAttr(scope.row)">修改</el-button>
  135. <el-button size="small" text type="danger" @click="onRowDel(scope.row.key, 'attr')">删除</el-button>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </el-tab-pane>
  140. <el-tab-pane label="功能定义" name="fun">
  141. <div class="wu-title">
  142. <div class="title">功能定义</div>
  143. <div>
  144. <el-button type="primary" @click="onOpenEditFun()">添加</el-button>
  145. </div>
  146. </div>
  147. <el-table style="width: 100%" :data="tableData.data" v-if="activetab == 'fun'">
  148. <el-table-column label="功能标识" align="center" prop="key" />
  149. <el-table-column label="名称" prop="name" show-overflow-tooltip />
  150. <el-table-column label="描述" prop="desc" show-overflow-tooltip />
  151. <el-table-column label="操作" width="300" align="center" fixed="right">
  152. <template #default="scope">
  153. <el-button size="small" text type="warning" @click="onEditFun(scope.row)">修改</el-button>
  154. <el-button size="small" text type="danger" @click="onRowDel(scope.row.key, 'fun')">删除</el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. </el-tab-pane>
  159. <el-tab-pane label="事件定义" name="event">
  160. <div class="wu-title">
  161. <div class="title">事件定义</div>
  162. <div>
  163. <el-button type="primary" @click="onOpenEditEvent()">添加</el-button>
  164. </div>
  165. </div>
  166. <el-table style="width: 100%" :data="tableData.data" v-if="activetab == 'event'">
  167. <el-table-column label="事件标识" align="center" prop="key" />
  168. <el-table-column label="名称" prop="name" show-overflow-tooltip />
  169. <el-table-column prop="level" label="事件级别" width="120" align="center">
  170. <template #default="scope">
  171. <el-tag type="primary" size="small" v-if="scope.row.level == 0">普通</el-tag>
  172. <el-tag type="warning" size="small" v-if="scope.row.level == 1">警告</el-tag>
  173. <el-tag type="danger" size="small" v-if="scope.row.level == 2">紧急</el-tag>
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="描述" prop="desc" show-overflow-tooltip />
  177. <el-table-column label="操作" width="300" align="center" fixed="right">
  178. <template #default="scope">
  179. <el-button size="small" text type="warning" @click="onEditEvent(scope.row)">修改</el-button>
  180. <el-button size="small" text type="danger" @click="onRowDel(scope.row.key, 'event')">删除</el-button>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. </el-tab-pane>
  185. <el-tab-pane label="标签定义" name="tab">
  186. <div class="wu-title">
  187. <div class="title">标签定义</div>
  188. <div>
  189. <el-button type="primary" @click="onOpenEditTab()">添加</el-button>
  190. </div>
  191. </div>
  192. <el-table style="width: 100%" :data="tableData.data" v-if="activetab == 'tab'">
  193. <el-table-column label="属性标识" align="center" prop="key" />
  194. <el-table-column label="属性名称" prop="name" show-overflow-tooltip />
  195. <el-table-column prop="valueType" label="数据类型" width="120" align="center">
  196. <template #default="scope">
  197. <span>{{ scope.row.valueType.type }}</span>
  198. </template>
  199. </el-table-column>
  200. <el-table-column prop="accessMode" label="是否只读" width="120" align="center">
  201. <template #default="scope">
  202. <el-tag type="info" size="small" v-if="scope.row.accessMode">只读</el-tag>
  203. <el-tag type="success" size="small" v-else>读写</el-tag>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="描述" prop="desc" show-overflow-tooltip />
  207. <el-table-column label="操作" width="300" align="center" fixed="right">
  208. <template #default="scope">
  209. <el-button size="small" text type="warning" @click="onEditTag(scope.row)">修改</el-button>
  210. <el-button size="small" text type="danger" @click="onRowDel(scope.row.key, 'tab')">删除</el-button>
  211. </template>
  212. </el-table-column>
  213. </el-table>
  214. </el-tab-pane>
  215. </el-tabs>
  216. <pagination
  217. v-show="tableData.total > 0"
  218. :total="tableData.total"
  219. v-model:page="tableData.param.pageNum"
  220. v-model:limit="tableData.param.pageSize"
  221. @pagination="getList()"
  222. />
  223. </div>
  224. </el-tab-pane>
  225. <el-tab-pane label="设备功能" name="5">
  226. <functionCom :device-key="detail.key" :product-key="prodetail.key" v-if="detail.key && prodetail.key"></functionCom>
  227. </el-tab-pane>
  228. <el-tab-pane label="日志管理" name="4">
  229. <div class="system-user-search mb15">
  230. <el-form :model="logtableData.param" ref="queryRef" inline label-width="68px">
  231. <el-form-item label="日志类型" prop="types">
  232. <el-select v-model="logtableData.param.types" placeholder="日志类型" clearable>
  233. <el-option v-for="item in logTypeData" :key="item" :label="item" :value="item" />
  234. </el-select>
  235. </el-form-item>
  236. <el-form-item label="创建时间" prop="dateRange">
  237. <el-date-picker
  238. v-model="logtableData.param.dateRange"
  239. size="default"
  240. value-format="YYYY-MM-DD"
  241. type="daterange"
  242. range-separator="-"
  243. start-placeholder="开始日期"
  244. end-placeholder="结束日期"
  245. ></el-date-picker>
  246. </el-form-item>
  247. <el-form-item>
  248. <el-button type="primary" class="ml10" @click="getlog">
  249. <el-icon>
  250. <ele-Search />
  251. </el-icon>
  252. 查询
  253. </el-button>
  254. <el-button @click="resetQuery(queryRef)">
  255. <el-icon>
  256. <ele-Refresh />
  257. </el-icon>
  258. 重置
  259. </el-button>
  260. </el-form-item>
  261. </el-form>
  262. </div>
  263. <el-table style="width: 100%" :data="logtableData.data">
  264. <el-table-column label="类型" align="center" prop="type" />
  265. <el-table-column label="时间" prop="ts" show-overflow-tooltip />
  266. <el-table-column label="内容" prop="content" show-overflow-tooltip />
  267. <el-table-column label="操作" width="300" align="center" fixed="right">
  268. <template #default="scope">
  269. <el-button size="small" text type="warning" @click="onLogDetail(scope.row)">查看</el-button>
  270. </template>
  271. </el-table-column>
  272. </el-table>
  273. <pagination
  274. v-show="logtableData.total > 0"
  275. :total="logtableData.total"
  276. v-model:page="logtableData.param.pageNum"
  277. v-model:limit="logtableData.param.pageSize"
  278. @pagination="getlog"
  279. />
  280. </el-tab-pane>
  281. </el-tabs>
  282. </div>
  283. </el-dialog>
  284. <EditDic ref="editDicRef" @typeList="typeList" />
  285. <EditAttr ref="editAttrRef" @typeList="getproperty" />
  286. <EditFun ref="editFunRef" @typeList="getfunction" />
  287. <EditEvent ref="editEventRef" @typeList="getevent" />
  288. <EditTab ref="editTabRef" @typeList="gettab" />
  289. <ListDic ref="listDicRef" />
  290. <el-dialog v-model="dialogVisible" title="返回Json数据" width="30%">
  291. <JsonViewer :value="jsonData" boxed sort theme="jv-dark" @click="onKeyclick" />
  292. <template #footer>
  293. <span class="dialog-footer">
  294. <el-button @click="dialogVisible = false">关闭</el-button>
  295. </span>
  296. </template>
  297. </el-dialog>
  298. </div>
  299. </template>
  300. <script lang="ts">
  301. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue'
  302. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus'
  303. import functionCom from './function.vue'
  304. import 'vue3-json-viewer/dist/index.css'
  305. import EditDic from '../../product/component/editPro.vue'
  306. import EditAttr from '../../product/component/editAttr.vue'
  307. import EditFun from '../../product/component/editFun.vue'
  308. import EditEvent from '../../product/component/editEvent.vue'
  309. import EditTab from '../../product/component/editTab.vue'
  310. import devantd from '/@/components/devantd/index.vue'
  311. import ListDic from './list.vue'
  312. import { useRoute } from 'vue-router'
  313. import api from '/@/api/device'
  314. interface TableDataState {
  315. ids: number[]
  316. deviceIds: number[]
  317. detail: object[]
  318. isShowSubDeviceDialog: boolean
  319. deviceTableData: {
  320. data: []
  321. total: number
  322. loading: boolean
  323. param: {
  324. pageNum: number
  325. pageSize: number
  326. gatewayKey: string
  327. // status: string;
  328. dateRange: string[]
  329. }
  330. }
  331. tableData: {
  332. data: []
  333. total: number
  334. loading: boolean
  335. param: {
  336. pageNum: number
  337. pageSize: number
  338. name: string
  339. deviceType: string
  340. status: string
  341. dateRange: string[]
  342. }
  343. }
  344. logtableData: {
  345. data: []
  346. total: number
  347. loading: boolean
  348. param: {
  349. pageNum: number
  350. pageSize: number
  351. name: string
  352. deviceType: string
  353. status: string
  354. dateRange: string[]
  355. }
  356. }
  357. }
  358. export default defineComponent({
  359. name: 'deviceEditPro',
  360. components: { EditDic, EditAttr, EditFun, EditEvent, EditTab, devantd, ListDic, functionCom },
  361. setup(prop, context) {
  362. const route = useRoute()
  363. const editDicRef = ref()
  364. const editAttrRef = ref()
  365. const editFunRef = ref()
  366. const listDicRef = ref()
  367. const editEventRef = ref()
  368. const editTabRef = ref()
  369. const state = reactive<TableDataState>({
  370. deviceIds: [],
  371. areaData: [],
  372. isShowDialog: false,
  373. dialogVisible: false,
  374. isShowSubDeviceDialog: false,
  375. logTypeData: [],
  376. jsonData: '',
  377. activeName: '3', // 分类数据
  378. activetab: 'attr', // 分类数据
  379. detail: [],
  380. prodetail: [],
  381. product_id: 0,
  382. developer_status: 0,
  383. deviceTableData: {
  384. data: [],
  385. total: 0,
  386. loading: false,
  387. param: {
  388. pageNum: 1,
  389. gatewayKey: '',
  390. pageSize: 10,
  391. dateRange: [],
  392. },
  393. },
  394. tableData: {
  395. data: [],
  396. total: 0,
  397. loading: false,
  398. param: {
  399. pageNum: 1,
  400. productId: 0,
  401. pageSize: 10,
  402. status: '',
  403. dateRange: [],
  404. },
  405. },
  406. logtableData: {
  407. data: [],
  408. total: 0,
  409. loading: false,
  410. param: {
  411. pageNum: 1,
  412. productId: 0,
  413. pageSize: 10,
  414. status: '',
  415. dateRange: [],
  416. },
  417. },
  418. })
  419. const getDeviceTableData = () => {
  420. state.deviceTableData.param.gatewayKey = state.detail.key
  421. api.device.getList(state.deviceTableData.param).then((res: any) => {
  422. state.deviceTableData.data = res.list
  423. state.deviceTableData.total = res.Total
  424. })
  425. }
  426. // 多选框选中数据
  427. const handleSelectionChange = (selection: any[]) => {
  428. state.deviceIds = selection.map((item) => item.id)
  429. }
  430. // 打开弹窗
  431. const openDialog = (row: any | null) => {
  432. if (row) {
  433. const ids = row.id;
  434. api.instance.detail(ids).then((res: any) => {
  435. state.detail = res.data;
  436. state.developer_status = res.data.status;
  437. state.tableData.param.productId = res.data.product.id;
  438. state.product_id = res.data.product.id;
  439. getrunData();
  440. api.product.detail(res.data.product.id).then((productRes: any) => {
  441. state.prodetail = productRes.data;
  442. });
  443. //第一次加载
  444. api.model.property(state.tableData.param).then((modelRes: any) => {
  445. state.tableData.data = modelRes.Data;
  446. state.tableData.total = modelRes.Total;
  447. });
  448. getDeviceTableData()
  449. });
  450. }
  451. state.isShowSubDeviceDialog = true;
  452. }
  453. const onLogDetail = (row: TableDataRow) => {
  454. state.jsonData = JSON.parse(row.content)
  455. state.dialogVisible = true
  456. }
  457. //编辑属性
  458. const onEditAttr = (row: TableDataRow) => {
  459. editAttrRef.value.openDialog(row, state.product_id)
  460. }
  461. //编辑功能
  462. const onEditFun = (row: TableDataRow) => {
  463. editFunRef.value.openDialog(row, state.product_id)
  464. }
  465. //编辑事件
  466. const onEditEvent = (row: TableDataRow) => {
  467. editEventRef.value.openDialog(row, state.product_id)
  468. }
  469. //编辑标签
  470. const onEditTag = (row: TableDataRow) => {
  471. editTabRef.value.openDialog(row, state.product_id)
  472. }
  473. //打开添加属性弹窗
  474. const onOpenEditAttr = () => {
  475. editAttrRef.value.openDialog({ product_id: state.product_id, id: 0, accessMode: 0 })
  476. }
  477. //打开添加功能弹窗
  478. const onOpenEditFun = () => {
  479. editFunRef.value.openDialog({ product_id: state.product_id, id: 0 })
  480. }
  481. //打开添加事件弹窗
  482. const onOpenEditEvent = () => {
  483. editEventRef.value.openDialog({ product_id: state.product_id, id: 0, level: 0 })
  484. }
  485. //打开添加事件弹窗
  486. const onOpenEditTab = () => {
  487. editTabRef.value.openDialog({ product_id: state.product_id, id: 0, accessMode: 0 })
  488. }
  489. //查看日志列表
  490. const onOpenListDetail = (row: TableDataRow) => {
  491. listDicRef.value.openDialog(row, state.detail.id)
  492. }
  493. // 打开修改产品弹窗
  494. const onOpenEditDic = (row: TableDataRow) => {
  495. editDicRef.value.openDialog(row)
  496. }
  497. // 删除产品
  498. const onRowDel = (key, type) => {
  499. let msg = `此操作将永久删除该数据,是否继续?`
  500. if (key.length === 0) {
  501. ElMessage.error('请选择要删除的数据。')
  502. return
  503. }
  504. ElMessageBox.confirm(msg, '提示', {
  505. confirmButtonText: '确认',
  506. cancelButtonText: '取消',
  507. type: 'warning',
  508. })
  509. .then(() => {
  510. if (type == 'attr') {
  511. api.model.propertydel(state.product_id, key).then(() => {
  512. ElMessage.success('删除成功')
  513. getproperty()
  514. })
  515. }
  516. if (type == 'fun') {
  517. api.model.functiondel(state.product_id, key).then(() => {
  518. ElMessage.success('删除成功')
  519. getfunction()
  520. })
  521. }
  522. if (type == 'event') {
  523. api.model.eventdel(state.product_id, key).then(() => {
  524. ElMessage.success('删除成功')
  525. getevent()
  526. })
  527. }
  528. if (type == 'tab') {
  529. api.model.tagdel(state.product_id, key).then(() => {
  530. ElMessage.success('删除成功')
  531. tagdel()
  532. })
  533. }
  534. })
  535. .catch(() => {})
  536. }
  537. //根据不同类型获取列表
  538. const getList = () => {
  539. switch (state.activetab) {
  540. case 'attr':
  541. getproperty()
  542. break
  543. case 'fun':
  544. getfunction()
  545. break
  546. case 'event':
  547. getevent()
  548. break
  549. case 'tab':
  550. gettab()
  551. break
  552. }
  553. }
  554. const getproperty = () => {
  555. api.model.property(state.tableData.param).then((res: any) => {
  556. state.tableData.data = res.Data
  557. state.tableData.total = res.Total
  558. })
  559. }
  560. const getfunction = () => {
  561. api.model.function(state.tableData.param).then((res: any) => {
  562. state.tableData.data = res.Data
  563. state.tableData.total = res.Total
  564. })
  565. }
  566. const getevent = () => {
  567. api.model.event(state.tableData.param).then((res: any) => {
  568. state.tableData.data = res.Data
  569. state.tableData.total = res.Total
  570. })
  571. }
  572. const gettab = () => {
  573. api.model.tag(state.tableData.param).then((res: any) => {
  574. state.tableData.data = res.Data
  575. state.tableData.total = res.Total
  576. })
  577. }
  578. const wuhandleClick = (tab: TabsPaneContext) => {
  579. state.activetab = tab.props.name
  580. switch (tab.props.name) {
  581. case 'attr':
  582. getproperty()
  583. break
  584. case 'fun':
  585. getfunction()
  586. break
  587. case 'event':
  588. getevent()
  589. break
  590. case 'tab':
  591. gettab()
  592. break
  593. }
  594. }
  595. const handleClick = (tab: TabsPaneContext, event: Event) => {
  596. if (tab.props.name == 4) {
  597. //获取日志
  598. getlog()
  599. getlogtype()
  600. } else if (tab.props.name == 2) {
  601. getList()
  602. } else if (tab.props.name == 3) {
  603. getrunData()
  604. }
  605. }
  606. const getrunData = () => {
  607. api.instance.getrun_status({ id: state.detail.id }).then((res: any) => {
  608. state.areaData = res
  609. let properties = state.areaData.properties || []
  610. var temp = new Array()
  611. properties.forEach(function (item, index) {
  612. let datalist = item.list || []
  613. temp[index] = []
  614. var temps = new Array()
  615. datalist.forEach(function (a, b) {
  616. if (b < 15) {
  617. temps.push(a)
  618. }
  619. })
  620. temp[index]['name'] = item.name
  621. temp[index]['key'] = item.key
  622. temp[index]['type'] = item.type
  623. temp[index]['unit'] = item.unit
  624. temp[index]['value'] = item.value
  625. temp[index]['list'] = temps
  626. })
  627. state.areaData.properties = temp
  628. })
  629. }
  630. const getlogtype = () => {
  631. api.instance.getlogcate({}).then((res: any) => {
  632. state.logTypeData = res.list
  633. })
  634. }
  635. const getlog = () => {
  636. state.logtableData.param.deviceKey = state.detail.key
  637. api.instance.getLogList(state.logtableData.param).then((res: any) => {
  638. state.logtableData.data = res.list
  639. state.logtableData.total = res.Total
  640. })
  641. }
  642. const CkOption = () => {
  643. if (state.developer_status == 2) {
  644. api.instance.devoffline({ id: state.detail.id }).then((res: any) => {
  645. ElMessage.success('操作成功')
  646. state.developer_status = 1
  647. })
  648. } else {
  649. api.instance.devonline({ id: state.detail.id }).then((res: any) => {
  650. ElMessage.success('操作成功')
  651. state.developer_status = 2
  652. })
  653. }
  654. }
  655. const tinyAreas = () => {
  656. var data = state.data
  657. const tinyArea = new TinyArea('container', {
  658. height: 60,
  659. autoFit: false,
  660. data,
  661. smooth: true,
  662. areaStyle: {
  663. fill: '#d6e3fd',
  664. },
  665. })
  666. tinyArea.render()
  667. }
  668. return {
  669. tinyAreas,
  670. editDicRef,
  671. editAttrRef,
  672. listDicRef,
  673. editFunRef,
  674. editEventRef,
  675. editTabRef,
  676. onOpenListDetail,
  677. getrunData,
  678. getlog,
  679. getlogtype,
  680. onLogDetail,
  681. CkOption,
  682. onRowDel,
  683. onEditFun,
  684. onEditEvent,
  685. onEditTag,
  686. onEditAttr,
  687. getList,
  688. getproperty,
  689. getDeviceTableData,
  690. handleSelectionChange,
  691. getfunction,
  692. getevent,
  693. gettab,
  694. wuhandleClick,
  695. openDialog,
  696. onOpenEditTab,
  697. onOpenEditEvent,
  698. onOpenEditAttr,
  699. onOpenEditFun,
  700. onOpenEditDic,
  701. handleClick,
  702. ...toRefs(state),
  703. }
  704. },
  705. })
  706. </script>
  707. <style>
  708. .content {
  709. background: #fff;
  710. width: 100%;
  711. padding: 20px;
  712. }
  713. .content-box {
  714. background: #fff;
  715. width: 100%;
  716. padding: 20px;
  717. margin-top: 20px;
  718. }
  719. .cont_box {
  720. display: flex;
  721. }
  722. .cont_box .title {
  723. font-size: 24px;
  724. }
  725. .cont_box .pro-status {
  726. line-height: 40px;
  727. margin-left: 30px;
  728. }
  729. .cont_box .pro-status .on {
  730. background: #52c41a;
  731. }
  732. .cont_box .pro-status .off {
  733. background: #c41a1a;
  734. }
  735. .cont_box .pro-status span {
  736. position: relative;
  737. top: -1px;
  738. display: inline-block;
  739. width: 6px;
  740. height: 6px;
  741. vertical-align: middle;
  742. border-radius: 50%;
  743. margin-right: 5px;
  744. }
  745. .cont_box .pro-option {
  746. line-height: 40px;
  747. margin-left: 10px;
  748. color: #1890ff;
  749. cursor: pointer;
  750. }
  751. .content-box .pro-box {
  752. display: flex;
  753. padding: 10px;
  754. justify-content: space-between;
  755. }
  756. .content-box .pro-box .protitle {
  757. font-size: 18px;
  758. font-weight: bold;
  759. line-height: 35px;
  760. }
  761. .content-box .pro-box .buttonedit {
  762. border: 0px;
  763. color: #1890ff;
  764. }
  765. table {
  766. border-collapse: collapse;
  767. text-indent: initial;
  768. border-spacing: 2px;
  769. }
  770. tbody {
  771. box-sizing: border-box;
  772. display: table-row-group;
  773. vertical-align: middle;
  774. border-color: inherit;
  775. }
  776. tr {
  777. display: table-row;
  778. vertical-align: inherit;
  779. border-color: inherit;
  780. }
  781. .ant-descriptions-view {
  782. width: 100%;
  783. overflow: hidden;
  784. border-radius: 4px;
  785. }
  786. .ant-descriptions-view {
  787. border: 1px solid #e8e8e8;
  788. }
  789. .ant-descriptions-view table {
  790. width: 100%;
  791. table-layout: fixed;
  792. }
  793. .ant-descriptions-view > table {
  794. table-layout: auto;
  795. }
  796. .ant-descriptions-row {
  797. border-bottom: 1px solid #e8e8e8;
  798. }
  799. .ant-descriptions-item-label {
  800. color: rgba(0, 0, 0, 0.85);
  801. font-weight: 400;
  802. font-size: 14px;
  803. line-height: 1.5;
  804. }
  805. .ant-descriptions-item-label {
  806. padding: 16px 24px;
  807. border-right: 1px solid #e8e8e8;
  808. }
  809. .ant-descriptions-item-label {
  810. background-color: #fafafa;
  811. }
  812. .ant-descriptions-item-content {
  813. padding: 16px 24px;
  814. border-right: 1px solid #e8e8e8;
  815. display: table-cell;
  816. color: rgba(0, 0, 0, 0.65);
  817. font-size: 14px;
  818. line-height: 1.5;
  819. }
  820. .wu-box {
  821. border: #e8e8e8 solid 1px;
  822. padding: 20px;
  823. width: 100%;
  824. }
  825. .wu-box .wu-title {
  826. display: flex;
  827. flex-direction: row;
  828. justify-content: space-between;
  829. padding: 20px;
  830. border-bottom: #e8e8e8 1px solid;
  831. }
  832. .wu-box .wu-title .title {
  833. font-size: 18px;
  834. }
  835. .ant-card {
  836. box-sizing: border-box;
  837. margin: 10px;
  838. width: 23.2%;
  839. font-size: 14px;
  840. font-variant: tabular-nums;
  841. border: 1px solid var(--next-border-color-light);
  842. line-height: 1.5;
  843. list-style: none;
  844. font-feature-settings: 'tnum';
  845. position: relative;
  846. border-radius: 2px;
  847. transition: all 0.3s;
  848. }
  849. .ant-card-body {
  850. padding: 24px;
  851. zoom: 1;
  852. }
  853. .cardflex {
  854. display: flex;
  855. justify-content: space-between;
  856. }
  857. .statusname {
  858. font-size: 30px;
  859. margin-top: 10px;
  860. margin-bottom: 15px;
  861. }
  862. .comtest {
  863. margin-top: 20px;
  864. height: 30px;
  865. line-height: 30px;
  866. }
  867. </style>