index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. <el-dialog :visible.sync="open" title="设备状态详情" custom-class="detail-dialog">
  107. <div v-if="curRow">
  108. <!-- 设施基本信息 -->
  109. <el-card class="box-card">
  110. <div slot="header" class="clearfix">
  111. <span class="section-title">设备状态基本信息</span>
  112. </div>
  113. <div>
  114. <p><span class="bold">设备名称:</span>{{ curRow.deviceName }}</p>
  115. <p><span class="bold">设备代码:</span>{{ curRow.deviceCode }}</p>
  116. <p><span class="bold">归属设施:</span>{{ curRow.refFacs }}</p>
  117. <p><span class="bold">归属区域:</span>{{ curRow.refArea }}</p>
  118. <p><span class="bold">子系统:</span>{{ curRow.subsystemName }}</p>
  119. <p><span class="bold">设备状态:</span>{{ curRow.deviceStatus }}</p>
  120. </div>
  121. </el-card>
  122. <!-- 属性信息 -->
  123. <el-card class="box-card" v-if="attrData.length > 0">
  124. <div slot="header" class="clearfix">
  125. <span class="section-title">属性定义</span>
  126. </div>
  127. <div v-for="(item, index) in attrData" :key="index">
  128. <p><span class="bold">属性名称:</span>{{ item.attrName }}</p>
  129. <p><span class="bold">属性标识:</span>{{ item.attrKey }}</p>
  130. <p><span class="bold">属性值:</span>{{ item.attrValue }}</p>
  131. <p><span class="bold">属性单位:</span>{{ item.attrUnit }}</p>
  132. <!-- 在每个条目之后添加横线,除了最后一个条目 -->
  133. <div v-if="index < attrData.length - 1" class="divider"></div>
  134. </div>
  135. </el-card>
  136. <el-card class="box-card" v-else>
  137. <div slot="header" class="clearfix">
  138. <span class="section-title">属性定义</span>
  139. </div>
  140. <div>
  141. <p><span class="bold">属性名称:</span>暂无数据</p>
  142. <p><span class="bold">属性标识:</span>暂无数据</p>
  143. <p><span class="bold">属性值:</span>暂无数据</p>
  144. <p><span class="bold">属性单位:</span>暂无数据</p>
  145. </div>
  146. </el-card>
  147. <!-- 能力信息 -->
  148. <el-card class="box-card" v-if="abilityData.length > 0">
  149. <div slot="header" class="clearfix">
  150. <span class="section-title">能力定义</span>
  151. </div>
  152. <div v-for="(item, index) in abilityData" :key="index">
  153. <p><span class="bold">能力名称:</span>{{ item.abilityName }}</p>
  154. <p><span class="bold">能力键:</span>{{ item.abilityKey }}</p>
  155. <p><span class="bold">能力参数:</span>{{ item.abilityParam }}</p>
  156. <p><span class="bold">能力描述:</span>{{ item.abilityDesc }}</p>
  157. <!-- 在每个条目之后添加横线,除了最后一个条目 -->
  158. <div v-if="index < abilityData.length - 1" class="divider"></div>
  159. </div>
  160. </el-card>
  161. <el-card class="box-card" v-else>
  162. <div slot="header" class="clearfix">
  163. <span class="section-title">能力定义</span>
  164. </div>
  165. <div>
  166. <p><span class="bold">能力名称:</span>暂无数据</p>
  167. <p><span class="bold">能力键:</span>暂无数据</p>
  168. <p><span class="bold">能力参数:</span>暂无数据</p>
  169. <p><span class="bold">能力描述:</span>暂无数据</p>
  170. </div>
  171. </el-card>
  172. <!-- 事件信息 -->
  173. <el-card class="box-card" v-if="eventData.length > 0">
  174. <div slot="header" class="clearfix">
  175. <span class="section-title">事件定义</span>
  176. </div>
  177. <div v-for="(item, index) in eventData" :key="index">
  178. <p><span class="bold">事件名称:</span>{{ item.eventKey }}</p>
  179. <p><span class="bold">事件类型:</span>{{ item.eventType === 1 ? '消息上报' : '异常告警' }}</p>
  180. <p><span class="bold">事件代码:</span>{{ item.eventCode }}</p>
  181. <p><span class="bold">外部事件代码:</span>{{ item.extEventCode }}</p>
  182. <!-- 在每个条目之后添加横线,除了最后一个条目 -->
  183. <div v-if="index < eventData.length - 1" class="divider"></div>
  184. </div>
  185. </el-card>
  186. <el-card class="box-card" v-else>
  187. <div slot="header" class="clearfix">
  188. <span class="section-title">事件定义</span>
  189. </div>
  190. <div>
  191. <p><span class="bold">事件名称:</span>暂无数据</p>
  192. <p><span class="bold">事件类型:</span>暂无数据</p>
  193. <p><span class="bold">事件代码:</span>暂无数据</p>
  194. <p><span class="bold">外部事件代码:</span>暂无数据</p>
  195. </div>
  196. </el-card>
  197. </div>
  198. </el-dialog>
  199. </el-col>
  200. </el-row>
  201. </div>
  202. </template>
  203. <script>
  204. import { listDevRecursionByArea } from '@/api/device/device'
  205. import { areaTreeSelect } from "@/api/basecfg/area"
  206. import { getFacsCategorygetByCode, listFacsByCategory } from '@/api/basecfg/emsfacs'
  207. import { listSubsystemAll } from '@/api/adapter/subsystem'
  208. import { getModelByCode } from "@/api/basecfg/objModel";
  209. import Treeselect from "@riophae/vue-treeselect";
  210. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  211. export default {
  212. name: 'Device',
  213. dicts: ['sys_device_stat'],
  214. components: { Treeselect },
  215. data() {
  216. return {
  217. // 遮罩层
  218. loading: true,
  219. // 选中数组
  220. ids: [],
  221. // 非单个禁用
  222. single: true,
  223. // 非多个禁用
  224. multiple: true,
  225. // 显示搜索条件
  226. showSearch: true,
  227. // 总条数
  228. total: 0,
  229. // 能源设备表格数据
  230. deviceList: [],
  231. // 弹出层标题
  232. title: '',
  233. // 是否显示弹出层
  234. open: false,
  235. // 区域名称
  236. areaName: undefined,
  237. // 区域树选项
  238. treeAreaOptions: undefined,
  239. // 设施选项
  240. facsOptions: undefined,
  241. // 设备分类
  242. devcTypeOptions: undefined,
  243. subsystemOptions: undefined,
  244. defaultProps: {
  245. children: "children",
  246. label: "label"
  247. },
  248. curRow: {},
  249. attrData: [],
  250. abilityData: [],
  251. eventData: [],
  252. // 查询参数
  253. queryParams: {
  254. pageNum: 1,
  255. pageSize: 10,
  256. deviceCode: null,
  257. deviceName: null,
  258. deviceSubCategory: '',
  259. deviceCategory: 'E',
  260. deviceStatus: null,
  261. areaType: null,
  262. refArea: null,
  263. refFacs: null,
  264. subsystemCode: null
  265. },
  266. // 表单参数
  267. form: {}
  268. }
  269. },
  270. created() {
  271. this.getList();
  272. this.getAreaTree('Building');
  273. this.getFacsOptions();
  274. this.getSubsystem();
  275. this.getSubCategorygetByCode();
  276. },
  277. methods: {
  278. getDeviceStatusText(status) {
  279. const statusMap = {
  280. 0: '运行',
  281. 1: '故障',
  282. 2: '未运行'
  283. };
  284. return statusMap[status] || '';
  285. },
  286. getDeviceStatusTextColor(status) {
  287. if (status === 0) return 'rgb(232,244,255)';
  288. if (status === 1) return '#FFFFFF';
  289. if (status === 2) return 'rgb(255,235,235)';
  290. return '#000000'; // 默认黑色文字
  291. },
  292. getDeviceStatusBgColor(status) {
  293. if (status === 0) return 'rgb(117,186,255)';
  294. if (status === 1) return 'rgb(242,197,92)';
  295. if (status === 2) return 'rgb(255,159,159)';
  296. return 'transparent'; // 默认无背景色
  297. },
  298. /** 查询能源设备列表 */
  299. getList() {
  300. this.loading = true
  301. listDevRecursionByArea(this.queryParams).then(response => {
  302. this.deviceList = response.rows
  303. this.total = response.total
  304. this.loading = false
  305. })
  306. },
  307. /** 查询区域树结构 */
  308. getAreaTree(tier) {
  309. areaTreeSelect(tier).then(response => {
  310. this.treeAreaOptions = response.data;
  311. });
  312. },
  313. // 筛选节点
  314. filterNode(value, data) {
  315. if (!value) return true;
  316. return data.label.indexOf(value) !== -1;
  317. },
  318. // 节点单击事件
  319. handleNodeClick(data) {
  320. this.queryParams.refArea = data.id;
  321. this.queryParams.areaType = data.tier;
  322. this.handleQuery();
  323. },
  324. // 取消按钮
  325. cancel() {
  326. this.open = false
  327. this.reset()
  328. },
  329. // 表单重置
  330. reset() {
  331. this.form = {
  332. id: null,
  333. deviceCode: null,
  334. deviceName: null,
  335. deviceSubCategory: null,
  336. deviceCategory: null,
  337. deviceStatus: null,
  338. refArea: null,
  339. refFacs: null,
  340. createTime: null,
  341. updateTime: null
  342. }
  343. this.resetForm('form')
  344. },
  345. /** 搜索按钮操作 */
  346. handleQuery() {
  347. this.queryParams.pageNum = 1
  348. this.getList()
  349. },
  350. /** 重置按钮操作 */
  351. resetQuery() {
  352. this.queryParams.refArea = null;
  353. this.queryParams.areaType = null;
  354. this.resetForm('queryForm')
  355. this.handleQuery()
  356. },
  357. // 设备状态详情
  358. handleDetail(row) {
  359. this.reset()
  360. this.curRow= row
  361. console.log("设备data",this.curRow)
  362. getModelByCode(this.curRow.deviceModel).then(response => {
  363. this.open = true
  364. const code=response.data
  365. console.log("code",code)
  366. this.attrData=response.data.attrList
  367. this.eventData=response.data.eventList
  368. this.abilityData=response.data.abilityList
  369. })
  370. },
  371. getFacsOptions() {
  372. listFacsByCategory(this.queryParams.deviceCategory, this.queryParams.deviceSubCategory).then(response => {
  373. this.facsOptions = response.data;
  374. })
  375. },
  376. getSubsystem() {
  377. listSubsystemAll().then(response =>{
  378. this.subsystemOptions = response.data;
  379. })
  380. },
  381. getSubCategorygetByCode () {
  382. getFacsCategorygetByCode(this.queryParams.deviceCategory).then(response => {
  383. this.subCategoryOptions = response.data.subtypeList||[];
  384. })
  385. },
  386. deviceCategoryChange () {
  387. this.queryParams.deviceSubCategory = ''
  388. if (this.queryParams.deviceCategory === 'E' || this.queryParams.deviceCategory === 'W'
  389. || this.queryParams.deviceCategory === 'T'|| this.queryParams.deviceCategory === 'C') {
  390. this.getAreaTree("Building")
  391. } else if (this.queryParams.deviceCategory === 'Z') {
  392. this.getAreaTree("Zoning")
  393. }
  394. this.getSubCategorygetByCode()
  395. this.getFacsOptions()
  396. this.handleQuery()
  397. }
  398. }
  399. }
  400. </script>
  401. <style lang="scss" scoped>
  402. .detail-dialog .el-dialog {
  403. width: 80%; /* 调整弹框宽度 */
  404. }
  405. .section-title {
  406. font-size: 18px; /* 标题字体大小 */
  407. font-weight: bold; /* 字体加粗 */
  408. margin-top: 20px; /* 标题顶部间距 */
  409. margin-bottom: 10px; /* 标题底部间距 */
  410. }
  411. </style>