Blame view

src/views/basic/card/index.vue 11.2 KB
77ebf04d   梁保满   个人版
1
2
3
4
5
6
7
8
9
10
  <template>
    <div>
      <back-box>
        <template slot="title">
          <span>发卡记录</span>
        </template>
      </back-box>
  
      <div class="page-content">
        <div class="answer-header">
4c2fb560   梁保满   反馈新需求
11
          <div class="sel-box">
5e2e009a   梁保满   基站筛选条件显示问题,归档文本替换
12
            <!-- <template v-if="role == 'ROLE_XUEXIAO'">
4c2fb560   梁保满   反馈新需求
13
14
15
16
17
18
19
20
21
22
23
              <el-cascader
                @change="(page = 1), _QueryData(1)"
                size="small"
                class="sel"
                clearable
                placeholder="选择班级"
                v-model="query.classId"
                :options="gradeList"
                :props="props"
                :show-all-levels="false"
              ></el-cascader>
5e2e009a   梁保满   基站筛选条件显示问题,归档文本替换
24
            </template> -->
4c2fb560   梁保满   反馈新需求
25
            <template v-if="role == 'ROLE_JITUAN'">
dc015b2d   梁保满   发卡记录描述增加换班类型
26
27
              <el-select class="sel2" v-model="query.schoolId" placeholder="选择学校" @change="(page = 1), _QueryData(1)">
                <el-option v-for="item in schoolList" :key="item.value" :label="item.label" :value="item.value">
4c2fb560   梁保满   反馈新需求
28
29
30
                </el-option>
              </el-select>
            </template>
dc015b2d   梁保满   发卡记录描述增加换班类型
31
32
            <el-select class="sel sel3" v-model="query.operationType" placeholder="选择类型"
              @change="(page = 1), _QueryData(1)">
4c2fb560   梁保满   反馈新需求
33
34
35
              <el-option label="全部" value=""></el-option>
              <el-option label="发卡" :value="0"></el-option>
              <el-option label="补卡" :value="1"></el-option>
0ca11cc2   梁保满   学段参数调整,发卡记录类型增加
36
              <el-option label="换班" :value="2"></el-option>
4c2fb560   梁保满   反馈新需求
37
38
            </el-select>
            <div class="d1">
dc015b2d   梁保满   发卡记录描述增加换班类型
39
40
              <el-date-picker v-model="query.startDay" type="date" @change="handleChangeTimeStart" placeholder="选择日期时间"
                value-format="yyyy-MM-dd">
4c2fb560   梁保满   反馈新需求
41
42
              </el-date-picker>
              ~
dc015b2d   梁保满   发卡记录描述增加换班类型
43
44
              <el-date-picker v-model="query.endDay" type="date" placeholder="选择日期时间" @change="handleChangeTimeEnd"
                value-format="yyyy-MM-dd">
4c2fb560   梁保满   反馈新需求
45
46
              </el-date-picker>
            </div>
af0d559b   梁保满   样式调整
47
            <template v-if="role == 'ROLE_XUEXIAO'">
dc015b2d   梁保满   发卡记录描述增加换班类型
48
49
50
              <el-input placeholder="请输入学生姓名" v-model="query.studentName" class="input-with-select sel"
                @keyup.enter.native="(page = 1), _QueryData(2)">
                <el-button slot="append" icon="el-icon-search" @click="(page = 1), _QueryData(2)"></el-button>
af0d559b   梁保满   样式调整
51
              </el-input>
dc015b2d   梁保满   发卡记录描述增加换班类型
52
53
54
              <el-input placeholder="请输入学生学号" v-model="query.studentCode" class="input-with-select sel"
                @keyup.enter.native="(page = 1), _QueryData(3)">
                <el-button slot="append" icon="el-icon-search" @click="(page = 1), _QueryData(3)"></el-button>
af0d559b   梁保满   样式调整
55
56
              </el-input>
            </template>
dc015b2d   梁保满   发卡记录描述增加换班类型
57
            <el-button type="primary" round @click="(page = 1), _QueryData(4)">筛选</el-button>
77ebf04d   梁保满   个人版
58
          </div>
77ebf04d   梁保满   个人版
59
        </div>
dc015b2d   梁保满   发卡记录描述增加换班类型
60
        <el-empty :image-size="100" v-if="!tableData.length && !loading" description="暂无数据"></el-empty>
