<template>
  <!-- 修改收货地址 -->
  <div id="contractDetails">
    <page-title>编辑</page-title>
    <div class="main">
      <span class="text">修改收货地址</span>
      <span class="a"></span>
    </div>
    <div class="contractTitle">
      <div class="form-box">
        <div class="form-one">
          <span>收货地址：</span>
          <el-input v-model="input" placeholder="请输入内容"></el-input>
        </div>
      </div>
    </div>
    <div class="button-box">
      <el-button type="primary" @click="onClickConfirm">确认</el-button>
      <el-button @click="onClickCancel">返回</el-button>
    </div>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";
export default {
  components: { PageTitle },
  data() {
    return {
      input: "",
    };
  },
  mounted() {
    this.information();
  },
  methods: {
    information() {
      //编辑
      this.axios
        .post(
           "api/v1/ams/getAddress?saleOrderMaterialId=" +
            this.$route.params.saleOrderMaterialId
        )
        .then((res) => {
          this.input = res.data.data;
        });
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
      let amsSaleOrderMaterial = {
        saleOrderMaterialId: this.$route.params.saleOrderMaterialId,
        saleShippingAddress: this.input,
      };
      if (amsSaleOrderMaterial.saleShippingAddress == null)
        this.$message.error("必填项存在空值！");
      else
        this.axios
          .post(
            "/api/v1/ams/updateAddress",
            {
              saleOrderMaterialId:this.$route.params.saleOrderMaterialId,
              saleShippingAddress:this.input
            }
            
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$router.go(-1);
            }
          });
    },
  },
};
</script>
<style lang="scss" scoped>

</style>