dataDetail_chart.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div>
  3. <div style="margin-top:8px">
  4. <span style="font-size: 10px;">搜索:</span>
  5. <el-select style="width: 200px" v-model="currentSubEquipnameId" placeholder="请选择"
  6. @change="selectCurrentpoint()">
  7. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
  8. </el-option>
  9. </el-select>
  10. </div>
  11. <template>
  12. <el-table :data="tableData" style="width: 100%" @header-click="mpQuality" v-loading="dataListLoading">
  13. <el-table-column prop="rowKey" label="日期" width="150">
  14. <template slot-scope="scope">
  15. {{tableData[scope.$index].rowKey}}
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="properties" :label="item.name" align="center"
  19. v-for="(item, index) in tableHeader" :key="item.mpId">
  20. <el-table-column label="是否存在问题" width="80">
  21. <template slot-scope="scope">
  22. <div :style="tableData[scope.$index].Isproblem[index]=='是'?'color:#FF0000;':'color:#000000;'">
  23. {{tableData[scope.$index].Isproblem[index]}}
  24. </div>
  25. <!-- {{tableData[scope.$index].properties[index].isProblem}} -->
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="治理前" width="80">
  29. <template slot-scope="scope">
  30. {{tableData[scope.$index].before[index]}}
  31. <!-- {{tableData[scope.$index].properties[index].before}} -->
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="治理后" width="80">
  35. <template slot-scope="scope">
  36. {{tableData[scope.$index].after[index]}}
  37. <!-- {{tableData[scope.$index].properties[index].after}} -->
  38. </template>
  39. </el-table-column>
  40. </el-table-column>
  41. <!-- <el-table-column prop="classify" label="所属分类" header-align="center" align="center" width="120">
  42. </el-table-column> -->
  43. <!-- <el-table-column label="测点值" header-align="center" align="center" width="120">
  44. <template slot-scope="scope">
  45. <el-button type="text" size="small" @click="pointnum(scope.row)">...</el-button>
  46. </template>
  47. </el-table-column> -->
  48. <el-table-column label="更多" header-align="center" align="center" width="120">
  49. <template slot-scope="scope">
  50. <el-button type="text" size="small" @click="more(scope.row)">...</el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. </template>
  55. <!-- 分页区域 -->
  56. <el-pagination background @current-change="currentChange" @size-change="sizeChange" :current-page="page"
  57. :page-size="size" layout="sizes, prev, pager, next, jumper, ->, total, slot" :total="total">
  58. </el-pagination>
  59. <detailDia v-if="detailVisible" ref="detailDialog"></detailDia>
  60. </div>
  61. </template>
  62. <script>
  63. import { pinyin } from 'pinyin-pro';
  64. // import {
  65. // getFullChars
  66. // } from '@/utils/convertToPinyin'
  67. import detailDia from "./detailDia";
  68. export default {
  69. name:"dataDetail_chart",
  70. data() {
  71. return {
  72. page:1, //当前第几页
  73. size:10, //当前每页页数
  74. total:100, //全部数据量
  75. visible: false,
  76. // 当前下拉选框对应的hbase表名
  77. hbasetablename:'',
  78. // pointnumVisible:false,
  79. value: '',
  80. currentEquipId:0,
  81. options: [{
  82. id: 1,
  83. name: '皮带张力'
  84. }, {
  85. id: 2,
  86. name: '1#滚筒'
  87. }, {
  88. id: 3,
  89. name: '2#滚筒'
  90. }],
  91. tableData:[{
  92. before:[1,2,3],
  93. after:[4,5,6]
  94. }
  95. ],
  96. tableHeader: [],
  97. databaseType: '',
  98. database: [{
  99. value: '选项1',
  100. label: 'hbase'
  101. }, {
  102. value: '选项2',
  103. label: 'influxdb'
  104. }, {
  105. value: '选项3',
  106. label: 'mysql'
  107. }],
  108. currentPage1: 1,
  109. currentPage2: 2,
  110. currentPage3: 3,
  111. currentPage4: 4,
  112. detailVisible: false,
  113. moreVisible: false,
  114. currentSubEquipnameId:'',
  115. subEuipname:'',
  116. currentEquipname:'',
  117. dataListLoading: false,
  118. timer: null
  119. }
  120. },
  121. components:{
  122. detailDia
  123. },
  124. methods: {
  125. // 点击表头查看测点信息
  126. mpQuality(column,event){
  127. if(column.level == 1 && column.property == "properties"){
  128. var columnData = this.tableHeader.filter(item=>{
  129. return item.name == column.label;
  130. })
  131. }
  132. // console.log(columnData);
  133. this.detailVisible = true;
  134. this.$nextTick(() => {
  135. this.$refs.detailDialog.init(columnData);
  136. });
  137. },
  138. confirmEnding(str, target) {
  139. var start = str.length-target.length;
  140. var arr = str.substr(start,target.length);
  141. if(arr == target){
  142. return true;
  143. }
  144. return false;
  145. },
  146. getMore(row){
  147. // console.log(row);
  148. },
  149. // 改变当前子设备选项
  150. selectCurrentpoint(){
  151. if (this.timer !== null) {
  152. clearInterval(this.timer)
  153. this.timer = null
  154. }
  155. this.tableData = []
  156. this.tableHeader = []
  157. for (let i in this.options) {
  158. if (this.options[i].id == this.currentSubEquipnameId){
  159. this.subEuipname = this.options[i].name;
  160. this.hbasetablename = this.options[i].hbasetablename;
  161. // console.log('this.hbasetablename');
  162. // console.log(this.options[0]);
  163. break;
  164. }
  165. }
  166. this.initData();
  167. },
  168. currentChange(currentPage){
  169. this.page=currentPage;
  170. this.initData();
  171. },
  172. sizeChange(currentSize) {
  173. this.size = currentSize;
  174. this.initData();
  175. },
  176. watch(id) {
  177. this.detailVisible = true;
  178. this.$nextTick(() => {
  179. this.$refs.detailDialog.init(id);
  180. });
  181. },
  182. more(id) {
  183. this.moreVisible = true;
  184. this.$nextTick(() => {
  185. this.$refs.moreDialog.init(id);
  186. });
  187. },
  188. // pointnum(row) {
  189. // this.pointnumVisible = true;
  190. // this.$nextTick(() => {
  191. // this.$refs.pointnumDialog.init(row);
  192. // });
  193. // },
  194. // 根据传来的设备currentEquipId找到对应的子设备选项
  195. getSubEquipOption(){
  196. this.getRequest('/subEquipmentManage/getSubEquipmentInfoByEquipmentId/?equipmentId=' + this.currentEquipId).then(resp=>{
  197. if (resp.data){
  198. this.options = resp.data.data;
  199. this.currentSubEquipname = this.options[0].name; //将当前子系统与id设置为下拉框第一个
  200. this.currentSubEquipnameId = this.options[0].id;
  201. this.subEuipname = this.options[0].name;
  202. this.hbasetablename = this.options[0].hbasetablename;
  203. // console.log(this.hbasetablename);
  204. this.initData()
  205. }
  206. });
  207. },
  208. // 根据子设备id拿到对应的测点,并展示在table中
  209. initData() {
  210. this.dataListLoading = true
  211. // this.currentSubEquipnameId = parseInt(this.currentSubEquipnameId);
  212. this.getRequest('/dataQualityMeasurePoint/getMeasurePointBySubEquipmentId/?subEquipmentId=' + this.currentSubEquipnameId + '&page=' + this.page + '&size=' + this.size).then(resp => {
  213. // this.getRequest('/dataList/getMeasurepointInfoBySubEuipId/?SubEuipId=' + this.currentSubEquipnameId + '&page=' + this.page + '&size=' + this.size).then(resp=>{
  214. if (resp) {
  215. this.tableHeader = resp.data.data;
  216. // console.log('this.tableHeader');
  217. // console.log(this.tableHeader);
  218. this.total = resp.data.total;
  219. }
  220. });
  221. this.dataListLoading = false
  222. this.startGetData()
  223. },
  224. getHbaseData() {
  225. this.getRequest('/hbase/getMpInfoByHbaseTablename/?hbasetablename='+ this.hbasetablename).then(resp=>{
  226. // console.log("----------");
  227. // console.log(this.hbasetablename);
  228. // this.getRequest('/dataList/getMeasurepointInfoBySubEuipId/?SubEuipId=' + this.currentSubEquipnameId + '&page=' + this.page + '&size=' + this.size).then(resp.data=>{
  229. if (resp.data){
  230. var arr = [];
  231. for(let i in resp.data){
  232. var o={
  233. before: [],
  234. after: [],
  235. Isproblem:[]
  236. };
  237. o["rowKey"] = resp.data[i].date;
  238. var pronumn = Object.keys(resp.data[0]).length;
  239. // for(var j = 0;j<pronumn/2;j++){
  240. for(var j = 0;j<this.tableHeader.length;j++){
  241. for (var key in resp.data[i]){
  242. if(this.confirmEnding(key,"before") && (key.indexOf(pinyin(this.tableHeader[j].name, { toneType: 'none' }).replace(/\s*/g, '')) == 0) ){
  243. // o.before.push(resp.data[i].properties[key]);
  244. // j是索引,1是个数
  245. o.before.splice(j,1,eval("resp.data[i]."+key));
  246. }
  247. if(this.confirmEnding(key,"after") && (key.indexOf(pinyin(this.tableHeader[j].name, { toneType: 'none' }).replace(/\s*/g, '')) == 0) ){
  248. o.after.splice(j,1,eval("resp.data[i]."+key));
  249. // o.after.push(resp.data[i].properties[key]);
  250. }
  251. }
  252. }
  253. for(var k = 0;k<this.tableHeader.length;k++){
  254. o.Isproblem.push(o.before[k]==o.after[k]?"否":"是")
  255. }
  256. arr.push(o);
  257. }
  258. // console.log(arr);
  259. this.tableData=arr;
  260. }
  261. // console.log('this.tableData');
  262. // console.log(this.tableData);
  263. });
  264. },
  265. startGetData() {
  266. this.timer = setInterval(()=> {
  267. this.getHbaseData()
  268. }, 2000)
  269. },
  270. },
  271. mounted(){
  272. this.currentEquipId = this.$route.query.equipmentId
  273. // this.currentEquipId = window.sessionStorage.getItem("dataList_currentEquipId");
  274. // 获取子设备选项
  275. this.getSubEquipOption();
  276. // this.currentSubEquipname = this.options[0].name; //将当前子系统与id设置为下拉框第一个
  277. // this.currentSubEquipnameId = this.options[0].id;
  278. // this.initData()
  279. },
  280. beforeDestroy() {
  281. clearInterval(this.timer)
  282. this.timer = null
  283. console.log("chart kill")
  284. },
  285. }
  286. </script>
  287. <style scoped>
  288. </style>>