77ebf04d   梁保满   个人版
61
62
        <div v-else class="table-box" v-loading="loading">
          <el-table :data="tableData" border style="width: 100%">
dc015b2d   梁保满   发卡记录描述增加换班类型
63
            <el-table-column align="center" label="答题器编码" prop="clickerSn"></el-table-column>
a6eb85ed   梁保满   下载模版错误信息展示,图标根据环境切换
64
65
            <el-table-column align="center" label="年级">
              <template slot-scope="scope">
e5e4a3e6   梁保满   v1.3
66
                <span>{{ scope.row.classList[0]?.gradeName }}</span>
a6eb85ed   梁保满   下载模版错误信息展示,图标根据环境切换
67
68
              </template>
            </el-table-column>
77ebf04d   梁保满   个人版
69
70
            <el-table-column align="center" label="班级">
              <template slot-scope="scope">
dc015b2d   梁保满   发卡记录描述增加换班类型
71
72
                <span v-for="(item, index) in scope.row.classList" :key="item.classCode">{{ (index == 0 ? "" : "、") +
                  item.className }}</span>
77ebf04d   梁保满   个人版
73
74
              </template>
            </el-table-column>
dc015b2d   梁保满   发卡记录描述增加换班类型
75
76
            <el-table-column align="center" label="学生姓名" prop="studentName"></el-table-column>
            <el-table-column align="center" label="学号" prop="studentCode"></el-table-column>
77ebf04d   梁保满   个人版
77
78
            <el-table-column align="center" label="类型">
              <template slot-scope="scope">
0ca11cc2   梁保满   学段参数调整,发卡记录类型增加
79
80
                {{
                  scope.row.operationType == 0
dc015b2d   梁保满   发卡记录描述增加换班类型
81
82
                  ? "发卡"
                  : scope.row.operationType == 1
0ca11cc2   梁保满   学段参数调整,发卡记录类型增加
83
84
85
                    ? "补卡"
                    : "换班"
                }}
dc015b2d   梁保满   发卡记录描述增加换班类型
86
87
              </template></el-table-column>
            <el-table-column align="center" label="操作次数" prop="operations"></el-table-column>
77ebf04d   梁保满   个人版
88
89
90
91
            <el-table-column align="center" label="描述">
              <template slot-scope="scope">
                {{
                  scope.row.operationType == 0
dc015b2d   梁保满   发卡记录描述增加换班类型
92
93
                  ? "--"
                  : scope.row.reason == 0
77ebf04d   梁保满   个人版
94
                    ? "丢失"
dc015b2d   梁保满   发卡记录描述增加换班类型
95
                    : scope.row.reason == 1 ? "损坏" : "换班"
77ebf04d   梁保满   个人版
96
                }}
dc015b2d   梁保满   发卡记录描述增加换班类型
97
98
              </template></el-table-column>
            <el-table-column align="center" label="操作时间" prop="modifiedTime" width="160"></el-table-column>
77ebf04d   梁保满   个人版
99
100
          </el-table>
          <div class="pagination-box">
dc015b2d   梁保满   发卡记录描述增加换班类型
101
102
            <el-pagination small="" layout="total,prev, pager, next" :hide-on-single-page="true" :total="total"
              @current-change="changePage" :current-page="page" :page-size="size">
77ebf04d   梁保满   个人版
103
104
105
            </el-pagination>
          </div>
        </div>
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
106
        <p class="down" v-if="tableData.length">
dc015b2d   梁保满   发卡记录描述增加换班类型
107
          <el-button type="primary" plain round icon="fa fa-cloud-download" @click="downExl">导出报表</el-button>
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
108
        </p>
77ebf04d   梁保满   个人版
109
110
111
112
113
      </div>
    </div>
  </template>
  
  <script>
a6eb85ed   梁保满   下载模版错误信息展示,图标根据环境切换
114
  import { downloadFile, formatDate } from "utils";
47a01cb6   梁保满   v1.3测试问题
115
116
117
118
119
120
121
122
  const defauleQuery = {
    classId: "",
    studentName: "",
    studentCode: "",
    operationType: "",
    startDay: "",
    endDay: "",
  };
