<template>
  <div class="app-container">
    <el-form ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <kindergarten @kinbatlist="kinbatlist" style="width: 500px; display: inline"></kindergarten>
      <el-form-item label="班级类型" prop="categoryName" label-width="70px">
        <el-select v-model="analysislist.classType" clearable placeholder="请选择">
          <el-option
            v-for="item in dictValues"
            :key="item.name"
            :label="item.name"
            :value="item.type"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查看</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-row v-show="itemshow">
      <el-table :data="physicalActionList">
        <el-table-column :label="classTypeName" align="center">
          <el-table-column prop="itemName" label="项目" align="center"></el-table-column>
          <el-table-column label="男孩" align="center">
            <el-table-column prop="maleAvgScore" label="平均值" align="center"></el-table-column>
            <el-table-column prop="maleCityAvgScore" label="全市平均值" align="center"></el-table-column>
            <!-- <el-table-column
              prop="malePassCount"
              label="合格人数"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="malePassRate"
              label="合格率"
              align="center"
            >
              <template slot-scope="scope"
                >{{ scope.row.malePassRate }}%</template
              >
            </el-table-column>-->
          </el-table-column>
          <el-table-column label="女孩" align="center">
            <el-table-column prop="feMaleAvgScore" label="平均值" align="center"></el-table-column>
            <el-table-column prop="feMaleCityAvgScore" label="全市平均值" align="center"></el-table-column>
            <!-- <el-table-column
              prop="feMalePassCount"
              label="合格人数"
              width="120"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="feMalePassRate"
              label="合格率"
              width="120"
              align="center"
            >
              <template slot-scope="scope"
                >{{ scope.row.feMalePassRate }}%</template
              >
            </el-table-column>-->
          </el-table-column>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row :gutter="20" v-if="itemshow2">
      <el-col :span="24" :offset="0">
        <el-card>
          <div slot="header" style="text-align: center">
            <img style="width: 40px" src="@/icons/笑脸.png" alt />

            <div>
              <!-- card title -->
              此批次暂无数据
            </div>
          </div>
          <!-- card body -->
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { tKindergartenInfo } from "@/api/system/kindergartenInfo";
import { getRoleInfo } from "@/api/system/quality";
import { developmentanalysis } from "@/api/system/development";
import kindergarten from "../../assembly/kindergarten.vue";
export default {
  components: { kindergarten },
  name: "classconstitution",
  data() {
    return {
      itemshow: false,
      itemshow2: false,
      //班级类型
      ClassType: "class_type",
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      analysislist: {
        kindergartenId: "",
        classType: "",
        batchCode: ""
        // kindergartenId: "21",
        // classType: "SMALL_CLASS",
        // batchCode: "PC202208030005",
      },
      dictValues: [],
      classTypeName: "",
      physicalActionList: []
    };
  },

  created() {
    this.getList();
    this.class();
    // this.analysisinfo();
  },
  methods: {
    handleQuery() {
      this.analysisinfo();
    },
    kinbatlist(kindergartenId, batchCode) {
      this.analysislist.kindergartenId = kindergartenId;
      this.analysislist.batchCode = batchCode;
      if (batchCode == "请选择批次") {
        this.analysislist.batchCode = "";
      }
    },
    //动作发展状况
    analysisinfo() {
      developmentanalysis(this.analysislist).then(res => {
        if (res.data) {
          var obj = res.data;
          this.physicalActionList = obj.physicalActionList;
          this.classTypeName = res.data.classTypeName;
          this.itemshow = true;
          this.itemshow2 = false;
        } else {
          this.itemshow = false;
          this.itemshow2 = true;
        }
      });
    },
    //幼儿园左侧点击
    kindergartenNameclick(row) {
      this.analysislist.kindergartenId = row.id;
      this.kindergartenName = row.kindergartenName;
      this.kindergartenId = row.id;
      this.analysislist.classType = "";
      this.kindergartenshow = false;
    },
    //班级类型
    class() {
      tKindergartenInfo(this.ClassType).then(res => {
        res.data.forEach(e => {
          var obj = {
            name: e.dictLabel,
            type: e.dictValue
          };
          this.dictValues.push(obj);
        });
      });
    },
    getList() {
      //用户权限
      getRoleInfo().then(res => {
        var user = res.data.roleKeys;
        if (user.includes("enchou")) {
          return;
        } else if (user.includes("teacher")) {
          return;
        } else if (user.includes("parent")) {
          return;
        }
      });
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    }
  }
};
</script>
<style scoped='scss'>
::v-deep .el-form {
  display: inline;
}
</style>
