ManageSchoolTable.vue 18.4 KB
Newer Older
1
<template>
Joey0610's avatar
Joey0610 已提交
2
  <div style="width: 100%" class="ManageCompititionTable">
3 4 5 6 7 8 9 10 11 12
    <el-card style="margin-top: 15px">
      <el-form
        :inline="true"
        :model="formInline"
        ref="formInline"
        :rules="rules"
        style="margin-top: 15px"
      >
        <el-form-item style="float: left">
          <el-button @click="release" type="primary" plain round size="medium"
Joey0610's avatar
Joey0610 已提交
13
            >新增用户1</el-button
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
          >
        </el-form-item>

        <el-form-item prop="param1">
          <el-input
            v-model="formInline.param1"
            placeholder="请输入要查询的内容"
            size="medium"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="地址:" prop="param2">
          <el-select v-model="formInline.param2" placeholder="条件2">
            <el-option label="选项1" value="item1"></el-option>
            <el-option label="选项2" value="item2"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item>
          <!-- <el-button type="primary" round @click="onSubmit('formInline')"
            >查询</el-button -->
          <el-button
            style="position: relative; right: 25px"
            type="primary"
            icon="el-icon-search"
            plain
            round
            size="medium"
            @click="onSubmit('formInline')"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
    </el-card>
    <el-card style="margin-top: 20px">
Joey0610's avatar
Joey0610 已提交
47 48 49 50 51 52 53
      <el-table
        :data="competeList"
        stripe
        border
        style="width: 100%"
        @sort-change="onSortChange"
      >
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
        <!-- <el-table-column label="序号" width="50" align="center">
          <template slot-scope="scope">
            <span>{{
              (this.currentPage - 1) * this.pageSize + scope.$index + 1
            }}</span>
          </template>
        </el-table-column> -->
        <el-table-column
          label="序号"
          width="50"
          align="center"
          type="index"
          :index="indexMethod"
          header-align="center"
        >
        </el-table-column>

        <!-- <el-table-column prop="competitionId" label="竞赛id" width="80"> -->
        <!-- <template slot-scope="scope"> -->
        <!-- <span style="margin-left: 10px">{{ item.competitionId }}</span> -->
        <!-- </template> -->

        <!-- </el-table-column> -->
        <el-table-column
          prop="title"
Joey0610's avatar
Joey0610 已提交
79
          label="帖子主题"
80 81 82 83 84 85
          width="420"
          align="center"
          header-align="center"
        >
        </el-table-column>
        <el-table-column
Joey0610's avatar
Joey0610 已提交
86 87 88
          prop="auditStatus"
          label="审核状态"
          width="320"
89 90 91 92
          align="center"
          header-align="center"
        >
        </el-table-column>
Joey0610's avatar
Joey0610 已提交
93
        <!-- <el-table-column
94 95 96 97 98
          prop="count"
          label="已报名人数"
          width="200"
          align="center"
          header-align="center"
Joey0610's avatar
Joey0610 已提交
99 100
          sortable="custom"
          :sort-orders="['1', '2']"
101
        >
