<template>
  <div>
    <el-form
      ref="FSUForm"
      :rules="rules"
      :model="FSUForm"
      label-width="200px"
      class="form"
    >
      <el-form-item label="所在铁路线：" prop="parentId">
        <el-select v-model="FSUForm.parentId" placeholder="请选择铁路线">
          <el-option
            v-for="item in parentIdSelect"
            :key="item.key"
            :label="item.label"
            :value="item.key"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="所在站点：" prop="station">
        <el-select v-model="FSUForm.station" placeholder="请选择站点">
          <el-option
            v-for="item in stationSelect"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="FSU身份编号：" prop="fsuCode">
        <el-input v-model="FSUForm.fsuCode" placeholder="请输入FSU身份编号" />
      </el-form-item>
      <el-form-item label="FSU端口数：" prop="fsuPort">
        <el-input v-model="FSUForm.fsuPort" placeholder="请输入FSU端口数" />
      </el-form-item>
      <el-form-item label="设备名称：" prop="equipName">
        <el-input v-model="FSUForm.equipName" placeholder="请输入设备名称" />
      </el-form-item>
      <el-form-item label="IP地址：" prop="ip">
        <el-input v-model="FSUForm.ip" placeholder="请输入IP地址" />
      </el-form-item>
      <el-form-item label="设备厂商：" prop="equipFactory">
        <el-input v-model="FSUForm.equipFactory" placeholder="请输入设备厂商" />
      </el-form-item>

      <el-form-item label="设备备用方式：" prop="backupMode">
        <el-select
          v-model="FSUForm.backupMode"
          placeholder="请选择设备备用方式"
        >
          <el-option
            v-for="item in backupModeSelect"
            :key="item.key"
            :label="item.label"
            :value="item.key"
          ></el-option
        ></el-select>
      </el-form-item>
      <el-form-item label="通信方式：" prop="connectMode">
        <el-select v-model="FSUForm.connectMode" placeholder="请选择通信方式">
          <el-option
            v-for="item in connectModeSelect"
            :key="item.key"
            :label="item.label"
            :value="item.key"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备类型：" prop="equipType">
        <el-select v-model="FSUForm.equipType" placeholder="请选择设备类型">
          <el-option
            v-for="item in equipTypeSelect"
            :key="item.key"
            :label="item.label"
            :value="item.key"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备子类型：" prop="equipSubType">
        <el-select
          v-model="FSUForm.equipSubType"
          placeholder="请选择设备子类型"
        >
          <el-option
            v-for="item in equipSubTypeSelect"
            :key="item.key"
            :label="item.label"
            :value="item.key"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="软件版本号：" prop="softVersion">
        <el-input
          v-model="FSUForm.softVersion"
          placeholder="请输入软件版本号"
        />
      </el-form-item>
      <el-form-item label="设备生产序列号：" prop="equipSerialNumber">
        <el-input
          v-model="FSUForm.equipSerialNumber"
          placeholder="请输入设备生产序列号"
        />
      </el-form-item>
      <el-form-item label="设备所在铁路公里标：" prop="kmSign">
        <el-input
          v-model="FSUForm.kmSign"
          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 { fsusave } from "../../api";
export default {
  props: [],
  components: {},
  data() {
    return {
      parentIdSelect: [
        {
          key: 2,
          label: "张呼客运专线",
        },
        {
          key: 3,
          label: "南昆客运专线",
        },
      ],
      stationSelect: [
        {
          value: 0,
          label: "NiGeLong",
        },
        {
          value: 1,
          label: "STATION2",
        },
      ],
      backupModeSelect: [
        {
          key: 0,
          label: "整机备份",
        },
        {
          key: 1,
          label: "整机备份2",
        },
        {
          key: 2,
          label: "整机备份3",
        },
      ],
      connectModeSelect: [
        {
          key: 0,
          label: "以太网",
        },
        {
          key: 1,
          label: "以太网2",
        },
        {
          key: 2,
          label: "以太网3",
        },
      ],
      equipTypeSelect: [
        {
          key: 0,
          label: "漏缆监控单元",
        },
        {
          key: 1,
          label: "漏缆监控单元2",
        },
        {
          key: 2,
          label: "漏缆监控单元3",
        },
      ],
      equipSubTypeSelect: [
        {
          key: 0,
          label: "故障定位设备",
        },
        {
          key: 1,
          label: "故障定位设备2",
        },
        {
          key: 2,
          label: "故障定位设备3",
        },
      ],
      FSUForm: {
        parentId: 2,

        fsuCode: "21",
        fsuPort: "0",
        equipName: "阿达",
        ip: "15151",
        equipFactory: "打发点", //设备厂商
        backupMode: 2,
        connectMode: 1, //通信方式
        equipType: 0,
        equipSubType: 2,
        softVersion: "845",
        equipSerialNumber: "465",
        kmSign: "4651",
      },
      rules: {
        parentId: [
          { required: true, message: "请选择铁路线", trigger: "blur" },
        ],
        station: [{ required: true, message: "请选择站点", trigger: "blur" }],
        fsuCode: [
          { required: true, message: "请输入FSU身份编号", trigger: "blur" },
        ],
        fsuPort: [
          { required: true, message: "请输入FSU端口数", trigger: "blur" },
        ],
        equipName: [
          { required: true, message: "请输入设备名称", trigger: "blur" },
        ],
        ip: [{ required: true, message: "请输入IP地址", trigger: "blur" }],
        equipFactory: [
          { required: true, message: "请输入设备厂商", trigger: "blur" },
        ],
        backupMode: [
          { required: true, message: "请选择设备备用方式", trigger: "blur" },
        ],
        connectMode: [
          { required: true, message: "请选择通信方式", trigger: "blur" },
        ],
        equipType: [
          { required: true, message: "请选择设备类型", trigger: "blur" },
        ],
        equipSubType: [
          { required: true, message: "请选择设备子类型", trigger: "blur" },
        ],
        softVersion: [
          { required: true, message: "请输入软件版本号", trigger: "blur" },
        ],
        equipSerialNumber: [
          { required: true, message: "请输入设备生产序列号", trigger: "blur" },
        ],
        kmSign: [
          {
            required: true,
            message: "请输入设备所在铁路公里标",
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {},
  methods: {
    reset() {
      this.$refs.FSUForm.resetFields();
    },
    submit() {
      this.$refs.FSUForm.validate((valid) => {
        if (valid) {
          fsusave(this.FSUform).then((res) => {});
        }
        this.FSUForm = {
          parentId: "",

          fsuCode: "",
          fsuPort: "",
          equipName: "",
          ip: "",
          equipFactory: "",
          backupMode: "",
          connectMode: "",
          equipType: "",
          equipSubType: "",
          softVersion: "",
          equipSerialNumber: "",
          kmSign: "",
        };
      });
    },
  },
  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>