<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">
          <div class="addBtn">
            <el-button type="primary" icon="el-icon-plus" @click="addTantou"
              >修改新增报警规则</el-button
            >
          </div>
          <el-form :model="formData" ref="formData">
            <el-row style="margin-top: 10px">
              <el-col :span="24" :offset="2">
                <el-form-item label="报警启用状态:">
                  <el-radio-group v-model="formData.status">
                    <el-radio :label="1" :disabled="disabled">开</el-radio>
                    <el-radio :label="0" :disabled="disabled">关</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="10">
              <el-col :span="10" :offset="2">
                <h4>电话通知:</h4>
                <p>
                  电话1:
                  <span>{{ formData.telephoneNumber1 }}</span>
                </p>
                <p>
                  电话2:
                  <span>{{ formData.telephoneNumber2 }}</span>
                </p>
              </el-col>
              <el-col :span="10" :offset="2">
                <h4>短信通知:</h4>
                <p>
                  电话1:
                  <span>{{ formData.smsNumber1 }}</span>
                </p>
                <p>
                  电话2:
                  <span>{{ formData.smsNumber2 }}</span>
                </p>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </div>
    </d2-container>

    <!-- //弹框 -->
    <el-dialog title="新增修改报警规则" :visible.sync="dialogAlarm">
      <el-form :model="dialog">
        <el-form-item label="报警启用状态:" :label-width="formLabelWidth">
          <el-radio-group v-model="dialog.name">
            <el-radio label="开"></el-radio>
            <el-radio label="关"></el-radio>
          </el-radio-group>
        </el-form-item>
        <h4>电话通知:</h4>
        <el-form-item label="电话1:" :label-width="formLabelWidth">
          <el-input v-model="dialog.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="电话2:" :label-width="formLabelWidth">
          <el-input v-model="dialog.name" autocomplete="off"></el-input>
        </el-form-item>
         <h4>短信通知:</h4>
        <el-form-item label="电话1:" :label-width="formLabelWidth">
          <el-input v-model="dialog.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="电话2:" :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="dialogAlarm = 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",
      // 弹框默认关闭
      dialogAlarm: 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: "",
      },
      formData: {
        status: 0,
        totalStatus: 0,
        totalThreshold: "",
        timeThreshold: "",
        telephoneNumber1: "",
        telephoneNumber2: "",
        smsNumber1: "",
        smsNumber2: "",
        id: "",
      },
      //弹框字段
      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.dialogAlarm = 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;
    width:100%;
  }
  .addBtn {
    margin-bottom: 20px;
  }
  h4 {
    font-size: 16px;
    font-weight: 700;
    line-height: 40px;
  }
  p {
    color: #525357;
    font-size: 14px;
    line-height: 40px;
    position: relative;
  }
  span {
    margin: 10px;
    color: #000000;
  }
}
</style>