lzhe
2024-04-25 fc4b9d3aec93c8552484f2264689c68662e0d3aa
Merge branch 'master' of http://www.beijingsoft.cn:9090/r/smart-web
已修改2个文件
326 ■■■■■ 文件已修改
src/views/mdc/processParam/TimeLine.vue 88 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/processParam/index.vue 238 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/processParam/TimeLine.vue
@@ -1,11 +1,11 @@
<!--
 * @Date: 2024-04-23 20:03:41
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-23 23:03:45
 * @LastEditTime: 2024-04-24 20:48:55
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/processParam/TimeLine.vue
-->
<template>
    <el-main>
    <el-main style="padding: 0 30px;">
        <el-row>
            <el-col :span="1">
                <el-slider v-model="step" :min="1" :max="4" :step="1" show-stops />
@@ -14,7 +14,8 @@
        <div class="timeline-box">
            <div class="timeline-box-item" v-for="item in dateList" :key="item.startTime" :style="{
                width: item.width + '%',
                background: item.color
                background: item.color,
                left: item.left + '%'
            }">
                {{ item.shiftName }}
            </div>
@@ -24,7 +25,10 @@
                last: lines.length - 1 === index,
                active: index === active
            }" v-for="(item, index) in lines" :key="index">
                <!-- {{ item.title }} -->
                <div class="title">{{ item.title }}</div>
                <div class="date">
                    <p>{{ item.date }}</p>
                </div>
            </div>
        </div>
    </el-main>
@@ -56,10 +60,17 @@
        },
        changeActive(index) {
            this.active = index
            this.$emit('update:modelValue', this.lines[index])
        },
        getColor(v) {
            if (v.shiftIndex === 1) return { color: 'rgb(211, 174, 248)' }
            return { color: 'rgb(233, 241, 208)' }
        },
        setDate(v) {
            if (moment(v.startTime).format('HH:mm:ss') === '00:00:00') return {
                dateTitle: moment(v.startTime).format('MM-DD')
            }
            return {}
        },
        setLines() {
            this.lines = []
@@ -67,17 +78,16 @@
            let max = moment(`${this.params.dates[1]} 24:00:00`, 'YYYY-MM-DD HH:mm:ss')
            let total = max.diff(min)
            let lineNum = total / (this.step * 60 * 60 * 1000)
            console.log(total, lineNum)
            let date = ''
            for (let i = 0; i < lineNum; i++) {
                let currentDate = min.add(this.step, 'h').format('YYYY-MM-DD')
                let currentDate = min.format('MM-DD')
                this.lines.push({
                    date: currentDate === date ? '' : currentDate,
                    title: min.format('HH:mm')
                    date: min.format('HH:mm').endsWith('00:00') ? min.format('MM-DD') : '',
                    title: min.format('HH:mm'),
                    startTime: min.format('YYYY-MM-DD HH:mm:ss'),
                    endTime: min.add(this.step, 'h').format('YYYY-MM-DD HH:mm:ss')
                })
                date = currentDate
                this.changeActive(0)
            }
            console.log(this.lines, '>>>>>>.1')
        },
        queryTime(data) {
            if (!data.workstationId) return
@@ -90,12 +100,14 @@
                    let full = moment(`${this.params.dates[0]} 00:00:00`, 'YYYY-MM-DD HH:mm:ss').diff(moment(`${this.params.dates[1]} 24:00:00`, 'YYYY-MM-DD HH:mm:ss'))
                    this.dateList = res.data.filter(v => {
                        return moment(v.startTime).isBetween(min, max) || moment(v.endTime).isBetween(min, max)
                    }).map(v => {
                    }).map((v, i) => {
                        if (moment(v.startTime).isBetween(min, max) && moment(v.endTime).isBetween(min, max)) {
                            let current = moment(v.startTime, 'YYYY-MM-DD HH:mm:ss').diff(moment(v.endTime, 'YYYY-MM-DD HH:mm:ss'))
                            return {
                                ...v,
                                left: moment(min, 'YYYY-MM-DD HH:mm:ss').diff(moment(v.startTime, 'YYYY-MM-DD HH:mm:ss')) / full * 100,
                                ...this.getColor(v),
                                ...this.setDate(v),
                                width: (current / full * 100).toFixed(2)
                            }
                        } else if (moment(v.startTime).isBetween(min, max)) {
@@ -104,6 +116,8 @@
                                ...v,
                                ...this.getColor(v),
                                endTime: max,
                                ...this.setDate(v),
                                left: moment(min, 'YYYY-MM-DD HH:mm:ss').diff(moment(v.startTime, 'YYYY-MM-DD HH:mm:ss')) / full * 100,
                                width: (current / full * 100).toFixed(2)
                            }
                        } else {
@@ -112,12 +126,13 @@
                                ...v,
                                ...this.getColor(v),
                                startTime: min,
                                ...this.setDate(v),
                                left: moment(min, 'YYYY-MM-DD HH:mm:ss').diff(moment(min, 'YYYY-MM-DD HH:mm:ss')) / full * 100,
                                width: (current / full * 100).toFixed(2)
                            }
                        }
                    })
                    console.log(this.dateList, '>>>>>>')
                }
            })
        }
