<template>
    <div v-loading.fullscreen.lock="fullscreenLoading">
        <div class="payroll-all">
            <div class="payroll-head">
                <div style="display: flex;" class="payroll-head-li">
                    <el-date-picker
                    style="width: 120px;"
                    v-model="value2"
                    :clearable="false"
                    type="month"
                    placeholder="选择月"
                    @change="PickTime()">
                    </el-date-picker>
                    <el-select style="width: 220px;margin-left: 10px;" @change="companychange()" v-model="companyName" filterable placeholder="请选择公司">
                        <el-option
                            v-for="item in companylist"
                            :key="item.id"
                            :label="item.companyName"
                            :value="item.id">
                        </el-option>
                    </el-select>
                    <!-- <el-select v-model="depName" filterable placeholder="请选择部门">
                        <el-option
                            v-for="item in deplist"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                        </el-option>
                    </el-select> -->
                    <el-input @input="cnNamechange()" style="width: 220px;margin-left: 10px;" v-model="cnName" placeholder="请输入员工姓名"></el-input>
                    <!-- <el-select v-model="cnName" filterable placeholder="请选择员工">
                        <el-option
                            v-for="item in comuserlist"
                            :key="item.id"
                            :label="item.cnName"
                            :value="item.id">
                        </el-option>
                    </el-select> -->
                </div>
                <div class="payroll-head-li">
                    <el-button type="primary" @click="addsalary()">新增员工薪资结构</el-button>
                    <el-button type="primary" @click="openSalaryCalculator()">计算当月工资</el-button>
                    <el-button @click="Download()" type="primary">导出工资单</el-button>
                    <el-button type="primary" @click="DownloadTaxes()">下载个税模板</el-button>
                    <el-button type="primary" @click="UploadTaxes=true">上传个税</el-button>
                    <!--<el-button type="primary">四川公司工资单</el-button>
                    <el-button type="primary">纽茵公司工资单</el-button> -->
                </div>
            </div>
            <div class="payroll-table">
                <template>
                    <el-table
                    height="760"
                    :data="tableDatatwo"
                    border
                    style="width: 100%">
                        <el-table-column
                            prop="row_Number"
                            label="序号"
                            width="50">
                        </el-table-column>
                        <el-table-column
                            prop="yearMonth"
                            label="年月"
                            width="80">
                        </el-table-column>
                        <el-table-column
                            prop="name"
                            label="员工"
                            width="80">
                        </el-table-column>
                        <el-table-column
                            prop="companyName"
                            label="公司"
                            width="170">
                        </el-table-column>
                        <el-table-column
                            label="假勤/打卡"
                            width="85">
                            <template slot-scope="scope">
                                <el-popover
                                v-if="scope.row.ex_ItemsRemark!=''"
                                placement="right"
                                width="150"
                                trigger="hover">
                                    <div v-for="(items,index) in scope.row.ex_ItemsRemark!=''?JSON.parse(scope.row.ex_ItemsRemark):''" :key="index">
                                        <div v-if="items.Type=='假勤'">
                                            <div class="title-popover">{{items.Type}}({{(items.Ex_ItemInfo).length}})</div>
                                            <!-- <div class="title-content" v-for="(itemss,index) in items.Ex_ItemInfo" :key="index">
                                                请假类型:{{itemss.SubType}}
                                            </div> -->
                                        </div>
                                        <div v-if="items.Type=='打卡'">
                                            <div class="title-popover">{{items.Type}}异常({{(items.Ex_ItemInfo).length}})</div>
                                        </div>
                                        <div v-if="items=='[]'">
                                            <div class="title-popover">本月无假勤</div>
                                        </div>
                                    </div>
                                    <div style="cursor: pointer;" slot="reference">移上查看</div>
                                </el-popover>
                                <el-popover
                                v-if="scope.row.ex_ItemsRemark==''"
                                placement="right"
                                width="150"
                                trigger="hover">
                                    <span>无考勤异常</span>
                                    <div style="cursor: pointer;" slot="reference">移上查看</div>
                                </el-popover>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="startDate"
                            label="起止日期"
                            width="190">
                            <template slot-scope="scope">
                                <div>{{scope.row.startDate+'~'+scope.row.endDate}}</div>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="workDays"
                            label="应出勤天数"
                            width="95">
                        </el-table-column>
                        <!-- <el-table-column
                            prop="regularDays"
                            label="正常出勤天数"
                            width="110">
                        </el-table-column> -->
                        <el-table-column
                            prop="should"
                            label="应发合计"
                            width="90"
                            :formatter="rounding">
                        </el-table-column>
                        <el-table-column
                            prop="totalDeductions"
                            label="扣款合计"
                            width="90"
                            :formatter="rounding">
                        </el-table-column>
                        <el-table-column
                            prop="beforeTax"
                            label="税前合计	"
                            width="90"
                            :formatter="rounding">
                        </el-table-column>
                        <el-table-column
                            prop="withholdingTax"
                            label="代缴个税"
                            width="90"
                            :formatter="rounding">
                        </el-table-column>
                        <el-table-column
                            prop="totalRealHair"
                            label="税后合计"
                            width="90"
                            :formatter="rounding">
                        </el-table-column>
                        <el-table-column
                            prop="lastUpdateUserName"
                            label="最后操作人"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="lastUpdateDt"
                            label="最后时间"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="name"
                            label="操 作"
                            width="100">
                            <!-- eslint-disable-next-line -->
                            <template slot-scope="scope">
                                <el-button type="text" @click="SalaryDetails(scope.$index, scope.row)">修改</el-button>
                                <el-button style="color: red;" type="text" @click="deleteaddsalary(scope.$index,scope.row,tableDatatwo)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </template>
            </div>
            <!-- 上传个税 -->
            <el-dialog title="上传个税" width="400px" :visible.sync="UploadTaxes">
                <div>
                    <el-form :model="TaxesData" ref="TaxesData" :rules="Taxesrules">
                        <el-form-item label="年月" prop="yearMonth" label-width="50">
                            <el-date-picker style="width:86%" v-model="TaxesData.yearMonth" size="medium" type="month" placeholder="选择月"></el-date-picker>
                        </el-form-item>
                    </el-form>
                    <el-upload drag
                         :limit=limitNum
                         :auto-upload="false"
                         accept=".xlsx"
                         :action="UploadUrl()"
                         :before-upload="beforeUploadFile"
                         :on-change="fileChange"
                         :on-exceed="exceedFile"
                         :on-success="handleSuccess"
                         :on-error="handleError"
                         :on-remove="removelist"
                         :file-list="fileList">
                      <i class="el-icon-upload"></i>
                      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                      <div class="el-upload__tip" slot="tip">只能上传xlsx文件，且不超过10M</div>
                    </el-upload>
                    <br/>
                    <el-button size="small" type="primary" @click="uploadFile('TaxesData')">立即上传</el-button>
                    <el-button size="small">取消</el-button>
                </div>
            </el-dialog>
            <!-- 计算工资 -->
            <el-dialog :close-on-click-modal="false" width="380px" title="选择计算当月工资日期" :visible.sync="gridTableVisible">
                <el-form :model="gridData" ref="gridData" :rules="gridrules">
                    <el-form-item label="年月" prop="yearMonth" :label-width="formLabelWidth">
                        <el-date-picker v-model="gridData.yearMonth" size="medium" type="month" placeholder="选择月"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="工资日期起" prop="startDate" :label-width="formLabelWidth">
                        <el-date-picker v-model="gridData.startDate" size="medium" type="date" placeholder="选择日期"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="工资日期止" prop="endDate" :label-width="formLabelWidth">
                        <el-date-picker v-model="gridData.endDate" size="medium" type="date" placeholder="选择日期"></el-date-picker>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="SalaryCalculator('gridData')">计 算</el-button>
                    <el-button @click="gridTableVisible = false">取 消</el-button>
                </div>
            </el-dialog>
            <!-- 修改新增 -->
            <el-dialog :close-on-click-modal="false" width="960px" class="pan" top="2.5vh" title="薪资详细信息" :visible.sync="dialogFormVisible">
                <el-form :model="salaryinif" ref="salaryinif" :rules="rules">
                    <div class="payroll-inif">
                        <el-form-item label="员工" prop="userId" :label-width="formLabelWidth">
                            <el-select size="medium" style="height:36px" :disabled="disabled" v-model="salaryinif.userId" filterable placeholder="请选择">
                                <el-option
                                  v-for="item in userlist"
                                  :key="item.id"
                                  :label="item.cnName"
                                  :value="item.id">
                                </el-option>
                              </el-select>
                        </el-form-item>
                        <!-- <el-form-item label="是否转正" :label-width="formLabelWidth">
                            <el-switch v-model="salaryinif.regularization" active-color="" inactive-color="">
                            </el-switch>
                        </el-form-item> -->
                        <el-form-item label="年月" prop="yearMonth" :label-width="formLabelWidth">
                            <el-date-picker @change="Rangetime()" v-model="salaryinif.yearMonth" size="medium" type="month" placeholder="选择月"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="工资日期起" prop="startDate" :label-width="formLabelWidth">
                            <el-date-picker v-model="salaryinif.startDate" size="medium" type="date" placeholder="选择日期"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="工资日期止" prop="endDate" :label-width="formLabelWidth">
                            <el-date-picker v-model="salaryinif.endDate" size="medium" type="date" placeholder="选择日期"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="基本工资" prop="basic" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.basic"></el-input-number>
                        </el-form-item>
                        <el-form-item label="绩效工资" prop="floats" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.floats"></el-input-number>
                        </el-form-item>
                        <el-form-item label="岗位津贴" prop="postAllowance" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.postAllowance"></el-input-number>
                        </el-form-item>
                        <!-- <el-form-item label="服装洗理补贴" prop="garmentWashSubsidies" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.garmentWashSubsidies"></el-input-number>
                        </el-form-item> -->
                        <!-- <el-form-item label="通讯补贴" prop="communicationSubsidies" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.communicationSubsidies"></el-input-number>
                        </el-form-item> -->
                        <el-form-item label="月度补贴" prop="otherSubsidies" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.otherSubsidies"></el-input-number>
                        </el-form-item>
                        <el-form-item label="保密费" prop="informationSecurityFee" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.informationSecurityFee"></el-input-number>
                        </el-form-item>
                        <!-- <el-form-item label="操作奖金" prop="operationBonus" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.operationBonus"></el-input-number>
                        </el-form-item> -->
                        <!-- <el-form-item label="部门团建费" prop="groupCost" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.groupCost"></el-input-number>
                        </el-form-item> -->
                        <!-- <el-form-item label="过节费" prop="specialAllowance" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.specialAllowance"></el-input-number>
                        </el-form-item> -->
                        <!-- <el-form-item label="其他补贴" prop="otherSubsidies" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.otherSubsidies"></el-input-number>
                        </el-form-item> -->
                        <el-form-item label="餐补" prop="mealsupplement" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="412"
                            trigger="hover">
                                <el-table height="500px" :border="border" :data="transfer" :default-sort="{prop:'StartTimeDt',order:'ascending'}">
                                    <el-table-column width="80" property="SubType" label="请假类型"></el-table-column>
                                    <el-table-column :sortable="true" width="108" property="StartTimeDt" :formatter="rounddadykaishi" label="开始时间"></el-table-column>
                                    <el-table-column width="100" property="EndTimeDt" :formatter="rounddadyjieshu" label="结束时间"></el-table-column>
                                    <el-table-column width="50" property="Duration" label="时长"></el-table-column>
                                    <el-table-column width="80" property="Unit" label="时长单位"></el-table-column>
                                    <!-- <el-table-column width="80" property="Deduction" label="扣款金额" :formatter="rounding"></el-table-column> -->
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.mealsupplement">
                                    <span slot="reference"></span>
                                </el-input-number>
                            </el-popover>
                        </el-form-item>
                        <el-form-item label="其他应付" prop="otherHandle" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.otherHandle"></el-input-number>
                        </el-form-item>
                        
                    </div>
                    <div class="payroll-inif">
                        <el-form-item label="代扣保险" prop="withholdingInsurance" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.withholdingInsurance"></el-input-number>
                        </el-form-item>
                        <el-form-item label="代扣公积金" prop="reservedFunds" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.reservedFunds"></el-input-number>
                        </el-form-item>
                        <el-form-item label="代缴个税" prop="withholdingTax" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.withholdingTax"></el-input-number>
                        </el-form-item>
                    </div>
                    <div class="remark-box">
                        <el-form-item label="其他扣款" prop="otherDeductions" :label-width="formLabelWidth">
                            <el-input-number :precision="2" size="medium" :controls="false" v-model="salaryinif.otherDeductions"></el-input-number>
                            <span class="ps-box">* 其他扣款 = 罚款 + 其他扣款；具体各项金额请在备注里描述。</span>
                        </el-form-item>
                    </div>
                    <!-- <div style="margin: 0 80px;text-align: right;margin-bottom: 5px;">
                        <el-button type="primary">获取企微假勤</el-button>
                    </div> -->
                    <div class="leave-inif">
                        <el-form-item label="应出勤天数" :label-width="formLabelWidth">
                            <span>{{salaryinif.workDays}}</span>
                        </el-form-item>
                        <el-form-item label="正常出勤天数" :label-width="formLabelWidth">
                            <span>{{salaryinif.regularDays}}</span>
                        </el-form-item>
                    </div>
                    <div class="leave-inif">
                        <el-form-item class="biaoji" label="事假" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="412"
                            trigger="hover">
                                <el-table height="200px" :border="border" :data="leave">
                                    <el-table-column width="100" property="StartTimeDt" :formatter="rounddadykaishi" label="开始时间"></el-table-column>
                                    <el-table-column width="100" property="EndTimeDt" :formatter="rounddadyjieshu" label="结束时间"></el-table-column>
                                    <el-table-column width="50" property="Duration" label="时长"></el-table-column>
                                    <el-table-column width="80" property="Unit" label="时长单位"></el-table-column>
                                    <el-table-column width="80" property="Deduction" :formatter="rounding" label="扣款金额"></el-table-column>
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.somethingFalse">
                                    <span slot="reference"></span>
                                </el-input-number>
                                <!-- <span slot="reference">{{salaryinif.somethingFalse.toFixed(2)}}</span> -->
                            </el-popover>
                        </el-form-item>
                        <el-form-item class="biaoji" label="病假" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="412"
                            trigger="hover">
                                <div>
                                    <div>病假最低发放标准(月)：1680=2100*0.8</div>
                                    <div>病假最低发放标准(天)：1680/{{salaryinif.workDays}}(工作日)≈{{ (1680/salaryinif.workDays).toFixed(2) }}</div>
                                    <div>病假最低发放标准(小时)：1680/{{salaryinif.workDays}}(工作日)/7.5(小时)≈{{ (1680/salaryinif.workDays/7.5).toFixed(2) }}</div>
                                    <span style="color:red;">
                                        员工在病假医疗期限内的病假工资按照成都市最低工资标准的 80%发放
                                    </span>
                                </div>
                                <el-table height="200px" :border="border" :data="sickleave">
                                    <el-table-column width="100" property="StartTimeDt" :formatter="rounddadykaishi" label="开始时间"></el-table-column>
                                    <el-table-column width="100" property="EndTimeDt" :formatter="rounddadyjieshu" label="结束时间"></el-table-column>
                                    <el-table-column width="50" property="Duration" label="时长"></el-table-column>
                                    <el-table-column width="80" property="Unit" label="时长单位"></el-table-column>
                                    <el-table-column width="80" property="Deduction" :formatter="rounding" label="扣款金额"></el-table-column>
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.sickLeave">
                                    <span slot="reference"></span>
                                </el-input-number>
                                <!-- <span slot="reference">{{salaryinif.sickLeave.toFixed(2)}}</span> -->
                            </el-popover>
                        </el-form-item>
                        <el-form-item class="biaoji" label="迟到" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="382"
                            trigger="hover">
                                <el-table height="200px" :border="border" :data="late">
                                    <el-table-column width="170" property="StartTimeDt" :formatter="rounddadykaishi" label="迟到时间"></el-table-column>
                                    <!-- <el-table-column width="100" property="EndTimeDt" label="结束时间"></el-table-column> -->
                                    <el-table-column width="50" property="Duration" label="时长"></el-table-column>
                                    <el-table-column width="80" property="Unit" label="时长单位"></el-table-column>
                                    <el-table-column width="80" property="Deduction" :formatter="rounding" label="扣款金额"></el-table-column>
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.lateTo">
                                    <span slot="reference"></span>
                                </el-input-number>
                                <!-- <span slot="reference">{{salaryinif.lateTo.toFixed(2)}}</span> -->
                            </el-popover>
                        </el-form-item>
                        <el-form-item class="biaoji" label="早退" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="412"
                            trigger="hover">
                                <el-table height="200px" :border="border" :data="early">
                                    <el-table-column width="150" property="StartTimeDt" :formatter="rounddadykaishi" label="早退时间"></el-table-column>
                                    <!-- <el-table-column width="100" property="EndTimeDt" label="结束时间"></el-table-column> -->
                                    <el-table-column width="100" property="Duration" label="时长"></el-table-column>
                                    <el-table-column width="80" property="Unit" label="时长单位"></el-table-column>
                                    <el-table-column width="80" property="Deduction" :formatter="rounding" label="扣款金额"></el-table-column>
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.leaveEarly">
                                    <span slot="reference"></span>
                                </el-input-number>
                                <!-- <span slot="reference">{{salaryinif.leaveEarly.toFixed(2)}}</span> -->
                            </el-popover>
                        </el-form-item>
                        <el-form-item class="biaoji" label="旷工" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="512"
                            trigger="hover">
                                <el-table height="200px" :border="border" :data="absenteeism">
                                    <el-table-column width="100" property="StartTimeDt" :formatter="rounddadykaishi" label="旷工日期"></el-table-column>
                                    <!-- <el-table-column width="100" property="EndTimeDt" label="结束时间"></el-table-column> -->
                                    <el-table-column width="50" property="Duration" label="时长"></el-table-column>
                                    <el-table-column width="80" property="Unit" label="时长单位"></el-table-column>
                                    <el-table-column width="80" property="Deduction" :formatter="rounding" label="扣款金额"></el-table-column>
                                    <el-table-column width="200" property="Reason" label="原因"></el-table-column>
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.absenteeism">
                                    <span slot="reference"></span>
                                </el-input-number>
                                <!-- <span class="sx" slot="reference">{{salaryinif.absenteeism.toFixed(2)}}</span> -->
                            </el-popover>
                        </el-form-item>
                        <el-form-item class="biaoji" label="补卡" :label-width="formLabelWidth">
                            <el-popover
                            placement="top"
                            width="512"
                            trigger="hover">
                                <el-table height="200px" :border="border" :data="notout">
                                    <el-table-column width="200" property="StartTimeDt" :formatter="rounddadykaishi" label="补卡时间"></el-table-column>
                                    <!-- <el-table-column width="100" property="EndTimeDt" label="结束时间"></el-table-column> -->
                                    <!-- <el-table-column width="50" property="Duration" label="时长"></el-table-column> -->
                                    <!-- <el-table-column width="80" property="Unit" label="时长单位"></el-table-column> -->
                                    <el-table-column width="80" property="Deduction" :formatter="rounding" label="扣款金额"></el-table-column>
                                    <el-table-column width="230" property="Reason" label="原因"></el-table-column>
                                </el-table>
                                <el-input-number slot="reference" :precision="2" size="medium" :controls="false" v-model="salaryinif.notPunch">
                                    <span slot="reference"></span>
                                </el-input-number>
                                <!-- <span slot="reference">{{salaryinif.notPunch.toFixed(2)}}</span> -->
                            </el-popover>
                        </el-form-item>
                    </div>
                    <div class="salary-payments">
                        <el-form-item label="应发合计" :label-width="formLabelWidth">
                            <span>{{salaryinif.should.toFixed(2)}}</span>
                        </el-form-item>
                        <el-form-item label="扣款合计" :label-width="formLabelWidth">
                            <span>{{salaryinif.totalDeductions.toFixed(2)}}</span>
                        </el-form-item>
                        <el-form-item label="税前合计" :label-width="formLabelWidth">
                            <span>{{salaryinif.beforeTax.toFixed(2)}}</span>
                        </el-form-item>
                        <el-form-item label="税后合计" :label-width="formLabelWidth">
                            <span>{{salaryinif.totalRealHair.toFixed(2)}}</span>
                        </el-form-item>
                    </div>
                    <div class="remark-box">
                        <el-form-item label="备注" :label-width="formLabelWidth">
                            <el-input :rows="6" type="textarea" v-model="salaryinif.remark"></el-input>
                        </el-form-item>
                    </div>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <span class="ps-box">* 请先点击获取企微假勤，否则将无法保存或修改。</span>
                    <el-button type="primary" @click="submitForm('salaryinif')">获取当月企微假勤</el-button>
                    <el-button v-if="disabled" type="primary" @click="salaryAD('修改','salaryinif')">确认修改</el-button>
                    <el-button v-if="preserve" type="primary" @click="salaryAD('新增','salaryinif')">保 存</el-button>
                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>
