index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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="treeAreaOptions"
  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="deviceCategoryName"/>
  65. <el-table-column label="归属设施" align="center" prop="refFacsName"/>
  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 } from '@/api/device/device'
  206. import { areaTreeSelect } from "@/api/basecfg/area"
  207. import { getFacsCategorygetByCode, listFacsByCategory } from '@/api/basecfg/emsfacs'
  208. import { listSubsystemAll } from '@/api/adapter/subsystem'
  209. import { getModelByCode } from "@/api/basecfg/objModel";
  210. import Treeselect from "@riophae/vue-treeselect";
  211. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  212. export default {
  213. name: 'Device',
  214. dicts: ['sys_device_stat'],
  215. components: { Treeselect },
  216. data() {
  217. return {
  218. // 遮罩层
  219. loading: true,
  220. // 选中数组
  221. ids: [],
  222. // 非单个禁用
  223. single: true,
  224. // 非多个禁用
  225. multiple: true,
  226. // 显示搜索条件
  227. showSearch: true,
  228. // 总条数
  229. total: 0,
  230. // 能源设备表格数据
  231. deviceList: [],
  232. // 弹出层标题
  233. title: '',
  234. // 是否显示弹出层
  235. open: false,
  236. // 区域名称
  237. areaName: undefined,
  238. // 区域树选项
  239. treeAreaOptions: undefined,
  240. // 设施选项
  241. facsOptions: undefined,
  242. // 设备分类
  243. devcTypeOptions: undefined,
  244. subsystemOptions: undefined,
  245. defaultProps: {
  246. children: "children",
  247. label: "label"
  248. },
  249. curRow: {},
  250. attrData: [],
  251. abilityData: [],
  252. eventData: [],
  253. // 查询参数
  254. queryParams: {
  255. pageNum: 1,
  256. pageSize: 10,
  257. deviceCode: null,
  258. deviceName: null,
  259. deviceSubCategory: '',
  260. deviceCategory: 'E',
  261. deviceStatus: null,
  262. areaType: null,
  263. refArea: null,
  264. refFacs: null,
  265. subsystemCode: null
  266. },
  267. // 表单参数
  268. form: {}
  269. }
  270. },
  271. created() {
  272. this.getList();
  273. this.getAreaTree('Building');
  274. this.getFacsOptions();
  275. this.getSubsystem();
  276. this.getSubCategorygetByCode();
  277. },
  278. methods: {
  279. getDeviceStatusText(status) {
  280. const statusMap = {
  281. 0: '运行',
  282. 1: '故障',
  283. 2: '未运行'
  284. };
  285. return statusMap[status] || '';
  286. },
  287. getDeviceStatusTextColor(status) {
  288. if (status === 0) return 'rgb(232,244,255)';
  289. if (status === 1) return '#FFFFFF';
  290. if (status === 2) return 'rgb(255,235,235)';
  291. return '#000000'; // 默认黑色文字
  292. },
  293. getDeviceStatusBgColor(status) {
  294. if (status === 0) return 'rgb(117,186,255)';
  295. if (status === 1) return 'rgb(242,197,92)';
  296. if (status === 2) return 'rgb(255,159,159)';
  297. return 'transparent'; // 默认无背景色
  298. },
  299. /** 查询能源设备列表 */
  300. getList() {
  301. this.loading = true
  302. listDevRecursionByArea(this.queryParams).then(response => {
  303. this.deviceList = response.rows
  304. this.total = response.total
  305. this.loading = false
  306. })
  307. },
  308. /** 查询区域树结构 */
  309. getAreaTree(tier) {
  310. areaTreeSelect(tier).then(response => {
  311. this.treeAreaOptions = response.data;
  312. });
  313. },
  314. // 筛选节点
  315. filterNode(value, data) {
  316. if (!value) return true;
  317. return data.label.indexOf(value) !== -1;
  318. },
  319. // 节点单击事件
  320. handleNodeClick(data) {
  321. this.queryParams.refArea = data.id;
  322. this.queryParams.areaType = data.tier;
  323. this.handleQuery();
  324. },
  325. // 取消按钮
  326. cancel() {
  327. this.open = false
  328. this.reset()
  329. },
  330. // 表单重置
  331. reset() {
  332. this.form = {
  333. id: null,
  334. deviceCode: null,
  335. deviceName: null,
  336. deviceSubCategory: null,
  337. deviceCategory: null,
  338. deviceStatus: null,
  339. refArea: null,
  340. refFacs: null,
  341. createTime: null,
  342. updateTime: null
  343. }
  344. this.resetForm('form')
  345. },
  346. /** 搜索按钮操作 */
  347. handleQuery() {
  348. this.queryParams.pageNum = 1
  349. this.getList()
  350. },
  351. /** 重置按钮操作 */
  352. resetQuery() {
  353. this.queryParams.refArea = null;
  354. this.queryParams.areaType = null;
  355. this.resetForm('queryForm')
  356. this.handleQuery()
  357. },
  358. // 设备状态详情
  359. handleDetail(row) {
  360. this.reset()
  361. this.curRow= row
  362. console.log("设备data",this.curRow)
  363. getModelByCode(this.curRow.deviceModel).then(response => {
  364. this.open = true
  365. const code=response.data
  366. console.log("code",code)
  367. this.attrData=response.data.attrList
  368. this.eventData=response.data.eventList
  369. this.abilityData=response.data.abilityList
  370. })
  371. },
  372. getFacsOptions() {
  373. listFacsByCategory(this.queryParams.deviceCategory, this.queryParams.deviceSubCategory).then(response => {
  374. this.facsOptions = response.data;
  375. })
  376. },
  377. getSubsystem() {
  378. listSubsystemAll().then(response =>{
  379. this.subsystemOptions = response.data;
  380. })
  381. },
  382. getSubCategorygetByCode () {
  383. getFacsCategorygetByCode(this.queryParams.deviceCategory).then(response => {
  384. this.subCategoryOptions = response.data.subtypeList||[];
  385. })
  386. },
  387. deviceCategoryChange () {
  388. this.queryParams.deviceSubCategory = ''
  389. if (this.queryParams.deviceCategory === 'E' || this.queryParams.deviceCategory === 'W'
  390. || this.queryParams.deviceCategory === 'T'|| this.queryParams.deviceCategory === 'C') {
  391. this.getAreaTree("Building")
  392. } else if (this.queryParams.deviceCategory === 'Z') {
  393. this.getAreaTree("Zoning")
  394. }
  395. this.getSubCategorygetByCode()
  396. this.getFacsOptions()
  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>