Joey0610's avatar
Joey0610 已提交
102
        </el-table-column> -->
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
        <el-table-column
          label="操作"
          width="414"
          align="center"
          header-align="center"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="handleDetail(scope.row.competitionId)"
              round
              >详细信息
            </el-button>
            <el-button
              size="mini"
              @click="handleEdit(scope.row.competitionId)"
              round
              plain
              >编辑信息
            </el-button>
            <el-button
              type="danger"
              size="mini"
              @click="handleDelete(scope.row.competitionId)"
              round
              plain
              >删除信息
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <br />
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        @prev-click="handlePrev"
        @next-click="handleNext"
        background
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageTotal"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "PageTable",
  data() {
    return {
      formInline: {
        param1: "",
        param2: "选项1",
      },
      // tableData: [
      //   {
      //     // no: "1",
      //     // title: "2022福州大学数学竞赛校赛",
      //     // num: "135",
      //     competitionId: "",
      //     title: "",
      //     teacherName: "",
      //     count: "",
      //   },
      // ],

      rules: {
        param1: [
          { required: false, message: "请输入", trigger: "blur" },
          {
            min: 0,
            max: 10,
            message: "长度在 0 到 10 个字符",
            trigger: "blur",
          },
        ],
      },
Joey0610's avatar
Joey0610 已提交
184
      type: 0,
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
      currentPage: 1,
      pageSize: 10,
      pageTotal: 8,
      dialogFormVisible: false,
      form: {
        // no: "0",
        // title: "2022福州大学数学竞赛校赛",
        // num: "135",
        // index: 0,
      },

      //   competitionId: ''
      // title: '',
      // teacherName: '',
      // count: ''
      competeList: [],
    };
  },

  created() {
    // this.getCompeteList();
  },

  mounted() {
    this.getCompeteList();
    console.log("this.competeList111");
    console.log(this.competeList);
    console.log("this.competeList111");
  },

  methods: {
    //点击跳转
    //序号
    indexMethod(index) {
      return (this.currentPage - 1) * this.pageSize + index + 1;
    },
    //发布竞赛功能
    release() {
      this.$router.replace("/PageFormsSignup");
    },
    //查询竞赛功能
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.formInline.param1 == "") {
            this.getCompeteList();
          } else {
            this.$axios({
              method: "get",
Joey0610's avatar
Joey0610 已提交
234
              url: "http://124.220.174.249:8085/backend/admin/showAllCompetition",
235 236
              headers: { token: localStorage.token },
              params: {
Joey0610's avatar
Joey0610 已提交
237 238
                // title: this.formInline.param1, //获取查询内容
                // teacherNo: localStorage.getItem("userId"),
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
                page: 1,
                limit: 10,
              },
            })
              .then((res) => {
                console.log("5");
                console.log(res);
                if (res.data.code == "200") {
                  this.competeList = res.data.data;
                  this.pageTotal = Number(res.data.details.infoCount); //显示当前条数
                  this.handleCurrentChange(1);
                  console.log(res.data.data);
                }
              })
              .catch((err) => {
                console.log(err);
              });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
Joey0610's avatar
Joey0610 已提交
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
    // //退出登录
    // exit() {
    //   // this.$router.replace("/");
    //   this.$axios({
    //     method: "post",
    //     url: "http://124.220.174.249:8085/backend/logout",
    //     headers: { token: localStorage.token },
    //   })
    //     .then((res) => {
    //       console.log(res);
    //       if (res.data.code == "200") {
    //         console.log("返回登录界面");
    //         this.$router.replace("/");
    //       }
    //     })
    //     .catch((err) => {
    //       return this.$message.error("退出失败");
    //       console.log("退出失败");
    //     });
    // },
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
    //查看竞赛详情
    handleDetail(id) {
      console.log("id");
      console.log(id);
      console.log("id");
      this.$router.push({ path: "/PageFormsDetail", query: { id: id } });
      // this.form.index = index + (this.currentPage - 1) * this.pageSize;
      // this.form.no = row.no;
      // this.form.title = row.title;
      // this.form.num = row.num;
      // this.dialogFormVisible = true;
    },
    //修改竞赛信息
    handleEdit(id) {
      this.$router.push({ path: "/PageFormsModify", query: { id: id } });
      // this.form.index = index + (this.currentPage - 1) * this.pageSize;
      // this.form.no = row.no;
      // this.form.title = row.title;
      // this.form.num = row.num;
      // this.dialogFormVisible = true;
    },
    //删除竞赛信息
Joey0610's avatar
Joey0610 已提交
305 306 307 308 309 310 311 312 313 314
    handleDelete(id) {
      this.$router.push({ path: "/PageFormsDelete", query: { id: id } }); // 通过this.$route.query.id获得id
      // this.tableData.splice(index + (this.currentPage - 1) * this.pageSize, 1);
      // this.pageTotal = this.tableData.length;
      // this.$message({
      //   message: "删除" + row.name + "成功!",
      //   type: "success",
      // });
       //确定删除
    },
315 316 317 318 319 320 321 322 323
    handleDelete(id) {
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$axios({
            method: "post",
Joey0610's avatar
Joey0610 已提交
324
            url: "http://124.220.174.249:8085/backend/teacher/deleteCompetition",
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
            headers: { token: localStorage.token },
            data: {
              competitionId: id,
            },
          })
            .then((res) => {
              console.log("5");
              console.log(res);
              if (res.data.code == "200") {
                console.log("删除成功");
                this.getCompeteList();
                // this.$router.replace("/PageTable");
                // this.$notify({
                //   title: "竞赛删除成功",
                //   message: "返回大厅!",
                //   type: "success",
                // });
              }
            })
            .catch((err) => {
              console.log(err);
              console.log("删除失败");
            });
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
      // this.$axios
      //   .post("http://47.113.195.148:8085/backend/teacher/deleteCompetition", {
      //     competitionId: this.queryInfo.competeId,
      //     //  competitionId: "11"
      //   })
    },

    //每页条数改变
    handleSizeChange(size) {
      this.pageSize = size;
      console.log("this.pageSize");
      console.log(this.pageSize);
      console.log("this.pagesize");
      if (this.formInline.param1 == "") {
        this.$axios({
          method: "get",
Joey0610's avatar
Joey0610 已提交
375
          url: "http://124.220.174.249:8085/backend/admin/showAllCompetition",
376 377
          headers: { token: localStorage.token },
          params: {
Joey0610's avatar
Joey0610 已提交
378
            // teacherNo: localStorage.getItem("userId").replace(/\"/g, ""), //去掉双引号
379 380
            page: this.currentPage,
            limit: this.pageSize,
Joey0610's avatar
Joey0610 已提交
381
            type: this.type,
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
          },
        })
          .then((res) => {
            console.log(res);
            if (res.data.code == "200") {
              this.competeList = res.data.data;
              console.log("res.data.data");
              console.log(this.competeList);
              console.log("res.data.data");
              this.pageTotal = Number(res.data.details.infoCount);
            }
          })
          .catch((err) => {
            return this.$message.error("获取竞赛列表信息失败!");
          });
      } else {
        this.$axios({
          method: "get",
Joey0610's avatar
Joey0610 已提交
400
          url: "http://124.220.174.249:8085/backend/teacher/searchCompetition",
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
          headers: { token: localStorage.token },
          params: {
            title: this.formInline.param1, //获取查询内容
            teacherNo: localStorage.getItem("userId"),
            page: this.currentPage,
            limit: this.pageSize,
          },
        })
          .then((res) => {
            console.log("5");
            console.log(res);
            if (res.data.code == "200") {
              this.competeList = res.data.data;
              this.pageTotal = Number(res.data.details.infoCount); //显示当前条数
              console.log(res.data.data);
            }
          })
          .catch((err) => {
            console.log(err);
          });
      }
    },
    //当前页改变会触发?
    handleCurrentChange(currentPage) {
      this.currentPage = currentPage;
      if (this.formInline.param1 == "") {
        this.$axios({
          method: "get",
Joey0610's avatar
Joey0610 已提交
429
          url: "http://124.220.174.249:8085/backend/admin/showAllCompetition",
430 431 432 433 434
          headers: { token: localStorage.token },
          params: {
            // teacherNo: localStorage.getItem("userId").replace(/\"/g, ""), //去掉双引号
            page: this.currentPage,
            limit: this.pageSize,
Joey0610's avatar
Joey0610 已提交
435
            type: this.type,
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
          },
        })
          .then((res) => {
            console.log(res);
            if (res.data.code == "200") {
              this.competeList = res.data.data;
              console.log("res.data.data222");
              console.log(this.competeList);
              console.log("res.data.data222");
              this.pageTotal = Number(res.data.details.infoCount);
            }
          })
          .catch((err) => {
            return this.$message.error("获取竞赛列表信息失败!");
          });
      } else {
        this.$axios({
          method: "get",
Joey0610's avatar
Joey0610 已提交
454
          url: "http://124.220.174.249:8085/backend/teacher/searchCompetition",
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
          headers: { token: localStorage.token },
          params: {
            title: this.formInline.param1, //获取查询内容
            teacherNo: localStorage.getItem("userId"),
            page: this.currentPage,
            limit: this.pageSize,
          },
        })
          .then((res) => {
            console.log("5");
            console.log(res);
            if (res.data.code == "200") {
              this.competeList = res.data.data;
              this.pageTotal = Number(res.data.details.infoCount); //显示当前条数
              console.log(res.data.data);
            }
          })
          .catch((err) => {
            console.log(err);
          });
      }
    },

    // //用户点击上一页按钮改变当前页后触发
    // handlePrev() {},
    // //用户点击下一页按钮改变当前页后触发
    // handleNext() {},
    //获取竞赛信息(竞赛大厅)
    getCompeteList() {
      console.log(localStorage.getItem("token"));
      console.log(localStorage.getItem("userId"));
      // this.$axios.defaults.headers.common["Authorization"] =  localStorage.getItem('token');
      // this.$axios.interceptors.request.use(
      //   function (config) {
      //     // Do something before request is sent
      //     let token = localStorage.getItem("token");
      //     if (token) {
      //       config.headers.token = token; //将token放到请求头发送给服务器
      //       return config;
      //       //这里经常搭配token使用,将token值配置到tokenkey中,将tokenkey放在请求头中
      //       // config.headers['accessToken'] = Token;
      //     }
      //   },
      //   function (error) {
      //     // Do something with request error
      //     return Promise.reject(error);
      //   }
      // );
      // console.log("papa");
      // console.log(this.pageSize);
      // console.log("papa");
      this.$axios({
        method: "get",
Joey0610's avatar
Joey0610 已提交
508
        url: "http://124.220.174.249:8085/backend/admin/showAllHelp",
509 510 511 512 513 514 515
        // Headers: { token: localStorage.getItem("token") },
        // headers: {
        //   authorization: `Bearer ${localStorage.getItem("token")}`,
        // },
        headers: { token: localStorage.token },
        params: {
          // teacherNo: 101,
Joey0610's avatar
Joey0610 已提交
516
          // teacherNo: localStorage.getItem("userId").replace(/\"/g, ""), //去掉双引号
517 518
          page: this.currentPage,
          limit: this.pageSize,
Joey0610's avatar
Joey0610 已提交
519
          // type: this.type,
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
          // limit: 30,
          // token:localStorage.token
          // headers:{token:localStorage.token},
        },
      })
        // this.$axios
        //   .get("http://47.113.195.148:8085/backend/teacher/showAllCompetitions", {
        //     //params参数必写 , 如果没有可传参数,传{}以
        //     params: {
        //       teacherNo: localStorage.getItem("userId"),
        //     },
        //   })
        .then((res) => {
          // console.log(username + password);
          console.log(res);
          if (res.data.code == "200") {
            this.competeList = res.data.data;
            console.log("res.data.data");
            console.log(this.competeList);
            console.log("res.data.details.infoCount");
            console.log(res.data.details.infoCount);
            console.log(res.data.data.length);
            this.pageTotal = Number(res.data.details.infoCount);
            console.log("res.data.data");
          }
        })
        .catch((err) => {
          return this.$message.error("获取竞赛列表信息失败!");
        });
Joey0610's avatar
Joey0610 已提交
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
    },
        //分页升降序
    onSortChange({ prop, order }) {
      if (order == "ascending") this.type = 1;
      else this.type = 2;
      this.$axios({
        method: "get",
        url: "http://124.220.174.249:8085/backend/admin/showAllCompetition",
        headers: { token: localStorage.token },
        params: {
          // teacherNo: 101,
          // teacherNo: localStorage.getItem("userId").replace(/\"/g, ""), //去掉双引号
          page: this.currentPage,
          limit: this.pageSize,
          type: this.type,
        },
      })
        .then((res) => {
          console.log(res);
          if (res.data.code == "200") {
            this.competeList = res.data.data;
            console.log("res.data.data");
            console.log(this.competeList);
            console.log("res.data.details.infoCount");
            console.log(res.data.details.infoCount);
            console.log(res.data.data.length);
            this.pageTotal = Number(res.data.details.infoCount);
            console.log("res.data.data");
          }
        })
        .catch((err) => {
          return this.$message.error("获取竞赛列表信息失败!");
        });
582 583 584 585 586 587
    },
  },
};
</script>

<style scoped>
Joey0610's avatar
Joey0610 已提交
588 589 590 591 592 593 594 595 596 597
.el-menu-demo{
  float:right;
}

.icon_left{
  float: left;
  font-size: 30px;
  color: cornflowerblue;
  font-weight: 700;
}
Joey0610's avatar
Joey0610 已提交
598 599 600 601 602

.ManageCompititionTable{
  position: absolute;
  top: 80px;
}
603
</style>