<template>
    <div class="page">
        <LayoutTable :data="tableData" :config="tableConfig" notDel notAdd>
            <el-button
                slot="table-head-left2"
                style="margin-left: 10px"
                size="mini"
                type="primary"
                @click="morehandle"
            >批量处理</el-button>
        </LayoutTable>
        <dialog-show ref="dialogform" @ok="getData" />
        <!-- 撤销提示 -->
        <el-dialog :visible.sync="dialogVisible" title="提示" width="40%">
            <div>撤销异常处理结果后，当天的考勤结果将会重新计算，系统需要花费一点时间。</div>
            <div class="flex flex_end">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="resetError">确定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    /** 表单弹出框模式需引入 */
    import dialogShow from "./dialogshow";
    import table from "@/assets/mixins/table";
    export default {
        name: "AttendanceRecordErrorList",
        components: {
            dialogShow
        },
        mixins: [table],
        created() {
        },
        methods: {
            /** 重写新增方法 */
            // toAdd(row) {
            //     this.$refs.dialogform.add(row);
            // },
            // /** 重写编辑方法 */
            // toEdit(row) {
            //     this.$refs.dialogform.edit(row);
            // },
            // /** 重写查看方法 */
            // toView(row) {
            //     this.$refs.dialogform.view(row);
            // },
            // morehandle(row){
            //     console.log(this.selection)
            //     this.$refs.dialogform.edit(row);
            // },
            // 处理
            handle(err){
                console.log(err)
                this.$refs.dialogform.edit(err);
            },
            // 撤销
            reCancle(err){
                console.log(err)
                this.dialogVisible = true
            },
            resetError(data){
                this.$get('attendance/record/error/delete',{id:data.id}).then(res => {
                    if(res.code == 1){
                        this.dialogVisible = false
                        this.getData()
                    }
                })
            }
        },
        data() {
            return {
                config: {
                    isshowTabPane:true,
                    search: [
                        {
                            name: "deptId",
                            type: "select",
                            label: "全部部门",
                            fuzzy: false
                        },
                        {
                            name: "groupId",
                            type: "select",
                            label: "全部考勤组",
                            fuzzy: false
                        },
                        {
                            name: "classId",
                            type: "select",
                            label: "全部班次",
                            fuzzy: false
                        },
                        {
                            name: "errorStatus",
                            type: "select",
                            label: "全部异常状态",
                            fuzzy: false
                        },
                        {
                            name: "processStatus",
                            type: "select",
                            label: "全部处理状态",
                            fuzzy: false
                        },
                        {
                            name:'attendanceDateStart',
                            type: "date",
                            label: "异常开始时间",
                            fuzzy: false
                        },
                        {
                            name:'attendanceDateEnd',
                            type: "date",
                            label: "异常结束时间",
                            fuzzy: false
                        },
                        {
                            name: "staffName",
                            type: "text",
                            label: "员工姓名",
                            fuzzy: false
                        },
                        {
                            name: "phoneNumber",
                            type: "text",
                            label: "手机号",
                            fuzzy: false
                        },
                    ],
                    columns: [
                        {type: "selection", width: 60},
                        {type: "index",label: "序号",width: 50},

                        {label: "员工姓名", prop: "staffName"},
                        {label: "工号", prop: "workNum"},
                        {label: "部门", prop: "staffName"},
                        {label: "考勤组", prop: "deptName"},
                        {label: "班次", prop: "shiftsName"},
                        {label: "异常状态", prop: "errorStatus",formatter: this.formattereErrorStatus},
                        {label: "异常时间", prop: "errorDateTime", formatter: this.formatterDate},
                        {label: "处理结果", prop: "processResult", formatter: this.formatterDate},
                        {label: "上下班时间", prop: "goOffDateTime", formatter: this.formatterDate},
                        {label: "实际打卡时间", prop: "actualAttendanceDateTime", formatter: this.formatterDate},
                        {label: "处理时间", prop: "operDateTime", formatter: this.formatterDate},
                        {label: "处理状态", prop: "processStatus",formatter: this.formattereDealStatus},
                        {label: "处理人", prop: "opertor"},
                        {label: "备注", prop: "remark"},
                        {
                            label: "操作",
                            width: 240,
                            formatter: row => {
                                return (
                                    <span>
                                        <el-button type="text" size='mini' onClick={(row) => {
                                            this.handle(row)
                                        }} v-if={row.processStatus == 0}>处理</el-button>
                                        <el-button type="text" size='mini' onClick={(row) => {
                                            this.reCancle(row)
                                        }} v-else>撤销</el-button>
                                    </span>
                                )
                            }
                        }
                    ]
                },
                dialogVisible:false
            }
        }
    };
</script>