<template>
  <!-- 船只信息页面 -->
  <div class="homeworkPath">
    <page-title>位置作业信息</page-title>
    <div class="main">
      <span class="text">位置作业新增</span>
      <span class="a"></span>
    </div>
    <div>
      <div class="form-box" style="margin-left: 5rem">
        <el-form ><dil-form :formId="127" v-model="form"></dil-form>
        <el-button type="primary" @click="makeSure">新增位置作业</el-button>
        </el-form>
      </div>
    </div>
     <div class="main">
      <span class="text">位置作业新增</span>
      <span class="a"></span>
    </div>
     <div class="top">
      <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
      <el-button type="primary" class="btn" @click="onclick()">
        <i class="el-icon-search"></i>查询
      </el-button>   
    </div>
    <dilTable v-bind.sync="option" @radio-change="currentRadioChange">
    </dilTable>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";
import { sjTime } from "@/utils/sharedJsFile";
export default {
  components: { PageTitle },
  data() {
    return {
      input:'',
      restaurants: [],
      state: "",
      form: {},
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/tms/getCapacityList?apiId=138",
        // 控制显示当选列
        selectionType: "radio",
        shipLocationMap:{},
      },
    };
  },
  mounted() {
  },
  methods: {
    currentRadioChange(row) {
      this.shipLocationMap=row
      console.log(row);
    },
    // 新增
    makeSure() {
      let mapVal = {
        locationValue: this.form.locationValue,
        locationRouteTime: sjTime(
          this.form.locationRouteTime
        ),
        locationStatus: this.form.locationStatus,
        locationMemo: this.form.locationMemo,
      };
      console.log(mapVal);
      if (mapVal.locationValue==null||
      mapVal.locationRouteTime==null||
      mapVal.locationStatus==null||
      mapVal.locationMemo==null
      ) this.$message.error("存在空值！");
      else
      this.axios
        .post(
          "/api/v1/tms/addShipLocation",
          {
            mapVal: mapVal,
            shipLocationMap: this.shipLocationMap
          }
        )
        .then((res) => {
          if (res.data.code == 200) {
            this.$message({
              type: "success",
              message: "新增成功!",
            });
            // this.$refs.table.refreshData();
            this.$router.go(-1);
          } else {
            this.$message.error("新增失败！");
          }
          this.$refs['table'].resetField();
        });
    },
    loadAll() {
      return [

      ];
    },
    handleSelect(item) {
      console.log(item);
    },
    onclick() {
      this.option.requestUrl = "/api/v1/tms/getCapacityList?apiId=138&con=" + this.input
    },
  },
};
</script>
<style lang='scss' scoped>
.homeworkPath{
  .main{
    margin-bottom: 0.125rem;
  }
  .button-ins{
    margin: 0 50rem; 
    text-align: center
  }
  .top {
    margin: 0 auto;
    padding: 1.25rem 1.875rem;
  }
}
</style>