<template>
  <div>
    <el-dialog
      :close-on-click-modal="false"
      :title="title"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
      width="40%"
    >
      <el-form label-width="160px" :model="form" :disabled="disabled">
        <el-form-item label="IP地址:">
          <el-input
            clearable
            v-model.trim="form.ip"
            placeholder="请输入IP地址"
          ></el-input>
        </el-form-item>
        <el-form-item label="设备状态1:">
          <el-select
            clearable
            v-model.trim="form.devStatus"
            placeholder="请选择设备状态"
          >
            <el-option
              v-for="item in motherList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="MAC地址:">
          <el-input
            clearable
            v-model.trim="form.MAC"
            placeholder="请输入MAC地址"
          ></el-input>
        </el-form-item>
        <el-form-item label="子网掩码:">
          <el-input
            clearable
            v-model.trim="form.SubnetMask"
            placeholder="请输入子网掩码"
          ></el-input>
        </el-form-item>

        <el-form-item label="端口:">
          <el-input
            clearable
            v-model.trim="form.port"
            placeholder="请输入端口"
          ></el-input>
        </el-form-item>
        <el-form-item label="网关:">
          <el-input
            clearable
            v-model.trim="form.gateway"
            placeholder="请输入网关"
          ></el-input>
        </el-form-item>

        <el-form-item label="装置型号:">
          <el-select
            clearable
            v-model.trim="form.devType"
            placeholder="请选择装置型号"
          >
            <el-option
              v-for="item in TypeList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="生产厂家:">
          <el-select
            clearable
            v-model.trim="form.manufacturer"
            placeholder="请选择生产厂家"
          >
            <el-option
              v-for="item in manufacturerList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="出厂日期:">
          <el-date-picker
            clearable
            v-model.trim="form.ExFactory"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="出厂编号:">
          <el-input
            clearable
            v-model.trim="form.number"
            placeholder="请输入出厂编号"
          >
          </el-input>
        </el-form-item>

        <el-form-item label="装置电源电压(kV):">
          <el-select
            clearable
            v-model.trim="form.Voltage"
            placeholder="请选择装置电源电压"
          >
            <el-option
              v-for="item in VoltageList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="测量信号输入形式1:">
          <el-select
            clearable
            v-model.trim="form.InputForm"
            placeholder="请选择测量信号输入形式"
          >
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="电压信号输入通道数1:">
          <el-input
            clearable
            v-model.trim="form.passageway"
            placeholder="请输入电压信号输入通道数"
          ></el-input>
        </el-form-item>
        <el-form-item label="电流信号输入通道数1:">
          <el-input
            clearable
            v-model.trim="form.electricCurrent"
            placeholder="请输入电流信号输入通道数"
          ></el-input>
        </el-form-item>

        <el-form-item label="存储卡或硬盘容量(GB)1:">
          <el-input
            clearable
            v-model.trim="form.storage"
            placeholder="请输入存储卡或硬盘容量"
          ></el-input>
        </el-form-item>
        <el-form-item label="对时方式1:">
          <el-select
            clearable
            v-model.trim="form.Timing"
            placeholder="请选择对时方式"
          >
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="设备编码:">
          <el-input
            clearable
            v-model.trim="form.devCode"
            placeholder="请输入设备编码"
          ></el-input>
        </el-form-item>
        <el-form-item label="等级时间:">
          <el-date-picker
            clearable
            v-model.trim="form.Grade"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="发布状态1:">
          <el-input
            clearable
            v-model.trim="form.terminal"
            placeholder="请选择发布状态"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="设备类型1:">
          <el-input
            clearable
            v-model.trim="form.type"
            placeholder="请选择设备类型"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="PM编号:">
          <el-input
            clearable
            v-model.trim="form.pm"
            placeholder="请输入PM编号"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="资产编号:">
          <el-select
            clearable
            v-model.trim="form.whether"
            placeholder="请选择资产编号"
          >
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="备注:" style="width: 100%">
          <el-input
            clearable
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            v-model.trim="form.remarks"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleClose">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { dicData } from "@/assets/commjs/dictypeData";

export default {
  components: {},
  props: {
    dialogVisible: {
      type: Boolean, //类型
      required: true, //是否必须传入
    },
    title: { type: String, required: true },
    formInline: { type: [Array, Object], required: true },
  },
  data() {
    return {
      options: [
        {
          value: "选项1",
          label: "测试1",
        },
        {
          value: "选项2",
          label: "测试2",
        },
        {
          value: "选项3",
          label: "测试3",
        },
        {
          value: "选项4",
          label: "测试3",
        },
      ],
      motherList: [
        {
          id: 1,
          name: "正常",
        },
        {
          id: 0,
          name: "中断",
        },
      ],
      form: {
        terminal: "192.168.1.1", //IP地址
        mother: "0", //设备状态1
        MAC: "8C-8A-28-86-E2-9C", //MAC地址
        SubnetMask: "255.255.255.2", //子网掩码
        port: "8080", //端口
        gateway: "192.168.1.0", //网关
        device: "", //装置型号1
        Manufacturer: "", //生产厂家
        ExFactory: "2022-03-05", //出厂日期
        number: "1", //出厂编号
        Voltage: "37b81bf8aa0fd54098716da3fc0ee433", //装置电源电压
        InputForm: "", //测量信号输入形式1
        passageway: "", //电压信号输入通道数1
        electricCurrent: "", //电流信号输入通道数1
        storage: "", //存储卡或硬盘容量
        Timing: "", //对时方式1
        equipment: "4712837", //设备编码
        Grade: "2022-04-11", //等级时间
        status: "", //发布状态1
        EquipmentType: "", //设备类型1
        pm: "614691", //PM编号
        AssetNumber: "12638", //资产编号
        remarks: "", //备注
      },
      disabled: false,
      TypeList: [],
      manufacturerList: [],
      VoltageList: [],
    };
  },
  created() {
    this.form = {
      ...this.form,
      ...JSON.parse(JSON.stringify(this.formInline)),
    };

    // console.log(this.form);
    this.dictypeData();
  },

  methods: {
    // 字典表
    dictypeData() {
      // 装置型号
      this.TypeList = dicData("Dev_Type", []);
      // 装置电源电压
      this.VoltageList = dicData("Dev_Voltage", []);
      // 生产厂家
      this.manufacturerList = dicData("Dev_Manufacturers", []);
    },
    // 关闭
    handleClose() {
      this.$emit("monitorClose");
    },
  },

  computed: {},

  watch: {},
};
</script>
<style lang="less" scoped>
::v-deep .el-dialog {
  margin-top: 0px !important;
}
</style>
