index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div class="siteManage-main variableList">
  3. <!-- 筛选start -->
  4. <div class="filter-container mb-20">
  5. <div class="left">
  6. <div>
  7. <a class="" style="margin-right: 30px">
  8. 【{{ labelCom }}】 站点的所有变量
  9. </a>
  10. <el-button icon="el-icon-plus" type="success" @click="addItem()">
  11. 新增
  12. </el-button>
  13. <el-button icon="el-icon-refresh" type="primary">
  14. 同步配置到采集器
  15. </el-button>
  16. </div>
  17. <div style="margin-top: 15px">
  18. <el-button @click="Select(1)" :type="select == 1 ? 'primary' : ''">
  19. 模拟量
  20. </el-button>
  21. <el-button @click="Select(2)" :type="select == 2 ? 'primary' : ''">
  22. 状态量
  23. </el-button>
  24. <el-button @click="Select(3)" :type="select == 3 ? 'primary' : ''">
  25. 参数量
  26. </el-button>
  27. <el-input
  28. placeholder="搜索变量名称"
  29. style="width: 200px; margin-left: 20px"
  30. v-model="variableName"
  31. ></el-input>
  32. <el-button
  33. type="primary"
  34. icon="el-icon-search"
  35. class="search-button"
  36. @click="query()"
  37. >
  38. 搜索
  39. </el-button>
  40. </div>
  41. <!-- <el-radio-group v-model="tabPosition" style="margin-top: 20px">
  42. <el-radio-button label="one">模拟量</el-radio-button>
  43. <el-radio-button label="two">状态量</el-radio-button>
  44. <el-radio-button label="three">参数量</el-radio-button>
  45. </el-radio-group> -->
  46. </div>
  47. <div class="right">
  48. <el-upload
  49. class="upload-demo"
  50. :action="fileUrl + 'deviceAnalogVariableList/variableListImport'"
  51. :on-progress="handleProgress"
  52. :on-success="handleUpAvatar"
  53. multiple
  54. :limit="1"
  55. :headers="{
  56. accessToken: [accessToken],
  57. }"
  58. :file-list="fileList"
  59. style="margin-right: 10px; display: inline-block"
  60. >
  61. <el-button size="small" type="primary">导入</el-button>
  62. </el-upload>
  63. <el-button type="primary" @click="DataReportExport()">导出</el-button>
  64. </div>
  65. </div>
  66. <!-- 筛选end -->
  67. <!-- 表格start -->
  68. <el-table
  69. :data="tableData"
  70. border
  71. stripe
  72. :header-cell-style="headClass"
  73. :default-sort="{ prop: 'date', order: 'descending' }"
  74. >
  75. <el-table-column
  76. type="index"
  77. label="序号"
  78. width="80px"
  79. sortable
  80. ></el-table-column>
  81. <el-table-column
  82. prop="variableName"
  83. label="变量名"
  84. width="150px"
  85. sortable
  86. ></el-table-column>
  87. <el-table-column
  88. prop="variableCoding"
  89. label="变量编号"
  90. width="150px"
  91. sortable
  92. ></el-table-column>
  93. <el-table-column
  94. prop="monitorDeviceName"
  95. label="监控设备"
  96. width="150px"
  97. ></el-table-column>
  98. <el-table-column
  99. prop="deviceName"
  100. label="通信设备"
  101. width=""
  102. ></el-table-column>
  103. <el-table-column
  104. prop="dataAddress"
  105. label="数据地址"
  106. width=""
  107. ></el-table-column>
  108. <el-table-column
  109. prop="dataType"
  110. label="数据类型"
  111. width=""
  112. ></el-table-column>
  113. <el-table-column
  114. prop="coefficient"
  115. label="系数"
  116. width=""
  117. ></el-table-column>
  118. <el-table-column
  119. prop="saveCycle"
  120. label="存盘周期"
  121. width=""
  122. ></el-table-column>
  123. <el-table-column fixed="right" label="操作" width="180">
  124. <template #default="scope">
  125. <el-button
  126. type="text"
  127. size="small"
  128. @click.prevent="editRow(scope.row)"
  129. >
  130. 修改
  131. </el-button>
  132. <el-popconfirm
  133. confirm-button-text="是"
  134. cancel-button-text="否"
  135. icon="el-icon-info"
  136. icon-color="red"
  137. title="确定删除?"
  138. @confirm="handleDelete(scope.row)"
  139. @cancel="cancelEvent"
  140. >
  141. <template #reference>
  142. <el-button type="text" size="small" class="delete-text">
  143. 删除
  144. </el-button>
  145. </template>
  146. </el-popconfirm>
  147. </template>
  148. </el-table-column>
  149. </el-table>
  150. <!-- 表格end -->
  151. <!-- 分页start -->
  152. <div class="paginationBlock">
  153. <el-pagination
  154. @size-change="handleSizeChange"
  155. @current-change="handleCurrentChange"
  156. :current-page="currentPage"
  157. :page-sizes="[15, 20, 25, 30]"
  158. :page-size="pageSize"
  159. layout="total, sizes, prev, pager, next, jumper"
  160. :total="total"
  161. ></el-pagination>
  162. </div>
  163. <!-- 分页end -->
  164. <!--弹框组件开始-----------------------start-->
  165. <dialog-component
  166. :dialogTitle="dialogTitle"
  167. :itemInfo="tableItem"
  168. @closeDialog="closeDialog"
  169. :flag="showDialog"
  170. :siteId="siteId"
  171. ></dialog-component>
  172. <!--弹框组件开始-----------------------end-->
  173. </div>
  174. </template>
  175. <script>
  176. import { useStore } from 'vuex'
  177. import DialogComponent from './dialogComponent'
  178. import * as api from '@/api/siteManage/variableList'
  179. import { defineComponent, onMounted, reactive, ref, watch } from 'vue'
  180. import { ElMessage } from 'element-plus'
  181. export default defineComponent({
  182. name: 'VariableList',
  183. props: {
  184. siteId: Number,
  185. labelCom: String,
  186. activeName: String,
  187. },
  188. components: { DialogComponent },
  189. setup(props) {
  190. const store = useStore()
  191. store
  192. const tableItem = reactive([])
  193. const tableData = ref()
  194. const currentPage = ref(1)
  195. const pageSize = ref(15)
  196. const total = ref(0)
  197. const select = ref(1)
  198. // const siteId = ref(1)
  199. const variableName = ref('')
  200. const showDialog = ref(false)
  201. const dialogTitle = ref('')
  202. const fileUrl = ref(window.PLATFROM_CONFIG.baseUrl)
  203. const fileList = ref([])
  204. const accessToken = ref(store.state.user.accessToken)
  205. const handleProgress = (file, fileList) => {
  206. file
  207. if (
  208. !(
  209. fileList.raw.type ===
  210. 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ||
  211. fileList.raw.type === 'application/vnd.ms-excel'
  212. )
  213. ) {
  214. ElMessage({
  215. message: '上传文件只能是 xls 和 xlsx 格式!',
  216. type: 'error',
  217. })
  218. return false
  219. } else {
  220. return true
  221. }
  222. }
  223. const handleUpAvatar = (res, file) => {
  224. console.log(res, file)
  225. fileList.value = []
  226. ElMessage.success({
  227. message: '导入成功',
  228. type: 'success',
  229. })
  230. query()
  231. }
  232. //是否删除 ---- 否
  233. const cancelEvent = () => {
  234. console.log('cancel!')
  235. }
  236. //查询变量列表
  237. function query() {
  238. api
  239. .variableList({
  240. size: pageSize.value,
  241. current: currentPage.value,
  242. dataArea: select.value,
  243. siteId: props.siteId,
  244. variableName: variableName.value,
  245. })
  246. .then((requset) => {
  247. if (requset.status === 'SUCCESS') {
  248. tableData.value = requset.data.records
  249. total.value = requset.data.total
  250. } else {
  251. ElMessage.error(requset.msg)
  252. }
  253. })
  254. }
  255. const Select = (value) => {
  256. select.value = value
  257. query()
  258. }
  259. //监听变化
  260. watch(
  261. () => props.siteId,
  262. () => {
  263. if (props.activeName == 'third') {
  264. query()
  265. }
  266. }
  267. )
  268. watch(
  269. () => props.activeName,
  270. (newVal) => {
  271. if (newVal == 'third') {
  272. query()
  273. }
  274. }
  275. )
  276. onMounted(() => {})
  277. const handleSizeChange = (val) => {
  278. console.log(`每页 ${val} 条`)
  279. }
  280. const handleCurrentChange = (val) => {
  281. console.log(`当前页: ${val}`)
  282. }
  283. // input输入框无法输入解决
  284. const change = () => {
  285. this.$forceUpdate()
  286. }
  287. // 表头样式设置
  288. const goVariableList = () => {
  289. // 跳转至订单列表页面传参
  290. this.$router.push({
  291. path: '../siteManage/variableList/index.vue',
  292. })
  293. // this.$router.push({ name:'variableList'})
  294. }
  295. const headClass = () => {
  296. return 'background:#FAFAFA;'
  297. }
  298. // 添加操作
  299. const addItem = () => {
  300. tableItem.value = {
  301. monitoringEquipment: '',
  302. communicationEquipment: '',
  303. // dataArea:'1'
  304. }
  305. dialogTitle.value = '新增'
  306. showDialog.value = true
  307. }
  308. // 编辑操作
  309. const editRow = (row) => {
  310. // tableItem.value = {
  311. // dataArea: row.dataArea.toString(),
  312. // monitoringEquipment: row.monitoringEquipment,
  313. // communicationEquipment: row.communicationEquipment,
  314. // }
  315. tableItem.value = row
  316. tableItem.value.dataArea = row.dataArea.toString()
  317. tableItem.value.monitoringEquipment = row.monitoringEquipment
  318. tableItem.value.communicationEquipment = row.communicationEquipment
  319. dialogTitle.value = '编辑'
  320. showDialog.value = true
  321. }
  322. // 关闭操作
  323. const closeDialog = () => {
  324. showDialog.value = false
  325. query()
  326. }
  327. //删除操作
  328. const handleDelete = (row) => {
  329. api.variableListDel({ id: row.id }).then((requset) => {
  330. if (requset.status === 'SUCCESS') {
  331. ElMessage.success({
  332. message: '删除成功',
  333. type: 'success',
  334. })
  335. query()
  336. } else {
  337. ElMessage.error(requset.msg)
  338. }
  339. })
  340. }
  341. // 获取数据
  342. const getVariableListone = () => {
  343. console.log('hzy')
  344. }
  345. //导出
  346. const DataReportExport = () => {
  347. api
  348. .variableListExport({
  349. dataArea: select.value,
  350. siteId: props.siteId,
  351. variableName: variableName.value,
  352. })
  353. .then((requset) => {
  354. if (requset.status === 'SUCCESS') {
  355. window.location.href = window.PLATFROM_CONFIG.fileUrl + requset.data
  356. ElMessage.success({
  357. message: '导出成功',
  358. type: 'success',
  359. })
  360. } else {
  361. ElMessage.error(requset.msg)
  362. }
  363. })
  364. }
  365. return {
  366. cancelEvent,
  367. handleSizeChange,
  368. handleCurrentChange,
  369. change,
  370. goVariableList,
  371. headClass,
  372. addItem,
  373. editRow,
  374. closeDialog,
  375. handleDelete,
  376. getVariableListone,
  377. query,
  378. Select,
  379. DataReportExport, //导出
  380. select,
  381. showDialog,
  382. dialogTitle,
  383. total,
  384. pageSize,
  385. currentPage,
  386. tableData,
  387. input: '请输入状态',
  388. variableName,
  389. tableItem,
  390. fileList,
  391. fileUrl,
  392. accessToken,
  393. handleProgress,
  394. handleUpAvatar,
  395. }
  396. },
  397. })
  398. </script>
  399. <style lang="scss" scoped>
  400. </style>