From 1988d77f4df3c01a9137303e0c959b3442c14377 Mon Sep 17 00:00:00 2001
From: lzhe <lzhe@example.com>
Date: 星期一, 30 九月 2024 22:10:30 +0800
Subject: [PATCH] 1

---
 src/views/mdc/processParam/index.vue |  208 +++++++++++++++++++++++++++++----------------------
 1 files changed, 119 insertions(+), 89 deletions(-)

diff --git a/src/views/mdc/processParam/index.vue b/src/views/mdc/processParam/index.vue
index 764c3b7..287e218 100644
--- a/src/views/mdc/processParam/index.vue
+++ b/src/views/mdc/processParam/index.vue
@@ -1,57 +1,7 @@
 <!--
- * ......................................&&.........................
- * ....................................&&&..........................
- * .................................&&&&............................
- * ...............................&&&&..............................
- * .............................&&&&&&..............................
- * ...........................&&&&&&....&&&..&&&&&&&&&&&&&&&........
- * ..................&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&..............
- * ................&...&&&&&&&&&&&&&&&&&&&&&&&&&&&&.................
- * .......................&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.........
- * ...................&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&...............
- * ..................&&&   &&&&&&&&&&&&&&&&&&&&&&&&&&&&&............
- * ...............&&&&&@  &&&&&&&&&&..&&&&&&&&&&&&&&&&&&&...........
- * ..............&&&&&&&&&&&&&&&.&&....&&&&&&&&&&&&&..&&&&&.........
- * ..........&&&&&&&&&&&&&&&&&&...&.....&&&&&&&&&&&&&...&&&&........
- * ........&&&&&&&&&&&&&&&&&&&.........&&&&&&&&&&&&&&&....&&&.......
- * .......&&&&&&&&.....................&&&&&&&&&&&&&&&&.....&&......
- * ........&&&&&.....................&&&&&&&&&&&&&&&&&&.............
- * ..........&...................&&&&&&&&&&&&&&&&&&&&&&&............
- * ................&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&............
- * ..................&&&&&&&&&&&&&&&&&&&&&&&&&&&&..&&&&&............
- * ..............&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&....&&&&&............
- * ...........&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&......&&&&............
- * .........&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.........&&&&............
- * .......&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&...........&&&&............
- * ......&&&&&&&&&&&&&&&&&&&...&&&&&&...............&&&.............
- * .....&&&&&&&&&&&&&&&&............................&&..............
- * ....&&&&&&&&&&&&&&&.................&&...........................
- * ...&&&&&&&&&&&&&&&.....................&&&&......................
- * ...&&&&&&&&&&.&&&........................&&&&&...................
- * ..&&&&&&&&&&&..&&..........................&&&&&&&...............
- * ..&&&&&&&&&&&&...&............&&&.....&&&&...&&&&&&&.............
- * ..&&&&&&&&&&&&&.................&&&.....&&&&&&&&&&&&&&...........
- * ..&&&&&&&&&&&&&&&&..............&&&&&&&&&&&&&&&&&&&&&&&&.........
- * ..&&.&&&&&&&&&&&&&&&&&.........&&&&&&&&&&&&&&&&&&&&&&&&&&&.......
- * ...&&..&&&&&&&&&&&&.........&&&&&&&&&&&&&&&&...&&&&&&&&&&&&......
- * ....&..&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&...........&&&&&&&&.....
- * .......&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&..............&&&&&&&....
- * .......&&&&&.&&&&&&&&&&&&&&&&&&..&&&&&&&&...&..........&&&&&&....
- * ........&&&.....&&&&&&&&&&&&&.....&&&&&&&&&&...........&..&&&&...
- * .......&&&........&&&.&&&&&&&&&.....&&&&&.................&&&&...
- * .......&&&...............&&&&&&&.......&&&&&&&&............&&&...
- * ........&&...................&&&&&&.........................&&&..
- * .........&.....................&&&&........................&&....
- * ...............................&&&.......................&&......
- * ................................&&......................&&.......
- * .................................&&..............................
- * ..................................&..............................
- -->
-
-<!--
  * @Date: 2024-04-09 22:11:21
  * @LastEditors: Sneed
- * @LastEditTime: 2024-04-26 21:23:30
+ * @LastEditTime: 2024-06-25 19:22:46
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/processParam/index.vue
  瀹炴椂鐪嬫澘
 -->
@@ -75,11 +25,14 @@
                             <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-col :span="18" style='text-align: right;'>
                                 <el-date-picker :max-range="3" :clearable="true" 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-col :span="2" style='text-align: right;'>
