<template>
  <div>
    <el-form
      ref="leakyCableForm"
      :model="leakyCableForm"
      :rules="rules"
      label-width="200px"
      class="form"
    >
      <el-form-item label="所在铁路线：" prop="parentId">
        <el-select v-model="leakyCableForm.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="leakyCableCode">
        <el-input
          v-model="leakyCableForm.leakyCableCode"
          placeholder="请输入漏缆编号"
        />
      </el-form-item>
      <el-form-item label="漏缆描述：" prop="leakyCableDescribe">
        <el-input
          v-model="leakyCableForm.leakyCableDescribe"
          placeholder="请输入漏缆描述"
        />
      </el-form-item>

      <el-form-item label="漏缆型号：" prop="leakyCableMode">
        <el-input
          v-model="leakyCableForm.leakyCableMode"
          placeholder="请输入漏缆型号"
        />
      </el-form-item>
      <el-form-item label="漏缆长度：" prop="leakyCableLength">
        <el-input
          v-model="leakyCableForm.leakyCableLength"
          placeholder="请输入漏缆长度"
        />
      </el-form-item>
      <el-form-item label="漏缆百米损耗：" prop="hundredMetersLoss">
        <el-input
          v-model="leakyCableForm.hundredMetersLoss"
          placeholder="请输入漏缆百米损耗"
        />
      </el-form-item>
      <el-form-item label="漏缆速度衰减系数：" prop="reductRatio">
        <el-input
          v-model="leakyCableForm.reductRatio"
          placeholder="请输入漏缆速度衰减系数"
        />
      </el-form-item>
      <el-form-item label="漏缆测试信号发射功率：" prop="sendPower">
        <el-input
          v-model="leakyCableForm.sendPower"
          placeholder="请输入漏缆测试信号发射功率"
        />
      </el-form-item>
      <el-form-item label="跳线长度：" prop="jumperLength">
        <el-input
          v-model="leakyCableForm.jumperLength"
          placeholder="请输入跳线长度"
        />
      </el-form-item>
      <el-form-item label="插入器长度：" prop="inserterLength">
        <el-input
          v-model="leakyCableForm.inserterLength"
          placeholder="请输入插入器长度"
        />
      </el-form-item>
      <el-form-item label="天馈线长度：" prop="antennaFeederLength">
        <el-input
          v-model="leakyCableForm.antennaFeederLength"
          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 { leakyCablesave } from "../../api";
export default {
  props: [],
  components: {},
  data() {
    return {
      FSUrailway: [
        {
          key: 6,
          label: "张呼客运专线",
        },
        {
          key: 12,
          label: "南昆客运专线",
        },
      ],
      leakyCableForm: {
        antennaFeederLength: 0,
        hundredMetersLoss: 0,
        inserterLength: 0,
        jumperLength: 0,
        leakyCableCode: "22",
        leakyCableDescribe: "打打",
        leakyCableLength: 0,
        leakyCableMode: "打打",
        parentId: 0,
        reductRatio: 0,
        sendPower: 0,
      },
      rules: {
        parentId: [
          { required: true, message: "请选择铁路线", trigger: "blur" },
        ],
        antennaFeederLength: [
          { required: true, message: "请输入天馈线长度", trigger: "blur" },
        ],
        hundredMetersLoss: [
          { required: true, message: "请输入漏缆百米损耗", trigger: "blur" },
        ],
        inserterLength: [
          { required: true, message: "请输入插入器长度", trigger: "blur" },
        ],
        jumperLength: [
          { required: true, message: "请输入跳线长度", trigger: "blur" },
        ],
        leakyCableCode: [
          { required: true, message: "请输入漏缆编号", trigger: "blur" },
        ],
        leakyCableDescribe: [
          { required: true, message: "请输入漏缆描述", trigger: "blur" },
        ],
        leakyCableLength: [
          { required: true, message: "请输入漏缆长度", trigger: "blur" },
        ],
        leakyCableMode: [
          {
            required: true,
            message: "请输入漏缆型号",
            trigger: "blur",
          },
        ],
        reductRatio: [
          {
            required: true,
            message: "请输入漏缆速度衰减系数",
            trigger: "blur",
          },
        ],
        sendPower: [
          { required: true, message: "请输入漏缆测试信号发射功率", trigger: "blur" },
        ],
      },
    };
  },
  computed: {},
  methods: {
    reset() {
      this.$refs.leakyCableForm.resetFields();
    },
    submit() {
      this.$refs.leakyCableForm.validate((valid) => {
        if (valid) {
          leakyCablesave(this.leakyCableForm).then((res) => {});
        }
        this.leakyCableForm = {
          antennaFeederLength: 0,
          hundredMetersLoss: 0,
          inserterLength: 0,
          jumperLength: 0,
          leakyCableCode: "22",
          leakyCableDescribe: "打打",
          leakyCableLength: 0,
          leakyCableMode: "打打",
          parentId: 0,
          reductRatio: 0,
          sendPower: 0,
        };
      });
    },
  },
  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>