<script>
import { co, el } from '@fullcalendar/core/internal-common';
export default {
    data() {
      return {
        limitNum: 1,  // 上传excell时，同时允许上传的最大数
        fileList: [],   // excel文件列表

        companyName:-1,//公司
        depName:'',//部门
        cnName:'',//员工

        gridTableVisible:false,
        fullscreenLoading:false,
        border:true,

        companylist:[],
        deplist:[],
        userlist:[],//全部员工
        comuserlist:[],//公司筛选员工

        loginuserid:'',
        value2:'',
        tableData: [],
        tableDatatwo: [],
        dialogTableVisible: false,
        dialogFormVisible: false,
        UploadTaxes:false,
        disabled:true,
        preserve:'',
        addaex_ItemsRemark:{},

        leave:[],//事假
        sickleave:[],//病假
        late:[],//迟到
        early:[],//早退
        transfer:[],//调休假
        absenteeism:[],//旷工
        notout:[],//补卡

        clicknot:false,//是否获取企业微信
        jsonstring:'',//企业微信json字符串
        //计算工资
        gridData:{
            yearMonth:"",//年月
            startDate:"",//工资日期 起
            endDate:"",//工资日期 止
        },
        gridrules:{
            yearMonth: [
                { type: 'date', required: true, trigger: 'blur',message:'选择年月' }
            ],
            startDate: [
                { type: 'date', required: true, trigger: 'blur',message:'选择工资日期起' }
            ],
            endDate: [
                { type: 'date', required: true, trigger: 'blur',message:'选择工资日期止' }
            ],
        },
        //上传个税
        TaxesData:{
            yearMonth:"",//年月
        },
        Taxesrules:{
            yearMonth: [
                { type: 'date', required: true, trigger: 'blur',message:'选择年月' }
            ],
        },
        //薪资详细
        salaryinif:{
            // regularization: true,//是否转正
            userId:"",//员工Id
            name:"",//姓名
            yearMonth:"",//年月
            startDate:"",//工资日期 起
            endDate:"",//工资日期 止
            basic:0,//基本工资
            floats:0,//绩效工资
            postAllowance:0,//岗位津贴
            //garmentWashSubsidies:0,//服装洗理补贴
            //communicationSubsidies:0,// 通讯补贴
            otherSubsidies:0,// 月度补贴
            informationSecurityFee:0,// 保密费
            //operationBonus:0,// 操作奖金
            //specialAllowance:0,// 特殊津贴
            //otherSubsidies:0,// 其他补贴
            withholdingInsurance:0,// 代扣保险
            mealsupplement:0,// 餐补
            reservedFunds:0,// 代扣公积金
            otherHandle:0,//其他应付
            //groupCost:0,// 部门集体团建费
            sickLeave:0,// 病假
            somethingFalse:0,//  事假
            lateTo:0,//  迟到 
            leaveEarly:0,//   早退  
            absenteeism:0,//旷工 
            notPunch:0,//补卡 
            otherDeductions:0,//其他扣款 
            should:0,//应发合计 
            workDays:0,//应出勤天数
            regularDays:0,//正常出勤天数
            totalDeductions:0,//扣款合计 
            totalRealHair:0,//实发合计 
            withholdingTax:0,//代扣个税 
            afterTax:0,//税后工资 
            isLock:0,//锁定标识 
            lastUpdateUserId:"",//最后操作人 
            lastUpdateUserName:"",//最后操作人Name 
            lastUpdateDt:"",//最后操作时间 
            remark:"",//备注 
            beforeTax:0//税前合计
        },
        rules: {
            userId: [
                { required: true,  trigger: 'blur' }
            ],
            yearMonth: [
                { type: 'date', required: true, trigger: 'blur' }
            ],
            startDate: [
                { type: 'date', required: true, trigger: 'blur' }
            ],
            endDate: [
                { type: 'date', required: true, trigger: 'blur' }
            ],
            basic: [
                { required: true, trigger: 'blur' },
            ],
            floats: [
                { required: true, trigger: 'blur' },
            ],
            postAllowance: [
                { required: true, trigger: 'blur' },
            ],
            // garmentWashSubsidies: [
            //     { required: true, trigger: 'blur' },
            // ],
            // communicationSubsidies: [
            //     { required: true, trigger: 'blur' },
            // ],
            otherSubsidies: [
                { required: true, trigger: 'blur' },
            ],
            otherHandle:[
                {required:true,trigger:'blur'}
            ],
            informationSecurityFee: [
                { required: true, trigger: 'blur' },
            ],
            // operationBonus: [
            //     { required: true, trigger: 'blur' },
            // ],
            // otherSubsidies: [
            //     { required: true, trigger: 'blur' },
            // ],
            // groupCost: [
            //     { required: true, trigger: 'blur' },
            // ],
            // specialAllowance: [
            //     { required: true, trigger: 'blur' },
            // ],
            mealsupplement: [
                { required: true, trigger: 'blur' },
            ],
            withholdingInsurance: [
                { required: true, trigger: 'blur' },
            ],
            reservedFunds: [
                { required: true, trigger: 'blur' },
            ],
            withholdingTax: [
                { required: true, trigger: 'blur' },
            ],
            otherDeductions: [
                { required: true, trigger: 'blur' },
            ],
        },
        form: {
          name: '',
          region: '',
        },
        formLabelWidth: '110px'
      }
    },
    methods:{
        submitForm(formName) {
            console.log(this.$refs[formName])
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    // alert('submit!');
                    // this.clicknot=true;
                    this.$confirm('是否获取企业微信假勤！', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.SalaryCalculatorSingle();
                    }).catch(()=>{})
                } else {
                    this.$message.error('请将红框内容补全！');
                    return false;
                }
            });
        },
        Rangetime(){
            console.log('2023-10' instanceof Date)
            console.log(this.salaryinif.startDate instanceof Date)
        },
        getnewDate(){
            let nowDate = new Date()
            let date = {
                year: nowDate.getFullYear(),
                month: nowDate.getMonth() + 1,
                date: nowDate.getDate()
            }
            console.log(date.year + '-' + date.month)
            this.value2=date.year + '-' + date.month;
            this.GetWageSheetList();
        },
        //获取员工
        GetWageSheetBasicsDataSource(){
            var url = "/api/PersonnelModule/GetWageSheetBasicsDataSource"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                }
            }).then(function (res) {
                if(res.data.code==200){
                    console.log(res)
                    console.log(res.data.data)
                    that.userlist=res.data.data.userNames;
                    that.companylist=res.data.data.compnayData;
                    that.companylist.push(
                        {companyName:'全部',id:-1}
                    )
                }else{
                    that.$message({
                        message: '加载失败！原因：'+res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //薪资列表
        GetWageSheetList(){
            this.fullscreenLoading = true;
            var url = "/api/PersonnelModule/GetWageSheetList"
            var that = this
            console.log(that.value2)
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    portType: 1,
                    yearMonth: that.value2,
                }
            }).then(function (res) {
                that.tableData=[];
                if(res.data.code==200){
                    console.log(res)
                    that.tableData=res.data.data;
                    that.tableDatatwo=that.tableData;
                    console.log(that.tableData)
                    that.fullscreenLoading = false;
                }else{
                    that.fullscreenLoading = false;
                    that.$message({
                        message: '加载失败！原因：'+res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //日期处理（日）
        TimeProcessingri(val){
            if(val instanceof Date){
                let newsyear=val.getFullYear();
                let newsMonth=val.getMonth() + 1;
                let newsday=val.getDate();
                if((val.getMonth() + 1)<10){
                    newsMonth='0'+newsMonth
                }else{
                    newsMonth=val.getMonth() + 1
                }
                if(val.getDate()<10){
                    newsday=newsday='0'+newsday
                }else{
                    newsday=val.getDate()
                }
                return newsyear+ '-' +newsMonth+ '-' + newsday;
            }else{
                return val
            }
        },
        //日期处理（月）
        TimeProcessingyue(val){
            if(val instanceof Date){
                let newsyear=val.getFullYear();
                let newsMonth=val.getMonth() + 1;
                if((val.getMonth() + 1)<10){
                    newsMonth='0'+newsMonth
                }else{
                    newsMonth=val.getMonth() + 1
                }
                return newsyear+ '-' +newsMonth;
            }else{
                return val
            }
            
        },
        //时间切换
        PickTime(){
            this.tableDatatwo=[];
            this.companyName=-1;
            this.cnName='';
            let newyear=this.value2.getFullYear();
            let newMonth=this.value2.getMonth() + 1;
            if((this.value2.getMonth() + 1)<10){
                newMonth='0'+newMonth
            }else{
                newMonth=this.value2.getMonth() + 1
            }
            this.value2=newyear+ '-' +newMonth;
            console.log(this.value2)
            this.GetWageSheetList();
        },
        //薪资详细
        SalaryDetails(index, row){
            if (this.$refs.salaryinif){
                this.$nextTick(() => {
                    this.$refs['salaryinif'].clearValidate();
                })
            }

            // this.clicknot=false;

            this.leave=[];//事假
            this.sickleave=[];//病假
            this.late=[];//迟到
            this.early=[];//早退
            this.transfer=[];//调休假
            this.absenteeism=[];//旷工
            this.notout=[];//补卡

            this.dialogFormVisible = true;
            this.disabled=true;
            this.preserve=false;
            console.log(row.id)
            var url = "/api/PersonnelModule/GetWageSheetById"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    portType: 1,
                    id: row.id,
                }
            }).then(function (res) {
                if(res.data.code==200){
                    console.log(res)
                    that.salaryinif=res.data.data;
                    that.salaryinif.yearMonth=new Date(res.data.data.yearMonth);
                    that.salaryinif.startDate=new Date(res.data.data.startDate);
                    that.salaryinif.endDate=new Date(res.data.data.endDate);
                    that.jsonstring=res.data.data.ex_ItemsRemark;
                    that.salaryinif.beforeTax=res.data.data.beforeTax;
                    if(res.data.data.ex_ItemsRemark!=''){
                        let ItemsRemark=JSON.parse(res.data.data.ex_ItemsRemark);
                        console.log(ItemsRemark)
                        let jiaqininif;
                        let dakainif;
                        for(let i=0;i<ItemsRemark.length;i++){
                            if(ItemsRemark[i].Type=='假勤'){
                                jiaqininif=ItemsRemark[i]
                            }
                            if(ItemsRemark[i].Type=='打卡'){
                                dakainif=ItemsRemark[i]
                            }
                        }
                        console.log(jiaqininif)
                        console.log(dakainif)
                        if(jiaqininif!=undefined){
                            that.transfer=jiaqininif.Ex_ItemInfo
                            for(let j=0;j<jiaqininif.Ex_ItemInfo.length;j++){
                                if(jiaqininif.Ex_ItemInfo[j].SubType=="事假"){
                                    that.leave.push(jiaqininif.Ex_ItemInfo[j])
                                }
                                if(jiaqininif.Ex_ItemInfo[j].SubType=="病假"){
                                    that.sickleave.push(jiaqininif.Ex_ItemInfo[j])
                                }
                                // if(jiaqininif.Ex_ItemInfo[j].SubType=="调休假"||jiaqininif.Ex_ItemInfo[j].SubType=="年假"||jiaqininif.Ex_ItemInfo[j].SubType=="婚假"||jiaqininif.Ex_ItemInfo[j].SubType=="产假"||jiaqininif.Ex_ItemInfo[j].SubType=="陪产假"||jiaqininif.Ex_ItemInfo[j].SubType=="丧假"||jiaqininif.Ex_ItemInfo[j].SubType=="出差"){
                                //     that.transfer.push(jiaqininif.Ex_ItemInfo[j])
                                // }
                            }
                        }
                        console.log(that.transfer)
                        if(dakainif!=undefined){
                            for(let x=0;x<dakainif.Ex_ItemInfo.length;x++){
                                if(dakainif.Ex_ItemInfo[x].SubType=="迟到"){
                                    that.late.push(dakainif.Ex_ItemInfo[x])
                                }
                                if(dakainif.Ex_ItemInfo[x].SubType=="早退"){
                                    that.early.push(dakainif.Ex_ItemInfo[x])
                                }
                                if(dakainif.Ex_ItemInfo[x].SubType=="旷工"){
                                    that.absenteeism.push(dakainif.Ex_ItemInfo[x])
                                    that.transfer.push(dakainif.Ex_ItemInfo[x])
                                }
                                if(dakainif.Ex_ItemInfo[x].SubType=="打卡补卡"){
                                    that.notout.push(dakainif.Ex_ItemInfo[x])
                                }
                            }
                        }
                        console.log(that.late)
                    }
                }else{
                    that.$message({
                        message: '加载失败！原因：'+res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //薪资(新增，修改)API
        PostWageSheetAddOrEdit(inif){
            console.log(inif)
            var url = "/api/PersonnelModule/PostWageSheetAddOrEdit"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    status:inif.statuss,
                    createUserId:that.loginuserid,
                    userId:that.salaryinif.userId,
                    id:inif.ids,
                    remark:that.salaryinif.remark,
                    yearMonth:that.TimeProcessingyue(that.salaryinif.yearMonth),
                    startDate:that.TimeProcessingri(that.salaryinif.startDate),
                    endDate:that.TimeProcessingri(that.salaryinif.endDate),
                    basic:that.salaryinif.basic,
                    floats:that.salaryinif.floats,
                    postAllowance:that.salaryinif.postAllowance,
                    // garmentWashSubsidies:that.salaryinif.garmentWashSubsidies,
                    // communicationSubsidies:that.salaryinif.communicationSubsidies,
                    otherSubsidies:that.salaryinif.otherSubsidies,
                    otherHandle:that.salaryinif.otherHandle,
                    informationSecurityFee:that.salaryinif.informationSecurityFee,
                    // operationBonus:that.salaryinif.operationBonus,
                    // specialAllowance:that.salaryinif.specialAllowance,
                    // otherSubsidies:that.salaryinif.otherSubsidies,
                    withholdingInsurance:that.salaryinif.withholdingInsurance,
                    mealsupplement:that.salaryinif.mealsupplement,
                    reservedFunds:that.salaryinif.reservedFunds,
                    // groupCost:that.salaryinif.groupCost,
                    sickLeave:that.salaryinif.sickLeave,
                    somethingFalse:that.salaryinif.somethingFalse,
                    lateTo:that.salaryinif.lateTo,
                    leaveEarly:that.salaryinif.leaveEarly,
                    absenteeism:that.salaryinif.absenteeism,
                    notPunch:that.salaryinif.notPunch,
                    otherDeductions:that.salaryinif.otherDeductions,
                    should:that.salaryinif.should,
                    totalDeductions:that.salaryinif.totalDeductions,
                    totalRealHair:that.salaryinif.totalRealHair,
                    withholdingTax:that.salaryinif.withholdingTax,
                    afterTax:that.salaryinif.afterTax,
                    workDays:that.salaryinif.workDays,
                    regularDays:that.salaryinif.regularDays,
                    ex_ItemsRemark:that.jsonstring
                }
            }).then(function (res) {
                if(res.data.code==200){
                    console.log(res)
                    that.GetWageSheetList();
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                }else{
                    that.$message({
                        message: '操作失败！原因：'+res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //薪资(新增，修改)
        salaryAD(text,formName){
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    // alert('submit!');
                    this.dialogFormVisible = false;
                    let inifadd={
                        statuss:'',
                        userIds:'',
                        ids:''
                    }
                    if(text=='新增'){
                        inifadd.statuss=1;
                        inifadd.userIds=0;
                        inifadd.ids=0;
                        this.PostWageSheetAddOrEdit(inifadd)
                    }else if(text=='修改'){
                        inifadd.statuss=2;
                        inifadd.userIds=this.salaryinif.userId;
                        inifadd.ids=this.salaryinif.id;
                        this.PostWageSheetAddOrEdit(inifadd)
                    }

                } else {
                    this.$message.error('请将红框内容补全！');
                    return false;
                }
            });
        },
        //新增薪资
        addsalary(){
            // console.log(this.$refs.salaryinif)
            if (this.$refs.salaryinif){
                this.$nextTick(() => {
                    this.$refs['salaryinif'].clearValidate();
                })
            }

            this.leave=[];//事假
            this.sickleave=[];//病假
            this.late=[];//迟到
            this.early=[];//早退
            this.transfer=[];//调休假
            this.absenteeism=[];//旷工
            this.notout=[];//补卡

            let myDate = new Date(this.value2);
            let month = myDate.getMonth() + 1;
            month = month < 10 ? "0" + month : month;   //格式化月份，补0
            let statDateStart = new Date(myDate.getFullYear().toString() +'-'+ month +'-'+ "01"); //月初
            let dayEnd = new Date(myDate.getFullYear(), month, 0).getDate(); //获取当月一共有多少天
            let statDateEnd = new Date(myDate.getFullYear().toString() +'-'+ month +'-'+ dayEnd); //月末
            // this.clicknot=false;

            this.dialogFormVisible = true;
            this.disabled=false;
            this.preserve=true;
            this.salaryinif={
                // regularization:true,
                userId:"",//员工Id
                name:"",//姓名
                yearMonth:new Date(this.value2),//年月
                startDate:statDateStart,//工资日期 起
                endDate:statDateEnd,//工资日期 止
                basic:0,//基本工资
                floats:0,//绩效工资
                postAllowance:0,//岗位津贴
                // garmentWashSubsidies:0,//服装洗理补贴
                // communicationSubsidies:0,// 通讯补贴
                otherSubsidies:0,// 月度补贴
                otherHandle:0,//其他应付
                informationSecurityFee:0,// 保密费
                // operationBonus:0,// 操作奖金
                // specialAllowance:0,// 特殊津贴
                // otherSubsidies:0,// 其他补贴
                withholdingInsurance:0,// 代扣保险
                mealsupplement:0,// 餐补
                reservedFunds:0,// 代扣公积金
                // groupCost:0,// 部门集体团建费
                sickLeave:0,// 病假
                somethingFalse:0,//  事假
                lateTo:0,//  迟到 
                leaveEarly:0,//   早退  
                absenteeism:0,//旷工 
                notPunch:0,//补卡 
                otherDeductions:0,//其他扣款 
                should:0,//应发合计 
                workDays:0,//应出勤天数
                regularDays:0,//正常出勤天数
                totalDeductions:0,//扣款合计 
                totalRealHair:0,//实发合计 
                withholdingTax:0,//代扣个税 
                afterTax:0,//税后工资 
                isLock:0,//锁定标识 
                lastUpdateUserId:"",//最后操作人 
                lastUpdateUserName:"",//最后操作人Name 
                lastUpdateDt:"",//最后操作时间 
                remark:"",//备注 
                beforeTax:0,//税前合计
            };
        },
        //删除薪资列表
        deleteaddsalary(index,row,rows){
            this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                var url = "/api/PersonnelModule/PostWageSheetDel"
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + this.token
                    },
                    data:{
                        userId:that.loginuserid,
                        id:row.id
                    }
                }).then(function (res) {
                    if(res.data.code==200){
                        console.log(res)
                        that.$message({
                            message: res.data.msg,
                            type: 'success'
                        });
                        rows.splice(index, 1);
                    }else{
                        that.$message({
                            message: res.data.msg,
                            type: 'warning'
                        });
                    }
                })
            })
            console.log(row)
            
        },
        //计算工资
        SalaryCalculator(formName){
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.fullscreenLoading=true;
                    var url = "/api/PersonnelModule/SalaryCalculator"
                    var that = this
                    this.$axios({
                        method: 'post',
                        url: url,
                        headers: {
                            Authorization: 'Bearer ' + this.token
                        },
                        data:{
                            userId:that.loginuserid,
                            yearMonth:that.TimeProcessingyue(that.gridData.yearMonth),
                            startDt:that.TimeProcessingri(that.gridData.startDate),
                            endDt:that.TimeProcessingri(that.gridData.endDate),
                        }
                    }).then(function (res) {
                        console.log(res)
                        if(res.data.code==200){
                            console.log(res)
                            that.value2=that.TimeProcessingyue(that.gridData.yearMonth);
                            that.gridTableVisible=false;
                            that.fullscreenLoading=false;
                            that.GetWageSheetList();
                            that.$message({
                                message: res.data.msg,
                                type: 'success'
                            });
                        }else{
                            that.value2=that.TimeProcessingyue(that.gridData.yearMonth);
                            that.gridTableVisible=false;
                            that.fullscreenLoading=false;
                            that.GetWageSheetList();
                            that.$message({
                                message: res.data.msg,
                                type: 'warning'
                            });
                        }
                    })
                } else {
                    this.$message.error('请将红框内容补全！');
                    return false;
                }
            });
        },
        //打开计算工资
        openSalaryCalculator(){
            this.gridTableVisible=true;
            this.gridData={
                yearMonth:"",//年月
                startDate:"",//工资日期 起
                endDate:"",//工资日期 止
            }
        },
        //获取企业微信假勤
        SalaryCalculatorSingle(){

            this.leave=[];//事假
            this.sickleave=[];//病假
            this.transfer=[];//调休假
            this.late=[];//迟到
            this.early=[];//早退
            this.absenteeism=[];//旷工
            this.notout=[];//补卡

            console.log('jin')

            var url = "/api/PersonnelModule/SalaryCalculatorSingle"
            var that = this
            this.fullscreenLoading = true;
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    userId:that.salaryinif.userId,
                    yearMonth:that.TimeProcessingyue(that.salaryinif.yearMonth),
                    startDate:that.TimeProcessingri(that.salaryinif.startDate),
                    endDate:that.TimeProcessingri(that.salaryinif.endDate),
                    basic:that.salaryinif.basic,
                    floats:that.salaryinif.floats,
                    postAllowance:that.salaryinif.postAllowance,
                    // garmentWashSubsidies:that.salaryinif.garmentWashSubsidies,
                    // communicationSubsidies:that.salaryinif.communicationSubsidies,
                    otherSubsidies:that.salaryinif.otherSubsidies,
                    informationSecurityFee:that.salaryinif.informationSecurityFee,
                    // operationBonus:that.salaryinif.operationBonus,
                    // specialAllowance:that.salaryinif.specialAllowance,
                    // otherSubsidies:that.salaryinif.otherSubsidies,
                    otherHandle:that.salaryinif.otherHandle,
                    withholdingInsurance:that.salaryinif.withholdingInsurance,
                    mealsupplement:that.salaryinif.mealsupplement,
                    withholdingTax:that.salaryinif.withholdingTax,
                    // groupCost:that.salaryinif.groupCost,
                    reservedFunds:that.salaryinif.reservedFunds,
                    withholdingInsurance:that.salaryinif.withholdingInsurance,
                    otherDeductions:that.salaryinif.otherDeductions,
                }

            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.fullscreenLoading = false;
                    console.log(res);
                    that.jsonstring=res.data.data.ex_ItemsRemark;
                    console.log(that.addaex_ItemsRemark)
                    that.salaryinif.somethingFalse=res.data.data.somethingFalse;
                    that.salaryinif.sickLeave=res.data.data.sickLeave;
                    that.salaryinif.lateTo=res.data.data.lateTo;
                    that.salaryinif.leaveEarly=res.data.data.leaveEarly;
                    that.salaryinif.absenteeism=res.data.data.absenteeism;
                    that.salaryinif.notPunch=res.data.data.notPunch;
                    that.salaryinif.should=res.data.data.should;
                    that.salaryinif.workDays=res.data.data.workDays;
                    that.salaryinif.regularDays=res.data.data.regularDays;
                    that.salaryinif.totalDeductions=res.data.data.totalDeductions;
                    that.salaryinif.afterTax=res.data.data.afterTax;
                    that.salaryinif.mealsupplement=res.data.data.mealsupplement;
                    that.salaryinif.beforeTax=res.data.data.beforeTax;
                    that.salaryinif.totalRealHair=res.data.data.totalRealHair;
                    if(res.data.data.ex_ItemsRemark!=''){
                        that.addaex_ItemsRemark=JSON.parse(res.data.data.ex_ItemsRemark);
                        let jiaqin;
                        let daka;
                        for(let i=0;i<that.addaex_ItemsRemark.length;i++){
                            if(that.addaex_ItemsRemark[i].Type=='假勤'){
                                jiaqin=that.addaex_ItemsRemark[i]
                            }
                            if(that.addaex_ItemsRemark[i].Type=='打卡'){
                                daka=that.addaex_ItemsRemark[i]
                            }
                        }
                        console.log(jiaqin)
                        console.log(daka)
                        if(jiaqin!=undefined){
                            that.transfer=jiaqin.Ex_ItemInfo;
                            for(let j=0;j<jiaqin.Ex_ItemInfo.length;j++){
                                if(jiaqin.Ex_ItemInfo[j].SubType=="事假"){
                                    that.leave.push(jiaqin.Ex_ItemInfo[j])
                                }
                                if(jiaqin.Ex_ItemInfo[j].SubType=="病假"){
                                    that.sickleave.push(jiaqin.Ex_ItemInfo[j])
                                }
                                // if(jiaqin.Ex_ItemInfo[j].SubType=="调休假"||jiaqin.Ex_ItemInfo[j].SubType=="年假"||jiaqin.Ex_ItemInfo[j].SubType=="婚假"||jiaqin.Ex_ItemInfo[j].SubType=="产假"||jiaqin.Ex_ItemInfo[j].SubType=="陪产假"||jiaqin.Ex_ItemInfo[j].SubType=="丧假"||jiaqin.Ex_ItemInfo[j].SubType=="出差"){
                                //     that.transfer.push(jiaqin.Ex_ItemInfo[j])
                                // }
                            }
                        }
                        console.log(that.transfer)
                        if(daka!=undefined){
                            for(let x=0;x<daka.Ex_ItemInfo.length;x++){
                                if(daka.Ex_ItemInfo[x].SubType=="迟到"){
                                    that.late.push(daka.Ex_ItemInfo[x])
                                }
                                if(daka.Ex_ItemInfo[x].SubType=="早退"){
                                    that.early.push(daka.Ex_ItemInfo[x])
                                }
                                if(daka.Ex_ItemInfo[x].SubType=="旷工"){
                                    that.absenteeism.push(daka.Ex_ItemInfo[x])
                                    that.transfer.push(daka.Ex_ItemInfo[x])
                                }
                                if(daka.Ex_ItemInfo[x].SubType=="打卡补卡"){
                                    that.notout.push(daka.Ex_ItemInfo[x])
                                }
                            }
                        }
                        that.GetWageSheetList();
                        that.$message({
                            message: res.data.msg,
                            type: 'success'
                        });
                    }
                }else{
                    that.fullscreenLoading = false;
                    that.$message({
                        message: res.data.msg,
                        type: 'warning'
                    });
                }
            })
        },
        //保留两位小数
        rounding(row,column) {
            return parseFloat(row[column.property]).toFixed(2)
        },
        //处理时间
        rounddadykaishi(val){
            if(val.StartTimeDt.indexOf('T')!=-1){
                return val.StartTimeDt.replace('T',' ')
            } 
            
        },
        rounddadyjieshu(val){
            if(val.EndTimeDt.indexOf('T')!=-1){
                return val.EndTimeDt.replace('T',' ')
            }
        },
        //选择公司
        companychange(){
            this.cnName='';
            this.tableDatatwo=[];
            let tableDataone=[];
            if(this.companyName!=-1){
                for(let i=0;i<this.tableData.length;i++){
                    if(this.tableData[i].companyId==this.companyName){
                        tableDataone.push(this.tableData[i]);
                    }
                }
                this.tableDatatwo=tableDataone;
            }else{
                this.tableDatatwo=this.tableData;
            }
        },
        //选择员工
        cnNamechange(){
            let tableDatatheer=[];
            let tableDatafour=this.tableDatatwo;
            if(this.cnName!=''){
                for(let j=0;j<this.tableDatatwo.length;j++){
                    if(this.tableDatatwo[j].name.indexOf(this.cnName)!=-1){
                        tableDatatheer.push(this.tableDatatwo[j])
                    }
                }
                this.tableDatatwo=tableDatatheer;
            }else{
                this.companychange()
                // this.tableDatatwo=this.tableDatatwo
            }
            
        },
        //下载
        Download(){
            this.$confirm('请确认左上角的日期，是否要导出'+this.value2+'的工资单！', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                console.log(this.value2)
                var url = "/api/PersonnelModule/ExportWageCard?yearMonth="+this.value2
                var that = this
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + this.token
                    }
                }).then(function (res) {
                    if(res.data.code==200){
                        console.log(res)
                        window.open(res.data.data.fileUrl);
                        that.$message({
                            message:res.data.msg,
                            type: 'success'
                        });
                    }else{
                        that.$message({
                            message: '导出失败！原因：'+res.data.msg,
                            type: 'warning'
                        });
                    }
                }).catch(()=>{})
            })
        },
        // 文件超出个数限制时的钩子
        exceedFile(files, fileList) {
            this.$message.warning(`只能选择 ${this.limitNum} 个文件，当前共选择了 ${files.length + fileList.length} 个`);
        },
        // 文件状态改变时的钩子
        fileChange(file, fileList) {
            console.log(file.raw);
            this.fileList.push(file.raw) ;
            console.log(this.fileList);
        },
        // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
        beforeUploadFile(file) {
            console.log('before upload');
            console.log(file);
            let extension = file.name.substring(file.name.lastIndexOf('.')+1);
            let size = file.size / 1024 / 1024;
            if(extension !== 'xlsx') {
            this.$message.warning('只能上传后缀是.xlsx的文件');
            }
            if(size > 10) {
            this.$message.warning('文件大小不得超过10M');
            }
        },
        // 文件上传成功时的钩子
        handleSuccess(res, file, fileList) {
            this.$message.success('文件上传成功');
        },
        // 文件上传失败时的钩子
        handleError(err, file, fileList) {
            this.$message.error('文件上传失败');
        },
        UploadUrl:function(){
        // 因为action参数是必填项，我们使用二次确认进行文件上传时，直接填上传文件的url会因为没有参数导致api报404，所以这里将action设置为一个返回为空的方法就行，避免抛错
            return ""
        },
        uploadFile(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    if (this.fileList.length === 0){
                    this.$message.warning('请上传文件');
                    } else {
                    var form = new FormData();
                    form.append('file', this.fileList[0]);
                    // form.append('yearMonth', this.TaxesData.yearMonth);
                    console.log("wenjian"+this.fileList)
                    console.log(form)
                    var that = this
                    this.$axios({
                        method:"post",
                        url: "/api/PersonnelModule/UploadTax",
                        headers: {
                            'Content-type': 'multipart/form-data',
                            Authorization: 'Bearer ' + this.token,
                            YearMonth: that.TimeProcessingyue(that.TaxesData.yearMonth)
                        },
                        data:form
                    }).then(function (res) {
                        console.log(res)
                        if(res.data.code==200){
                            console.log(res)
                            that.UploadTaxes=false;
                            that.value2=that.TimeProcessingyue(that.TaxesData.yearMonth)
                            that.GetWageSheetList();
                            that.$message({
                                message:res.data.msg,
                                type: 'success'
                            });
                        }else{
                            that.$message({
                                message: '上传失败！原因：'+res.data.msg,
                                type: 'warning'
                            });
                        }
                    }).catch(()=>{})
                    }
                } else {
                    this.$message.error('请将红框内容补全！');
                    return false;
                }
            });
            
        },
        removelist(file, fileList){
            console.log(file)
            console.log(fileList)
            console.log(this.fileList)
            this.fileList=[]
        },
        //下载模板
        DownloadTaxes(){
            var url = "/api/PersonnelModule/WageSheetTaxTemplate"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                }
            }).then(function (res) {
                if(res.data.code==200){
                    console.log(res)
                    window.open(res.data.data.fileUrl);
                    that.$message({
                        message:res.data.msg,
                        type: 'success'
                    });
                }else{
                    that.$message({
                        message: '下载失败！原因：'+res.data.msg,
                        type: 'warning'
                    });
                }
            }).catch(()=>{})
        }
    },
    mounted(){
        this.GetWageSheetBasicsDataSource()
        this.loginuserid=JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
        this.getnewDate();
    }
}
</script>
<style>
.payroll-all{
    background-color: #fff;
    padding: 10px;
    box-shadow: 0 0 5px #0005;
    border-radius: 10px;
    height: 100%;
    min-height: 830px;
}
.payroll-head-li label{
    color: #606266;
    font-size: 15px;
    font-weight: 600;
}
.payroll-head-li{
    margin-top: 5px;
}
.payroll-head{
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.payroll-inif{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: 0 80px;
}
.payroll-inif .el-form-item{
    width: 350px;
}
.payroll-inif .el-input-number--medium{
    width: 218px;
}
.payroll-inif .el-form-item{
    margin-bottom: 2px;
}
.payroll-inif .el-input--medium .el-input__inner{
    text-align: left;
}
.leave-inif{
    margin: 0 80px;
    display: flex;
    flex-wrap: wrap;
}
.leave-inif .el-form-item{
    margin-bottom: 0px;
    width: 24%;
}
.salary-payments{
    display: flex;
    flex-wrap: wrap;
    margin: 0 80px;
}
.salary-payments .el-form-item{
    margin-bottom: 0px;
    font-size: 17px;
    font-weight: 600;
    width: 24%;
}
.payroll-all .el-dialog__body{
    padding: 16px 20px;
}
.remark-box{
    margin: 0 80px;
}
.payroll-inif .el-input--medium {
    width: 218px;
}
.remark-box.el-form-item{
    margin-bottom: 0px;
}
.remark-box .el-input--medium .el-input__inner{
    text-align: left;
}
.remark-box .el-input-number--medium{
    width: 218px;
    text-align:left;
}
.ps-box{
    font-size:12px ;
    color: red;
}
.pan .el-form-item__error{
    display: none;
}
.remark-box .el-textarea__inner{
    width: 96.5%;
}
.payroll-all::-webkit-scrollbar-track-piece {
    background-color: #f1f1f1;
}
.payroll-all::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.payroll-all::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    background-clip: padding-box;
    min-height: 28px;
    border-radius: 8px;
}
.payroll-all::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}
.biaoji .el-input-number--medium{
    width: 90px;
}
.biaoji .el-input--medium .el-input__inner{
    text-align: left;
}
.payroll-all .el-dialog{
    margin: 0 auto 23px;
}
</style>