<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">
          <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="设备名称:">
              <el-input
                v-model="formInline.sbName"
                placeholder="请输入"
              ></el-input>
            </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>
          <div class="addBtn">
            <el-button type="primary" icon="el-icon-plus" @click="addTantou"
              >新增激光探头</el-button
            >
          </div>
          <el-table :data="hardwareList" border style="width: 100%">
            <el-table-column
              align="center"
              label="序号"
              type="index"
              width="100px"
              :index="indexMethod"
              show-overflow-tooltip
            ></el-table-column>

            <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="设备IP" align="center">
            </el-table-column>
            <el-table-column align="center" label="操作" width="180">
              <template slot-scope="scope">
                <el-button type="text" size="small" icon="el-icon-edit"
                  >编辑</el-button
                >
                <el-button type="text" size="small" icon="el-icon-delete"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </d2-container>




    <!-- //弹框 -->
    <el-dialog title="新增探头" :visible.sync="dialogTantou">
  <el-form :model="dialog">
    <el-form-item label="设备名称:" :label-width="formLabelWidth">
      <el-input v-model="dialog.name" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="设备IP:" :label-width="formLabelWidth">
      <el-input v-model="dialog.name" autocomplete="off"></el-input>
    </el-form-item>
     <el-form-item label="设备编码:" :label-width="formLabelWidth">
      <el-input v-model="dialog.name" autocomplete="off"></el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogTantou = false">取 消</el-button>
    <el-button type="primary" @click="determine()">确 定</el-button>
  </div>
</el-dialog>

  </div>
</template>
<script>
export default {
  name: "hardwareParame",
  data() {
    return {
      // label宽度
      formLabelWidth: '120px',
      // 弹框默认关闭
      dialogTantou:false,
      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号仓",
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
      // 日期插件
      //

      formInline: {
        sbNames: "",
      },
      //表格字段
      hardwareList: [
        {
          directLibrary: "",
          subTreasury: "",
          cfName: "",
          scanStart: "",
          scanEnd: "",

          cfState: "",
        },
      ],
      //弹框字段
      dialog:{
        name:""
      }
    };
  },
  watch: {
    filterTest(val) {
      this.$refs.tree.filter(val);
    },
  },
  methods: {
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    search() {},
    reset() {},
    //新增
    addTantou() {
      this.dialogTantou=true;
    },
    //表格序号
    indexMethod(index) {
      // return (
      //   (this.pagination.curPage - 1) * this.pagination.pageSize + index + 1
      // );
    },
    //弹框确定按钮
    determine(){}
  },
};
</script>
<style lang="scss" scoped>
.main {
  height: 100%;
  display: flex;
  .left {
    width: 200px;
    height: 100%;
    border-right: 1px solid #ccc;
    padding-right: 20px;
  }
  .right {
    margin-left: 20px;
  }
  .addBtn {
    margin-bottom: 20px;
  }
}
</style>