<template>
  <!-- 修改运价 -->
  <div id="contractDetails">
    <page-title>编辑</page-title>
    <div class="main">
      <span class="text">修改运价</span>
      <span class="a"></span>
    </div>
    <div class="form">
      <div class="form_box">
        <el-form :model="obj" :rules="batchFormRules" label-width="100px" label-position="left">
          <div class="preview-group">
            <el-form-item label="运价" prop="priceValue">
              <el-input v-model="obj.priceValue" placeholder="请输入内容" type="number"></el-input>
            </el-form-item>
            <el-form-item label="货物名称" prop="materialNames">
              <el-input v-model="obj.materialNames" readonly></el-input>
            </el-form-item>
            <el-form-item label="执行日期" prop="priceDate">
              <el-input v-model="obj.priceDate" readonly></el-input>
            </el-form-item>
            <el-form-item label="运力类型" prop="capacityTypeName">
              <el-input v-model="obj.capacityTypeName" readonly></el-input>
            </el-form-item>
            <el-form-item label="当前基准油价" prop="oilpriceBase">
              <el-input v-model="obj.oilpriceBase" readonly></el-input>
            </el-form-item>
            <el-form-item label="油品名称" prop="oilTypeName">
              <el-input v-model="obj.oilTypeName" readonly></el-input>
            </el-form-item>
            <el-form-item label="油价变化率阈值" prop="oilpriceChangeThreshold">
              <el-input v-model="obj.oilpriceChangeThreshold" readonly></el-input>
            </el-form-item>
            <el-form-item label="计价单位" prop="type">
              <el-input v-model="obj.type" readonly></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
    </div>

    <div class="button-box">
      <el-button type="primary" @click="onClickConfirm">修改</el-button>
      <el-button @click="onClickCancel">返回</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "updateTransPrice",
  data() {
    return {
      obj: {},
      batchFormRules: {
        priceValue: [{ required: true, message: '运价不能为空', trigger: 'blur' }]
      }
    };
  },
  mounted() {
    this.obj=this.$route.query.row;
  },
  methods: {
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 修改
    onClickConfirm() {
      if (this.obj.priceValue==''|| this.obj.priceValue == undefined){
        this.$message.info("修改前请填写运价！")
          return;
      }

      let paramsList = {
        priceId: this.obj.priceId,
        priceValue: this.obj.priceValue,
      };
        this.axios
          .post(
            "/api/v1/ams/updateTransPrice",
            paramsList
          )
          .then((res) => {
            if (res.data.data >=1) {
              this.$message.success("修改成功！")
              this.$router.go(-1);
            }
          });
    }
  }
}
</script>

<style lang="scss" scoped>
.form {
  display: flex;
  .form_box {
    width: 400px;
    margin-left: 35%;
    margin-top: 30px;
    margin-right: 20px;

    .el-form {
      .preview-group {
        .el-form-item {
          .el-form-item__label {
            display: inline-block;
            width: 70px !important;
          }

          .el-form-item__content {
            .el-select {
              width: 250px;
            }

            .el-input {
              width: 250px;
            }
          }
        }
      }
    }
  };
.txt1{
  display: inline-block;
  width: 150px;
  text-align: right;
};
}
</style>
