﻿<template>
	<div class="NCC-common-layout">
		<div class="NCC-common-layout-center">
			<el-row class="NCC-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="考勤编号">
							<el-input v-model="query.id" placeholder="考勤编号" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="门店编号">
							<el-input v-model="query.mdbh" placeholder="门店编号" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="门店名称">
							<el-input v-model="query.mdmc" placeholder="门店名称" clearable />	
						</el-form-item>
					</el-col>
					<template v-if="showAll">
					<el-col :span="6">
						<el-form-item label="职位">
							<el-input v-model="query.zw" placeholder="职位" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="岗位分类1">
							<el-input v-model="query.gwfl1" placeholder="岗位分类1" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="员工编号">
							<el-input v-model="query.ygbh" placeholder="员工编号" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="姓名">
							<el-input v-model="query.xm" placeholder="姓名" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="在职情况">
							<el-input v-model="query.zzqk" placeholder="在职情况" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="岗位分类2">
							<el-input v-model="query.gwfl2" placeholder="岗位分类2" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="发放月份">
							<el-input v-model="query.ffyf" placeholder="发放月份" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="在岗天数">
							<el-input v-model="query.zgts" placeholder="在岗天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="当月休息天数">
							<el-input v-model="query.dybzxxts" placeholder="当月休息天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="实际休息天数">
							<el-input v-model="query.sjxxts" placeholder="实际休息天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="休息">
							<el-input v-model="query.xx" placeholder="休息" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="请假">
							<el-input v-model="query.qj" placeholder="请假" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="福利假">
							<el-input v-model="query.flj" placeholder="福利假" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="丧假">
							<el-input v-model="query.sj" placeholder="丧假" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="年假">
							<el-input v-model="query.nj" placeholder="年假" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="出勤">
							<el-input v-model="query.cq" placeholder="出勤" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="出勤加休息">
							<el-input v-model="query.cqjxx" placeholder="出勤加休息" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="应休">
							<el-input v-model="query.yx" placeholder="应休" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="不扣天数">
							<el-input v-model="query.bkts" placeholder="不扣天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="调减休息">
							<el-input v-model="query.tjxx" placeholder="调减休息" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="实际请假">
							<el-input v-model="query.sjqj" placeholder="实际请假" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="少休天数">
							<el-input v-model="query.sxts" placeholder="少休天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="少休补贴">
							<el-input v-model="query.sxbt" placeholder="少休补贴" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="缺卡">
							<el-input v-model="query.qk" placeholder="缺卡" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="迟到">
							<el-input v-model="query.cd" placeholder="迟到" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="全勤">
							<el-input v-model="query.qq" placeholder="全勤" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="交通补助">
							<el-input v-model="query.jtbz" placeholder="交通补助" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="学习期扣款">
							<el-input v-model="query.xxqkk" placeholder="学习期扣款" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="住宿">
							<el-input v-model="query.zs" placeholder="住宿" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="工作服">
							<el-input v-model="query.gzf" placeholder="工作服" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="手机押金">
							<el-input v-model="query.sjyj" placeholder="手机押金" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="宿舍押金">
							<el-input v-model="query.ssyj" placeholder="宿舍押金" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="其他奖励">
							<el-input v-model="query.qtjl" placeholder="其他奖励" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="保底核算金额">
							<el-input v-model="query.bdyhsje" placeholder="保底核算金额" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="当月培训">
							<el-input v-model="query.dypx" placeholder="当月培训" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="当月交通补贴">
							<el-input v-model="query.dyjtbt" placeholder="当月交通补贴" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="应发上月">
							<el-input v-model="query.yfsy" placeholder="应发上月" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="应发次月">
							<el-input v-model="query.yfcy" placeholder="应发次月" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="在店天数">
							<el-input v-model="query.zdts" placeholder="在店天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="跨月天数">
							<el-input v-model="query.kyts" placeholder="跨月天数" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="上月工资有">
							<el-input v-model="query.sygzy" placeholder="上月工资有" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="在店加正常休">
							<el-input v-model="query.dyzdjzcxts" placeholder="在店加正常休" clearable />	
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="当月是否核算">
							<el-input v-model="query.dysfhs" placeholder="当月是否核算" clearable />	
						</el-form-item>
					</el-col>
					</template>
					<el-col :span="6">
						<el-form-item>
							<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
							<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
							<el-button type="text" icon="el-icon-arrow-down" @click="showAll=true" v-if="!showAll">展开</el-button>
							<el-button type="text" icon="el-icon-arrow-up" @click="showAll=false" v-else>收起</el-button>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="NCC-common-layout-main NCC-flex-main">
				<div class="NCC-common-head">
					<div>
						<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
						<el-button type="text" icon="el-icon-download" @click="exportData()">导出</el-button>
						<el-button type="text" icon="el-icon-delete" @click="handleBatchRemoveDel()">批量删除</el-button>
					</div>
					<div class="NCC-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false" @click="reset()" />
						</el-tooltip>
						<screenfull isContainer />
					</div>
				</div>
                <NCC-table v-loading="listLoading" :data="list" has-c @selection-change="handleSelectionChange">
					<el-table-column prop="id" label="考勤编号" align="left" />
					<el-table-column prop="mdbh" label="门店编号" align="left" />
					<el-table-column prop="mdmc" label="门店名称" align="left" />
					<el-table-column prop="zw" label="职位" align="left" />
					<el-table-column prop="gwfl1" label="岗位分类1" align="left" />
					<el-table-column prop="ygbh" label="员工编号" align="left" />
					<el-table-column prop="xm" label="姓名" align="left" />
					<el-table-column prop="zzqk" label="在职情况" align="left" />
					<el-table-column prop="gwfl2" label="岗位分类2" align="left" />
					<el-table-column prop="ffyf" label="发放月份" align="left" />
					<el-table-column prop="zgts" label="在岗天数" align="left" />
					<el-table-column prop="dybzxxts" label="当月休息天数" align="left" />
					<el-table-column prop="sjxxts" label="实际休息天数" align="left" />
					<el-table-column prop="xx" label="休息" align="left" />
					<el-table-column prop="qj" label="请假" align="left" />
					<el-table-column prop="flj" label="福利假" align="left" />
					<el-table-column prop="sj" label="丧假" align="left" />
					<el-table-column prop="nj" label="年假" align="left" />
					<el-table-column prop="cq" label="出勤" align="left" />
					<el-table-column prop="cqjxx" label="出勤加休息" align="left" />
					<el-table-column prop="yx" label="应休" align="left" />
					<el-table-column prop="bkts" label="不扣天数" align="left" />
					<el-table-column prop="tjxx" label="调减休息" align="left" />
					<el-table-column prop="sjqj" label="实际请假" align="left" />
					<el-table-column prop="sxts" label="少休天数" align="left" />
					<el-table-column prop="sxbt" label="少休补贴" align="left" />
					<el-table-column prop="qk" label="缺卡" align="left" />
					<el-table-column prop="cd" label="迟到" align="left" />
					<el-table-column prop="qq" label="全勤" align="left" />
					<el-table-column prop="jtbz" label="交通补助" align="left" />
					<el-table-column prop="xxqkk" label="学习期扣款" align="left" />
					<el-table-column prop="zs" label="住宿" align="left" />
					<el-table-column prop="gzf" label="工作服" align="left" />
					<el-table-column prop="sjyj" label="手机押金" align="left" />
					<el-table-column prop="ssyj" label="宿舍押金" align="left" />
					<el-table-column prop="qtjl" label="其他奖励" align="left" />
					<el-table-column prop="bdyhsje" label="保底核算金额" align="left" />
					<el-table-column prop="dypx" label="当月培训" align="left" />
					<el-table-column prop="dyjtbt" label="当月交通补贴" align="left" />
					<el-table-column prop="yfsy" label="应发上月" align="left" />
					<el-table-column prop="yfcy" label="应发次月" align="left" />
					<el-table-column prop="zdts" label="在店天数" align="left" />
					<el-table-column prop="kyts" label="跨月天数" align="left" />
					<el-table-column prop="sygzy" label="上月工资有" align="left" />
					<el-table-column prop="dyzdjzcxts" label="在店加正常休" align="left" />
					<el-table-column prop="dysfhs" label="当月是否核算" align="left" />
					<el-table-column label="操作" fixed="right" width="100">
							<template slot-scope="scope">
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id)" >编辑</el-button>
							<el-button type="text" @click="handleDel(scope.row.id)" class="NCC-table-delBtn" >删除</el-button>
						</template>
					</el-table-column>
				</NCC-table>
                <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
            </div>
        </div>
		<NCC-Form v-if="formVisible" ref="NCCForm" @refresh="refresh" />
		<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
	</div>
