<template>
  <div>
    <!-- 头部标签 -->
    <LHeader v-bind:text="text"></LHeader>
    <van-form
      @submit="onSubmit"
      :show-error="false"
      validate-trigger="onSubmit"
      :scroll-to-error="true"
    >
      <van-field
        required
        v-model="fromObj.taskId"
        name="任务编号"
        label="任务编号"
        placeholder="请输入与平台相关的任务编号"
        :rules="[{ required: true, message: '任务编号不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.taskType"
        name="任务类型"
        label="任务类型"
        @click="goSelectTaskType"
        placeholder="请选择任务类型"
        :rules="[{ required: true, message: '请选择任务类型' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.workType"
        name="作业任务"
        label="作业任务"
        @click="goSelectWorkType"
        placeholder="请选择作业任务"
        :rules="[{ required: true, message: '请选择作业任务' }]"
      />
      <van-field
        required
        readonly
        clickable
        name="hdDiscoveryTime"
        :value="fromObj.PlanTime"
        label="作业计划开始时间"
        placeholder="点击选择作业计划开始时间"
        @click="
          showPlanTime = true;
          currentDate = new Date();
        "
        :rules="[{ required: true, message: '作业计划开始时间不能为空' }]"
      />
      <van-popup v-model="showPlanTime" position="bottom">
        <van-datetime-picker
          type="datetime"
          @confirm="onConPlanTime"
          @cancel="showPlanTime = false"
          v-model="currentDate"
        />
      </van-popup>
      <van-field
        required
        readonly
        v-model="fromObj.workSynthesisClass"
        name="作业综合班"
        label="作业综合班"
        @click="goSelectWorkSynthesisClass"
        placeholder="请选择作业综合班"
        :rules="[{ required: true, message: '作业综合班不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.workSynthesisGroup"
        name="作业综合组"
        label="作业综合组"
        @click="goSelectWorkSynthesisGroup"
        placeholder="请选择作业综合组"
        :rules="[{ required: true, message: '作业综合组不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.workPerson"
        name="作业负责人"
        label="作业负责人"
        @click="goSelectWorkPerson"
        placeholder="请选择作业负责人"
        :rules="[{ required: true, message: '请选择作业负责人' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.workOther"
        name="作业组其他人员"
        label="作业组其他人员"
        @click="goSelectWorkOther"
        placeholder="请选择作业组其他人员"
        :rules="[{ required: true, message: '请选择作业组其他人员不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.area"
        name="微流域"
        label="微流域"
        @click="goSelectArea"
        placeholder="请选择微流域"
        :rules="[{ required: true, message: '微流域不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.pipeline"
        name="管段"
        label="管段"
        @click="goSelectPipeline"
        placeholder="请选择管段"
        :rules="[{ required: true, message: '管段不能为空' }]"
      />
      <van-field
        required
        v-model="fromObj.workPlace"
        name="作业地点"
        label="作业地点"
        placeholder="请输入作业地点"
        :rules="[{ required: true, message: '作业地点不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.carNumber"
        name="车牌号"
        label="车牌号"
        @click="goSelectCarNumber"
        placeholder="请选择车牌号"
        :rules="[{ required: true, message: '车牌号不能为空' }]"
      />
      <van-field
        required
        readonly
        v-model="fromObj.hand"
        name="手杆/爬行器设备编号"
        label="手杆/爬行器设备编号"
        @click="goSelectHand"
        placeholder="请选择手杆/爬行器设备编号"
        :rules="[{ required: true, message: '手杆/爬行器设备编号不能为空' }]"
      />
      <van-field name="radio" label="是否开展有限空间作业">
        <template #input>
          <van-radio-group v-model="fromObj.radio1" direction="horizontal">
            <van-radio name="1">是</van-radio>
            <van-radio name="2">否</van-radio>
          </van-radio-group>
        </template>
      </van-field>
      <van-field name="radio2" label="是否跨班作业">
        <template #input>
          <van-radio-group v-model="fromObj.radio2" direction="horizontal">
            <van-radio name="1">是</van-radio>
            <van-radio name="2">否</van-radio>
          </van-radio-group>
        </template>
      </van-field>
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
    <div style="margin: 10px 16px 0px; padding-bottom: 16px">
      <van-button round block plain type="info" @click.native="cancel"
        >取消</van-button
      >
    </div>
    <!-- tanBar -->
  </div>
</template>

<script>
import LHeader from "@/components/header.vue";
import { getFun, postFun } from "@/service/table";
export default {
  components: {
    LHeader: LHeader,
  },
  data() {
    return {
      text: "新建任务",
      showPlanTime: false, //作业计划开始时间
      currentDate: "", //默认日期
      fromObj: {
        taskId: "",
        taskType: "",
        workType: "",
        PlanTime: "",
        workSynthesisClass: "",
        workSynthesisGroup: "",
        workPerson: "",
        workOther: "",
        area: "",
        pipeline: "",
        workPlace: "",
        carNumber: "",
        hand: "",
        radio1: "1",
        radio2: "2",
      },
    };
  },
  created() {},
  methods: {
    onSubmit() {},
    cancel() {},
    onConPlanTime(date) {
      this.PlanTime = this.util.timestampToTime(date, "DT1", true);
      this.showPlanTime = false;
    },
    //任务类型跳转
    goSelectTaskType() {
      this.$router.push("/task-type");
    },
    //作业类型跳转
    goSelectWorkType() {
      this.$router.push("/work-task");
    },
    //作业综合班跳转
    goSelectWorkSynthesisClass() {
      this.$router.push("/work-class");
    },
    //作业综合组跳转
    goSelectWorkSynthesisGroup() {
      this.$router.push("/work-group");
    },
    //作业负责人跳转
    goSelectWorkPerson() {
      this.$router.push("/work-leader");
    },
    //作业组其他人员跳转
    goSelectWorkOther() {
      this.$router.push("/work-other-per");
    },
    //微流域跳转
    goSelectArea() {
      this.$router.push("/micro-watersh");
    },
    //管段跳转
    goSelectPipeline() {
      this.$router.push("/pipe-section");
    },
    //车牌号跳转
    goSelectCarNumber() {
      this.$router.push("/license-plate");
    },
    //手杆/爬行器跳转
    goSelectHand() {
      this.$router.push("/work-device");
    },
  },
};
</script>
<style lang="less" scoped>
</style>
