<template>
  <div class="concerned-major-container" v-loading="loading">
    <mx-table :rows="dataList" :propDefines="propDefines">
      <template #column-delete="{ row }">
        <i class="el-icon-delete pointer" @click="del(row)"></i>
      </template>
    </mx-table>
    <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" :page-size="20"
      @pagination="getList" />
  </div>
</template>
<script>
  import {
    concernedMajors,
    removeConcernedMajor,
  } from "@/api/webApi/career-other";

  export default {
    data() {
      return {
        loading: false,
        total: 1,
        dataList: [],
        propDefines: {
          code: {
            label: "专业代码"
          },
          name: {
            label: "专业名称"
          },
          type: {
            label: "专业类型"
          },
          actions: {
            label: "操作",
            slot: "column-delete",
            width: "80px",
          },
        },
        queryParams: {
          pageNum: 1,
          pageSize: 20,
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        concernedMajors(this.queryParams).then((res) => {
          console.log("concernedMajors res", res);
          if (res.code == 200 || res.code == 0) {
            this.dataList = res.rows;
            this.total = res.total;
          } else {
            this.msgError(res.msg || "concernedMajors 请求异常");
          }
          this.loading = false;
        });
      },
      del(row) {
        if (!row || !row.id) return;
        this.$confirm(`确认删除 '${row.name}'`, "提示", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          removeConcernedMajor({
            id: row.id
          }).then((res) => {
            const msgFunc = res.code == 200 ? this.msgError : this.msgSuccess;
            msgFunc(res.msg);
          });
        });
      },
    },
  };
</script>
<style lang="scss" scoped>
</style>
