<template>
    <el-table :data="data"  border stripe>
		  <el-table-column label="序列id" min-width="60">
			  <template slot-scope="{row}" >
			    <span>{{ row.id }}</span>
			  </template>
		  </el-table-column>
		  <el-table-column label="接单人" min-width="150">
			  <template slot-scope="{row}" >
			    <span>{{ row.name }}</span>
			  </template>
		  </el-table-column>
          <el-table-column label="联系电话" min-width="150">
			  <template slot-scope="{row}" >
			    <span>{{ row.phone }}</span>
			  </template>
		  </el-table-column>
          <el-table-column label="是否确认" min-width="150">
			  <template slot-scope="{row}" >
			    <span>{{ row.confirm?'是':'否'}}</span>
			  </template>
		  </el-table-column>
		  <el-table-column label="接单时间" min-width="150">
			  <template slot-scope="{row}" >
			    <span>{{ row.created_at|toDatetime }}</span>
			  </template>
		  </el-table-column>
          <el-table-column label="操作" min-width="150">
			<template slot-scope="{ row }">
                <el-button  type="text" v-if="!row.confirm" @click="setTaskMaker(row)">
                    确认接单
                </el-button>
                <el-button type="text" v-else disabled>
                    已经确认
                </el-button>
            </template>
		  </el-table-column>

		  
		</el-table>
</template>

<script>
import { toLogStage } from "@/utils/stringFun";
import { toDatetime } from "@/utils/date";
import {setTaskMaker} from "@/api/task"
    export default {
        name: "taskInfo",
        filters:{toLogStage,toDatetime},
        props:{
            data:{
                type:Array,
                default:()=>{
                    return []
                }
            }
        },
        methods:{
            setTaskMaker( row ){
                let param = {user_id:row.user_id,task_id:row.task_id}
                setTaskMaker( param).then(res=>{
                    if(res.code == 200){
                        this.$message.successMsg("更新成功", 1)
                        this.$emit("updateMaker")
                        row.confirm = 1
                    }
                })

            }
        }

    }

</script>