<template>
  <!-- 修改分解计划页面 -->
  <div id="contractDetails">
    <page-title>修改分解计划</page-title>

    <div>
      <dilTable
        v-bind.sync="option"
        v-model="table1"
        @change="handleCheckedCitiesChange"
        ref="table"
        @radio-change="currentRadioChange"
      >
      </dilTable>
    </div>

    <!-- <div class="main">
      <span class="text">请选择运力</span>
      <span class="a"></span>
    </div>
    <div>
      <dilTable
        v-bind.sync="option2"
        v-model="table2"
        @change="handleCheckedCitiesChange"
        ref="table"
        @radio-change="currentRadioChange2"
      >
      </dilTable>
    </div> -->


    <div class="contractTitle">
      <div class="form-box">
        <div class="form-one">
          <dil-form :formId="169" v-model="form1"></dil-form>
        </div>
      </div>
    </div>

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

<script>
import PageTitle from "@/components/Page/Title";

export default {
  components: { PageTitle },
  data() {
    return {
      option: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getDecomposedPlan?planId=" + this.$route.params.planId + "&apiId=82",
       
      },
      // option2: {
      //   // 表格请求数据的地址
      //   requestUrl:
      //     "/api/v1/tms/getAllCapacity?apiId=85",
      //   // 控制显示当选列
      //   selectionType: "radio",
      // },
      // 表单
      form1: {},
      // 表格
      table1: {},
      table2:{},
      contractId: "",
      inf: {},
      inf2: {}
    };
  },
  mounted() {
    // this.unit();
  },
  methods: {
    handleCheckedCitiesChange(value) {
      console.log(value);
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    currentRadioChange(row) {
      this.inf = row;
    },
    currentRadioChange2(row) {
      this.inf2 = row;
    },
    // 确认
    onClickConfirm() {
      console.log(12)
      let udb = {
        planId: this.$route.params.planId,
        orderId: this.$route.query.orderId,
        // capacityId: this.inf2.capacityId,
        weight: this.$route.query.weight,
        orderMaterialWeight: this.form1.orderMaterialWeight,
        orderType:8
      };
      function isNumber() {
        var value = udb.orderMaterialWeight;
        //验证是否为数字
        var patrn = /^(-)?\d+(\.\d+)?$/;
        if (patrn.exec(value) == null || value == "") {
          return false;
        } else {
          return true;
        }
      }
      var val = this.value;
      if (
        udb.planId==null||
        udb.orderId==null||
        // udb.materialId==null||
        // udb.capacityId==null||
        udb.orderMaterialWeight==null
      ) this.$message.error("存在空值！");
      else
      if (!isNumber(val)) this.$message.error("分配物资重量必须是数字！");
      else
      this.axios
        .post("/api/v1/oms/updateOrder", udb)
        .then(() => {
          this.$message({
            type: "success",  
            message: "修改成功!",
          });
          this.$router.go(-1);
        });
    },
  },
};
</script>
<style lang="scss" scoped>
//@import "@/styles/appoint/contract/ContractInsert.scss";
</style>