<template>
  <div class="assessing-content ele-body">
    <el-card shadow="never" v-loading="loading" element-loading-background="rgba(255, 255, 255, 1)">
    <search :type="3" :search-params="searchParams" />
    <div class="operating">
        <el-button size="small" type="primary">导出</el-button>
    </div>
    <el-table highlight-current-row :data="dataList" :height="tableHeight" border>
      <el-table-column type="index" width="50" align="center" label="编号"></el-table-column>
      <el-table-column label="考核指标" min-width="150" align="center"></el-table-column>
      <el-table-column label="考核内容和计分细则" min-width="200" align="center"></el-table-column>
      <el-table-column label="小条内容" min-width="150" align="center"></el-table-column>
      <el-table-column label="分值" min-width="60" align="center"></el-table-column>
      <el-table-column label="区牵头单位" min-width="80" align="center"></el-table-column>
      <el-table-column label="牵头部门" min-width="80" align="center"></el-table-column>
      <el-table-column label="责任领导" min-width="80" align="center"></el-table-column>
      <el-table-column label="配合部门" min-width="80" align="center"></el-table-column>
      <el-table-column label="责任领导" min-width="80" align="center"></el-table-column>
      <el-table-column
        label="操作"
        width="125"
        align="center"
        :key="Math.random()"
      >
        <template slot-scope="{ row }">
          <el-link
            slot="reference"
            type="primary"
            :underline="false"
            @click="edit(row)"
            >编辑</el-link
          >
        </template>
      </el-table-column>
    </el-table>

     <el-pagination
        :current-page.sync="page.page"
        :page-size="page.limit"
        :total="count"
        :background="true"
        layout="total, prev, pager, next, jumper"
        :pager-count="5"
        class="ele-pagination-circle"
        :flat="true"
        @current-change="getDataList()"
      />
    </el-card>
    <el-dialog
      title="编辑考核内容"
      :visible.sync="showEdit"
      width="400px"
      custom-class="ele-dialog-form"
      :lock-scroll="false"
      :destroy-on-close="true"
      @closed="form = {}"
    >
      <el-form
        :model="form"
        label-width="82px"
        custom-class="editForm"
        @keyup.enter.native="save"
        @submit.native.prevent
        ref="editForm"
      >
        <el-form-item label="小条内容：" prop="">
          <el-input
            type="textarea"
            :rows="5"
            placeholder="请输入考核内容"
          ></el-input>
        </el-form-item>
        <el-form-item label="分值：" prop="">
          <el-input placeholder="请输入分值"></el-input>
        </el-form-item>

        <el-form-item label="牵头部门：" prop="">
          <treeselect
            :flat="true"
            :options="formatDep"
            :multiple="true"
            placeholder="请选择牵头部门"
            :defaultExpandLevel="2"
            :normalizer="
              (d) => {
                return {
                  id: d.id,
                  label: d.name,
                  children:
                    d.children && d.children.length > 0
                      ? d.children
                      : undefined,
                };
              }
            "
          />
          </el-form-item>
          <el-form-item label="配合部门：" prop="">
            <treeselect
              :flat="true"
              :options="formatDep"
              :multiple="true"
              placeholder="请选择牵头部门"
              :defaultExpandLevel="2"
              :normalizer="
                (d) => {
                  return {
                    id: d.id,
                    label: d.name,
                    children:
                      d.children && d.children.length > 0
                        ? d.children
                        : undefined,
                  };
                }
              "
            />
          </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="save">确定</el-button>
        <el-button @click="showEdit = false">取消</el-button>&nbsp;
      </div>
    </el-dialog>
  </div>
</template>

<script>
import search from "../search";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Treeselect from "@riophae/vue-treeselect";
import { mapGetters } from "vuex";
export default {
  components: {
    search,
    Treeselect
  },
  data() {
    return {
      searchParams: {},
      dataList: [
        {}
      ],
      loading: false,
      showEdit: false,
      form: {},
      count: 0,
      tableHeight: document.documentElement.clientHeight - 310,
      page: {
        page: 1,
        limit: Math.floor(
          (document.documentElement.clientHeight - 310 - 45) / 45
        ),
      },
    };
  },
  created() {
    this.getDataList();
  },
  computed: {
    ...mapGetters(["formatDep"]),
  },
  methods: {
    getDataList() {},
    edit(row) {
      this.showEdit = true
    },
    save() {
      this.showEdit = false
    }
  }
};
</script>

<style scoped>
</style>