<template>
  <el-dialog :title="title" :visible.sync="addTaskDialog" :before-close="handleClose" width="500px">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="140px">
      <el-form-item label="只选择未验证过的" prop="isVerification">
        <el-switch v-model="ruleForm.isVerification"></el-switch>
      </el-form-item>
      <el-form-item label="任务类型" prop="taskType">
        <div>
          <el-radio v-model="ruleForm.taskType" label="model">现场验证模型</el-radio>
        </div>
        <div>
          <el-radio v-model="ruleForm.taskType" label="device">现场验证设备台账</el-radio>
        </div>
        <div>
          <el-radio v-model="ruleForm.taskType" label="assets">现场验证资产台账</el-radio>
        </div>
      </el-form-item>
    </el-form>
    <!-- <el-row>
      请选择新建现场验证任务的数据源：
      <el-checkbox v-model="ruleForm.isVerification">只选择未验证的</el-checkbox>
    </el-row>
    <el-row style="margin-top:15px;padding-left:15px;">
      <div><el-radio v-model="ruleForm.taskType" label="model">现场验证模型</el-radio></div>
      <div><el-radio v-model="ruleForm.taskType" label="device">现场验证设备台账</el-radio></div>
      <div><el-radio v-model="ruleForm.taskType" label="assets">现场验证资产台账</el-radio></div>
    </el-row>-->
    <span slot="footer" class="dialog-footer">
      <el-button type="default" @click="$emit('update:addTaskDialog',false)">取 消</el-button>
      <el-button type="primary" @click="toAddTask()">确 认</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {} from "@/api/scan/request";
import { mapGetters } from "vuex";
export default {
  components: {},
  computed: {
    ...mapGetters("layout", ["projectId"])
  },
  data() {
    return {
      title: "添加验证任务",
      dialogVisible: false,
      ruleForm: {
        isVerification: true,
        taskType: ""
      },
      rules: {
        taskType: [
          { required: true, message: "请选择任务类型", trigger: "change" }
        ]
      }
    };
  },
  created() {},
  props: {
    addTaskDialog: Boolean, //是否显示弹窗
    newTaskTypes: Array
  },
  methods: {
    toAddTask() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.ruleForm.newTaskTypes = this.newTaskTypes;
          if (this.ruleForm.taskType == "model") {
            this.$router.push({
              path: "/floor/addModelTask",
              query: this.ruleForm
            });
          } else if (this.ruleForm.taskType == "device") {
            this.$router.push({
              path: "/floor/addDeviceTask",
              query: this.ruleForm
            });
          } else if (this.ruleForm.taskType == "assets") {
            this.$router.push({
              path: "/floor/addAssetsTask",
              query: this.ruleForm
            });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handleClose() {
      this.$emit("update:addTaskDialog", this.dialogVisible);
    }
  }
};
</script>
<style lang="less" scoped>
</style>
