zxl
2026-01-21 aab6b50f31e0da9736a8a221b082b246cd47c498
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<template>
  <div class="demerit-record-table">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
      <el-form-item label="区域" prop="belongUnit">
        <el-select v-model="queryParams.deptId" @change="handleQuery" clearable placeholder="运维考核单位">
          <el-option v-for="(item, index) in deptList" :key="index" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
 
      <el-form-item label="搜索类型:">
        <el-radio-group v-model="queryParams.searchType" size="small">
          <el-radio label="day">按日</el-radio>
          <el-radio label="month">按月</el-radio>
        </el-radio-group>
      </el-form-item>
 
      <el-form-item label="选择日期:" v-show="queryParams.searchType === 'day'">
        <el-date-picker v-model="queryParams.dayDate" type="daterange"  range-separator="至" start-placeholder="选择日期"
        end-placeholder="结束日期" format="yyyy-MM-dd"  value-format="yyyy-MM-dd" size="small"></el-date-picker>
      </el-form-item>
 
      <el-form-item label="选择月份:" v-show="queryParams.searchType === 'month'">
        <el-date-picker v-model="queryParams.monthDate" type="monthrange" range-separator="至" start-placeholder="开始月份"
          end-placeholder="结束月份" format="yyyy-MM" value-format="yyyy-MM" size="small"></el-date-picker>
      </el-form-item>
      <el-form-item label="分建类型">
        <el-select v-model="queryParams.constructionType" @change="handleQuery" clearable placeholder="分建类型">
          <el-option v-for="(item, index) in constructionTypeList" :key="index" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
        <el-button size="small" @click="updateData">更新</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" border stripe style="width: 100%" v-loading="loading"
      :header-cell-style="{ 'background-color': '#f5f7fa', 'font-weight': 'bold' }">
      <el-table-column prop="deptName" label="区域名" align="center" min-width="150"></el-table-column>
 
      <el-table-column prop="constructionType" label="分建设类型" align="center" min-width="180">
        <template slot-scope="scope">
          {{ formatConstructionType(scope.row.constructionType) }}
        </template>
      </el-table-column>
 
      <el-table-column prop="demerit" label="扣分" align="center" min-width="120">
        <template slot-scope="scope">
          {{ formatDemerit(scope.row.demerit) }}
        </template>
      </el-table-column>
 
      <el-table-column prop="recordTime" label="日期" align="center" min-width="200">
        <template slot-scope="scope">
          <!-- recordTime格式为 "yyyy-MM-dd HH:mm:ss",通过split截取日期部分 -->
          {{ scope.row.recordTime ? scope.row.recordTime.split(' ')[0] : '-' }}
        </template>
      </el-table-column>
      <el-table-column prop="videoOnlineRate" label="在线率" align="center" min-width="200">
        <template slot-scope="scope">
          {{ formatDemeritRate(scope.row.videoOnlineRate) }}
        </template>
      </el-table-column>
      <el-table-column prop="action" label="操作" align="=center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="exportInfo(scope.row)">导出详情</el-button>
 
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getPage" />
  </div>