</template>
<script>
    import request from '@/utils/request'
    import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
    import NCCForm from './Form'
    import ExportBox from './ExportBox'
    import { previewDataInterface } from '@/api/systemData/dataInterface'
	export default {
        components: { NCCForm, ExportBox },
        data() {
            return {
                showAll: false,
				query: {
                    id:undefined,
                    mdbh:undefined,
                    mdmc:undefined,
                    zw:undefined,
                    gwfl1:undefined,
                    ygbh:undefined,
                    xm:undefined,
                    zzqk:undefined,
                    gwfl2:undefined,
                    ffyf:undefined,
                    zgts:undefined,
                    dybzxxts:undefined,
                    sjxxts:undefined,
                    xx:undefined,
                    qj:undefined,
                    flj:undefined,
                    sj:undefined,
                    nj:undefined,
                    cq:undefined,
                    cqjxx:undefined,
                    yx:undefined,
                    bkts:undefined,
                    tjxx:undefined,
                    sjqj:undefined,
                    sxts:undefined,
                    sxbt:undefined,
                    qk:undefined,
                    cd:undefined,
                    qq:undefined,
                    jtbz:undefined,
                    xxqkk:undefined,
                    zs:undefined,
                    gzf:undefined,
                    sjyj:undefined,
                    ssyj:undefined,
                    qtjl:undefined,
                    bdyhsje:undefined,
                    dypx:undefined,
                    dyjtbt:undefined,
                    yfsy:undefined,
                    yfcy:undefined,
                    zdts:undefined,
                    kyts:undefined,
                    sygzy:undefined,
                    dyzdjzcxts:undefined,
                    dysfhs:undefined,
				},
                list: [],
                listLoading: true,
                multipleSelection: [], total: 0,
                listQuery: {
                    currentPage: 1,
                    pageSize: 20,
					sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                exportBoxVisible: false,
                columnList: [
                    { prop: 'id', label: '考勤编号' },
                    { prop: 'mdbh', label: '门店编号' },
                    { prop: 'mdmc', label: '门店名称' },
                    { prop: 'zw', label: '职位' },
                    { prop: 'gwfl1', label: '岗位分类1' },
                    { prop: 'ygbh', label: '员工编号' },
                    { prop: 'xm', label: '姓名' },
                    { prop: 'zzqk', label: '在职情况' },
                    { prop: 'gwfl2', label: '岗位分类2' },
                    { prop: 'ffyf', label: '发放月份' },
                    { prop: 'zgts', label: '在岗天数' },
                    { prop: 'dybzxxts', label: '当月休息天数' },
                    { prop: 'sjxxts', label: '实际休息天数' },
                    { prop: 'xx', label: '休息' },
                    { prop: 'qj', label: '请假' },
                    { prop: 'flj', label: '福利假' },
                    { prop: 'sj', label: '丧假' },
                    { prop: 'nj', label: '年假' },
                    { prop: 'cq', label: '出勤' },
                    { prop: 'cqjxx', label: '出勤加休息' },
                    { prop: 'yx', label: '应休' },
                    { prop: 'bkts', label: '不扣天数' },
                    { prop: 'tjxx', label: '调减休息' },
                    { prop: 'sjqj', label: '实际请假' },
                    { prop: 'sxts', label: '少休天数' },
                    { prop: 'sxbt', label: '少休补贴' },
                    { prop: 'qk', label: '缺卡' },
                    { prop: 'cd', label: '迟到' },
                    { prop: 'qq', label: '全勤' },
                    { prop: 'jtbz', label: '交通补助' },
                    { prop: 'xxqkk', label: '学习期扣款' },
                    { prop: 'zs', label: '住宿' },
                    { prop: 'gzf', label: '工作服' },
                    { prop: 'sjyj', label: '手机押金' },
                    { prop: 'ssyj', label: '宿舍押金' },
                    { prop: 'qtjl', label: '其他奖励' },
                    { prop: 'bdyhsje', label: '保底核算金额' },
                    { prop: 'dypx', label: '当月培训' },
                    { prop: 'dyjtbt', label: '当月交通补贴' },
                    { prop: 'yfsy', label: '应发上月' },
                    { prop: 'yfcy', label: '应发次月' },
                    { prop: 'zdts', label: '在店天数' },
                    { prop: 'kyts', label: '跨月天数' },
                    { prop: 'sygzy', label: '上月工资有' },
                    { prop: 'dyzdjzcxts', label: '在店加正常休' },
                    { prop: 'dysfhs', label: '当月是否核算' },
				],
			}
        },
		computed: {},
		created() {
			this.initData()
		},
		methods: {
			initData() {
                this.listLoading = true;
                let _query = {
                    ...this.listQuery,
                    ...this.query
                };
                let query = {}
                for (let key in _query) {
                    if (Array.isArray(_query[key])) {
                        query[key] = _query[key].join()
                    } else {
                        query[key] = _query[key]
                    }
                }
                request({
                    url: `/api/Extend/LqKqhzb`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    this.list = res.data.list
                    this.total = res.data.pagination.total
                    this.listLoading = false
                })
            },
			handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/Extend/LqKqhzb/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => {
                });
            },
			handleSelectionChange(val) {
                const res = val.map(item => item.id)
                this.multipleSelection = res
            },
            handleBatchRemoveDel() {
                if (!this.multipleSelection.length) {
                    this.$message({
                        type: 'error',
                        message: '请选择一条数据',
                        duration: 1500,
                    })
                    return
                }
                const ids = this.multipleSelection
                this.$confirm('您确定要删除这些数据吗, 是否继续？', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/Extend/LqKqhzb/batchRemove`,
                        method: 'POST',
                        data: ids ,
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => { })
            },
			addOrUpdateHandle(id, isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.NCCForm.init(id, isDetail)
                })
            },
			exportData() {
                this.exportBoxVisible = true
                this.$nextTick(() => {
                    this.$refs.ExportBox.init(this.columnList)
                })
            },
            download(data) {
                let query = { ...data, ...this.listQuery, ...this.query }
                request({
                    url: `/api/Extend/LqKqhzb/Actions/Export`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    if (!res.data.url) return
                    window.location.href = this.define.comUrl + res.data.url
                    this.$refs.ExportBox.visible = false
                    this.exportBoxVisible = false
                })
            },
			search() {
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            },
            refresh(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            reset() {
                for (let key in this.query) {
                    this.query[key] = undefined
                }
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            }
		}
    }
</script>