tabControlTest.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div id="controlTest">
  3. <div class="query-area" style="padding:10px;" v-if="isShowSelect">
  4. <el-select v-model="originName" placeholder="请选择数据源" clearable @change="changeHandleSelect">
  5. <el-option
  6. v-for="(item,index) in selectAggregate.originList"
  7. :key="index"
  8. :label="item"
  9. :value="item">
  10. </el-option>
  11. </el-select>
  12. <el-select v-model="statusName" placeholder="请选择读写" clearable @change="changeHandleSelect">
  13. <el-option
  14. v-for="(item,index) in statusList"
  15. :key="index"
  16. :label="item"
  17. :value="index">
  18. </el-option>
  19. </el-select>
  20. <el-input
  21. placeholder="输入整合ID或点位描述"
  22. style="width: 220px"
  23. v-model.trim="describe"
  24. clearable
  25. @change="handleDescribe"
  26. >
  27. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  28. </el-input>
  29. <span style="float: right">
  30. <el-popover
  31. placement="bottom"
  32. style="padding: 0 20px 10px 20px;right: 10px"
  33. width="200"
  34. v-model="visible">
  35. <div>输入控制指令</div>
  36. <el-input type="textarea" :rows="2" v-model="instructions"/>
  37. <div style="text-align: right; margin-top: 10px">
  38. <el-button size="mini" type="text" @click="visible = false">取消</el-button>
  39. <el-button type="primary" size="mini" @click="implement">确定</el-button>
  40. </div>
  41. <el-button slot="reference">执行</el-button>
  42. </el-popover>
  43. <i class="el-icon-download" style="cursor: pointer" @click="downloads" title="下载"/>
  44. </span>
  45. </div>
  46. <div v-else class="query-area">
  47. <el-button style="margin: 10px" @click="back">返回</el-button>
  48. </div>
  49. <!-- 数据表格 -->
  50. <div class="table-area">
  51. <el-table
  52. :data="tableDate"
  53. style="width: 100%"
  54. height="calc(100% - 32px)"
  55. v-loading="loading"
  56. :header-cell-style="headerStyle"
  57. @selection-change="handleSelectionChange"
  58. >
  59. <el-table-column type="selection" v-if="isShowSelect"/>
  60. <el-table-column label="序号" type="index" align='center' width="55">
  61. <template slot-scope="scope">
  62. {{ scope.$index + (currentPage - 1) * pageSize + 1 }}
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop='DatasourceName' label='数据源名称' show-overflow-tooltip align='center'/>
  66. <el-table-column prop='ReadWrite' label='读写' show-overflow-tooltip align='center'/>
  67. <el-table-column prop='Meterfunc' label='整合ID' show-overflow-tooltip align='center'/>
  68. <el-table-column prop='Description' label='点位描述' show-overflow-tooltip align='center'/>
  69. <el-table-column prop='Status' label='状态' show-overflow-tooltip align='center'>
  70. <template slot-scope="scope">
  71. <span v-if="scope.row.Status== 0">进行中</span>
  72. <span v-if="scope.row.Status== 1">成功</span>
  73. <span v-if="scope.row.Status== 2">失败</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop='Data' label='反馈值' show-overflow-tooltip align='center'/>
  77. </el-table>
  78. <!-- 分页 -->
  79. <el-pagination
  80. @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
  81. :page-sizes="pageSizes"
  82. :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"
  83. style="float:right;margin-top:10px;padding:2px 5px;">
  84. </el-pagination>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import {pointTest, settingValue} from '@/api/scan/request'
  90. import axios from "axios";
  91. import {mapGetters} from 'vuex'
  92. export default {
  93. name: "tabControlTest",
  94. props: ['selectAggregate'],
  95. data() {
  96. return {
  97. isShowSelect: true,
  98. describe: '',
  99. pageSizes: [10, 20, 50, 100],
  100. pageSize: 50,
  101. currentPage: 1,
  102. total: 0,
  103. tableDate: [],
  104. visible: false,
  105. //表格头样式
  106. headerStyle: {
  107. backgroundColor: '#e1e4e5',
  108. color: '#2b2b2b',
  109. lineHeight: '30px'
  110. },
  111. instructions: '',
  112. originName: "",
  113. statusName: '',//读写
  114. statusList: ['读', '写', '读写'], // 0:读 1:写 2:读写
  115. loading: false,//加载
  116. }
  117. },
  118. created() {
  119. this.getSettingValue()
  120. },
  121. computed: {
  122. ...mapGetters('layout', ['projectId'])
  123. },
  124. methods: {
  125. //返回
  126. back() {
  127. this.isShowSelect = true
  128. this.getSettingValue()
  129. },
  130. //搜索
  131. handleDescribe() {
  132. if (this.describe) {
  133. let Filters = `Description='${this.describe}' or Meterfunc='${this.describe}';`
  134. this.getSettingValue(Filters)
  135. } else {
  136. this.getSettingValue()
  137. }
  138. },
  139. //执行
  140. implement() {
  141. this.visible = false
  142. if (this.multipleSelection) {
  143. let list = this.multipleSelection
  144. list.forEach(i => i.Data = this.instructions)
  145. this.getPointTest(list)
  146. } else {
  147. return false
  148. }
  149. this.instructions = ''
  150. },
  151. //当前设定值
  152. getSettingValue(val) {
  153. let _this = this
  154. _this.loading = true;
  155. let param = {
  156. PageNumber: this.currentPage,
  157. PageSize: this.pageSize
  158. }, Filters = ''
  159. if (_this.originName) {
  160. Filters += `DatasourceName='${_this.originName}';`
  161. }
  162. if (_this.statusName) {
  163. Filters += `ReadWrite='${_this.statusName}';`
  164. }
  165. if (val) {
  166. Filters += val
  167. }
  168. let index = Filters.lastIndexOf(';')
  169. Filters = Filters.substring(0, index)
  170. param.Filters = Filters !== '' ? Filters : undefined
  171. settingValue(param, res => {
  172. this.tableDate = res.Content
  173. _this.total = res.Total
  174. _this.loading = false;
  175. })
  176. },
  177. //点位测试
  178. getPointTest(list) {
  179. // pointTest(list, res => {
  180. // this.tableDate = res.Content
  181. //
  182. // })
  183. pointTest(list).then(res => {
  184. if (res.data.Result === "failure") {
  185. this.$message.error('执行失败')
  186. this.getSettingValue()
  187. } else {
  188. this.isShowSelect = false
  189. this.tableDate = res.data.Content
  190. }
  191. });
  192. },
  193. changeHandleSelect() {
  194. this.currentPage = 1
  195. this.getSettingValue()
  196. },
  197. handleSelectionChange(val) {
  198. this.multipleSelection = val;
  199. },
  200. //分页更换size
  201. handleSizeChange(val) {
  202. this.currentPage = 1;
  203. this.pageSize = val;
  204. this.getSettingValue()
  205. },
  206. //分页更换页
  207. handleCurrentChange(val) {
  208. this.currentPage = val;
  209. this.getSettingValue()
  210. },
  211. //点击下载
  212. downloads() {
  213. let param = {
  214. method: 'post',
  215. url: `/pointconfig/datasource/pointset-present-download`,
  216. responseType: 'blob',
  217. headers: {
  218. //头信息中的 ProjectId 改为 projectId nh-2021.11.25
  219. projectId: this.projectId
  220. },
  221. data: {},
  222. }
  223. axios(param).then(function (res) {
  224. var blob = new Blob([res.data], {
  225. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  226. });
  227. var fileName = res.headers['content-disposition'];
  228. if (fileName)
  229. fileName = fileName.substring(fileName.indexOf('=') + 1);
  230. if ('download' in document.createElement('a')) { // 非IE下载
  231. const elink = document.createElement('a')
  232. elink.download = fileName
  233. elink.style.display = 'none'
  234. elink.href = URL.createObjectURL(blob)
  235. document.body.appendChild(elink)
  236. elink.click()
  237. URL.revokeObjectURL(elink.href) // 释放URL 对象
  238. document.body.removeChild(elink)
  239. } else { // IE10+下载
  240. navigator.msSaveBlob(blob, fileName)
  241. }
  242. }).catch(function (err) {
  243. })
  244. },
  245. }
  246. }
  247. </script>
  248. <style lang="less" scoped>
  249. #controlTest {
  250. border-top: 5px solid #eee;
  251. height: calc(100% - 5px);
  252. width: 100%;
  253. overflow: hidden;
  254. }
  255. .table-area {
  256. height: calc(100% - 72px);
  257. padding: 0px 10px 10px 10px;
  258. }
  259. .table-area i {
  260. text-align: right;
  261. font-size: 12px;
  262. cursor: pointer;
  263. float: right;
  264. }
  265. .dialog-btn {
  266. display: none;
  267. height: 29px;
  268. }
  269. /deep/ .el-drawer__body {
  270. height: 90%;
  271. overflow-y: auto;
  272. }
  273. /deep/ .el-table__body-wrapper tr:hover {
  274. .dialog-btn {
  275. display: inline;
  276. }
  277. }
  278. /deep/ .el-dialog__body {
  279. padding-bottom: 20px;
  280. }
  281. /deep/ .el-drawer__header > :first-child:focus {
  282. outline: none;
  283. }
  284. </style>