<template>
  <div>
    <d2-container>
      <!-- <template slot="header">首页/数据查询</template> -->
      <div class="main">
        <div class="left">
          <el-input placeholder="输入关键字进行过滤" v-model="filterText">
          </el-input>

          <el-tree
            class="filter-tree"
            :data="leftList"
            node-key="id"
            :props="defaultProps"
            default-expand-all
            :filter-node-method="filterNode"
            ref="tree"
          >
            <span class="custom-tree-node" slot-scope="{ node, data }">
              <span> <i :class="node.icon"></i>{{ node.label }} </span>
            </span>
          </el-tree>
        </div>
        <div class="right">
          <!-- <template slot="header">首页/数据查询</template> -->
          <div class="nav">首页/数据查询</div>
          <div class="right_main">
            <div class="right_title">数据查询</div>
            <div class="right_table">
          <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="扫描时间">
              <el-date-picker
                v-model="formInline.scanTime"
                type="daterange"
                align="right"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search"
                >查询</el-button
              >
            </el-form-item>

            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-refresh-left"
                @click="reset"
                >重置</el-button
              >
            </el-form-item>
          </el-form>
          <el-table :data="dataSearchList" border style="width: 100%">
            <el-table-column
              prop="directLibrary"
              label="所属直属库"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="subTreasury" label="所属分库" align="center">
            </el-table-column>
            <el-table-column prop="cfName" label="仓房名称" align="center">
            </el-table-column>
            <el-table-column
              prop="scanStart"
              label="扫描开始时间"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="scanEnd" label="扫描结束时间" align="center">
            </el-table-column>

            <el-table-column prop="isAlarm" label="是否报警" align="center">
            </el-table-column>

            <el-table-column prop="cfState" label="仓房状态" align="center">
            </el-table-column>
             <el-table-column prop="cfState" label="体积" align="center">
            </el-table-column>  
             <el-table-column prop="cfState" label="重量" align="center">
            </el-table-column>     
             <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="detail(scope.row)" type="text" size="small">详情</el-button>
    
      </template>
    </el-table-column>     
          </el-table>
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="1"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pagination.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pagination.total"
          >
          </el-pagination>
          </div>
        </div>
        </div>
      </div>
    </d2-container>
  </div>
</template>
<script>
export default {
  name: "dataQuery",
  data() {
    return {
      filterText: "",
      //默认展开的节点
      defaultProps: {
        children: "children",
        label: "label",
      },
      //左侧树数据
      leftList: [
        {
          id: 0,
          label: "中储粮河南分公司",
          icon: "el-icon-tickets",
          children: [
            {
              id: 1,
              label: "商丘直属库",
              icon: "el-icon-paperclip",
              children: [
                {
                  id: 4,
                  label: "宁陵粮油储备公司",
                  children: [
                    {
                      id: 9,
                      label: "1号仓",
                    },
                    {
                      id: 10,
                      label: "2号仓",
                    },
                  ],
                },
              ],
            },
            {
              id: 2,
              label: "郑州直属库",
              icon: "el-icon-paperclip",
              children: [
                {
                  id: 5,
                  label: "中牟粮油储备公司",
                  children: [
                    {
                      id: 8,
                      label: "1号仓",
                    },
                    {
                      id: 9,
                      label: "1号仓",
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
      // 日期插件
      //
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      formInline: {
        scanTime: "",
      },
      //表格字段
      dataSearchList: [
        {
          directLibrary: "",
          subTreasury: "",
          cfName: "",
          scanStart: "",
          scanEnd: "",

          cfState: "",
        },
      ],

      pagination: {
        //每页显示的条数
        pageSize: 10,
        //当前页
        curPage: 1,
        //总数
        total: 20
      },
    };
  },
  watch: {
    filterTest(val) {
      this.$refs.tree.filter(val);
    },
  },
  methods: {
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    search() {},
    reset() {},
    //每页条数改变
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    //当前页改变
    handleCurrentChange(val) {
      // this.pagination.curPage = val;
      console.log(`当前页: ${val}`);
    },
    detail(){}
  },
};
</script>
<style lang="scss" scoped>
.main {
  height: 100%;
  display: flex;
  .left {
    width: 250px;
    height: 100%;
   background: #163d79;
  
  }
  .right {
    margin-left: 20px;
    width:calc(100% - 250px);
    .nav {
      padding: 10px 0 10px 10px;
      color:#FFF;
  
      background: #004a93;
    }
    .right_main{
      border:1px solid #0a3e6b;
      background:#112f5d;
      margin-top:10px;
      .right_title{
        color:#FFF;
        border-bottom:1px solid #0a3e6b;
        padding:10px;
    }
    .right_table{
       padding:20px;
    
    }
    }
   
  }
}

</style>