Explorar o código

设备维护月度统计主子窗口月份联动

luoaoxuan hai 1 ano
pai
achega
30b250dc20

+ 16 - 4
src/views/component/device/maintenanceStatic.vue

@@ -67,7 +67,7 @@
                                         <div>
                                             <span v-if="i.todo">待处理:{{ i.todo }};</span>
                                             <span v-if="i.done">已完成:{{ i.done }};</span>
-                                            <div v-for="ii in i.data" :key="ii.mainId" class="detail">
+                                            <div v-for="(ii,indd) in i.data" :key="indd" class="detail">
                                                 <el-divider />
                                                 <div class="detail-item">
                                                     <div class="item" style="margin:2px 0">处理人:{{ switchIdToUserName(ii.bian_zhi_ren_)|| '/' }}</div>
@@ -208,7 +208,7 @@ export default {
                     })
                 }
             })
-            console.log('fliterData', result)
+            // console.log('fliterData', result)
             const answer = new Array(this.monthDays)
             for (let i = 0; i < this.monthDays; i++) {
                 const arr = []
@@ -238,7 +238,12 @@ export default {
         }
     },
     mounted () {
-        this.init()
+        if (this.params.searchMonth) {
+            this.month = this.params.searchMonth
+            this.handleMonthChange(this.month)
+        } else {
+            this.init()
+        }
     },
     methods: {
         handleActionEvent ({ key }) {
@@ -273,7 +278,7 @@ export default {
             const ws = xlsx.utils.json_to_sheet(json, { header: Object.values(fields) }) // 将JS对象数组转换为工作表。
             wb.SheetNames.push(sheetName)
             wb.Sheets[sheetName] = ws
-            console.log('json', ws)
+            // console.log('json', ws)
             const defaultCellStyle = { font: { name: 'Verdana', sz: 13, color: 'FF00FF88' }, fill: { fgColor: { rgb: 'FFFFAA00' }}}// 设置表格的样式
             const wopts = { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true, defaultCellStyle: defaultCellStyle, showGridLines: false } // 写入的样式
             const wbout = xlsx.write(wb, wopts)
@@ -313,8 +318,14 @@ export default {
             this.$message.success('导出设备成功!')
         },
         async handleMonthChange (val) {
+            const year = +val.split('-')[0]
             const month = +val.split('-')[1]
             this.monthDays = this.monthList[month - 1]
+            if ((year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0)) {
+                this.monthList[1] = 29
+            } else {
+                this.monthList[1] = 28
+            }
             await this.init()
         },
         // 获取人员部门
@@ -457,6 +468,7 @@ export default {
                         border-bottom: 1px solid #333;
                         border-right: 1px solid #333;
                         border-left: 1px solid #333;
+                        min-width: 100px;
                     }
                     @media screen and (max-width: 1800px) {
                          >.item{

+ 11 - 4
src/views/component/device/maintenanceStaticAll.vue

@@ -96,7 +96,7 @@
                                         <div>
                                             <span v-if="i.todo">待处理:{{ i.todo }};</span>
                                             <span v-if="i.done">已完成:{{ i.done }};</span>
-                                            <div v-for="ii in i.data" :key="ii.mainId" class="detail">
+                                            <div v-for="(ii,indd) in i.data" :key="indd" class="detail">
                                                 <el-divider />
                                                 <div class="detail-item">
                                                     <div class="item" style="margin:2px 0">处理人:{{ switchIdToUserName(ii.bian_zhi_ren_)|| '/' }}</div>
@@ -265,7 +265,7 @@ export default {
                     })
                 }
             })
-            console.log('fliterData', result)
+            // console.log('fliterData', result)
             return result
         },
         formatData () {
@@ -291,7 +291,7 @@ export default {
                 })
                 answer[i] = arr
             }
-            console.log('data', answer)
+            // console.log('data', answer)
             return answer
         }
     },
@@ -314,6 +314,7 @@ export default {
         // 查看设备统计
         goLookStatic (row) {
             this.dialogParams = row
+            this.dialogParams.searchMonth = this.month
             this.MaintenanceStaticVisible = true
         },
         // 人员id 转人员名称
@@ -336,7 +337,7 @@ export default {
             const ws = xlsx.utils.json_to_sheet(json, { header: Object.values(fields) }) // 将JS对象数组转换为工作表。
             wb.SheetNames.push(sheetName)
             wb.Sheets[sheetName] = ws
-            console.log('json', ws)
+            // console.log('json', ws)
             const defaultCellStyle = { font: { name: 'Verdana', sz: 13, color: 'FF00FF88' }, fill: { fgColor: { rgb: 'FFFFAA00' }}}// 设置表格的样式
             const wopts = { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true, defaultCellStyle: defaultCellStyle, showGridLines: false } // 写入的样式
             const wbout = xlsx.write(wb, wopts)
@@ -376,8 +377,14 @@ export default {
             this.$message.success('导出设备成功!')
         },
         async handleMonthChange (val) {
+            const year = +val.split('-')[0]
             const month = +val.split('-')[1]
             this.monthDays = this.monthList[month - 1]
+            if ((year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0)) {
+                this.monthList[1] = 29
+            } else {
+                this.monthList[1] = 28
+            }
             await this.init()
         },
         // 获取人员部门