+                                <el-button type="primary" @click="exportExcel">瀵煎嚭</el-button>
                             </el-col>
                         </el-row>
                         <TimeLine v-model="timeRange" ref="timeLine"></TimeLine>
@@ -91,7 +44,7 @@
                                     <div>
                                         <el-button size="small" @click="viewData(item)">鏌ョ湅鏁版嵁</el-button>
                                     </div>
-                                    <scEcharts style="width:100%" height="200px" :option="item?.dayCharts">
+                                    <scEcharts style="width:100%" :height="item.height" :option="item?.dayCharts">
                                     </scEcharts>
                                 </div>
                                 <el-empty v-else description="鏆傛棤鏁版嵁" />
@@ -114,6 +67,19 @@
                 </div>
             </template>
         </el-drawer>
+        <scDialog v-model="visible">
+            <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">
+                鍏ㄩ��
+            </el-checkbox>
+            <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
+                <el-checkbox v-for="city in list" :key="city.id" :label="city.id" :value="city.id">
+                    {{ city.description }}
+                </el-checkbox>
+            </el-checkbox-group>
+            <template #footer>
+                <el-button type="primary" @click="save">纭畾</el-button>
+            </template>
+        </scDialog>
     </el-main>
 </template>
 
@@ -162,6 +128,10 @@
                 let min = moment(this.timeStart, 'YYYY-MM-DD').subtract(3, 'd').format('YYYY-MM-DD')
                 return !moment(Date).isBetween(min, max);
             },
