index.vue 8.5 KB

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