dataDetail_chart.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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="请选择" v-loading="optionLoading"
  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="200">
  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:50, //全部数据量
  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. ],
  93. tableHeader: [],
  94. databaseType: '',
  95. database: [{
  96. value: '选项1',
  97. label: 'hbase'
  98. }, {
  99. value: '选项2',
  100. label: 'influxdb'
  101. }, {
  102. value: '选项3',
  103. label: 'mysql'
  104. }],
  105. currentPage1: 1,
  106. currentPage2: 2,
  107. currentPage3: 3,
  108. currentPage4: 4,
  109. detailVisible: false,
  110. moreVisible: false,
  111. currentSubEquipnameId:'',
  112. subEuipname:'',
  113. currentEquipname:'',
  114. dataListLoading: true,
  115. optionLoading: true,
  116. timer: null
  117. }
  118. },
  119. components:{
  120. detailDia
  121. },
  122. methods: {
  123. // 点击表头查看测点信息
  124. mpQuality(column,event){
  125. if(column.level == 1 && column.property == "properties"){
  126. var columnData = this.tableHeader.filter(item=>{
  127. return item.name == column.label;
  128. })
  129. }
  130. // console.log(columnData);
  131. this.detailVisible = true;
  132. this.$nextTick(() => {
  133. this.$refs.detailDialog.init(columnData);
  134. });
  135. },
  136. confirmEnding(str, target) {
  137. var start = str.length-target.length;
  138. var arr = str.substr(start,target.length);
  139. if(arr == target){
  140. return true;
  141. }
  142. return false;
  143. },
  144. getMore(row){
  145. // console.log(row);
  146. },
  147. // 改变当前子设备选项
  148. selectCurrentpoint(){
  149. if (this.timer !== null) {
  150. clearInterval(this.timer)
  151. this.timer = null
  152. }
  153. this.tableData = []
  154. this.tableHeader = []
  155. for (let i in this.options) {
  156. if (this.options[i].id == this.currentSubEquipnameId){
  157. this.subEuipname = this.options[i].name;
  158. this.hbasetablename = this.options[i].hbasetablename;
  159. // console.log('this.hbasetablename');
  160. // console.log(this.options[0]);
  161. break;
  162. }
  163. }
  164. this.initData();
  165. },
  166. currentChange(currentPage){
  167. this.page=currentPage;
  168. this.initData();
  169. },
  170. sizeChange(currentSize) {
  171. this.size = currentSize;
  172. this.initData();
  173. },
  174. watch(id) {
  175. this.detailVisible = true;
  176. this.$nextTick(() => {
  177. this.$refs.detailDialog.init(id);
  178. });
  179. },
  180. more(id) {
  181. this.moreVisible = true;
  182. this.$nextTick(() => {
  183. this.$refs.moreDialog.init(id);
  184. });
  185. },
  186. // pointnum(row) {
  187. // this.pointnumVisible = true;
  188. // this.$nextTick(() => {
  189. // this.$refs.pointnumDialog.init(row);
  190. // });
  191. // },
  192. // 根据传来的设备currentEquipId找到对应的子设备选项
  193. getSubEquipOption(){
  194. this.getRequest('/subEquipmentManage/getSubEquipmentInfoByEquipmentId/?equipmentId=' + this.currentEquipId).then(resp=>{
  195. if (resp.data){
  196. this.options = resp.data.data;
  197. this.currentSubEquipname = this.options[0].name; //将当前子系统与id设置为下拉框第一个
  198. this.currentSubEquipnameId = this.options[0].id;
  199. this.subEuipname = this.options[0].name;
  200. this.hbasetablename = this.options[0].hbasetablename;
  201. this.optionLoading = false;
  202. // console.log(this.hbasetablename);
  203. this.initData()
  204. }
  205. });
  206. },
  207. // 根据子设备id拿到对应的测点,并展示在table中
  208. initData() {
  209. // this.dataListLoading = true
  210. // this.currentSubEquipnameId = parseInt(this.currentSubEquipnameId);
  211. this.getRequest('/dataQualityMeasurePoint/getMeasurePointBySubEquipmentId/?subEquipmentId=' + this.currentSubEquipnameId + '&page=' + this.page + '&size=' + this.size).then(resp => {
  212. // this.getRequest('/dataList/getMeasurepointInfoBySubEuipId/?SubEuipId=' + this.currentSubEquipnameId + '&page=' + this.page + '&size=' + this.size).then(resp=>{
  213. if (resp) {
  214. this.tableHeader = resp.data.data;
  215. this.dataListLoading = false;
  216. // console.log('this.tableHeader');
  217. // console.log(this.tableHeader);
  218. this.total = resp.data.total;
  219. }
  220. });
  221. this.startGetData()
  222. },
  223. getHbaseData() {
  224. this.getRequest('/hbase/getMpInfoByHbaseTablename/?hbasetablename='+ this.hbasetablename).then(resp=>{
  225. // console.log("----------");
  226. // console.log(this.hbasetablename);
  227. // this.getRequest('/dataList/getMeasurepointInfoBySubEuipId/?SubEuipId=' + this.currentSubEquipnameId + '&page=' + this.page + '&size=' + this.size).then(resp.data=>{
  228. if (resp.data){
  229. var arr = [];
  230. for(let i in resp.data){
  231. var o = {
  232. before: new Array(this.tableHeader.length).fill(""),
  233. after: new Array(this.tableHeader.length).fill(""),
  234. Isproblem:new Array(this.tableHeader.length).fill(""),
  235. };
  236. o["rowKey"] = resp.data[i].date;
  237. var pronumn = Object.keys(resp.data[0]).length;
  238. // for(var j = 0;j<pronumn/2;j++){
  239. for(var j = 0;j<this.tableHeader.length;j++){
  240. for (var key in resp.data[i]){
  241. if(this.confirmEnding(key,"before") && (key.indexOf(pinyin(this.tableHeader[j].name, { toneType: 'none' }).replace(/\s*/g, '')) == 0) ){
  242. // o.before.push(resp.data[i].properties[key]);
  243. // j是索引,1是个数
  244. o.before.splice(j,1,eval("resp.data[i]."+key));
  245. }
  246. if(this.confirmEnding(key,"after") && (key.indexOf(pinyin(this.tableHeader[j].name, { toneType: 'none' }).replace(/\s*/g, '')) == 0) ){
  247. o.after.splice(j,1,eval("resp.data[i]."+key));
  248. // o.after.push(resp.data[i].properties[key]);
  249. }
  250. }
  251. }
  252. for (var k = 0; k < this.tableHeader.length; k++) {
  253. if(o.before[k] !== "" ){
  254. o.Isproblem.splice(k,1,o.before[k] == o.after[k] ? "否" : "是")
  255. }
  256. }
  257. arr.push(o);
  258. }
  259. // console.log(arr);
  260. this.tableData=arr;
  261. }
  262. // console.log('this.tableData');
  263. // console.log(this.tableData);
  264. });
  265. },
  266. startGetData() {
  267. this.timer = setInterval(()=> {
  268. this.getHbaseData()
  269. }, 2000)
  270. },
  271. },
  272. mounted(){
  273. this.currentEquipId = this.$route.query.equipmentId
  274. // this.currentEquipId = window.sessionStorage.getItem("dataList_currentEquipId");
  275. // 获取子设备选项
  276. this.getSubEquipOption();
  277. // this.currentSubEquipname = this.options[0].name; //将当前子系统与id设置为下拉框第一个
  278. // this.currentSubEquipnameId = this.options[0].id;
  279. // this.initData()
  280. },
  281. beforeDestroy() {
  282. clearInterval(this.timer)
  283. this.timer = null
  284. console.log("chart kill")
  285. },
  286. }
  287. </script>
  288. <style scoped>
  289. </style>>