+            visible: false,
+            checkAll: false,
+            isIndeterminate: false,
+            checkedCities: []
         }
     },
     created() {
@@ -169,6 +139,38 @@
         this.init()
     },
     methods: {
+        handleCheckAllChange(val) {
+            this.checkedCities = val ? this.list.map(v => v.id) : []
+            this.isIndeterminate = false
+        },
+        handleCheckedCitiesChange(value) {
+            console.log(value)
+            this.checkAll = value.length === this.list.length
+            this.isIndeterminate = value.length > 0 && value.length < this.list.length
+        },
+        save() {
+            console.log(this.checkedCities)
+            this.$HTTP.post(`/api/blade-mdc/process-parameter/excel/export`, {
+                collectItem: this.list.filter(v => this.checkedCities.includes(v.id)),
+                endTime: this.timeRange.endTime,
+                startTime: this.timeRange.startTime,
+                methodEnum: 'HOUR',
+                workstationId: this.treeChecked.toString(),
+                workstationName: ''
+            }).then(res => {
+                if (res.success) {
+                    window.open(res.data.link)
+                } else {
+                    this.$message.error(res.msg)
+                }
+            })
+        },
+        exportExcel() {
+            this.checkAll = false
+            this.isIndeterminate = false
+            this.checkedCities = []
+            this.visible = true
+        },
         init() {
             this.$HTTP.get('/api/blade-mdc/process-parameter').then(res => {
                 if (res.code === 200) {
@@ -198,14 +200,20 @@
             }).then(res => {
                 if (res.code === 200) {
                     if (item.name !== 'DeviceStatus') {
-                        this.tableData = res.data.records
+                        this.tableData = res.data.records.map(v => {
+                            return {
+                                ...v,
+                            }
+                        })
+                    } else {
+                        this.tableData = res.data.records.map(item => {
+                            return {
+                                ...item,
+                                value: this.legend.find(v => v.code === item.value)?.name
+                            }
+                        })
                     }
-                    this.tableData = res.data.records.map(item => {
-                        return {
-                            ...item,
-                            value: this.legend.find(v => v.code === item.value)?.name
-                        }
-                    })
+
                     this.drawer = true
                 }
             })
@@ -217,7 +225,13 @@
             })
             this.$HTTP.get('/api/blade-mdc/process-parameter/param', { workstationId: this.treeChecked.toString() }).then(res => {
                 if (res.code === 200) {
-                    this.list = res.data
+                    console.log('jkjkjkjkj', this.list)
+                    this.list = res.data.map(v => {
+                        return {
+                            ...v,
+                            height: ['ProcessProgram', 'DeviceStatus'].includes(v.name) ? '100px' : '200px'
+                        }
+                    })
                     this.queryChart()
                 }
             })
@@ -258,7 +272,7 @@
         },
         setLineOptions(data, myname) {
             if (!data) return
-            console.log(data, myname)
+            // console.log(data, myname)
             let xAxis = data?.map(item => {
                 return item.time
             })
@@ -269,8 +283,7 @@
                 tooltip: {
                     position: ['50%', '50%']
                 },
-                legend: [
-                ],
+                legend: {},
                 title: {
                     text: '',
                     subtext: '',
@@ -282,7 +295,7 @@
                     {
                         data: yAxisData,
                         type: 'line',
-
+                        step: 'start',
                     }
                 ],
                 xAxis: {
@@ -297,7 +310,6 @@
                     dayCharts: {}
                 })
             } else {
-                console.log(myname, '>>>>>>???????????>>>>>>', yAxisData)
                 let index = this.list.findIndex(item => item.name === myname)
                 this.list[index] = Object.assign({
                     ...this.list[index],
@@ -309,8 +321,8 @@
         setDeviceStatusOptions(data, myname) {
             let total = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime)))
             let start = this.timeRange.startTime
-            let len = data.data.length
-            if (moment(data.data[len - 1].time).unix() < moment(this.timeRange.endTime).unix()) {
+            let len = data?.data?.length
+            if (len > 0 && moment(data.data[len - 1].time).unix() < moment(this.timeRange.endTime).unix()) {
                 let addItem = {
                     time: this.timeRange.endTime,
                     value: data.data[len - 1].value
@@ -331,34 +343,51 @@
                     stack: 'total',
                     barWidth: '20px',
                     data: [current / total],
-                    label: {
+                    // label: {
+                    //     show: true,
+                    //     position: 'insideLeft',
+                    //     color: '#FFF',
+                    //     formatter: params => {
+                    //         if (i == 0 || current === 0) return ''
+                    //         return `${name}:寮�濮嬫椂闂�${moment(data.data[i - 1].time).format('HH:mm')}-${moment(item.time).format('HH:mm')}`
+                    //     }
+                    // },
+                    // itemStyle: {
+                    //     // color, // 杩欎竴琛屽浐瀹氱殑棰滆壊鍊奸渶瑕佸垹闄ゆ垨娉ㄩ噴
+                    //     borderColor: '#FFF',
+                    //     borderWidth: 1
+                    // },
+                    tooltip: {
                         show: true,
-                        position: 'insideLeft',
-                        color: '#FFF',
-                        formatter: params => {
+                        trigger: 'item',
+                        position: 'top',
+                        triggerOn: 'click',
+                        formatter: (value, ticket) => {
+                            // console.log('----------1111')
+                            // let add = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))) * value
+                            // let current = moment(this.timeRange.startTime).add(add, 'ms')
+                            // console.log('--11111111------------', current)
+                            // return current.format('HH:mm')
+                            // return value
                             if (i == 0 || current === 0) return ''
-                            return `${name}:寮�濮嬫椂闂�${moment(data.data[i - 1].time).format('HH:mm')}-${moment(item.time).format('HH:mm')}`
+                            return `${name}:鏃舵${moment(data.data[i - 1].time).format('HH:mm')}-${moment(item.time).format('HH:mm')}`
                         }
-                    },
-                    itemStyle: {
-                        // color, // 杩欎竴琛屽浐瀹氱殑棰滆壊鍊奸渶瑕佸垹闄ゆ垨娉ㄩ噴
-                        borderColor: '#FFF',
-                        borderWidth: 1
                     },
                 }
             })
             let dayCharts = {
-                // tooltip: {
-                //     position: ['50%', '50%'],
-                //     formatter: (value, ticket) => {
-                //         console.log('>>>>>>>>>>>>____________', value, ticket)
-                //         let add = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))) * value
-                //         let current = moment(this.timeRange.startTime).add(add, 'ms')
-                //         return current.format('HH:mm')
-                //     }
-                // },
-                legend: [
-                ],
+                tooltip: {
+                    position: ['50%', '50%'],
+                    // formatter: (value, ticket) => {
+                    //     // console.log('>>>>>>>>>>>>____________', value, ticket)
+                    //     let add = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))) * value
+                    //     let current = moment(this.timeRange.startTime).add(add, 'ms')
+                    //     return current.format('HH:mm')
+                    // }
+                },
+                legend: {
+                    selectedMode: false
+                },
                 title: {
                     text: '',
                     subtext: '',
@@ -380,6 +409,7 @@
                     },
                 },
             }
+            console.log(dayCharts, '>>>>>>>???')
             let index = this.list.findIndex(item => item.name === myname)
             this.list[index] = Object.assign({
                 ...this.list[index],

--
Gitblit v1.9.3