index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="siteManage-main watchDog">
  3. <!-- 筛选start -->
  4. <div class="filter-container mb-20">
  5. <span class="">
  6. 【{{ labelCom }}】站点的所有监控设备
  7. <a
  8. href="./static/伍继监控设备导入模板.xlsx"
  9. download
  10. class="downloadMb"
  11. >
  12. 模板下载
  13. </a>
  14. </span>
  15. <!-- <el-button icon="el-icon-plus" type="success" @click="addItem()">新增</el-button > -->
  16. <div>
  17. <el-upload
  18. class="upload-demo"
  19. :action="fileUrl + '/deviceAttribute/deviceAttributeImport'"
  20. :on-progress="handleProgress"
  21. :on-success="handleUpAvatar"
  22. :on-error="handleError"
  23. multiple
  24. :limit="1"
  25. :headers="{
  26. accessToken: [accessToken],
  27. }"
  28. :file-list="fileList"
  29. style="margin-right: 10px; display: inline-block"
  30. >
  31. <el-button size="small" type="primary">导入</el-button>
  32. </el-upload>
  33. <el-button type="primary" @click="DataReportExport()">导出</el-button>
  34. </div>
  35. </div>
  36. <!-- 筛选end -->
  37. <!-- 表格start -->
  38. <el-table :data="tableData" border stripe :header-cell-style="headClass">
  39. <el-table-column prop="status" align="center" label="状态" width="50">
  40. <template #default="scope">
  41. <el-avatar
  42. class="status"
  43. :style="
  44. scope.row.status == 0
  45. ? 'background-color:red'
  46. : 'background-color:#04F21C'
  47. "
  48. ></el-avatar>
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. prop="monitorDeviceName"
  53. label="监控设备名称"
  54. align="center"
  55. width="200px"
  56. ></el-table-column>
  57. <el-table-column
  58. prop="monitorDeviceCode"
  59. label="监控设备编号"
  60. align="center"
  61. width=""
  62. ></el-table-column>
  63. <el-table-column
  64. prop="loopMeterAddress"
  65. label="回路表计地址"
  66. align="center"
  67. width=""
  68. ></el-table-column>
  69. <el-table-column
  70. prop="ratedVoltage"
  71. label="额定电压 (kV)"
  72. align="center"
  73. width=""
  74. ></el-table-column>
  75. <el-table-column
  76. prop="ratedCurrent"
  77. label="额定电流 (A)"
  78. align="center"
  79. width=""
  80. ></el-table-column>
  81. <el-table-column
  82. prop="currentLoadRate"
  83. label="电流负载率门限"
  84. align="center"
  85. width="150"
  86. ></el-table-column>
  87. <el-table-column
  88. prop="qualityAnalysis"
  89. label="电能质量分析"
  90. align="center"
  91. width=""
  92. ></el-table-column>
  93. <el-table-column fixed="right" label="操作" width="140">
  94. <template #default="scope">
  95. <el-button
  96. type="text"
  97. size="small"
  98. @click.prevent="editRow(scope.row)"
  99. >
  100. 编辑
  101. </el-button>
  102. <el-popconfirm
  103. confirm-button-text="是"
  104. cancel-button-text="否"
  105. icon="el-icon-info"
  106. icon-color="red"
  107. title="确定删除?"
  108. @confirm="handleDelete(scope.row)"
  109. @cancel="cancelEvent"
  110. >
  111. <template #reference>
  112. <el-button type="text" size="small" class="delete-text">
  113. 删除
  114. </el-button>
  115. </template>
  116. </el-popconfirm>
  117. </template>
  118. </el-table-column>
  119. <el-table-column fixed="right" label="变量" width="100">
  120. <template #default>
  121. <el-button type="text" size="small" @click="goVariableList">
  122. 变量列表
  123. </el-button>
  124. <!-- <el-button @click="cloneDialog(scope.row)" type="text" size="small"
  125. >克隆</el-button
  126. > -->
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <!-- 表格end -->
  131. <!-- 分页start -->
  132. <div class="paginationBlock">
  133. <el-pagination
  134. v-model:currentPage="currentPage"
  135. :page-sizes="[15, 20, 25, 30]"
  136. :page-size="pageSize"
  137. layout="total, sizes, prev, pager, next, jumper"
  138. :total="total"
  139. @size-change="handleSizeChange"
  140. @current-change="handleCurrentChange"
  141. background
  142. ></el-pagination>
  143. </div>
  144. <!-- 分页end -->
  145. <!--弹框组件开始-----------------------start-->
  146. <dialog-component
  147. :dialogTitle="dialogTitle"
  148. :itemInfo="tableItem"
  149. @closeDialog="closeDialog"
  150. :flag="showDialog"
  151. ></dialog-component>
  152. <!--弹框组件开始-----------------------end-->
  153. <!--克隆组件开始-----------------------start-->
  154. <clone
  155. v-if="showDialog"
  156. ref="cloneDialog"
  157. :dialog-title="dialogTitle"
  158. :item-info="tableItem"
  159. @closeDialog="closeDialog"
  160. ></clone>
  161. <!--克隆组件end-----------------------end-->
  162. </div>
  163. </template>
  164. <script>
  165. import { useStore } from 'vuex'
  166. import { defineComponent, ref, reactive, onMounted, watch } from 'vue'
  167. import * as api from '@/api/siteManage/watchDog.js'
  168. import { ElMessage } from 'element-plus'
  169. import DialogComponent from './dialogComponent'
  170. import Clone from './clone'
  171. export default defineComponent({
  172. components: { DialogComponent, Clone },
  173. props: {
  174. siteId: Number,
  175. activeName: String,
  176. },
  177. setup(props, { emit }) {
  178. const store = useStore()
  179. store
  180. const fileUrl = ref(window.PLATFROM_CONFIG.baseUrl)
  181. const fileList = ref([])
  182. const accessToken = ref(store.state.user.accessToken)
  183. const total = ref(0)
  184. const pageSize = ref(15)
  185. const currentPage = ref(1)
  186. const goSiteListParam = ref('')
  187. const platformAreaName = ref('')
  188. const pageShow = ref(false)
  189. const showDialog = ref(false)
  190. const tableData = ref([])
  191. const labelCom = ref(store.state.siteManageLabelCom)
  192. function goSiteList(params) {
  193. goSiteListParam.value = params.id
  194. pageShow.value = !pageShow.value
  195. }
  196. const getMsgFormSon = () => {
  197. pageShow.value = !pageShow.value
  198. }
  199. const tableItem = reactive([])
  200. const dialogTitle = ref('')
  201. //监控设备列表
  202. function deviceNewsList() {
  203. api
  204. .deviceNewsList({
  205. siteId: props.siteId,
  206. size: pageSize.value,
  207. current: currentPage.value,
  208. })
  209. .then((requset) => {
  210. if (requset.status === 'SUCCESS') {
  211. tableData.value = requset.data.records
  212. total.value = requset.data.total
  213. } else {
  214. ElMessage.error(requset.msg)
  215. }
  216. })
  217. }
  218. // 添加操作
  219. // const addItem = () => {
  220. // tableItem.value = {
  221. // platformAreaName: '',
  222. // platformAreaCode: '',
  223. // platformAreaAddress: '',
  224. // }
  225. // dialogTitle.value = '新增'
  226. // showDialog.value = true
  227. // }
  228. // 编辑操作
  229. const editRow = (row) => {
  230. tableItem.value = {
  231. id: row.id,
  232. monitorDeviceCode: row.monitorDeviceCode,
  233. monitorDeviceName: row.monitorDeviceName,
  234. loopMeterAddress: row.loopMeterAddress,
  235. ratedVoltage: row.ratedVoltage,
  236. ratedCurrent: row.ratedCurrent,
  237. currentLoadRate: row.currentLoadRate,
  238. siteId: row.siteId,
  239. variableListId: row.variableListId,
  240. qualityAnalysis: row.qualityAnalysis === '是' ? true : false,
  241. }
  242. dialogTitle.value = '编辑'
  243. showDialog.value = true
  244. }
  245. // 关闭操作
  246. const closeDialog = () => {
  247. showDialog.value = false
  248. deviceNewsList()
  249. }
  250. //删除 是否删除 ---- 是
  251. const handleDelete = (row) => {
  252. api.deviceNewsDel({ id: row.id }).then((requset) => {
  253. if (requset.status === 'SUCCESS') {
  254. ElMessage.success({
  255. message: '删除成功',
  256. type: 'success',
  257. })
  258. deviceNewsList()
  259. } else {
  260. ElMessage.error(requset.msg)
  261. }
  262. })
  263. }
  264. //是否删除 ---- 否
  265. const cancelEvent = () => {
  266. console.log('cancel!')
  267. }
  268. const handleProgress = (file, fileList) => {
  269. file
  270. if (
  271. !(
  272. fileList.raw.type ===
  273. 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ||
  274. fileList.raw.type === 'application/vnd.ms-excel'
  275. )
  276. ) {
  277. ElMessage({
  278. message: '上传文件只能是 xls 和 xlsx 格式!',
  279. type: 'error',
  280. })
  281. return false
  282. } else {
  283. return true
  284. }
  285. }
  286. const handleUpAvatar = (res, file) => {
  287. console.log(res, file)
  288. fileList.value = []
  289. ElMessage.success({
  290. message: '导入成功',
  291. type: 'success',
  292. })
  293. deviceNewsList()
  294. }
  295. const handleError = (res) => {
  296. let myError = res.toString() //转字符串
  297. myError = myError.replace('Error: ', '') //去掉前面的
  298. myError = JSON.parse(myError) //转对象
  299. ElMessage.error({
  300. message: myError.msg,
  301. type: 'error',
  302. })
  303. }
  304. function goVariableList() {
  305. emit('func')
  306. }
  307. // 表头样式设置
  308. const headClass = () => {
  309. return 'background:#FAFAFA;'
  310. }
  311. const handleSizeChange = (val) => {
  312. pageSize.value = val
  313. deviceNewsList()
  314. }
  315. const handleCurrentChange = (val) => {
  316. currentPage.value = val
  317. deviceNewsList()
  318. }
  319. //导出
  320. const DataReportExport = () => {
  321. api
  322. .deviceAttributeExport({
  323. siteId: props.siteId,
  324. })
  325. .then((requset) => {
  326. if (requset.status === 'SUCCESS') {
  327. window.location.href = window.PLATFROM_CONFIG.fileUrl + requset.data
  328. ElMessage.success({
  329. message: '导出成功',
  330. type: 'success',
  331. })
  332. } else {
  333. ElMessage.error(requset.msg)
  334. }
  335. })
  336. }
  337. //监听变化
  338. watch(
  339. () => props.siteId,
  340. (newVal) => {
  341. console.log('newVal')
  342. console.log(newVal)
  343. labelCom.value = store.state.siteManageLabelCom
  344. if (props.activeName == 'second') {
  345. deviceNewsList()
  346. }
  347. }
  348. )
  349. watch(
  350. () => props.activeName,
  351. (newVal) => {
  352. if (newVal == 'second') {
  353. deviceNewsList()
  354. }
  355. }
  356. )
  357. onMounted(() => {
  358. if (store.state.goUrl==2) {
  359. deviceNewsList()
  360. }
  361. })
  362. return {
  363. tableData,
  364. showDialog,
  365. platformAreaName,
  366. pageShow,
  367. dialogTitle,
  368. props,
  369. tableItem,
  370. goSiteListParam,
  371. total,
  372. pageSize,
  373. currentPage,
  374. goVariableList,
  375. deviceNewsList,
  376. goSiteList,
  377. getMsgFormSon,
  378. headClass,
  379. // addItem,
  380. editRow,
  381. closeDialog,
  382. handleDelete,
  383. cancelEvent,
  384. handleSizeChange,
  385. handleCurrentChange,
  386. DataReportExport,
  387. fileList,
  388. fileUrl,
  389. accessToken,
  390. handleProgress,
  391. handleUpAvatar,
  392. handleError,
  393. labelCom,
  394. }
  395. },
  396. })
  397. </script>
  398. <style lang="scss" scoped>
  399. </style>