index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. <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, getDevice, delDevice, addDevice, updateDevice } from '@/api/device/device'
  205. import { areaTreeSelect } from "@/api/basecfg/area"
  206. import { getFacsCategorygetByCode, listAllFacs } from '@/api/basecfg/emsfacs'
  207. import { getDevcType} from '@/api/commonApi'
  208. import { listSubsystemAll } from '@/api/adapter/subsystem'
  209. import Treeselect from "@riophae/vue-treeselect";
  210. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  211. import { getBuilding } from '@/api/basecfg/building'
  212. import {getModelByCode} from "@/api/basecfg/objModel";
  213. export default {
  214. name: 'Device',
  215. dicts: ['sys_device_stat'],
  216. components: { Treeselect },
  217. data() {
  218. return {
  219. // 遮罩层
  220. loading: true,
  221. // 选中数组
  222. ids: [],
  223. // 非单个禁用
  224. single: true,
  225. // 非多个禁用
  226. multiple: true,
  227. // 显示搜索条件
  228. showSearch: true,
  229. // 总条数
  230. total: 0,
  231. // 能源设备表格数据
  232. deviceList: [],
  233. // 弹出层标题
  234. title: '',
  235. // 是否显示弹出层
  236. open: false,
  237. // 区域名称
  238. areaName: undefined,
  239. // 区域树选项
  240. areaOptions: undefined,
  241. // 设施选项
  242. facsOptions: undefined,
  243. // 设备分类
  244. devcTypeOptions: undefined,
  245. subsystemOptions: undefined,
  246. defaultProps: {
  247. children: "children",
  248. label: "label"
  249. },
  250. curRow: {},
  251. attrData: [],
  252. abilityData: [],
  253. eventData: [],
  254. // 查询参数
  255. queryParams: {
  256. pageNum: 1,
  257. pageSize: 10,
  258. deviceCode: null,
  259. deviceName: null,
  260. deviceSubCategory: null,
  261. deviceCategory: 'E',
  262. deviceStatus: null,
  263. areaType: null,
  264. refArea: null,
  265. refFacs: null,
  266. subsystemCode: null
  267. },
  268. // 表单参数
  269. form: {}
  270. }
  271. },
  272. created() {
  273. this.getList();
  274. this.getAreaTree('Area');
  275. this.getFacsOptions("");
  276. this.getSubsystem();
  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.areaOptions = 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(areaCode) {
  373. listAllFacs(areaCode).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("Area")
  392. } else if (this.queryParams.deviceCategory === 'Z') {
  393. this.getAreaTree("Zoning")
  394. }
  395. this.getSubCategorygetByCode()
  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>