Detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="1200"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. :footer="null"
  10. >
  11. <div class="table-operator" style="margin-bottom: 8px;">
  12. <a-row>
  13. <a-col :md="16">
  14. <!-- <a-date-picker
  15. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  16. @change="onChange"
  17. v-model="searchDay"/>-->
  18. <a-select default-value="1" v-model="searchDay" style="width: 120px" @change="onChange">
  19. <a-select-option value="1">
  20. 5分钟
  21. </a-select-option>
  22. <a-select-option value="2">
  23. 15分钟
  24. </a-select-option>
  25. <a-select-option value="3">
  26. 1小时
  27. </a-select-option>
  28. <!-- <a-select-option value="4">
  29. 3小时
  30. </a-select-option>
  31. <a-select-option value="5">
  32. 6小时
  33. </a-select-option>
  34. <a-select-option value="6">
  35. 12小时
  36. </a-select-option>
  37. <a-select-option value="7">
  38. 24小时
  39. </a-select-option>
  40. <a-select-option value="8">
  41. 2天
  42. </a-select-option>
  43. <a-select-option value="9">
  44. 7天
  45. </a-select-option>
  46. <a-select-option value="10">
  47. 30天
  48. </a-select-option>-->
  49. </a-select>
  50. <a-button
  51. style="margin-left: 8px"
  52. v-if="$auth('remote-opc-logs-export')"
  53. type="primary"
  54. icon="download"
  55. :loading="confirmLoading"
  56. @click="doExport">导出
  57. </a-button>
  58. </a-col>
  59. </a-row>
  60. </div>
  61. <a-divider>详情</a-divider>
  62. <detail-list title="" :col="2">
  63. <detail-list-item term="点位id">{{ model.sbId }}</detail-list-item>
  64. <detail-list-item term="点位名称">{{ model.sbName }}</detail-list-item>
  65. <detail-list-item term="点位">{{ model.positionNum }}</detail-list-item>
  66. <detail-list-item term="类型">{{ BaseTool.Object.getField(map,model.type) }}</detail-list-item>
  67. <detail-list-item term="描述">{{ model.description }}</detail-list-item>
  68. <detail-list-item term="系数">{{ model.ratio }}</detail-list-item>
  69. <detail-list-item term="单位">{{ model.unit }}</detail-list-item>
  70. <!-- <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
  71. <detail-list-item term="年">{{ model.year }}</detail-list-item>
  72. <detail-list-item term="月">{{ model.month }}</detail-list-item>
  73. <detail-list-item term="日">{{ model.day }}</detail-list-item>
  74. <detail-list-item term="时">{{ model.hour }}</detail-list-item>
  75. <detail-list-item term="实时数值">{{ model.result }}</detail-list-item>
  76. <detail-list-item term="创建人">{{ model.createdUserId }}</detail-list-item>
  77. <detail-list-item term="更新人">{{ model.updateUserId }}</detail-list-item>
  78. <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>-->
  79. </detail-list>
  80. <a-divider orientation="left">趋势图</a-divider>
  81. <div style="width: 100%">
  82. <div id="container"></div>
  83. </div>
  84. <a-divider orientation="left">数据明细</a-divider>
  85. <div>
  86. <a-table
  87. bordered
  88. :data-source="chartsData"
  89. :columns="columns"
  90. tableLayout="auto"
  91. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  92. rowKey="time">
  93. </a-table>
  94. </div>
  95. </a-modal>
  96. </template>
  97. <script>
  98. import { Chart } from '@antv/g2'
  99. import DetailList from '@/components/tools/DetailList'
  100. import { queryInfluxDBHistory, exportInfluxDBHistory } from '@/api/influxDB/influxDB'
  101. const DetailListItem = DetailList.Item
  102. export default {
  103. name: 'RemoteDegreeLogDetail',
  104. components: {
  105. DetailList,
  106. Chart,
  107. DetailListItem
  108. },
  109. data () {
  110. return {
  111. confirmLoading: false,
  112. mdl: {},
  113. modalTitle: null,
  114. searchDay: 1,
  115. map: {},
  116. visible: false,
  117. // 下拉框map
  118. model: {
  119. 'sbId': null,
  120. 'sbName': null,
  121. 'positionNum': null,
  122. 'type': null,
  123. 'description': null,
  124. 'result': null,
  125. 'ratio': null,
  126. 'unit': null,
  127. 'time': null,
  128. 'month': null,
  129. 'day': null,
  130. 'hour': null,
  131. 'remark': null,
  132. 'createdUserId': null,
  133. 'updateUserId': null,
  134. 'updateTime': null
  135. },
  136. // 表头
  137. chart: null, // 创建一个chart变量
  138. chartsData: [],
  139. columns: [
  140. {
  141. title: '时间',
  142. dataIndex: 'time'
  143. },
  144. {
  145. title: '数值',
  146. dataIndex: 'value'
  147. }
  148. ]
  149. }
  150. },
  151. watch: {
  152. chartsData: {
  153. handler (newDate) {
  154. this.chart.changeData(newDate)
  155. },
  156. deep: true
  157. }
  158. },
  159. created () {
  160. // 下拉框map
  161. this.map = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_OPC)
  162. },
  163. methods: {
  164. base (record) {
  165. this.visible = true
  166. this.confirmLoading = true
  167. this.modalTitle = '详情'
  168. this.model = record
  169. this.onChange(1)
  170. },
  171. getCharts () {
  172. this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
  173. const data1 = [
  174. { time: '1991', value: 3 },
  175. { time: '1992', value: 4 },
  176. { time: '1993', value: 3.5 },
  177. { time: '1994', value: 5 },
  178. { time: '1995', value: 4.9 },
  179. { time: '1996', value: 6 },
  180. { time: '1997', value: 7 },
  181. { time: '1998', value: 9 },
  182. { time: '1999', value: 13 }
  183. ]
  184. // 初始化,指定容器DOM id、高度
  185. this.chart = new Chart({
  186. container: 'container',
  187. autoFit: true,
  188. width: 1600, // 图标宽度
  189. height: 400, // 图表高度
  190. padding: [40, 40, 40, 40]// 图表内边距,依次为:上,右,下,左
  191. })
  192. // data 数据
  193. this.chart.data(this.chartsData)
  194. // scale 度量配置, 生成坐标轴刻度值
  195. // tooltip 提示信息,是指当鼠标悬停在图形上时,以提示框的形式展示该点的数据
  196. this.chart.tooltip({
  197. showCrosshairs: true, // 展示 Tooltip 辅助线
  198. shared: true
  199. })
  200. // 几何图形 Geometry;
  201. // 使用 line 绘制折线图
  202. // 使用 position 通道将对应的变量映射到 x 和 y 位置空间上;
  203. // 使用label 展示value值;
  204. // this.chart.line().position('time*value').label('value')
  205. this.chart.line().position('time*value')
  206. // 使用 point 绘制点
  207. // 使用 position 将对应的变量映射到 x 和 y 位置空间上;
  208. this.chart.point().position('time*value')
  209. this.chart.render()
  210. },
  211. onChange (value) {
  212. this.confirmLoading = true
  213. this.searchDay = value
  214. const parameter = {}
  215. parameter.id = this.model.id
  216. parameter.type = value
  217. queryInfluxDBHistory(parameter).then(res => {
  218. this.model = res.data
  219. if (this.model.dataJsonStr == null) {
  220. this.$message.info('无数据')
  221. }
  222. this.chartsData = JSON.parse(this.model.dataJsonStr)
  223. // this.getCharts(this.chartsData)
  224. this.confirmLoading = false
  225. }).catch(() => {
  226. this.confirmLoading = false
  227. })
  228. },
  229. doExport () {
  230. this.confirmLoading = true
  231. exportInfluxDBHistory(this.model).then(file => {
  232. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  233. this.confirmLoading = false
  234. })
  235. },
  236. handleCancel () {
  237. this.visible = false
  238. this.confirmLoading = false
  239. this.searchDay = 1
  240. this.chart = null
  241. this.chartsData = []
  242. this.$emit('ok')
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="less" scoped>
  248. .extra-wrapper {
  249. line-height: 55px;
  250. padding-right: 24px;
  251. .extra-item {
  252. display: inline-block;
  253. margin-right: 24px;
  254. a {
  255. margin-left: 24px;
  256. }
  257. }
  258. }
  259. .antd-pro-pages-dashboard-analysis-twoColLayout {
  260. position: relative;
  261. display: flex;
  262. display: block;
  263. flex-flow: row wrap;
  264. }
  265. .antd-pro-pages-dashboard-analysis-salesCard {
  266. height: calc(100% - 24px);
  267. /deep/ .ant-card-head {
  268. position: relative;
  269. }
  270. }
  271. .dashboard-analysis-iconGroup {
  272. i {
  273. margin-left: 16px;
  274. color: rgba(0,0,0,.45);
  275. cursor: pointer;
  276. transition: color .32s;
  277. color: black;
  278. }
  279. }
  280. .analysis-salesTypeRadio {
  281. position: absolute;
  282. right: 54px;
  283. bottom: 12px;
  284. }
  285. </style>