gaoshp
2024-11-04 eef1ef0be935d4a3d8fc691b2666f41796b2d4a5
src/views/mdc/components/recordChartsByDate.vue
@@ -14,16 +14,8 @@
import * as echarts from 'echarts';
export default {
    components: {saveDialog},
    props: ['achievements','date','workstationInfoList'],
    props: ['achievements','date','workstationInfoList','humanFeedback'],
    watch: {
        date(val) {
            this.current = "1";
            this.getCharts();
        },
        workstationInfoList(val) {
            this.current = "1";
            this.getCharts();
        }
    },
    data() {
        return {
@@ -75,7 +67,6 @@
        },
        getColor(name) {
            var color = '';
            console.log(this.achievements,name);
            this.achievements.forEach(item=> {
                if(item.code == name) {
                    color = item.color;
@@ -83,14 +74,25 @@
            })
            return color;
        },
        getStatus(name) {
            var stauts = {};
            this.achievements.forEach(item=> {
                if(item.code == name) {
                    stauts.name= item.name;
                    stauts.type= item.type;
                }
            })
            return stauts;
        },
        getCharts() {
            if(this.date == "") return;
            var obj = {
                date: this.date,
                humanFeedback: true,
                humanFeedback: this.humanFeedback,
                machineFeedback: true,
                workstationInfoList: this.workstationInfoList
            }
            this.$HTTP.post(`/api/blade-mdc/status-record/status-record-by-date?current=${this.current}&size=${this.size}`,obj).then(res => {
            this.$HTTP.post(`/api/mdc/status-record/status-record-by-date?current=${this.current}&size=${this.size}`,obj).then(res => {
                if (res.code === 200) {
                    var yAxisData = [];
                    var newData = [];
@@ -98,6 +100,7 @@
                    res.data.records.reverse();
                    res.data.records.forEach((item,index)=> {
                        yAxisData.push(item.workstationInfo.name);
                        if(item.statusRecordList == null) item.statusRecordList = [];
                        //计算开始时间,显示时间
                        item.statusRecordList.forEach(item1=> {
                            var initstart = item1.startTime.split(" ")[0];  //根据日期计算差值
@@ -105,9 +108,10 @@
                            var endTime = moment(item1.endTime).diff(moment(initstart + " 00:00:00"), 'minutes');
                            var diff = moment(item1.endTime).diff(moment(item1.startTime), 'minutes') //开始了多久
                            var color = this.getColor(item1.wcs);
                            console.log(color,222)
                            item1.value = [index,startTime,endTime,diff];
                            item1.itemStyle = {"normal": {"color": color}};
                            item1.statusName = this.getStatus(item1.wcs).name;
                            item1.statusType = this.getStatus(item1.wcs).type;
                            item1.code = item.workstationInfo.code;
                            item1.name = item.workstationInfo.name;
                            item1.id = item.workstationInfo.id;
@@ -116,7 +120,6 @@
                    })
                    this.total = res.data.total;
                    //渲染图表
                    console.log(yAxisData,newData,111)
                    this.setCharts(yAxisData,newData);
                    // 检查是否存在id为'parentNodeDom'的DOM元素,有就先删除
                    var parentNodeDom = document.getElementById('parentNodeDom');  
@@ -131,12 +134,18 @@
            var option = {
                tooltip: {
                    formatter: function (params) {
                        return `<span class="tipdesc">工位</span>${params.data.name}</br>
                            <span class="tipdesc">状态</span>${params.data.wcsDesc}</br>
                            <span class="tipdesc">描述</span>${params.data.feedbackDesc}</br>
                            <span class="tipdesc">状态时间</span>${params.data.startTime} ~ ${params.data.endTime}</br>
                            <span class="tipdesc">反馈时间</span>${params.data.feedbackTime}</br>
                            <span class="tipdesc">反馈人</span>${params.data.feedUser}</br>`;
                       if(params.data.statusType == 4) {
                            var dom = `<span class="tipdesc">工位:</span>${params.data.name}</br>
                                        <span class="tipdesc">状态:</span>${params.data.wcsDesc}</br>
                                        <span class="tipdesc">描述:</span>${params.data.feedbackDesc}</br>
                                        <span class="tipdesc">状态时间:</span>${params.data.startTime} ~ ${params.data.endTime}</br>
                                        <span class="tipdesc">反馈时间:</span>${params.data.feedbackTime}</br>
                                        <span class="tipdesc">反馈人:</span>${params.data.feedUser}</br>`
                       }else {
                            var dom = `<span class="tipstatus">${params.data.statusName}</span></br>
                                    <span class="tipdesc">时段:</span><span>${params.data.startTime.split(" ")[1]} ~ ${params.data.endTime.split(" ")[1]}</span></br>`
                       }
                        return dom;
                    }
                },
                grid: {
@@ -305,9 +314,10 @@
        position: absolute;
        cursor: pointer;
    }
    #record /deep/ .tipdesc {
    #record /deep/ .tipstatus {
        width: 100%;
        display: inline-block;
        width: 80px;
        border-bottom: 1px solid #eee;
    }
    .pagination {
        text-align: right;