</template>
<script>
import {
  getPage, exportInfo,executeDecemberStats
} from "@/api/platform/demeritRecord"
export default {
  name: 'DemeritRecordTable',
  data() {
    return {
      loading:false,
      deptList: [
        { value: 201, label: '自流井区' },   // ZLJQ最后一个属性201,第一个属性"自流井区"
        { value: 202, label: '贡井区' },     // GJQ最后一个属性202,第一个属性"贡井区"
        { value: 102, label: '大安区' },     // DAQ最后一个属性102,第一个属性"大安区"
        { value: 211, label: '沿滩区' },     // YTQ最后一个属性211,第一个属性"沿滩区"
        { value: 203, label: '荣县' },       // RX最后一个属性203,第一个属性"荣县"
        { value: 101, label: '富顺县' },     // FSX最后一个属性101,第一个属性"富顺县"
        { value: 210, label: '高新区' }      // GXQ最后一个属性210,第一个属性"高新区"
      ],
      queryParams: {
        searchType: 'day',
        dayDate: null,
        monthDate: null,
        dayStart: null,
        dayEnd: null,
        monthStart: null,
        monthEnd: null,
        deptId: '',
        constructionType: '',
        pageNum: 1,
        pageSize: 20
      },
      constructionTypeList: [
        { label: '一二期', value: 'PHASE_ONE_TWO' },
        { label: '三期', value: 'PHASE_THREE' },
        { label: '四区人脸', value: 'PHASE_FOURTH' },
        { label: '东部新城', value: 'EASTERN_NEW_CITY' },
        { label: '沿滩二期人脸', value: 'YAN_TAN_PHASE_TWO_FACE' },
        { label: '入川即检', value: 'CHECK_ENTER_SICHUAN' }
      ],
      // 表格数据,实际项目中从接口获取
      total: 0,
      tableData: [
      ],
      // 建设类型映射,用于将英文标识转换为中文显示
      constructionTypeMap: {
        'PHASE_ONE_TWO': '一二期',
        'PHASE_THREE': '三期',
        'PHASE_FOURTH': '四区人脸',
        'EASTERN_NEW_CITY': '东部新城',
        'YAN_TAN_PHASE_TWO_FACE': '沿滩二期人脸',
        'CHECK_ENTER_SICHUAN': '入川即检',
      }
    };
  },
  mounted() {
    // 关键修复:移除原生radio的aria-hidden属性
    this.$nextTick(() => {
      const radioInputs = document.querySelectorAll('.el-radio__original');
      radioInputs.forEach(input => {
        input.removeAttribute('aria-hidden'); // 让辅助技术能识别焦点
      });
    });
    this.init();
 
  },
  methods: {
    updateData(){
      if (this.loading){
        return
      }
      this.loading = true
      executeDecemberStats().then(res =>{
        if (res.code === 200){
          this.$message("执行成功")
        }
        this.loading = false
      })
    },
    exportInfo(row) {
      console.log(row)
      let name = row.deptName + '设备详情.xlsx'
      this.download('demeritRecord/exportInfo',
        {
          id:row.id,
          date:row.recordTime,
          deptId:row.deptId,
          type:row.constructionType
        },
        `${name}`)
    },
    init() {
      // 初始化查询参数
      this.getPage();
 
    },
    getPage() {
      console.log(this.queryParams.dayDate)
      this.queryParams.dayStart = null;
      this.queryParams.dayEnd = null;
      this.queryParams.monthStart = null;
      this.queryParams.monthEnd = null;
      let from = null;
      if (this.queryParams.searchType === "day") {
        this.queryParams.monthDate = null;
 
        if (this.queryParams.dayDate && this.queryParams.dayDate.length === 2) {
          this.queryParams.dayStart = this.queryParams.dayDate[0];
          this.queryParams.dayEnd = this.queryParams.dayDate[1];
        }
        from = {
          searchType: this.queryParams.searchType,
          dayStart: this.queryParams.dayStart,
          dayEnd: this.queryParams.dayEnd,
          deptId: this.queryParams.deptId,
          constructionType: this.queryParams.constructionType,
          pageNum: this.queryParams.pageNum,
          pageSize: this.queryParams.pageSize
        }
      } else {
        this.queryParams.dayDate = null;
        if (this.queryParams.monthDate && this.queryParams.monthDate.length === 2) {
          const monthStart = this.queryParams.monthDate[0];
          const monthEnd = this.queryParams.monthDate[1];
 
 
          const [startYear, startMonth] = monthStart.split('-').map(Number);
          // 月份补零,比如 2025-1 → 2025-01
          const formattedStartMonth = String(startMonth).padStart(2, '0');
          // 拼接成完整的日期时间格式,兼容Timestamp解析
          this.queryParams.monthStart = `${startYear}-${formattedStartMonth}-01 00:00:00`;
 
 
          // 修复2:标准化结束月份格式,添加时间戳并补零
 
          const [year, month] = monthEnd.split('-').map(Number);
          const lastDay = new Date(year, month, 0).getDate();
          // 月份和日期都补零,比如 2025-11-3 → 2025-11-03
          const formattedMonth = String(month).padStart(2, '0');
          const formattedDay = String(lastDay).padStart(2, '0');
          // 拼接成当月最后一天的23:59:59,确保覆盖整个月份
          this.queryParams.monthEnd = `${year}-${formattedMonth}-${formattedDay} 23:59:59`;
 
          from = {
            searchType: this.queryParams.searchType,
            monthStart: this.queryParams.monthStart,
            monthEnd: this.queryParams.monthEnd,
            deptId: this.queryParams.deptId,
            constructionType: this.queryParams.constructionType,
            pageNum: this.queryParams.pageNum,
            pageSize: this.queryParams.pageSize
          }
        }
      }
      getPage(from).then(res => {
        if (res.code === 200) {
          this.tableData = res.data;
          this.total = res.total
        }
      })
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getPage()
    },
    resetQuery() {
      this.queryParams = {
        searchType: 'day',
        dayDate: null,
        monthDate: null,
        dayStart: null,
        dayEnd: null,
        monthStart: null,
        monthEnd: null,
        deptId: '',
        constructionType: '',
        pageNum: 1,
        pageSize: 20
      };
      this.getPage()
    },
    // 格式化建设类型显示
    formatConstructionType(type) {
      return this.constructionTypeMap[type] || type;
    },
    // 格式化扣分显示,保留一位小数
    formatDemerit(value) {
      return value.toFixed(1);
    },
    formatDemeritRate(value) {
      if (value !== null && value !== 0) {
        return value.toFixed(1) + "%";
      } else {
        return "暂无"
      }
 
    }
  }
};
</script>
<style>
.demerit-record-table {
  padding: 20px;
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
 
 
}
</style>