<template>
  <div class="concerned-college-container">
    <mx-table :rows="dataList" :propDefines="propDefines">
      <template #column-check-style="{value}">
        <mx-check-status :checked="value>1" yes-only />
      </template>
      <template #column-delete="{ row }">
        <i class="el-icon-delete pointer" @click="del(row)"></i>
      </template>
    </mx-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      :page-size="20" @pagination="getList" />
  </div>
</template>
<script>
  import {concernedUniversities, removeConcernedUniversity} from "@/api/webApi/career-other"

  export default {
    data() {
      return {
        total: 0,
        dataList: [],
        propDefines: {
          name: {
            label: "院校名称"
          },
          location: {
            label: "所在地"
          },
          managerType: {
            label: "主管部门"
          },
          type: {
            label: "院校类型"
          },
          level: {
            label: "学历层次"
          },
          ylxx: {
            label: "一流大学建设高校",
            sortable: true,
            displayIcon: true,
            slot: "column-check-style",
          },
          ylxk: {
            label: "一流学科建设高校",
            sortable: true,
            displayIcon: true,
            slot: "column-check-style",
          },
          yjsy: {
            label: "研究生院",
            sortable: true,
            displayIcon: true,
            slot: "column-check-style",
          },
          actions: {
            label: "操作",
            slot: "column-delete",
            width: "80px",
          },
        },
        queryParams: {
          pageNum: 1,
          pageSize: 20,
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        concernedUniversities(this.queryParams).then((res) => {
          console.log("concernedUniversities res", res);
          if (res.code == 200 || res.code == 0) {
            this.dataList = res.rows;
            this.total = res.total;
          } else {
            this.msgError(res.msg || "concernedUniversities 请求异常");
          }
          this.loading = false;
        });
      },
      del(row) {
        if (!row || !row.id) return;
        this.$confirm(`确认删除 '${row.name}'`, "提示", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          removeConcernedUniversity({
            id: row.id
          }).then((res) => {
            const msgFunc = res.code == 200 ? this.msgError : this.msgSuccess;
            msgFunc(res.msg);
          });
        });
      },
    },
  };
</script>
<style lang="scss" scoped>
</style>
