zhanghua
2024-09-14 46e5592169f0045fcb40d175c21ea3a1e9aeb593
登录二维码样式修改
关闭页面清空localStorage
4个文件已修改
444 ■■■■■ 已修改文件
src/App.vue 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/Navbar.vue 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/class/index.vue 386 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/App.vue
@@ -1,11 +1,36 @@
<template>
  <div id="app">
    <router-view />
  </div>
    <div id="app">
        <router-view v-if="isRouterAlive" />
    </div>
</template>
<script>
export default {
  name: 'App'
    name: 'App',
    provide() {
        return {
            reload: this.reload
        }
    },
    data() {
        return {
            isRouterAlive: true
        }
    },
    mounted() {
        // 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
        window.onbeforeunload = function (e) {
            var storage = window.localStorage;
            storage.clear()
        }
    },
    methods: {
        reload() {
            this.isRouterAlive = false
            this.$nextTick(function () {
                this.isRouterAlive = true
            })
        }
    }
}
</script>
src/layout/components/Navbar.vue
@@ -11,8 +11,12 @@
        <!-- <h3 style="position: fixed; top: 0; font-size: 16px; color: #5a5e66; " :style="'right:' + orgCss() ">{{ getOrgName() }}</h3> -->
        <div class="right-menu">
            <el-dropdown trigger="click" ref="eldrop" style="margin-right:20px">
                <div class="avatar-wrapper" style="font-size:20px">
            <el-dropdown
                trigger="click"
                ref="eldrop"
                style="margin-right: 20px"
            >
                <div class="avatar-wrapper" style="font-size: 20px">
                    {{ selectStaff.org.name }}
                    <i class="el-icon-caret-bottom"></i>
                </div>
