<template>
  <div>
    <el-form
      ref="monitorForm"
      :model="monitorForm"
      :rules="rules"
      label-width="200px"
      class="form"
    >
      <el-form-item label="站点所属铁路线：" prop="parentId">
        <el-select v-model="monitorForm.parentId" placeholder="请选择铁路线">
          <el-option
            v-for="item in FSUrailway"
            :key="item.key"
            :label="item.label"
            :value="item.key"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备身份编号：" prop="equipCode">
        <el-input
          v-model="monitorForm.equipCode"
          placeholder="请输入设备身份编号"
        />
      </el-form-item>
      <el-form-item label="设备厂商：" prop="equipFactory">
        <el-input
          v-model="monitorForm.equipFactory"
          placeholder="请输入设备厂商"
        />
      </el-form-item>
      <el-form-item label="设备型号：" prop="equipMode">
        <el-input
          v-model="monitorForm.equipMode"
          placeholder="请输入设备型号"
        />
      </el-form-item>
      <el-form-item label="设备名：" prop="equipName">
        <el-input v-model="monitorForm.equipName" placeholder="请输入设备名" />
      </el-form-item>
      <el-form-item label="设备生产序列号：" prop="equipSerialNumber">
        <el-input
          v-model="monitorForm.equipSerialNumber"
          placeholder="请输入设备生产序列号"
        />
      </el-form-item>
      <el-form-item label="设备类别：" prop="equipType">
        <el-input
          v-model="monitorForm.equipType"
          placeholder="请输入设备类别"
        />
      </el-form-item>
      <el-form-item label="安装日期：" prop="installDate">
        <el-input
          v-model="monitorForm.installDate"
          placeholder="请输入安装日期"
        />
      </el-form-item>
      <el-form-item label="设备所在铁路公里标：" prop="kmSign">
        <el-input
          v-model="monitorForm.kmSign"
          placeholder="请输入设备所在铁路公里标"
        />
      </el-form-item>
      <el-form-item label="	维护日期：" prop="repairDate">
        <el-input
          v-model="monitorForm.repairDate"
          placeholder="请输入维护日期"
        />
      </el-form-item>
    </el-form>
    <div class="btn">
      <el-button type="primary" @click="reset">重置</el-button>
      <el-button type="primary" @click="submit">确认提交</el-button>
    </div>
  </div>
</template>
<script>
import { monitorEquipsave } from "../../api";
export default {
  props: [],
  components: {},
  data() {
    return {
      FSUrailway: [
        {
          key: 6,
          label: "张呼客运专线",
        },
        {
          key: 12,
          label: "南昆客运专线",
        },
      ],
      monitorForm: {
        equipCode: "",
        equipFactory: "",
        equipMode: 0,
        equipName: "",
        equipSerialNumber: "",
        equipType: 0,
        installDate: "2022-02-24 12:24:84",
        kmSign: "",
        parentId: 0,
        repairDate: "2022-02-24 12:24:84",
      },
      rules: {
        parentId: [
          { required: true, message: "请选择铁路线", trigger: "blur" },
        ],
        equipCode: [
          { required: true, message: "请输入设备身份编号", trigger: "blur" },
        ],
        equipFactory: [
          { required: true, message: "请输入设备厂商", trigger: "blur" },
        ],
        equipMode: [
          { required: true, message: "请选择设备型号", trigger: "blur" },
        ],
        equipName: [
          { required: true, message: "请输入设备名", trigger: "blur" },
        ],
        equipSerialNumber: [
          { required: true, message: "请输入设备生产序列号", trigger: "blur" },
        ],
        equipType: [
          { required: true, message: "请输入设备类别", trigger: "blur" },
        ],
        installDate: [
          { required: true, message: "请输入安装日期", trigger: "blur" },
        ],
        kmSign: [
          {
            required: true,
            message: "请输入设备所在铁路公里标",
            trigger: "blur",
          },
        ],
        repairDate: [
          { required: true, message: "请输入维护日期", trigger: "blur" },
        ],
      },
    };
  },
  computed: {},
  methods: {
    reset() {
      this.$refs.monitorForm.resetFields();
    },
    submit() {
      this.$refs.monitorForm.validate((valid) => {
        if (valid) {
          monitorEquipsave(this.monitorForm).then((res) => {});
        }
        this.monitorForm = {
          equipCode: "",
          equipFactory: "",
          equipMode: 0,
          equipName: "",
          equipSerialNumber: "",
          equipType: 0,
          installDate: "2022-02-22 12:24:84",
          kmSign: "",
          parentId: 0,
          repairDate: "2022-02-24 12:24:84",
        };
      });
    },
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
.form {
  padding: 20px 0;
  width: 600px;
  margin: 0 auto;
}
.btn {
  padding-top: 50px;
  text-align: center;
  button {
    width: 120px;
  }
}
</style>