<template>
    <div>
        <div class="tasklist-all">
            <el-dialog width="500px" title="完成情况" :visible.sync="dialogTasklist">
                <el-form>
                    <el-form-item label="特殊说明:" :label-width="formLabelWidth">
                        <el-input type="textarea" :rows="5" v-model="shuju.remark" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="完成时间:" :label-width="formLabelWidth">
                        <el-date-picker v-model="shuju.overTime" type="datetime" placeholder="选择日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogTasklist = false">取 消</el-button>
                    <el-button type="primary" @click="PostTaskAllocationSetAuditStatus">确 定</el-button>
                </div>
            </el-dialog>

            <div class="tasklist-head">
                <el-form style="display: flex;justify-content: space-between;align-items: center;" label-width="70px"
                    class="demo-ruleForm">
                    <div class="tasklist-head-select">
                        <el-form-item label="任务名称" prop="name">
                            <el-select :clearable="true" size="medium" @change="changetasknames" filterable
                                v-model="tasknames" placeholder="请选择">
                                <el-option v-for="item in tasknamelist" :key="item" :label="item" :value="item">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="完成状态" prop="name">
                            <el-select @change="changecompletionstatus" size="medium" filterable
                                v-model="completionstatus" placeholder="请选择">
                                <el-option v-for="item in completionstatuslist" :key="item.id" :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="人员名称" prop="name">
                            <el-select @change="changecompletionstatus" size="medium" filterable
                                v-model="taskUserId" placeholder="请选择">
                                <el-option v-for="item in taskUserIdArr" :key="item.id" :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- <el-form-item label="指派类型" prop="name">
                            <el-select @change="changeassignmenttype" size="medium" filterable v-model="assignmenttype" placeholder="请选择">
                                <el-option
                                    v-for="item in assignmenttypelist"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item> -->
                    </div>
                    <el-button size="medium" @click="handleView" type="primary">新增任务</el-button>
                </el-form>
            </div>
            <div class="tasklist-title">任务列表</div>
            <div class="tasklist-table">
                <el-table :data="tableData" border style="width: 100%">
                    <!-- <el-table-column type="expand">
                        <template slot-scope="scopee">                                                                                                                                                                                                                                                                                                                                                                                                                             
                            <div v-if="userId==scopee.row.taskerDetails[0].taskCreateUserId" class="table-boxli">
                                <el-table
                                :data="scopee.row.taskerDetails"
                                border
                                style="width: 100%">
                                    <el-table-column 
                                    type="index" 
                                    label="序号" 
                                    width="50" >
                                    </el-table-column>
                                    <el-table-column
                                    prop="userName"
                                    label="姓名"
                                    width="100">
                                    </el-table-column>
                                    <el-table-column
                                    prop="beginTime"
                                    label="开始日期"
                                    width="180">
                                    </el-table-column>
                                    <el-table-column
                                    prop="overTime"
                                    label="完成日期"
                                    width="180">
                                    </el-table-column>
                                    <el-table-column
                                    label="状态"
                                    width="80">
                                        <template slot-scope="scopeStatus">
                                            <span v-if="scopeStatus.row.taskStatus==-1">
                                                未开始 
                                            </span>
                                            <span v-if="scopeStatus.row.taskStatus==0">
                                                已知晓
                                            </span>
                                            <span v-if="scopeStatus.row.taskStatus==1">
                                                进行中
                                            </span>
                                            <span v-if="scopeStatus.row.taskStatus==2">
                                                待审核
                                            </span>
                                            <span v-if="scopeStatus.row.taskStatus==3">
                                                未完成
                                            </span>
                                            <span v-if="scopeStatus.row.taskStatus==4">
                                                已完成
                                            </span>
                                            <span v-if="scopeStatus.row.taskStatus==5">
                                                任务中止
                                            </span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                    prop="score"
                                    label="评分"
                                    width="180">
                                    <template slot-scope="scopescore">
                                        <span v-if="scopescore.row.score==0">
                                            未评分
                                        </span>
                                        <span v-if="scopescore.row.score==1">
                                            不合格
                                        </span>
                                        <span v-if="scopescore.row.score==2">
                                            一般
                                        </span>
                                        <span v-if="scopescore.row.score==3">
                                            良好
                                        </span>
                                        <span v-if="scopescore.row.score==4">
                                            优秀
                                        </span>
                                    </template>
                                    </el-table-column>
                                    <el-table-column
                                    prop="scoreRemark"
                                    label="评分备注"
                                    width="250">
                                    </el-table-column>
                                    <el-table-column
                                    prop="cause"
                                    label="备注">
                                    </el-table-column>
                                    <el-table-column
                                    label="操作"
                                    width="180">
                                    <template slot-scope="scopes">
                                        <el-select v-if="scopes.row.taskStatus==2" size="small" @change="statuschange($event,scopes.row)" style="width:100px;margin-right: 15px;" v-model="reviewstatus" placeholder="请选择">
                                            <el-option label="未审核" value="shanghai"></el-option>
                                            <el-option label="已完成" value="4"></el-option>
                                            <el-option label="终止" value="beijing"></el-option>
                                            <el-option label="未完成" value="3"></el-option>
                                        </el-select>
                                        <el-button
                                        v-if="scopes.row.taskStatus==4"
                                        type="text"
                                        size="small"
                                        @click="scoreclick(scopes.$index,scopes.row)">
                                        评分
                                        </el-button>
                                    </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </template>
                    </el-table-column> -->
                    <el-table-column prop="taskName" label="任务名称">
                    </el-table-column>
                    <el-table-column prop="taskPriority" label="优先级" width="70">
                    </el-table-column>
                    <el-table-column prop="participant" label="指派给" width="200">
                    </el-table-column>
                    <el-table-column prop="status" label="状态" width="80">
                        <template slot-scope="scopes">
                            <!-- <div v-if="scopes.row.createUserName==cnName"> -->
                            <div>
                                <span v-if="scopes.row.status==0">
                                    未开始
                                </span>
                                <span v-if="scopes.row.status==1">
                                    进行中
                                </span>
                                <span v-if="scopes.row.status==2">
                                    待审核
                                </span>
                                <span v-if="scopes.row.status==3">
                                    未完成
                                </span>
                                <span v-if="scopes.row.status==4">
                                    已完成
                                </span>
                            </div>
                            <!-- <div v-else-if="scopes.row.createUserName!=cnName">
                                <span v-if="scopes.row.status==-1">
                                    未开始
                                </span>
                                <span v-if="scopes.row.status==0">
                                    已知晓
                                </span>
                                <span v-if="scopes.row.status==1">
                                    进行中
                                </span>
                                <span v-if="scopes.row.status==2">
                                    待审核
                                </span>
                                <span v-if="scopes.row.status==3">
                                    未完成
                                </span>
                                <span v-if="scopes.row.status==4">
                                    已完成
                                </span>
                                <span v-if="scopes.row.status==5">
                                    任务中止
                                </span>
                            </div> -->
                        </template>
                        <!-- <template v-if="status" slot-scope="scope">
                            {{ scope.row.status==0? scope.row.status==1?:'全部'  }}
                        </template> -->
                    </el-table-column>
                    <!-- <el-table-column
                    prop="consummator"
                    label="完成者"
                    width="100">
                    </el-table-column> -->
                    <el-table-column prop="depName" label="归属部门" width="100">
                    </el-table-column>
                    <el-table-column prop="taskTypeName" label="类型" width="100">
                    </el-table-column>
                    <el-table-column prop="date" label="预计起止时间" width="170">
                        <template slot-scope="scopeTime">
                            <div class="scopeTimeDQ">
                                <div>
                                    {{ scopeTime.row.predictBeginTime }}
                                </div>
                                <div>
                                    {{ scopeTime.row.predictEndTime }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="overTime" label="实际完成时间" width="170">
                    </el-table-column>
                    <el-table-column prop="createUserName" label="创建者" width="100">
                    </el-table-column>
                    <el-table-column prop="createTime" label="创建时间" width="180">
                    </el-table-column>
                    <el-table-column label="操作" width="210">
                        <template slot-scope="scopebtn">
                            <!-- //任务创建者
                            确认任务完成 编辑 删除
                            //任务归属者
                            开始 完成  -->
                            <el-button v-if="scopebtn.row.taskHavePerm" type="text" size="small"
                                @click.native.prevent="PostTaskAllocationSetHaveStatus(scopebtn.$index, scopebtn.row)">
                                已知晓
                            </el-button>
                            <el-button  v-if="scopebtn.row.taskDetailsPerm" @click.native.prevent="taskedit(scopebtn.$index, scopebtn.row)" type="text"
                                size="small">
                                详细
                            </el-button>
                            <el-button v-if="scopebtn.row.editPerm"
                                @click.native.prevent="taskedit(scopebtn.$index, scopebtn.row)" type="text"
                                size="small">
                                编辑
                            </el-button>
                            <el-button  v-if="scopebtn.row.taskCompletedPerm" type="text" size="small"
                                @click.native.prevent="openDialog(scopebtn.row)">
                                完成
                            </el-button>
                            <!-- <el-button
                            v-if="cnName!=scopebtn.row.createUserName"
                            type="text"
                            size="small"
                            @click.native.prevent="PostTaskAllocationSetHaveStatus(scopebtn.$index, scopebtn.row)">
                            已知晓
                            </el-button>
                            <el-button
                            v-if="cnName!=scopebtn.row.createUserName"
                            type="text"
                            size="small"
                            @click.native.prevent="PostTaskAllocationSetOverStatus(scopebtn.$index, scopebtn.row)">
                            完成
                            </el-button>
                            <el-button
                            v-if="cnName==scopebtn.row.createUserName"
                            @click.native.prevent="taskedit(scopebtn.$index, scopebtn.row)"
                            type="text"
                            size="small">
                            编辑
                            </el-button>
                            <el-button
                            v-if="cnName!=scopebtn.row.createUserName"
                            @click.native.prevent="taskedit(scopebtn.$index, scopebtn.row)"
                            type="text"
                            size="small">
                            详细
                            </el-button>
                            <el-button
                            v-if="cnName==scopebtn.row.createUserName"
                            @click.native.prevent="PostTaskAllocationTermination(scopebtn.$index, scopebtn.row)"
                            type="text"
                            size="small">
                            任务终止
                            </el-button> -->
                            <el-button
                            v-if="scopebtn.row.taskCompletedPerm"
                            @click.native.prevent="deleteRow(scopebtn.$index,scopebtn.row,tableData)"
                            type="text"
                            size="small">
                            移除
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="block">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page="currentPage" :page-sizes="[1,5, 10, 15, 20]" :page-size="pagesize"
                        layout="total, sizes, prev, pager, next, jumper" :total="count">
                    </el-pagination>
                </div>
            </div>
            <el-dialog top="30vh" width="900px" title="等级评分" :visible.sync="dialogFormVisible"
                :close-on-click-modal="false">
                <el-form>
                    <div class="score-box">
                        <el-form-item label="姓名" :label-width="labelWidth">
                            <el-input :disabled="true" v-model="scorename" placeholder="姓名"></el-input>
                        </el-form-item>
                        <el-form-item label="评分" :label-width="labelWidth">
                            <el-radio-group v-model="score">
                                <el-radio label="不合格"></el-radio>
                                <el-radio label="一般"></el-radio>
                                <el-radio label="良好"></el-radio>
                                <el-radio label="优秀"></el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item size="medium" label="评分备注" :label-width="labelWidth">
                            <el-input rows="1" type="textarea" v-model="scoreRemark"></el-input>
                        </el-form-item>
                    </div>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="scoreconfirm()">确 定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>
<script>
export default {
    beforeRouteLeave(to, from, next) {
        if(to.name!='MyTasksinif'||to.name!='AssignTasks'){
            from.meta.keepAlive = false;
        }
        next()
    },
    beforeRouteEnter(to, from, next) {
        // console.log(to)
        // console.log(from)
        // if(from.name=='MyTasksinif'){
        //     to.meta.keepAlive=true;
        //     //判断是从哪个路由过来的，
        // }else{
        //     to.meta.keepAlive=false;
        // }
        console.log(to)
        console.log(from)
        next();
    },
    data () {
        return {
            token:'',
            pageId:'',
            userId:'',
            jobName:'',
            tasknames:"",
            tasknamelist:[],
            completionstatus:-1,
            completionstatuslist:[
                {
                    id:-1,
                    name:'全部'
                },
                {
                    id:0,
                    name:'未开始'
                },
                {
                    id:1,
                    name:'进行中'
                },
                {
                    id:2,
                    name:'待审核'
                },
                {
                    id:3,
                    name:'未完成'
                },
                {
                    id:4,
                    name:'已完成'
                },
            ],
            assignmenttype:0,
            assignmenttypelist:[
                {
                    id:0,
                    name:'全部'
                },
                {
                    id:1,
                    name:'由我指派'
                },
                {
                    id:2,
                    name:'指派给我'
                },
            ],
            tableData: [],
            value: '',
            pagesize:10,
            currentPage: 1,
            count:0,
            dialogFormVisible:false,
            labelWidth:'80px',
            scorename:'',
            score:'',
            scoreid:'',
            ID:'',
            scoreRemark:'',
            cnName:'',//登录用户名
            reviewstatus:'',
            formLabelWidth: '80px',
            dialogTasklist: false,
            shuju:{
                id:'',
                remark:'',
                overTime:'',
            },
            taskUserId:-1,
            taskUserIdArr:[],
        }
    },
    methods: {
        //基础数据原
        PostTaskAllocationInit(){
            var url = "/api/PersonnelModule/PostTaskAllocationInit"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{
                    portType:1,
                    userId: that.userId
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.tasknamelist=res.data.data.taskNameInfos;
                    that.PostTaskAllocationPage()
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("获取数据源失败！");
            });
        },
        //获取列表
        PostTaskAllocationPage(){
            if(this.jobName.indexOf('经理')!=-1||this.jobName.indexOf('主管')!=-1){
                this.assignmenttype=0;
            }else{
                this.assignmenttype=2;
            }
            var url = "/api/PersonnelModule/PostTaskAllocationPage"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{
                    portType:1,
                    userId: that.userId,
                    pageId: that.pageId,
                    pageIndex: that.currentPage,
                    pageSize: that.pagesize,
                    type: that.assignmenttype,
                    status: that.completionstatus,
                    taskName: that.tasknames,
                    taskUserId: that.taskUserId,
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.count=res.data.count;
                    that.tableData=res.data.data;
                }else{
                    
                }
            }).catch(function (error) {
                that.$message.error("获取数据源失败！");
            });
        },
        deleteRow(index,row,rows) {
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
            }).then(() => {
                var url = "/api/PersonnelModule/PostTaskAllocationDel"
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + that.userId
                    },
                    data:{                                                                                                                                                      
                        portType: 1,
                        userId: that.userId,
                        pageId: that.pageId,
                        id: row.id,
                    }
                }).then(function (res) {
                    console.log(res)
                    if(res.data.code==200){
                        that.$message({
                            message: res.data.msg,
                            type: 'success'
                        });
                        rows.splice(index, 1);
                    }else{
                        that.$message.error(res.data.msg);
                    }
                }).catch(function (error) {
                    that.$message.error("任务终止失败！");
                });
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });          
            });
            
        },
        //每页条数改变时触发 选择一页显示多少行
        handleSizeChange(val) {
            this.currentPage = 1;
            this.pagesize = val;
            this.PostTaskAllocationPage()
        },
        //当前页改变时触发 跳转其他页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.PostTaskAllocationPage()
        },
        //xinzhen
        handleView() {
            this.$router.push({path: '/home/AssignTasks'});
            // this.$router.push({path: '/home/Reportstbale?id=' + row.id +''});
        },
        changetasknames(){
            this.currentPage = 1;
            this.PostTaskAllocationPage()
        },
        changecompletionstatus(){
            this.currentPage = 1;
            this.PostTaskAllocationPage()
        },
        changeassignmenttype(){
            this.currentPage = 1;
            this.PostTaskAllocationPage()
        },
        //编辑
        taskedit(index,val){
            // this.$router.push({path: '/home/AssignTasks?id='+val.id+''});
            // this.$router.push({path: '/home/MyTasksinif?id='+val.id+''});
            
            if(val.createUserName==this.cnName){
                this.$router.push({path: '/home/AssignTasks?id='+val.id+''});
            }else{
                if(val.participant.indexOf(this.cnName)!=-1){
                    this.$router.push({path: '/home/MyTasksinif?id='+val.id+''});
                }else{
                    this.$message.error("此任务被指派人没有此账号！");
                }
            }
        },
        //基础数据原
        PostTaskAllocationInit(){
            var url = "/api/PersonnelModule/PostTaskAllocationInit"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{
                    portType:1,
                    userId: that.userId
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.tasknamelist=res.data.data.taskNameInfos;
                    that.taskUserIdArr=res.data.data.executeTaskUserInfos;
                    that.taskUserIdArr.unshift({id:-1,name:'全部'});
                    that.PostTaskAllocationPage();
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("获取数据源失败！");
            });
        },
        //开始
        PostTaskAllocationSetHaveStatus(index,row){
            if(row.status>=1){
                this.$message.error('此任务已经开始！');
                return false
            }else{
                var url = "/api/PersonnelModule/PostTaskAllocationSetHaveStatus"
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + that.userId
                    },
                    data:{
                        userId: that.userId,
                        id: row.id,
                    }
                }).then(function (res) {
                    console.log(res)
                    if(res.data.code==200){
                        that.$message({
                            message: res.data.msg,
                            type: 'success'
                        });
                        that.PostTaskAllocationPage();
                    }else{
                        that.$message.error(res.data.msg);
                    }
                }).catch(function (error) {
                    that.$message.error("操作失败（开始步骤）");
                });
            }
        },
        //处理日期
        datetime(val){
            var date=new Date(val);
            var y=date.getFullYear();
            var m=date.getMonth()+1>=10?date.getMonth()+1:'0'+(date.getMonth()+1).toString();
            var d=date.getDate()>=10?date.getDate():'0'+(date.getDate()).toString();
            var s=date.getHours()>=10?date.getHours():'0'+(date.getHours()).toString();
            var f=date.getMinutes()>=10?date.getMinutes():'0'+(date.getMinutes()).toString();
            var mm=date.getSeconds()>=10?date.getSeconds():'0'+(date.getSeconds()).toString();
            return y+'-'+m+'-'+d+" "+s+':'+f+':'+mm
        },
        //完成
        PostTaskAllocationSetOverStatus(index,row){
            if(row.status==2||row.status==0||row.status==4){
                this.$message.error('此任务未开始或待审核，请勿多次提交！');
                return false
            }else{
                var url = "/api/PersonnelModule/PostTaskAllocationSetOverStatus"
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + that.userId
                    },
                    data:{
                        userId: that.userId,
                        id: row.id,
                    }
                }).then(function (res) {
                    console.log(res)
                    if(res.data.code==200){
                        that.$message({
                            message: res.data.msg,
                            type: 'success'
                        });
                        that.PostTaskAllocationPage();
                    }else{
                        that.$message.error(res.data.msg);
                    }
                }).catch(function (error) {
                    that.$message.error("操作失败（完成步骤）");
                });
            }
        },
        //评分
        scoreclick(index,row){
            console.log(index,row)
            this.dialogFormVisible=true;
            this.scorename=row.userName;
            this.scoreid=row.taId;
            this.scoreRemark=row.scoreRemark;
            this.ID=row.id;
            if(row.score==0){
                this.score='良好';
            }else{
                this.score=row.score==4?'优秀':row.score==3?'良好':row.score==2?'一般':'不合格';
            }
        },
        //评分确认
        scoreconfirm(){
            var score=3
            if(this.score=='不合格'){
                score=1
            }else if(this.score=='一般'){
                score=2
            }else if(this.score=='良好'){
                score=3
            }else{
                score=4
            }
            var url = "/api/PersonnelModule/PostTaskAllocationScore"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{                                                                                                                                                      
                    portType: 1,
                    userId: that.userId,
                    pageId: that.pageId,
                    subId: that.ID,
                    score: score,
                    scoreRemark: that.scoreRemark,
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.dialogFormVisible=false;                              
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                    that.PostTaskAllocationPage();
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("获取数据源失败！");
            });
        },
        //change
        statuschange(val,row){
            console.log(val,row)
            if(val==4){
                this.PostTaskAllocationSetAuditStatus(row.id);
            }else if(val==3){
                this.open(row.id);
            }
        },
        //打开情况传递数据
        openDialog(row){
            this.dialogTasklist = true;
            this.shuju.id = row.id;
            this.shuju.remark = row.remark;
            this.shuju.overTime = row.overTime;
        },
        //审核
        PostTaskAllocationSetAuditStatus(){
            var url = "/api/PersonnelModule/PostTaskAllocationSetAuditStatus"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{
                    userId:that.userId,
                    id:that.shuju.id,
                    overTime:that.datetime(that.shuju.overTime),
                    remark:that.shuju.remark,
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                    that.dialogTasklist = false;
                    that.PostTaskAllocationPage();
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("审核失败！");
            });
        },
        open(id) {
            this.$prompt('请输入未完成原因', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            inputPattern: /^.+$/,
            inputErrorMessage: '原因不能为空'
            }).then(({ value }) => {
                this.PostTaskAllocationSetUnFinishedStatus(id,value)
                // this.$message({
                //     type: 'success',
                //     message: '你的邮箱是: ' + value
                // });
            }).catch(() => {
                this.reviewstatus='';
                // this.$message({
                //     type: 'info',
                //     message: '取消输入'
                // });       
            });
        },
        //未完成
        PostTaskAllocationSetUnFinishedStatus(id,val){
            var url = "/api/PersonnelModule/PostTaskAllocationSetUnFinishedStatus"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{
                    subId:id,
                    cause:val,
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                    that.PostTaskAllocationPage();
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("审核失败！");
            });
        },
        //任务终止
        PostTaskAllocationTermination(index,row){
            var url = "/api/PersonnelModule/PostTaskAllocationTermination"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.userId
                },
                data:{                                                                                                                                                      
                    portType: 1,
                    userId: that.userId,
                    pageId: that.pageId,
                    id: row.id,
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                    that.PostTaskAllocationPage();
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("任务终止失败！");
            });
        },
    },
    filters:{
        filter_city(value){
            if(value){
                return value.replaceAll('|','、')
            }
        },
        filter_time(value){
            if(value){
                return value.split(" ")[0]
            }
        }
    },
    
    mounted(){
        this.token=JSON.parse(localStorage.getItem('userinif')).token;
        this.pageId=Number(localStorage.getItem('indexs').split('-')[1]);//页面id
        this.userId=JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
        this.jobName=JSON.parse(localStorage.getItem('userinif')).userInfo.jobName;
        this.cnName=JSON.parse(localStorage.getItem('userinif')).userInfo.cnName;
        this.PostTaskAllocationInit()
    }
}
</script>
<style>
.tasklist-all{
    background-color: #fff;
    padding: 10px;
    box-shadow: 0 0 5px #0005;
    border-radius: 10px;
    min-height: 830px;
}
.tasklist-title{
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 5px;
}
.tasklist-head-select{
    display: flex;
}
.tasklist-head-select .el-form-item{
    margin-bottom: 15px;
    margin-right: 15px;
    
}
.tasklist-head-select .el-select{
    width: 200px;
}
.tasklist-table .block{
    text-align: center;
    margin-top: 15px;
}
.scopeTimeDQ{
    display: flex;
    flex-direction: column;
    font-family: Monaco;
    align-items: center;
}
.score-box{
    display: flex;
    flex-wrap: wrap;
}
.score-box .el-form-item_content{
    width: 100%;
}
.score-box .el-form-item:nth-child(1){
    width: 50%;
}
.score-box .el-form-item:nth-child(2){
    width: 50%;
}
.score-box .el-form-item:nth-child(3){
    width: 100%;
}
.tasklist-table .demo-table-expand {
    font-size: 0;
}
.tasklist-table .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
}
.tasklist-table .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
}
.table-boxli{
    text-align: center;
    padding: 0 20px;
}
.table-boxli .el-table--border, .el-table--group{
    border: 1px solid #b5bfd7;
}
.table-boxli .el-table--border .el-table__cell{
    border: 1px solid #b5bfd7;
    padding: 12px 0;
    min-width: 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    text-overflow: ellipsis;
    vertical-align: middle;
    position: relative;
    text-align: left;
}

</style>