@@ -47,6 +51,7 @@
import Hamburger from '@/components/Hamburger'
export default {
    inject: ['reload'], // 依赖注入
    data() {
        return {
            selectStaff: JSON.parse(localStorage.getItem("selectStaff")),
@@ -67,7 +72,8 @@
        changeStaff(item) {
            this.selectStaff = item
            localStorage.setItem("selectStaff", JSON.stringify(item))
            this.$router.go(0)
            // this.$router.go(0)
            this.reload()
        },
        orgCss() {
            return JSON.parse(localStorage.getItem("user")).name.length * 20 + 100 + 'px';
src/views/class/index.vue
@@ -1,185 +1,231 @@
<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="fetchData">
      <el-tab-pane label="全部" name="all" />
      <el-tab-pane label="已停用" name="deactivated" />
    </el-tabs>
    <div style="display: flex; flex-direction: row-reverse">
      <div style="width: 300px">
        <el-input placeholder="按班级名称搜索" v-model="data.keyword" class="input-with-select" size="small">
          <el-button slot="append" icon="el-icon-search" @click="fetchData"></el-button>
        </el-input>
      </div>
    <div class="app-container">
        <el-tabs v-model="activeName" @tab-click="fetchData">
            <el-tab-pane label="全部" name="all" />
            <el-tab-pane label="已停用" name="deactivated" />
        </el-tabs>
        <div style="display: flex; flex-direction: row-reverse">
            <div style="width: 300px">
                <el-input
                    placeholder="按班级名称搜索"
                    v-model="data.keyword"
                    class="input-with-select"
                    size="small"
                >
                    <el-button
                        slot="append"
                        icon="el-icon-search"
                        @click="fetchData"
                    ></el-button>
                </el-input>
            </div>
        </div>
        <div style="height: calc(100vh - 248px)">
            <el-table
                v-loading="listLoading"
                :data="list"
                element-loading-text="Loading"
                fit
                v-if="activeName == 'all'"
                height="100%"
            >
                <el-table-column label="班级名称">
                    <template slot-scope="scope">
                        <el-link type="primary" :underline="false">{{
                            scope.row.team.name
                        }}</el-link>
                    </template>
                </el-table-column>
                <el-table-column label="班级人数" width="200">
                    <template slot-scope="scope"
                        >{{ scope.row.playerCount }} 人</template
                    >
                </el-table-column>
                <el-table-column label="课包/会员卡" width="200">
                    <template slot-scope="scope">{{
                        scope.row.team.voucher
                            ? scope.row.team.voucher.name
                            : ''
                    }}</template>
                </el-table-column>
                <el-table-column label="教师" width="">
                    <template slot-scope="scope">{{
                        concatenateArray(scope.row.team.sessionStaffs)
                    }}</template>
                </el-table-column>
                <el-table-column label="操作" width="200">
                    <template slot-scope="scope">
                        <el-button type="text" @click="handleExport(scope.row)">
                            导出
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-table
                v-loading="listLoading"
                :data="list"
                element-loading-text="Loading"
                fit
                height="100%"
                v-else
            >
                <el-table-column label="班级名称">
                    <template slot-scope="scope"
                        >{{ scope.row.name }}
                    </template>
                </el-table-column>
                <el-table-column label="停用时间">
                    <template slot-scope="scope"
                        >{{ scope.row.modifyTime }}
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="200">
                    <template slot-scope="">
                        <el-link type="primary" :underline="false"
                            >恢复</el-link
                        >
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div>
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="data.pageIn.index + 1"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="data.pageIn.size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
            >
            </el-pagination>
        </div>
        <el-dialog title="导出" :visible.sync="dialogVisible" width="50%">
            <el-form ref="form" :model="form" label-width="180px">
                <el-form-item label="日期范围">
                    <el-date-picker
                        v-model="form.dateRange"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        value-format="yyyy-MM-dd"
                    ></el-date-picker>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmExport"
                    >导 出</el-button
                >
            </div>
        </el-dialog>
    </div>
    <div style="height: calc(100vh - 248px)">
      <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" fit v-if="activeName == 'all'"
        height="100%">
        <el-table-column label="班级名称">
          <template slot-scope="scope">
            <el-link type="primary" :underline="false">{{
      scope.row.team.name
    }}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="班级人数" width="200">
          <template slot-scope="scope">{{ scope.row.playerCount }} 人</template>
        </el-table-column>
        <el-table-column label="课包/会员卡" width="200">
          <template slot-scope="scope">{{
      scope.row.team.voucher.name
    }}</template>
        </el-table-column>
        <el-table-column label="教师" width="">
          <template slot-scope="scope">{{
        concatenateArray(scope.row.team.sessionStaffs)
      }}</template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="text" @click="handleExport(scope.row)">
              导出
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" fit height="100%" v-else>
        <el-table-column label="班级名称">
          <template slot-scope="scope">{{ scope.row.name }} </template>
        </el-table-column>
        <el-table-column label="停用时间">
          <template slot-scope="scope">{{ scope.row.modifyTime }} </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template slot-scope="">
            <el-link type="primary" :underline="false">恢复</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div>
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="data.pageIn.index + 1" :page-sizes="[10, 20, 30, 40]" :page-size="data.pageIn.size"
        layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
    <el-dialog title="导出" :visible.sync="dialogVisible" width="50%">
      <el-form ref="form" :model="form" label-width="180px">
        <el-form-item label="日期范围">
          <el-date-picker v-model="form.dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期" value-format="yyyy-MM-dd"></el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmExport">导 出</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getTeamDtoAll, getDeletedItem } from "@/api/class";
export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger",
      };
      return statusMap[status];
    },
  },
  data() {
    return {
      dialogVisible: false,
      form: {
        dateRange: [],
        teamId: "",
        name: "",
      },
      list: null,
      listLoading: true,
      activeName: "all",
      total: 0,
      data: {
        staffId: JSON.parse(localStorage.getItem("selectStaff")).id,
        keyword: "",
        pageIn: {
          //可选,如果是分页查询,需要加上。
          index: 0, //必选
          size: 10, //每页的大小。默认20
          sorts: {
            name: "name", //排序字段名称
            direction: "ASC", //排序方向
          },
    filters: {
        statusFilter(status) {
            const statusMap = {
                published: "success",
                draft: "gray",
                deleted: "danger",
            };
            return statusMap[status];
        },
        types: ["NORMAL"],
      },
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    handleExport(row) {
      this.form.dateRange = [];
      this.form.teamId = row.team.id;
      this.form.name = row.team.name;
      this.dialogVisible = true;
    },
    confirmExport() {
      this.download('exportSignIn?teamId=' + this.form.teamId + '&startTime=' + this.form.dateRange[0] + '&endTime=' + this.form.dateRange[1], {
      }, `${this.form.name}上课签到表.xlsx`)
    },
    handleSizeChange(val) {
      this.data.pageIn.size = val;
      this.fetchData("pageIn");
    },
    handleCurrentChange(val) {
      this.data.pageIn.index = val - 1;
      this.fetchData("pageIn");
    },
    fetchData(_val) {
      if (_val !== "pageIn") {
        this.data.pageIn.index = 0;
        this.data.pageIn.size = 10;
      }
      this.listLoading = true;
      if (this.activeName == "all") {
        this.listLoading = true;
        getTeamDtoAll(this.data).then((response) => {
          this.list = response.data.findTeamDtoAll.ls;
          this.total = response.data.findTeamDtoAll.pageOut.total;
          this.listLoading = false;
        });
      } else if (this.activeName == "deactivated") {
        this.listLoading = true;
        let data = {
          itemType: "TEAM",
          staffId: JSON.parse(localStorage.getItem("selectStaff")).id,
          keyword: this.data.keyword,
          pageIn: { ...this.data.pageIn },
    data() {
        return {
            dialogVisible: false,
            form: {
                dateRange: [],
                teamId: "",
                name: "",
            },
            list: null,
            listLoading: true,
            activeName: "all",
            total: 0,
            data: {
                staffId: JSON.parse(localStorage.getItem("selectStaff")).id,
                keyword: "",
                pageIn: {
                    //可选,如果是分页查询,需要加上。
                    index: 0, //必选
                    size: 10, //每页的大小。默认20
                    sorts: {
                        name: "name", //排序字段名称
                        direction: "ASC", //排序方向
                    },
                },
                types: ["NORMAL"],
            },
        };
        getDeletedItem(data).then((response) => {
          this.list = response.data.findDeletedItem.ls;
          this.total = response.data.findDeletedItem.pageOut.total;
          this.listLoading = false;
        });
      }
    },
    concatenateArray(arr) {
      let result = "";
      for (let i = 0; i < arr.length; i++) {
        if (i == 0) {
          result += arr[i].name;
        } else {
          result += "," + arr[i].name;
        }
      }
      return result;
    created() {
        this.fetchData();
    },
  },
    methods: {
        handleExport(row) {
            this.form.dateRange = [];
            this.form.teamId = row.team.id;
            this.form.name = row.team.name;
            this.dialogVisible = true;
        },
        confirmExport() {
            this.download('exportSignIn?teamId=' + this.form.teamId + '&startTime=' + this.form.dateRange[0] + '&endTime=' + this.form.dateRange[1], {
            }, `${this.form.name}上课签到表.xlsx`)
        },
        handleSizeChange(val) {
            this.data.pageIn.size = val;
            this.fetchData("pageIn");
        },
        handleCurrentChange(val) {
            this.data.pageIn.index = val - 1;
            this.fetchData("pageIn");
        },
        fetchData(_val) {
            if (_val !== "pageIn") {
                this.data.pageIn.index = 0;
                this.data.pageIn.size = 10;
            }
            this.listLoading = true;
            if (this.activeName == "all") {
                this.listLoading = true;
                getTeamDtoAll(this.data).then((response) => {
                    this.list = response.data.findTeamDtoAll.ls;
                    this.total = response.data.findTeamDtoAll.pageOut.total;
                    this.listLoading = false;
                });
            } else if (this.activeName == "deactivated") {
                this.listLoading = true;
                let data = {
                    itemType: "TEAM",
                    staffId: JSON.parse(localStorage.getItem("selectStaff")).id,
                    keyword: this.data.keyword,
                    pageIn: { ...this.data.pageIn },
                };
                getDeletedItem(data).then((response) => {
                    this.list = response.data.findDeletedItem.ls;
                    this.total = response.data.findDeletedItem.pageOut.total;
                    this.listLoading = false;
                });
            }
        },
        concatenateArray(arr) {
            let result = "";
            for (let i = 0; i < arr.length; i++) {
                if (i == 0) {
                    result += arr[i].name;
                } else {
                    result += "," + arr[i].name;
                }
            }
            return result;
        },
    },
};
</script>
src/views/login/index.vue
@@ -40,7 +40,7 @@
            appid: "wx7103925df6236723",
            redirect_uri: encodeURIComponent("https://dingdang.9village.cn/#/login"),
            state: "1",
            href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7CiAgICAgICAgICBib3JkZXI6IG5vbmU7CiAgICAgICAgICB3aWR0aDogMTQwcHg7CiAgICAgICAgICBoZWlnaHQ6IDE0MHB4OwogICAgICAgIH0=", // 自定义样式链接
            href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30g", // 自定义样式链接
            loginForm: {
                username: "admin",
                password: "111111",
@@ -88,9 +88,9 @@
            login({
                code: code,
            }).then((res) => {
                localStorage.setItem("user", JSON.stringify(res));
                localStorage.setItem("staffs", JSON.stringify(res.staffs));
                localStorage.setItem("selectStaff", JSON.stringify(res.staffs[0]));
                sessionStorage.setItem("user", JSON.stringify(res));
                sessionStorage.setItem("staffs", JSON.stringify(res.staffs));
                sessionStorage.setItem("selectStaff", JSON.stringify(res.staffs[0]));
                this.$router.push("/student");
            });
        },
@@ -263,4 +263,9 @@
        user-select: none;
    }
}
.main_wx{
    height: 360px;
    margin-bottom: 100px;
}
</style>