<template>
    <div class="acceptanceDialog">
        <el-dialog class="mydialog" title="任务结项" :visible.sync="dialogVisible" width="550px" @close="cancle" :close-on-click-modal="false">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-form-item label="验证是否通过" prop="a">
                    <el-select v-model="form.status" placeholder="请选择">
                        <el-option label="通过" value="0"> </el-option>
                        <el-option label="不通过" value="1"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="备注：" v-if="form.status == 1" prop="remark">
                    <el-input type="textarea" v-model="form.remark"></el-input>
                </el-form-item>
            </el-form>
            <!-- <el-button @click="cancle">取 消</el-button>
                <el-button type="primary" @click="submit">确 定</el-button> -->
            <div class="footerdialog">
                <span class="submit" @click="submit">确 定</span>
                <span class="cancle" @click="cancle">取 消</span>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { resolveTask } from '@/api/crowdsource/crowdsourceNew'
export default {
    data() {
        return {
            dialogVisible: false,
            form: {},
            rules: {
                status: [{ required: true, message: '请选择是否通过', trigger: 'blur' }],
            },
            // 行信息
            rowInfo: {},
            taskId: '',
        }
    },
    methods: {
        submit() {
            const data = {
                taskId: this.taskId,
                testerId: this.rowInfo.user_id,
                status: Number(this.form.status),
                remark: this.form.remark
            }
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    resolveTask(data).then(res => {
                        this.$message.success('操作成功')
                        this.cancle()
                        this.$emit('refresh')
                    })
                }
            })
        },
        cancle() {
            this.dialogVisible = false
            this.form = {}
            this.rowInfo = {}
            this.taskId = ''
        },
    },
}
</script>

<style scoped>
.footerdialog {
    width: 100%;
    display: flex;
    justify-content: center;
}
.mydialog >>> .el-dialog__header {
    border-bottom: 1px solid rgba(153, 153, 153, 0.2);
    font-weight: bold;
    font-size: 20px;
    color: #000000;
}
.mydialog >>> .el-select {
    width: 390px;
}
.submit {
    width: 250px;
    height: 44px;
    background: linear-gradient(90deg, #5ea6fd, #1a81f9);
    border-radius: 22px;
    line-height: 44px;
    text-align: center;
    margin-right: 10px;
    font-weight: 500;
    font-size: 16px;
    color: #ffffff;
    cursor: pointer;
}
.cancle {
    width: 250px;
    height: 44px;
    border-radius: 22px;
    border: 1px solid #e0e0e0;
    line-height: 44px;
    text-align: center;
    font-weight: 500;
    font-size: 16px;
    color: #666666;
    cursor: pointer;
}
</style>