<template>
  <!-- 驻勤点点名数据 -->
  <div class="station-roll-call-list">
    <div class="query">
      <el-form :inline="true" :model="queryForm" class="query-form">
        <el-form-item label="计划名称">
          <el-input v-model="queryForm.name" placeholder="请输入名称"></el-input>
        </el-form-item>
        <el-form-item label="辖区">
          <tree-select
            class="tree-select"
            :options="departs"
            placeholder="请选择"
            :normalizer="normalizer"
            v-model="queryForm.depart"
            noOptionsText="无数据"
            noResultsText="无数据"
          />
        </el-form-item>
        <el-form-item label="驻勤点类型">
          <el-select v-model="queryForm.stationType" placeholder="请选择">
            <el-option v-for="item in stationTypes" :key="item.code" :label="item.name" :value="item.code"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="query">查询</el-button>
          <el-button type="primary" plain @click="back">重置</el-button>
        </el-form-item>
        <el-form-item label="点名发起人">
          <el-input v-model="queryForm.rollInitiator" placeholder="请输入点名发起人"></el-input>
        </el-form-item>
        <el-form-item label="点名时间">
          <el-date-picker
            v-model="queryForm.rollTime"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd HH:mm:ss"
            size="small"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
    </div>
    <el-table ref="table" :data="tableList" border stripe style="width: 100%" tooltip-effect="dark">
      <el-table-column type="index" width="60" label="序号"> </el-table-column>
      <el-table-column align="left" label="驻勤点名称" min-width="220" prop="name" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="辖区" min-width="220" prop="region" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="驻勤点类型" min-width="220" prop="stationType" show-overflow-tooltip>
      </el-table-column>
      <el-table-column align="left" label="所属公司" min-width="220" prop="company" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="点名时间" min-width="168" prop="time" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="督导点名总人数" min-width="220" prop="total" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="成功人数" min-width="102" prop="success" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="失败人数" min-width="102" prop="failed" show-overflow-tooltip> </el-table-column>
      <el-table-column align="left" label="点名发起人" min-width="100" prop="initiator" show-overflow-tooltip> </el-table-column>
      <el-table-column align="center" fixed="right" label="操作" width="157">
        <template slot-scope="scope">
          <div class="table-btn">
            <el-button type="text" @click="checkRow(scope.row)"> 查看 </el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination"
      :current-page="queryForm.pageNum"
      :page-size="queryForm.pageSize"
      :page-sizes="[10, 20, 30, 50]"
      :total="total"
      layout="total, prev, pager, next, sizes"
      @size-change="listSizeChange"
      @current-change="listCurrentChange"
    >
    </el-pagination>
  </div>
</template>

<script>
import treeSelect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { getAllStationTypes } from "@/api/security-station-controller";
import { getDeparts } from "@/api/departs-controller";

export default {
  name: "stationRollCallList",
  components: {
    treeSelect,
  },
  props: {
    data: Object,
  },
  data() {
    return {
      queryForm: {
        name: "",
        stationType: "", //驻勤点类型
        depart: null, //辖区
        rollInitiator: "", //点名发起人
        rollTime: "", //点名时间
      },
      stationTypes: [],
      departs: [],
      normalizer(node) {
        if (node.children && !node.children.length) {
          delete node.children;
        }
        return {
          id: node.code,
          label: node.name,
          children: node.children,
          isDisabled: !node.selectable,
        };
      },
      tableList: [
        {
          name: "xxx",
        },
      ],
      total: 0,
    };
  },
  methods: {
    async init() {
      this.stationTypes = await getAllStationTypes(); //获取驻勤点信息
      console.log("stationTypes", this.stationTypes);
      this.departs = await getDeparts(); // 获取辖区树
      console.log("departs", this.departs);
    },
    query() {},
    back() {
      this.$emit("back");
    },
    listSizeChange() {},
    listCurrentChange() {},
    checkRow(row) {
      this.$emit("toPersonCardList", row);
    },
  },
  mounted() {
    this.init();
  },
};
</script>

<style scoped lang="scss">
.tree-select {
  //padding-top: 6px;
  width: 400px;
  // font-size: 14px;
  line-height: 35px;
  // font-family: PingFang SC-Regular, PingFang SC;
  // font-weight: 400;
  color: #606266;
  .vue-treeselect__placeholder {
    line-height: 35px;
  }
  .vue-treeselect__control {
    height: 35px !important;
  }
  .vue-treeselect__placeholder,
  .vue-treeselect__single-value {
    line-height: 35px;
  }
}
.station-roll-call-list {
  width: 100%;
  height: 100%;
  .query {
    width: 100%;
    height: 164px;
    background: #f5faff;
    box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.04);
    margin-bottom: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: space-between;
  }
}
</style>