77ebf04d   梁保满   个人版
123
124
125
  export default {
    data() {
      return {
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
126
        role: "",
77ebf04d   梁保满   个人版
127
128
129
130
131
132
        loading: false,
        props: { multiple: false },
        query: {
          classId: "",
          studentName: "",
          studentCode: "",
4c2fb560   梁保满   反馈新需求
133
134
135
136
          operationType: "",
          schoolId: "",
          startDay: "",
          endDay: "",
77ebf04d   梁保满   个人版
137
        },
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
138
        schoolList: [],
77ebf04d   梁保满   个人版
139
140
141
142
143
144
145
        gradeList: [],
        tableData: [],
        page: 1,
        size: 20,
        total: 0,
      };
    },
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
146
147
148
149
150
151
152
153
154
155
156
    async created() {
      this.role =
        this.$store.getters.info.showRole ||
        this.$store.getters.info.permissions[0].role;
      this.loading = true;
      if (this.role == "ROLE_XUEXIAO") {
        this._QueryGradeList();
      } else if (this.role == "ROLE_JITUAN") {
        await this._QuerySchool();
      }
  
77ebf04d   梁保满   个人版
157
158
159
      this._QueryData();
    },
    methods: {
4c2fb560   梁保满   反馈新需求
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
      handleChangeTimeStart(val) {
        if (this.query.endDay) {
          if (new Date(val).getTime() > new Date(this.query.endDay).getTime()) {
            this.$message.error("任务结束时间不能任务开始时间前面,请重新设置");
            this.query.startDay = "";
          }
        }
      },
      handleChangeTimeEnd(val) {
        if (this.query.startDay) {
          if (new Date(val).getTime() < new Date(this.query.startDay).getTime()) {
            this.$message.error("任务结束时间不能任务开始时间前面,请重新设置");
            this.query.endDay = "";
          }
        }
      },
77ebf04d   梁保满   个人版
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
      // 查找班级
      async _QueryGradeList() {
        this.loading = true;
        const { data, status, info } = await this.$request.gradeList();
        console.log(status);
        if (status === 0) {
          if (!!data.list) {
            this.gradeList =
              data.list?.map((item) => {
                let gradeList = {
                  value: item.grade,
                  label: item.gradeName,
                };
                gradeList.children =
                  item.classList?.map((items) => {
                    return {
                      value: items.id,
                      label: items.className,
                    };
                  }) || [];
                return gradeList;
              }) || [];
          }
        } else {
          this.$message.error(info);
        }
      },
      changePage(page) {
        this.page = page;
        this._QueryData(4);
      },
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
207
208
209
210
211
212
213
214
215
216
      async _QuerySchool() {
        const { data, status, info } = await this.$request.schoolList();
        if (status === 0) {
          this.schoolList =
            data.list?.map((item) => {
              return {
                label: item.schoolName,
                value: item.id,
              };
            }) || [];
4c2fb560   梁保满   反馈新需求
217
218
219
220
221
          this.schoolList.unshift({
            label: "全部",
            value: "",
          });
          this.query.schoolId = this.schoolList[0].value || "";
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
222
223
224
225
        } else {
          this.$message.error(info);
        }
      },
4c2fb560   梁保满   反馈新需求
226
      serQuery(type) {
77ebf04d   梁保满   个人版
227
        let query = {};
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
228
        if (this.role == "ROLE_XUEXIAO") {
4c2fb560   梁保满   反馈新需求
229
          delete query.schoolId;
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
230
          if (type == 1) {
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
231
232
            this.query.studentCode = "";
            this.query.studentName = "";
0ca11cc2   梁保满   学段参数调整,发卡记录类型增加
233
            query = { ...this.query };
47a01cb6   梁保满   v1.3测试问题
234
            query.classId = this.query.classId[1] ? this.query.classId[1] : "";
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
235
          } else if (type == 2) {
0ca11cc2   梁保满   学段参数调整,发卡记录类型增加
236
237
            this.query = { ...defauleQuery, studentName: this.query.studentName };
            query = { ...this.query };
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
238
          } else if (type == 3) {
0ca11cc2   梁保满   学段参数调整,发卡记录类型增加
239
240
            this.query = { ...defauleQuery, studentCode: this.query.studentCode };
            query = { ...this.query };
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
241
242
          } else {
            query = { ...this.query };
967e02c9   梁保满   发卡记录显示参数调整
243
            query.classId = this.query.classId[1] ? this.query.classId[1] : "";
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
244
245
          }
        } else if (this.role == "ROLE_JITUAN") {
47a01cb6   梁保满   v1.3测试问题
246
247
248
249
          query.schoolId = this.query.schoolId;
          query.operationType = this.query.operationType;
          query.startDay = this.query.startDay;
          query.endDay = this.query.endDay;
77ebf04d   梁保满   个人版
250
        }
4c2fb560   梁保满   反馈新需求
251
252
253
        return query;
      },
      async _QueryData(type) {
5cfb0264   梁保满   班级管理交互优化
254
255
256
257
258
259
260
261
262
263
264
265
266
        if (this.role == "ROLE_XUEXIAO") {
          if (type == 2) {
            if (!this.query.studentName) {
              this.$message.warning("输入学生姓名~");
              return;
            }
          } else if (type == 3) {
            if (!this.query.studentCode) {
              this.$message.warning("输入学生学号~");
              return;
            }
          }
        }
4c2fb560   梁保满   反馈新需求
267
        let query = this.serQuery(type);
77ebf04d   梁保满   个人版
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
        this.loading = true;
        const { data, status, info } = await this.$request.cardList({
          ...query,
          page: this.page,
          size: 20,
        });
        this.loading = false;
        console.log(status);
        if (status === 0) {
          this.tableData = data.list || [];
          this.total = data.count;
        } else {
          this.$message.error(info);
        }
      },
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
283
      async downExl() {
47a01cb6   梁保满   v1.3测试问题
284
285
286
287
288
289
290
291
292
        let query = { ...this.query };
        if (this.role == "ROLE_XUEXIAO") {
          query.classId = this.query.classId[1] ? this.query.classId[1] : "";
          delete query.schoolId;
        } else if (this.role == "ROLE_JITUAN") {
          delete query.classId;
          delete query.studentName;
          delete query.studentCode;
        }
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
293
294
        //报表导出
        if (this.exportLoading == true) return;
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
295
        this.exportLoading = true;
4c2fb560   梁保满   反馈新需求
296
297
298
        const data = await this.$request.exportClickersLog({
          ...query,
        });
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
299
        this.exportLoading = false;
a6eb85ed   梁保满   下载模版错误信息展示,图标根据环境切换
300
        if (data && !data.code) {
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
301
302
303
          let blob = new Blob([data], {
            type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          });
a6eb85ed   梁保满   下载模版错误信息展示,图标根据环境切换
304
305
306
          let date = formatDate(new Date().getTime(), "yyyy-MM-dd");
          let name = `发卡记录_${date}.xlsx`;
          downloadFile(name, blob);
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
307
        } else {
a6eb85ed   梁保满   下载模版错误信息展示,图标根据环境切换
308
          this.$message.error(data.info);
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
309
310
        }
      },
77ebf04d   梁保满   个人版
311
312
313
314
315
316
317
318
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .table-box {
    padding: 0 20px;
  }
dc015b2d   梁保满   发卡记录描述增加换班类型
319
  
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
320
321
322
  .down {
    padding: 16px 20px;
  }
dc015b2d   梁保满   发卡记录描述增加换班类型
323
  
4c2fb560   梁保满   反馈新需求
324
325
  .answer-header {
    .sel-box {
af0d559b   梁保满   样式调整
326
327
328
329
      .sel {
        margin-right: 20px;
        min-width: 120px;
      }
dc015b2d   梁保满   发卡记录描述增加换班类型
330
  
4c2fb560   梁保满   反馈新需求
331
      .sel2 {
af0d559b   梁保满   样式调整
332
        width: 200px;
4c2fb560   梁保满   反馈新需求
333
334
        margin-right: 20px;
      }
dc015b2d   梁保满   发卡记录描述增加换班类型
335
  
af0d559b   梁保满   样式调整
336
337
338
      .sel3 {
        min-width: 80px;
      }
dc015b2d   梁保满   发卡记录描述增加换班类型
339
  
4c2fb560   梁保满   反馈新需求
340
341
342
343
      .d1 {
        margin-right: 20px;
      }
    }
f20c48c9   梁保满   集团管理员添加发卡记录,并添加报表导出
344
  }
77ebf04d   梁保满   个人版
345
  </style>