@@ -128,37 +143,70 @@
<style lang="scss" scoped>
.timeline-box {
    height: 20px;
    display: flex;
    // display: flex;
    position: relative;
    background: #d8e8e8;
    &-item {
        position: absolute;
        height: 22px;
        line-height: 22px;
        text-align: center;
        flex: 0 0 auto;
    }
}
.timeline-line {
    display: flex;
    height: 20px;
    height: 50px;
    position: relative;
    top: -20px;
    width: 100%;
    &-item {
        flex: 1 1 auto;
        height: 20px;
        padding: 20px 3px 0;
        position: relative;
        box-sizing: border-box;
        border: 1px solid transparent;
        &>div.title {
            position: absolute;
            z-index: 9;
            top: 15px;
            left: 0;
            transform: rotate(-45deg) translateX(-50%);
        }
        &>div.date {
            position: absolute;
            z-index: 9;
            top: 50px;
            left: 0;
            transform: translateX(-50%);
            p {
                white-space: pre;
            }
        }
        &:hover,
        &.active {
            height: 18px;
            box-sizing: border-box;
            border: 1px solid red;
        }
    }
    .timeline-line-item:hover,
    .timeline-line-item.active {
        border: 1px solid red;
    }
    &-item::before {
        content: "";
        position: absolute;
        left: 0;
        top: 20px;
        width: 1px;
        height: 10px;
        background: #ccc;
src/views/mdc/processParam/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-04-09 22:11:21
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-23 21:40:53
 * @LastEditTime: 2024-04-24 23:41:35
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/processParam/index.vue
 实时看板
-->
@@ -20,16 +20,40 @@
                    </el-container>
                </el-aside>
                <el-container>
                    <el-main>
                    <el-main v-show="list.length > 0">
                        <el-row>
                            <el-col style='text-align: right;'>
                            <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 ref="timeLine"></TimeLine>
                        <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 style="width:100%" height="300px" :option="dayCharts">
                                </scEcharts>
                                <!-- <scTable v-show="isShowTable" ref="table0" row-key="id" border :apiObj="item.apiObj"
                                    stripe>
                                    <el-table-column prop="alarmCode" label="报警代码" />
                                    <el-table-column prop="alarmMsg" label="报警信息" />
                                    <el-table-column prop="count" label="报警次数" />
                                </scTable> -->
                            </el-collapse-item>
                        </el-collapse>
                    </el-main>
                    <el-main v-show="list.length == 0">
                        <!-- <el-empty description="暂无数据" /> -->
                        <scEcharts style="width:100%" height="300px" :option="dayCharts">
                        </scEcharts>
                    </el-main>
                </el-container>
            </el-container>
@@ -39,12 +63,102 @@
<script>
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
        MYTree,
        scEcharts
    },
    watch: {
        treeChecked() {
@@ -52,10 +166,17 @@
        },
        time() {
            this.query()
        },
        timeRange(val) {
            console.log(val, '>>>>>>>???/')
        }
    },
    data() {
        return {
            isShowTable: false,
            list: [],
            activeList: [0],
            timeRange: '',
            treeChecked: [],
            timeStart: moment().format('YYYY-MM-DD'),
            time: [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
@@ -63,15 +184,120 @@
                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);
            },
            dayCharts: {
                legend: [
                ],
                title: {
                    text: '设备状态统计图',
                    subtext: '',
                },
                yAxis: {
                    type: 'category',
                    data: ['']
                },
                xAxis: {
                    type: 'value',
                },
                series
            }
        }
    },
    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({
            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(res.data[0])
                }
            })
        },
        queryChart(dmpDTO) {
            // 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(),
            //     dmpDTO
            // })
            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:30:00",
                        "name": "运行",
                        "color": "#73D13D",
                        "value": "2"
                    },
                    {
                        "time": "2024-04-24 11:40:00",
                        "name": "待机",
                        "color": "#FFC53D",
                        "value": "3"
                    },
                    {
                        "time": "2024-04-24 12:00:00",
                        "name": "待机",
                        "color": "#FFC53D",
                        "value": "3"
                    },
                    {
                        "time": "2024-04-24 12:00:00",
                        "name": "运行",
                        "color": "#73D13D",
                        "value": "2"
                    }
                ]
            }
            // {
            //     name: '运行',
            //         type: 'bar',
            //             stack: 'duration',
            //                 itemStyle: {
            //         color: '#007acc',
            //             borderColor: '#fff',
            //                 borderWidth: 1
            //     },
            //     zlevel: -1,
            //         data: ['2024-04-24 10:00:00'] // 结束时间
            // }
            // this.dayCharts.series = [...data.data.map(item => ({
            //     name: item.name,
            //     stack: 'duration',
            //     itemStyle: {
            //         color: item.color,
            //     },
            //     zlevel: -1,
            //     data: [item.time]
            // }))]
        },
        change(e) {
            this.timeStart = e[0] || moment().format('YYYY-MM-DD')