<template>
    <!-- 弹出框表单 -->
    <el-drawer
            title="批量处理"
            :visible.sync="open"
            :direction="direction"
            size="50%">
        <div>
            已选择6个：
        </div>
        <div class="staffList">
            <div v-for="item in 5" :key="item" class="mt10">
                将<span>刘德华</span>
                <span>的下班时间18：00打卡异常状态</span>
                <span class="ml10">缺卡</span>
                <span class="ml10">修改为</span>
            </div>
            <div>
                <!-- 处理异常状态 -->
                <el-select>
                    <el-option></el-option>
                </el-select>
                <!-- 早退/迟到 -->
                <el-input style="width:220px" placeholder="请输入数字">
                     <template slot="append">分钟</template>
                </el-input>
            </div>
            <div>
                <span>备注：</span>
                <el-input placeholder="请输入备注" v-model="dealParams.remark"></el-input>
            </div>
        </div>
    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        name: "AttendanceRecordDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("attendance/record")
        },
        data() {
            return {
                // 子表选中数据
                checkedAttendanceRecordDetail: [],
                // 考勤打卡记录详细信息表格数据
                attendanceRecordDetailList: [],
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "考勤打卡记录信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                ],
                toDate:[
                    "attendanceDate",
                ],
                // 表单校验
                rules: {
                    staffName: [
                        {required: true,message: "请输入员工姓名", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                },
                dealParams:{
                    remark:'',
                    errorStatus:''
                }
            }
        },

        methods: {
            /** 考勤打卡记录详细信息序号 */
            rowAttendanceRecordDetailIndex({ row, rowIndex }) {
                row.index = rowIndex + 1;
            },
            /** 考勤打卡记录详细信息添加按钮操作 */
            handleAddAttendanceRecordDetail() {
                let obj = {};
                obj.shiftsId = "";
                obj.shiftsName = "";
                obj.goWorkDate = "";
                obj.goWorkResult = "";
                obj.offWorkDate = "";
                obj.offWorkResult = "";
                obj.remark = "";
                obj.createUserId = "";
                obj.createTime = "";
                obj.updateUserId = "";
                obj.updateTime = "";
                this.attendanceRecordDetailList.push(obj);
            },
            /** 考勤打卡记录详细信息删除按钮操作 */
            handleDeleteAttendanceRecordDetail() {
                if (this.checkedAttendanceRecordDetail.length == 0) {
                    this.$alert("请先选择要删除的考勤打卡记录详细信息数据", "提示", { confirmButtonText: "确定", });
                } else {
                    this.attendanceRecordDetailList.splice(this.checkedAttendanceRecordDetail[0].index - 1, 1);
                }
            },
            /** 单选框选中数据 */
            handleAttendanceRecordDetailSelectionChange(selection) {
                if (selection.length > 1) {
                    this.$refs.attendanceRecordDetail.clearSelection();
                    this.$refs.attendanceRecordDetail.toggleRowSelection(selection.pop());
                } else {
                    this.checkedAttendanceRecordDetail = selection;
                }
            },
            // 渲染前置处理
            beforeRender(data) {
                if(data.entity.attendanceRecordDetailList) {
                    this.attendanceRecordDetailList = data.entity.attendanceRecordDetailList;
                }
                return data
            },
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/record/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改考勤打卡记录信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "attendance/record/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增考勤打卡记录信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="attendance/record/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "考勤打卡记录信息详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    staffId : null,
                    staffName : "",
                    workNum : "",
                    deptId : null,
                    deptName : "",
                    positionId : null,
                    positionName : "",
                    attendanceGroupId : null,
                    attendanceGroupName : "",
                    shiftsId : null,
                    shiftsName : "",
                    attendanceDate : null,
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
