From 35e855008db4be8a859d674ff937db4131760903 Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期四, 25 四月 2024 21:54:24 +0800
Subject: [PATCH] 甘特图
---
src/views/mdc/processParam/index.vue | 322 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 311 insertions(+), 11 deletions(-)
diff --git a/src/views/mdc/processParam/index.vue b/src/views/mdc/processParam/index.vue
index 2f42ed9..4f3d450 100644
--- a/src/views/mdc/processParam/index.vue
+++ b/src/views/mdc/processParam/index.vue
@@ -1,21 +1,321 @@
<!--
* @Date: 2024-04-09 22:11:21
* @LastEditors: Sneed
- * @LastEditTime: 2024-04-09 22:12:14
- * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/realtime-status/index.vue
+ * @LastEditTime: 2024-04-25 21:53:21
+ * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/processParam/index.vue
+ 瀹炴椂鐪嬫澘
-->
<template>
- <div>
- 瀹炴椂鐪嬫澘
- </div>
+ <el-main>
+ <el-card shadow="never">
+ <el-container style="height: 100%;">
+ <el-aside width="300px" style="height: 100%;">
+ <el-container>
+ <el-main class="nopadding">
+ <el-row style="margin-top: 14px;">
+ 宸ヤ綅
+ </el-row>
+ <MYTree v-model="treeChecked" @loaded="query"></MYTree>
+ </el-main>
+ </el-container>
+ </el-aside>
+ <el-container>
+ <el-main v-show="list.length > 0">
+ <el-row>
+ <el-col :span="4">
+ <!-- <el-switch v-model="isShowTable" class="mb-2" active-text="鏁版嵁琛�" inactive-text="缁熻鍥�" /> -->
+ </el-col>
+ <el-col :span="20" style='text-align: right;'>
+ <el-date-picker :max-range="3" :clearable="false" value-format="YYYY-MM-DD"
+ style="width: 250px" v-model="time" type="daterange" range-separator="-"
+ start-placeholder="" end-placeholder="" :disabled-date="disabledDate"
+ @calendar-change="change" />
+ </el-col>
+ </el-row>
+ <TimeLine v-model="timeRange" ref="timeLine"></TimeLine>
+ <el-collapse v-model="activeList" accordion>
+ <el-collapse-item :title="item.description" :name="index" v-for="(item, index) in list"
+ :key="index">
+ <div>
+ <el-button>鏌ョ湅鏁版嵁</el-button>
+ </div>
+ <scEcharts v-if="item?.dayCharts?.xAxis" style="width:100%" height="300px"
+ :option="item?.dayCharts">
+ </scEcharts>
+ </el-collapse-item>
+ </el-collapse>
+ </el-main>
+ <el-main v-show="list.length == 0">
+ <el-empty description="鏆傛棤鏁版嵁" />
+ </el-main>
+ </el-container>
+ </el-container>
+ </el-card>
+ </el-main>
</template>
<script>
- export default {
-
- }
+import moment from 'moment'
+import scEcharts from '@/components/scEcharts';
+import TimeLine from './TimeLine.vue'
+import MYTree from '../MYTree.vue'
+// const rawData = [
+// [100],
+// [320],
+// [220],
+// [150],
+// [820]
+// ]
+// const totalData = [];
+// for (let i = 0; i < rawData[0].length; ++i) {
+// let sum = 0;
+// for (let j = 0; j < rawData.length; ++j) {
+// sum += rawData[j][i];
+// }
+// totalData.push(sum);
+// }
+// const series = [
+// '杩愯',
+// '杩愯',
+// '杩愯',
+// '寰呮満',
+// '杩愯'
+// ].map((name, sid) => {
+// return {
+// name,
+// type: 'bar',
+// stack: 'total',
+// barWidth: '20px',
+// label: {
+// show: true,
+// formatter: (params) => Math.round(params.value * 1000) / 10 + '%'
+// },
+// data: rawData[sid].map((d, did) =>
+// totalData[did] <= 0 ? 0 : d / totalData[did]
+// )
+// };
+// });
+// let data = {
+// "collectItem": "璁惧鐘舵��",
+// "collectRealItem": "DeviceStatus",
+// "data": [
+// {
+// "time": "2024-04-24 10:00:00",
+// "name": "杩愯",
+// "color": "#73D13D",
+// "value": "2"
+// },
+// {
+// "time": "2024-04-24 10:30:00",
+// "name": "杩愯",
+// "color": "#73D13D",
+// "value": "2"
+// },
+// {
+// "time": "2024-04-24 11:00:00",
+// "name": "杩愯",
+// "color": "#73D13D",
+// "value": "2"
+// },
+// {
+// "time": "2024-04-24 11:30:00",
+// "name": "寰呮満",
+// "color": "#FFC53D",
+// "value": "3"
+// },
+// {
+// "time": "2024-04-24 12:00:00",
+// "name": "寰呮満",
+// "color": "#FFC53D",
+// "value": "3"
+// }
+// ]
+// }
+// const series = data.data.map(item => ({
+// name: item.name,
+// label: {
+// show: true,
+// },
+// barWidth: '20px',
+// type: 'bar',
+// stack: 'duration',
+// itemStyle: {
+// color: item.color,
+// borderColor: item.color,
+// },
+// zlevel: -1,
+// data: [item.time]
+// }))
+// console.log('>>>>>>>>????', series)
+export default {
+ components: {
+ TimeLine,
+ MYTree,
+ scEcharts
+ },
+ watch: {
+ treeChecked() {
+ this.query()
+ },
+ time() {
+ this.query()
+ },
+ timeRange(val) {
+ console.log(val, '>>>>>>>???/')
+ this.queryChart()
+ }
+ },
+ data() {
+ return {
+ isShowTable: false,
+ list: [],
+ activeList: [0, 1, 2, 3, 4, 5, 6, 7, 8],
+ timeRange: '',
+ treeChecked: [],
+ timeStart: moment().format('YYYY-MM-DD'),
+ time: [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
+ disabledDate: Date => {
+ let max = moment(this.timeStart, 'YYYY-MM-DD').add(3, 'd').format('YYYY-MM-DD')
+ let min = moment(this.timeStart, 'YYYY-MM-DD').subtract(3, 'd').format('YYYY-MM-DD')
+ return !moment(Date).isBetween(min, max);
+ },
+ dayCharts1: {
+ },
+ dayCharts2: {
+ },
+ dayCharts3: {
+ },
+ dayCharts4: {
+ },
+ dayCharts5: {
+ },
+ }
+ },
+ created() {
+ console.log('---------')
+ // console.log(series)
+ },
+ methods: {
+ init() {
+ this.$HTTP.get('/api/blade-mdc/process-parameter').then(res => {
+ if (res.code === 200) {
+ this.legend = res.data
+ }
+ })
+ },
+ query() {
+ this.$refs?.timeLine?.init({
+ dates: this.time,
+ workstationId: this.treeChecked.toString()
+ })
+ this.$HTTP.get('/api/blade-mdc/process-parameter/param', { workstationId: this.treeChecked.toString() }).then(res => {
+ if (res.code === 200) {
+ this.list = res.data
+ this.queryChart()
+ }
+ })
+ },
+ queryChart() {
+ this.queryChart1()
+ },
+ queryChart1() {
+ this.dayCharts = {}
+ this.$HTTP.post('/api/blade-mdc/process-parameter/chart/dmp-item', {
+ methodEnum: "HOUR",
+ startTime: this.timeRange.startTime,
+ endTime: this.timeRange.endTime,
+ workstationId: this.treeChecked.toString(),
+ workstationName: '461',
+ dmpDTO: {
+ "collectItem": "璁惧鐘舵��",
+ "collectRealItem": "DeviceStatus",
+ "legend": null,
+ "chartType": "line",
+ "id": "1699225758611169281",
+ "dmpDeviceId": "591",
+ "name": "DeviceStatus",
+ "description": "璁惧鐘舵��",
+ "dataType": 3,
+ "wcsDataType": 1,
+ "processParameter": true,
+ "data": [],
+ "timeRange": [
+ "2024-04-25 00:00:00",
+ "2024-04-25 02:00:00"
+ ]
+ }
+ }).then(res => {
+ let data = res.data
+ let total = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime)))
+ let start = this.timeRange.startTime
+ let series = data.data.map((item, i) => {
+ let current = Math.abs(moment(start).diff(moment(item.time)))
+ console.log(current, total)
+ start = item.time
+ let name = i === 0 ? '' : data.data[i - 1].name
+ let color = !name ? 'transparent' : data.data[i - 1].color
+ return {
+ name,
+ type: 'bar',
+ stack: 'total',
+ barWidth: '20px',
+ data: [current / total * 60],
+ label: {
+ show: true,
+ position: 'center',
+ color: '#FFF',
+ formatter: params => {
+ if (i == 0) return ''
+ return `寮�濮嬫椂闂�${moment(data.data[i - 1].time).format('HH:mm')}-${moment(item.time).format('HH:mm')}`
+ }
+ },
+ itemStyle: {
+ color, // 杩欎竴琛屽浐瀹氱殑棰滆壊鍊奸渶瑕佸垹闄ゆ垨娉ㄩ噴
+ borderColor: '#FFF',
+ borderWidth: 1
+ },
+ }
+ })
+ let arr = [12, 8, 9, 4]
+ let splitNumber = arr[Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))) / 3600000 - 1]
+ let dayCharts = {
+ legend: [
+ ],
+ title: {
+ text: '璁惧鐘舵�佺粺璁″浘',
+ subtext: '',
+ },
+ yAxis: {
+ type: 'category',
+ data: ['']
+ },
+ series,
+ xAxis: {
+ type: 'value',
+ splitNumber,
+ axisLabel: {
+ formatter: (value, index) => {
+ let start = moment(this.timeRange.startTime)
+ let ms = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))) / splitNumber * index
+ // console.log(ms, index, '>>>>>>>>>鍒诲害', Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))))
+ return ''
+ }
+ },
+ },
+ }
+ let index = this.list.findIndex(item => item.name === 'DeviceStatus')
+ this.list[index] = Object.assign({
+ ...this.list[index],
+ dayCharts
+ })
+ console.log('>>>>>>>>>>>>>>.......', series)
+ })
+ },
+ change(e) {
+ this.timeStart = e[0] || moment().format('YYYY-MM-DD')
+ }
+ },
+}
</script>
-<style lang="scss" scoped>
-
-</style>
\ No newline at end of file
+<style lang="scss" scoped></style>
\ No newline at end of file
--
Gitblit v1.9.3