detail.vue 25 KB

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