<template>
  <div>
    <el-dialog :title="title"  :visible.sync="open" width="700px" height="700px" append-to-body>
    <el-form v-loading="loading"     :model="form" :rules="rules" ref="form" label-width="150px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="项目名称" prop="projectName">
              <span>{{task.projectName}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="测试类型" prop="testType">
              <span>{{findLabelValueByProp(tasktypelist,task.testType,'id','name')}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="测试技能要求" prop="techNeed">
              <span>{{task.techNeed}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="金额" prop="price">
              <span>{{task.price | currency('￥')}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工期" prop="period">
              <span>{{task.period}}</span>天
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="发布有效天数" prop="validDays">
              <span>{{task.validDays}}</span>天
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="竞标者要求" prop="applicantTypeArr">
              <tester-type :type="task.applicantType"></tester-type>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="驻场要求" prop="onsiteType">
             <span> {{findByvalue(onsiteTypelist,task.onsiteType)}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="地域要求" prop="area">
              <span>{{task.area}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系人" prop="contactName">
              <span>{{task.contactName}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="contactTel">
              <span>{{task.contactTel}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="项目描述" prop="projectDesc">
              <span>{{task.projectDesc}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="projectDesc">
              <span>{{task.remark}}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="审核意见" prop="auditOpinion">
              <el-input v-model="form.auditOpinion" type="textarea" :rows="2" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item>
          <el-button type="primary" @click="audit(1)" style="padding: 10px!important; margin-right: 30px!important;">审核通过</el-button>
          <el-button type="danger" @click="audit(2)" style="padding: 10px!important;">审核不通过</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import {getApply, auditTask} from "@/api/crowdsource/crowdsource";
  import {applicantlist,onsiteTypelist,processStatuslist} from "@/const/dict/commondict";
  import {mapGetters} from "vuex";
  export default {
    name: "CrowdsourceAudit",
    components: {},
    
    data() {
      return {
        // 遮罩层
        loading: false,
        open: false,
        applyId: 0,
        title: '众包任务审核',
        onsiteTypelist,//驻场需求
        form: {},
        task:{},
        tasktypelist:[{name:'静态测试',id:'static'},{name:'功能测试',id:'function'},{name:'性能测试',id:'performance'},{name:'安全测试',id:'security'},
                {name:'配置项测试',id:'configuration'},{name:'可靠性测试',id:'reliability'}, {name:'研发任务',id:'development'},{name:'用人任务',id:'outsource'},{name:'其他',id:'other'}],
        rules:{
          
        }
      }
    },
    computed:{
        ...mapGetters(['testtypelist','feescopelist','token','userinform'])
    },
    methods: {
      audit(status) {
        this.form.status = status;
        this.form.applyId = this.applyId;
        this.$confirm("确定提交审核结果吗？").then(()=>{
          auditTask(this.form).then(response => {
            this.$notify({
              title: '审核完毕',
              message: '',
              align: 'center',
              type: 'success'
            });
            this.resetForm("form");
            this.open = false;
            this.$emit("closeDialog")
          });
        })
      },
      // 审核页调用的方法
      openDialog(applyId) {
        this.loading = true;
        this.applyId = applyId;
        getApply(applyId).then(response => {
          this.task = response.data;
          this.loading = false;
          this.open = true;
        });
      }
    },
    created() {

    },
    computed: {}
  }
</script>

<style scoped>
</style>
