<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="Visible"
      width="50%"
      @close="handleClose"
    >
      <el-form ref="form" size="small" :model="form" label-width="80px">
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="设备名称" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入设备名称"
              ></el-input> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="设备类型" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入设备名称"
              ></el-input> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="mac地址" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入mac地址"
              ></el-input> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="设备厂商" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入设备厂商"
              ></el-input> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="分辨率" prop="name">
              <el-select v-model="form.value" placeholder="请选择分辨率">
                <el-option
                  v-for="item in options"
                  :key="item.id"
                  :label="item.value"
                  :value="item.id"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="设备IP" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入设备IP"
              ></el-input> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="端口号" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入端口号"
              ></el-input> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="负责人" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入责任人姓名"
              ></el-input> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="手机号" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入责任人手机号"
              ></el-input> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="设备位置" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入设备位置（X坐标，Y坐标）"
              ></el-input> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="所在楼栋" prop="name">
              <el-input-number
                v-model="form.num"
                controls-position="right"
                :min="1"
                :max="100"
                placeholder="请输入楼栋"
              ></el-input-number> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="所在楼层" prop="name">
              <el-input-number
                v-model="form.num"
                controls-position="right"
                :min="1"
                :max="100"
                placeholder="请输入楼层"
              ></el-input-number> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24"
            ><el-form-item label="备注" prop="name">
              <el-input
                type="textarea"
                :autosize="{ minRows: 4, maxRows: 4 }"
                clearable
                placeholder="请输入备注"
                v-model="form.textarea"
                resize="none"
              >
              </el-input> </el-form-item
          ></el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="handleOk"
          >确 定</el-button
        >
        <el-button size="small" @click="handleReset">重 置</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true,
      default: "",
    },
    dialogVisible: {
      type: Boolean,
      required: true,
      default: false,
    },
  },
  data() {
    return {
      form: {
        name: "",
      },
      options: [
        {
          id: 1,
          value: "1920*1080",
        },
        {
          id: 2,
          value: "1080*1920",
        },
      ],
    };
  },
  computed: {
    Visible: {
      get() {
        return this.dialogVisible;
      },
      set(val) {
        this.$emit("update:dialogVisible", val);
      },
    },
  },
  methods: {
    handleReset() {
      this.$refs.form.resetFields();
    },
    handleOk() {
      console.log(1);
    },
    // 新增
    onAdd() {
      Object.assign(this.form, this.$options.data().form);
      this.form.id && this.$delete(this.form, "id");
    },
    // 编辑
    onEdit(row) {
      this.form = { ...row };
    },
    handleClose() {
      this.Visible = false;
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.el-input-number {
  width: 100%;
  input {
    text-align: left !important;
  }
}
/deep/.el-select {
  width: 100%;
}
</style>