index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div class="app-container" >
  3. <el-row :gutter="20">
  4. <el-col :span="4" :xs="24" >
  5. <div class="head-container" >
  6. <el-input
  7. v-model="areaName"
  8. placeholder="请输入区域名称"
  9. clearable
  10. size="small"
  11. prefix-icon="el-icon-search"
  12. style="margin-bottom: 20px"
  13. />
  14. </div>
  15. <div class="head-container" style="height: 100vh; overflow: hidden; position: relative;">
  16. <el-tree
  17. :data="areaOptions"
  18. :props="defaultProps"
  19. :expand-on-click-node="false"
  20. :filter-node-method="filterNode"
  21. ref="tree"
  22. node-key="id"
  23. default-expand-all
  24. highlight-current
  25. @node-click="handleNodeClick"
  26. style="height: calc(100vh - 50px); overflow-y: auto;"
  27. />
  28. </div>
  29. </el-col>
  30. <el-col :span="20" :xs="24">
  31. <el-tabs v-model="queryParams.deviceCategory" @tab-click="deviceCategoryChange">
  32. <el-tab-pane label="产能设备" name="E"></el-tab-pane>
  33. <el-tab-pane label="储能设备" name="C"></el-tab-pane>
  34. <el-tab-pane label="输能设备" name="W"></el-tab-pane>
  35. <el-tab-pane label="用能设备" name="Z"></el-tab-pane>
  36. </el-tabs>
  37. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  38. <el-form-item label="设备分类" prop="deviceSubCategory">
  39. <el-select v-model="queryParams.deviceSubCategory" >
  40. <el-option v-for="item in subCategoryOptions" placeholder="设备分类" :label="item.name" :value="item.code"
  41. :key="item.code" />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="归属设施" prop="refFacs">
  45. <el-select v-model="queryParams.refFacs">
  46. <el-option v-for="item in facsOptions" :label="item.facsName" :value="item.facsCode"
  47. :key="item.facsCode" />
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item label="子系统" prop="subsystemCode">
  51. <el-select v-model="queryParams.subsystemCode">
  52. <el-option v-for="item in subsystemOptions" :label="item.systemName" :value="item.systemCode"
  53. :key="item.systemCode" />
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  58. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  59. </el-form-item>
  60. </el-form>
  61. <el-table v-loading="loading" :data="deviceList" >
  62. <el-table-column label="设备名称" align="left" prop="deviceName"/>
  63. <el-table-column label="归属区域" align="left" prop="areaPath" width="280px"/>
  64. <el-table-column label="归属设施" align="center" prop="refFacsName"/>
  65. <el-table-column label="设备类型" align="center" prop="deviceTypeName"/>
  66. <el-table-column label="子系统" align="center" prop="subsystemName"/>
  67. <!-- <el-table-column label="设备状态" align="center" prop="deviceStatus">-->
  68. <!-- <template slot-scope="scope">-->
  69. <!-- <dict-tag :options="dict.type.sys_device_stat" :value="scope.row.deviceStatus"/>-->
  70. <!-- </template>-->
  71. <!-- </el-table-column>-->
  72. <el-table-column label="设备状态" align="center" prop="deviceStatus">
  73. <template slot-scope="scope">
  74. <span
  75. :style="{
  76. padding: '6px 12px',
  77. borderRadius: '4px',
  78. display: 'inline-block',
  79. textAlign: 'center',
  80. cursor: 'pointer',
  81. color: getDeviceStatusTextColor(scope.row.deviceStatus),
  82. backgroundColor: getDeviceStatusBgColor(scope.row.deviceStatus),
  83. minWidth: '70px',
  84. height: '35px',
  85. textAlign: 'center'
  86. }"
  87. >
  88. {{ getDeviceStatusText(scope.row.deviceStatus) }}
  89. </span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  93. <template slot-scope="scope">
  94. <el-button size="mini" type="text" @click="handleDetail(scope.row)">详情</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 设备基本信息 -->
  106. <!-- 详情弹框 -->
  107. <el-dialog :visible.sync="open" title="设备状态详情" custom-class="detail-dialog">
  108. <div v-if="curRow">
  109. <!-- 设施基本信息 -->
  110. <el-card class="box-card">
  111. <div slot="header" class="clearfix">
  112. <span class="section-title">设备状态基本信息</span>
  113. </div>
  114. <div>
  115. <p><span class="bold">设备名称:</span>{{ curRow.deviceName }}</p>
  116. <p><span class="bold">设备代码:</span>{{ curRow.deviceCode }}</p>
  117. <p><span class="bold">归属设施:</span>{{ curRow.refFacs }}</p>
  118. <p><span class="bold">归属区域:</span>{{ curRow.refArea }}</p>
  119. <p><span class="bold">子系统:</span>{{ curRow.subsystemName }}</p>
  120. <p><span class="bold">设备状态:</span>{{ curRow.deviceStatus }}</p>
  121. </div>
  122. </el-card>
  123. <!-- 属性信息 -->
  124. <el-card class="box-card" v-if="attrData.length > 0">
  125. <div slot="header" class="clearfix">
  126. <span class="section-title">属性定义</span>
  127. </div>
  128. <div v-for="(item, index) in attrData" :key="index">
  129. <p><span class="bold">属性名称:</span>{{ item.attrName }}</p>
  130. <p><span class="bold">属性标识:</span>{{ item.attrKey }}</p>
  131. <p><span class="bold">属性值:</span>{{ item.attrValue }}</p>
  132. <p><span class="bold">属性单位:</span>{{ item.attrUnit }}</p>
  133. <!-- 在每个条目之后添加横线,除了最后一个条目 -->
  134. <div v-if="index < attrData.length - 1" class="divider"></div>
  135. </div>
  136. </el-card>
  137. <el-card class="box-card" v-else>
  138. <div slot="header" class="clearfix">
  139. <span class="section-title">属性定义</span>
  140. </div>
  141. <div>
  142. <p><span class="bold">属性名称:</span>暂无数据</p>
  143. <p><span class="bold">属性标识:</span>暂无数据</p>
  144. <p><span class="bold">属性值:</span>暂无数据</p>
  145. <p><span class="bold">属性单位:</span>暂无数据</p>
  146. </div>
  147. </el-card>
  148. <!-- 能力信息 -->
  149. <el-card class="box-card" v-if="abilityData.length > 0">
  150. <div slot="header" class="clearfix">
  151. <span class="section-title">能力定义</span>
  152. </div>
  153. <div v-for="(item, index) in abilityData" :key="index">
  154. <p><span class="bold">能力名称:</span>{{ item.abilityName }}</p>
  155. <p><span class="bold">能力键:</span>{{ item.abilityKey }}</p>
  156. <p><span class="bold">能力参数:</span>{{ item.abilityParam }}</p>
  157. <p><span class="bold">能力描述:</span>{{ item.abilityDesc }}</p>
  158. <!-- 在每个条目之后添加横线,除了最后一个条目 -->
  159. <div v-if="index < abilityData.length - 1" class="divider"></div>
  160. </div>
  161. </el-card>
  162. <el-card class="box-card" v-else>
  163. <div slot="header" class="clearfix">
  164. <span class="section-title">能力定义</span>
  165. </div>
  166. <div>
  167. <p><span class="bold">能力名称:</span>暂无数据</p>
  168. <p><span class="bold">能力键:</span>暂无数据</p>
  169. <p><span class="bold">能力参数:</span>暂无数据</p>
  170. <p><span class="bold">能力描述:</span>暂无数据</p>
  171. </div>
  172. </el-card>
  173. <!-- 事件信息 -->
  174. <el-card class="box-card" v-if="eventData.length > 0">
  175. <div slot="header" class="clearfix">
  176. <span class="section-title">事件定义</span>
  177. </div>
  178. <div v-for="(item, index) in eventData" :key="index">
  179. <p><span class="bold">事件名称:</span>{{ item.eventKey }}</p>
  180. <p><span class="bold">事件类型:</span>{{ item.eventType === 1 ? '消息上报' : '异常告警' }}</p>
  181. <p><span class="bold">事件代码:</span>{{ item.eventCode }}</p>
  182. <p><span class="bold">外部事件代码:</span>{{ item.extEventCode }}</p>
  183. <!-- 在每个条目之后添加横线,除了最后一个条目 -->
  184. <div v-if="index < eventData.length - 1" class="divider"></div>
  185. </div>
  186. </el-card>
  187. <el-card class="box-card" v-else>
  188. <div slot="header" class="clearfix">
  189. <span class="section-title">事件定义</span>
  190. </div>
  191. <div>
  192. <p><span class="bold">事件名称:</span>暂无数据</p>
  193. <p><span class="bold">事件类型:</span>暂无数据</p>
  194. <p><span class="bold">事件代码:</span>暂无数据</p>
  195. <p><span class="bold">外部事件代码:</span>暂无数据</p>
  196. </div>
  197. </el-card>
  198. </div>
  199. </el-dialog>
  200. </el-col>
  201. </el-row>
  202. </div>
  203. </template>
  204. <script>
  205. import { listDevRecursionByArea, getDevice, delDevice, addDevice, updateDevice } from '@/api/device/device'
  206. import { areaTreeSelect } from "@/api/basecfg/area"
  207. import { getFacsCategorygetByCode, listAllFacs } from '@/api/basecfg/emsfacs'
  208. import { getDevcType} from '@/api/commonApi'
  209. import { listSubsystemAll } from '@/api/adapter/subsystem'
  210. import Treeselect from "@riophae/vue-treeselect";
  211. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  212. import { getBuilding } from '@/api/basecfg/building'
  213. import {getModelByCode} from "@/api/basecfg/objModel";
  214. export default {
  215. name: 'Device',
  216. dicts: ['sys_device_stat'],
  217. components: { Treeselect },
  218. data() {
  219. return {
  220. // 遮罩层
  221. loading: true,
  222. // 选中数组
  223. ids: [],
  224. // 非单个禁用
  225. single: true,
  226. // 非多个禁用
  227. multiple: true,
  228. // 显示搜索条件
  229. showSearch: true,
  230. // 总条数
  231. total: 0,
  232. // 能源设备表格数据
  233. deviceList: [],
  234. // 弹出层标题
  235. title: '',
  236. // 是否显示弹出层
  237. open: false,
  238. // 区域名称
  239. areaName: undefined,
  240. // 区域树选项
  241. areaOptions: undefined,
  242. // 设施选项
  243. facsOptions: undefined,
  244. // 设备分类
  245. devcTypeOptions: undefined,
  246. subsystemOptions: undefined,
  247. defaultProps: {
  248. children: "children",
  249. label: "label"
  250. },
  251. curRow: {},
  252. attrData: [],
  253. abilityData: [],
  254. eventData: [],
  255. // 查询参数
  256. queryParams: {
  257. pageNum: 1,
  258. pageSize: 10,
  259. deviceCode: null,
  260. deviceName: null,
  261. deviceSubCategory: null,
  262. deviceCategory: 'E',
  263. deviceStatus: null,
  264. areaType: null,
  265. refArea: null,
  266. refFacs: null,
  267. subsystemCode: null
  268. },
  269. // 表单参数
  270. form: {}
  271. }
  272. },
  273. created() {
  274. this.getList();
  275. this.getAreaTree('Area');
  276. this.getFacsOptions("");
  277. this.getSubsystem();
  278. },
  279. methods: {
  280. getDeviceStatusText(status) {
  281. const statusMap = {
  282. 0: '运行',
  283. 1: '故障',
  284. 2: '未运行'
  285. };
  286. return statusMap[status] || '';
  287. },
  288. getDeviceStatusTextColor(status) {
  289. if (status === 0) return 'rgb(232,244,255)';
  290. if (status === 1) return '#FFFFFF';
  291. if (status === 2) return 'rgb(255,235,235)';
  292. return '#000000'; // 默认黑色文字
  293. },
  294. getDeviceStatusBgColor(status) {
  295. if (status === 0) return 'rgb(117,186,255)';
  296. if (status === 1) return 'rgb(242,197,92)';
  297. if (status === 2) return 'rgb(255,159,159)';
  298. return 'transparent'; // 默认无背景色
  299. },
  300. /** 查询能源设备列表 */
  301. getList() {
  302. this.loading = true
  303. listDevRecursionByArea(this.queryParams).then(response => {
  304. this.deviceList = response.rows
  305. this.total = response.total
  306. this.loading = false
  307. })
  308. },
  309. /** 查询区域树结构 */
  310. getAreaTree(tier) {
  311. areaTreeSelect(tier).then(response => {
  312. this.areaOptions = response.data;
  313. });
  314. },
  315. // 筛选节点
  316. filterNode(value, data) {
  317. if (!value) return true;
  318. return data.label.indexOf(value) !== -1;
  319. },
  320. // 节点单击事件
  321. handleNodeClick(data) {
  322. this.queryParams.refArea = data.id;
  323. this.queryParams.areaType = data.tier;
  324. this.handleQuery();
  325. },
  326. // 取消按钮
  327. cancel() {
  328. this.open = false
  329. this.reset()
  330. },
  331. // 表单重置
  332. reset() {
  333. this.form = {
  334. id: null,
  335. deviceCode: null,
  336. deviceName: null,
  337. deviceSubCategory: null,
  338. deviceCategory: null,
  339. deviceStatus: null,
  340. refArea: null,
  341. refFacs: null,
  342. createTime: null,
  343. updateTime: null
  344. }
  345. this.resetForm('form')
  346. },
  347. /** 搜索按钮操作 */
  348. handleQuery() {
  349. this.queryParams.pageNum = 1
  350. this.getList()
  351. },
  352. /** 重置按钮操作 */
  353. resetQuery() {
  354. this.queryParams.refArea = null;
  355. this.queryParams.areaType = null;
  356. this.resetForm('queryForm')
  357. this.handleQuery()
  358. },
  359. // 设备状态详情
  360. handleDetail(row) {
  361. this.reset()
  362. this.curRow= row
  363. console.log("设备data",this.curRow)
  364. getModelByCode(this.curRow.deviceModel).then(response => {
  365. this.open = true
  366. const code=response.data
  367. console.log("code",code)
  368. this.attrData=response.data.attrList
  369. this.eventData=response.data.eventList
  370. this.abilityData=response.data.abilityList
  371. })
  372. },
  373. getFacsOptions(areaCode) {
  374. listAllFacs(areaCode).then(response =>{
  375. this.facsOptions = response.data;
  376. })
  377. },
  378. getSubsystem() {
  379. listSubsystemAll().then(response =>{
  380. this.subsystemOptions = response.data;
  381. })
  382. },
  383. getSubCategorygetByCode () {
  384. getFacsCategorygetByCode(this.queryParams.deviceCategory).then(response => {
  385. this.subCategoryOptions = response.data.subtypeList||[];
  386. })
  387. },
  388. deviceCategoryChange () {
  389. this.queryParams.deviceSubCategory = ''
  390. if (this.queryParams.deviceCategory === 'E' || this.queryParams.deviceCategory === 'W'
  391. || this.queryParams.deviceCategory === 'T'|| this.queryParams.deviceCategory === 'C') {
  392. this.getAreaTree("Area")
  393. } else if (this.queryParams.deviceCategory === 'Z') {
  394. this.getAreaTree("Zoning")
  395. }
  396. this.getSubCategorygetByCode()
  397. this.handleQuery()
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .detail-dialog .el-dialog {
  404. width: 80%; /* 调整弹框宽度 */
  405. }
  406. .section-title {
  407. font-size: 18px; /* 标题字体大小 */
  408. font-weight: bold; /* 字体加粗 */
  409. margin-top: 20px; /* 标题顶部间距 */
  410. margin-bottom: 10px; /* 标题底部间距 */
  411. }
  412. </style>