<template>
    <basic-container>
        <!-- 绩效填报 -->
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
            @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad">
            <template #status="scope">
                <el-tag v-if="scope.row.status == 1">进行中</el-tag>
                <el-tag v-if="scope.row.status == 2" type="warning">待汇总</el-tag>
                <el-tag v-if="scope.row.status == 3" type="warning">待审批</el-tag>
                <el-tag v-if="scope.row.status == 4" type="success">审批通过</el-tag>
                <el-tag v-if="scope.row.status == 5" type="danger">审批不通过</el-tag>
                <el-tag v-if="scope.row.status == 6" type="success">已完成</el-tag>
            </template>
            <template #menu="scope">
                <el-button type="text" v-if="scope.row.parentId && scope.row.status == 1" @click="fillRow(scope.row)">填报</el-button>
                <el-button type="text" v-if="scope.row.parentId && scope.row.status == 6" >下载</el-button>
                <el-button type="text" v-if="scope.row.status == 2" @click="collectRow(scope.row)">汇总</el-button>
                <el-button type="text" v-if="scope.row.status == 3" @click="examineRow(scope.row)">审批</el-button>
            </template>
        </avue-crud>
        <el-dialog append-to-body title="填报" v-model="showDialog">
            <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"></avue-form>
            <template #footer>
                <span class="dialog-footer">
                <el-button @click="showDialog = false">取 消</el-button>
                <el-button type="primary" @click="showDialog = false">确 定</el-button>
                </span>
            </template>
        </el-dialog>
        <el-dialog append-to-body title="审批" v-model="showExamine" width="85%">
            <!-- <div style="display: flex;align-items: center;">
                类别：
                <el-select v-model="typeValue" style="width: 200px;margin-right: 10px;" @change="changeType">
                    <el-option label="质量" value="1"></el-option>
                    <el-option label="工艺" value="2"></el-option>
                    <el-option label="辅助人员" value="3"></el-option>
                    <el-option label="生产线" value="4"></el-option>
                </el-select>
                
            </div> -->
            <el-table :data="tableData" style="margin-top: 10px;" height="400">
                <el-table-column  align="center" label="工号" prop="userCode"></el-table-column>
                <el-table-column  align="center" label="姓名" prop="userName"></el-table-column>
                <!-- <el-table-column v-if="typeValue == 1 || typeValue == 2" align="center" label="KPI得分" prop="KPI"></el-table-column>
                <el-table-column v-if="typeValue == 1 || typeValue == 2" align="center" label="量化得分" prop="lh"></el-table-column>
                <el-table-column v-if="typeValue == 4" align="center" label="订单准时完成率" prop="orderTime" width="130"></el-table-column>
                <el-table-column v-if="typeValue == 4" align="center" label="重点零件完成率" prop="keyPoint" width="130"></el-table-column>
                <el-table-column v-if="typeValue == 4" align="center" label="后工序审理单分数" prop="after" width="140"></el-table-column>
                <el-table-column v-if="typeValue == 4" align="center" label="出厂不合格率DPP" prop="unqualified" width="140"></el-table-column>
                <el-table-column v-if="typeValue == 4" align="center" label="成本费用率" prop="costMoney" width="100"></el-table-column>
                <el-table-column v-if="typeValue == 3" align="center" label="关键指标" prop="fz1" width="100"></el-table-column>
                <el-table-column v-if="typeValue == 3" align="center" label="发展类" prop="fz2" width="100"></el-table-column>
                <el-table-column v-if="typeValue == 3" align="center" label="基础工作" prop="fz3" width="100"></el-table-column>
                <el-table-column v-if="typeValue == 3" align="center" label="监控类" prop="fz4" width="100"></el-table-column> -->
                <el-table-column align="center" label="质量 关键KPI绩效模板" prop="KPI" width="180"></el-table-column>
                <el-table-column align="center" label="质量 量化绩效模板" prop="lh" width="180"></el-table-column>
                <el-table-column align="center" label="一线员工 绩效模板" prop="user" width="180"></el-table-column>
                <el-table-column align="center" label="通报" prop="notice"></el-table-column>
                <el-table-column align="center" label="请假扣分" prop="leave"></el-table-column>
                <el-table-column align="center" label="考勤扣分" prop="check"></el-table-column>
                <el-table-column align="center" label="投稿加分项" prop="add" width="100"></el-table-column>
                <el-table-column align="center" label="群策群力" prop="all"></el-table-column>
                <el-table-column align="center" label="优秀员工加分" prop="excellence" width="130"></el-table-column>
                <el-table-column align="center" label="成本" prop="cost"></el-table-column>
                <el-table-column align="center" label="总分" prop="total"></el-table-column>
            </el-table>
            <div style="margin-top: 20px;">
                <div style="display: flex;align-items: center;margin-bottom: 10px;">
                    <div style="width: 100px;">审批结果：</div>
                    <el-select v-model="resultValue" style="margin-right: 10px;">
                        <el-option label="通过" value="1"></el-option>
                        <el-option label="不通过" value="2"></el-option>
                    </el-select>
                </div>
                <div style="display: flex;align-items: center;">
                    <div style="width: 100px;">审批意见：</div>
                    <el-input v-model="opinion" type="textarea" ></el-input>
                </div>
            </div>
            <template #footer>
                <span class="dialog-footer">
                <el-button @click="showExamine = false">取 消</el-button>
                <el-button type="primary" @click="showExamine = false">确 定</el-button>
                </span>
            </template>
        </el-dialog>
    </basic-container>
</template>

<script>
import {excelOption} from './js/dataReportOption'
export default {
    data() {
        return {
            showDialog:false,
            excelForm:{},
            excelOption: excelOption,
            typeValue:'1',
            resultValue:'',
            tableData:[
                {id:1,userCode:'001',userName:'张三',KPI:70,lh:26,notice:0,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:98},
                {id:1,userCode:'002',userName:'李四',KPI:68,lh:26,notice:0,all:0,leave:2,check:0,add:0,excellence:0,cost:0,total:92},
                {id:1,userCode:'003',userName:'王五',KPI:70,user:96,lh:26,notice:5,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:93},
                {id:1,userCode:'004',userName:'刘明',KPI:70,user:98,lh:26,notice:2,all:2,leave:0,check:0,add:0,excellence:0,cost:0,total:94},
            ],
            showExamine:false,
            loading: false,
            data: [],
            form: {},
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            option: {
                height: 'auto',
                align: 'center',
                calcHeight: 32,
                rowKey: 'id',
                rowParentKey: 'parentId',
                tip: false,
                size: 'medium',
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: false,
                selection: false,
                viewBtn: false,
                delBtn: false,
                addBtn: false,
                editBtn: false,
                editBtnText: '修改',
                addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
                viewBtnText: '详情',
                labelWidth: 120,
                searchLabelWidth: 120,
                menu: true,
                menuWidth: 220,
                dialogWidth: 1200,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                excelBtn: true,
                columnSort: true,
                showOverflowTooltip: true,
                searchLabelPosition:'left',
searchLabelPosition:'left',
 searchGutter:24,
  searchSpan:6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
                column: [
                    {
                        label: '任务名称',
                        prop: 'taskName',
                        search: true,
                        sortable: true,
                        overHidden: true,
                        align:'left',
                        headerAlign:'center',
                    },
                    {
                        label: '下发时间',
                        prop: 'createName',
                        search: false,
                        sortable: true,
                        overHidden: true,
                    },
                    {
                        label: '任务人员',
                        prop: 'taskUserName',
                        search: true,
                        sortable: true,
                        overHidden: true,
                    },
                    {
                        label: '状态',
                        prop: 'status',
                        type:'select',
                        search: true,
                        sortable: true,
                        overHidden: true,
                        dicData:[
                            {label:'进行中',value:1},
                            {label:'待汇总',value:2},
                            {label:'待审批',value:3},
                            {label:'审批通过',value:4},
                            {label:'审批不通过',value:5},
                            {label:'已完成',value:6},
                        ]
                    },
                ]
            }
        }
    },
    mounted(){

    },
    methods:{
        // 填报
        fillRow(){
            this.showDialog = true
        },
        // 汇总
        collectRow(row){
            this.$confirm('确定汇总当前绩效?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(res =>{

            })
        },
        changeType(val){
            if(val == 1){
                this.tableData = [
                    {id:1,userCode:'0001',userName:'张三',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:0,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:98},
                    {id:1,userCode:'0002',userName:'李四',KPI:68,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:0,all:0,leave:2,check:0,add:0,excellence:0,cost:0,total:92},
                    {id:1,userCode:'0003',userName:'王五',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:5,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:93},
                    {id:1,userCode:'0004',userName:'刘明',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:2,all:2,leave:0,check:0,add:0,excellence:0,cost:0,total:94},
                ]
            }else if(val == 2){
                this.tableData = [
                    {id:1,userCode:'0005',userName:'王红',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:0,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:98},
                    {id:1,userCode:'0006',userName:'王明',KPI:68,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:0,all:0,leave:2,check:0,add:0,excellence:0,cost:0,total:92},
                    {id:1,userCode:'0007',userName:'刘丽',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:5,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:93},
                    {id:1,userCode:'0008',userName:'张磊',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:25,fz3:25,fz4:25, notice:2,all:2,leave:0,check:0,add:0,excellence:0,cost:0,total:94},
                ]
            }else if(val == 3){
                this.tableData = [
                    {id:1,userCode:'0010',userName:'张三',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:25,fz2:22,fz3:24,fz4:25, notice:0,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:98},
                    {id:1,userCode:'0011',userName:'李四',KPI:68,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:22,fz2:24,fz3:23,fz4:21,notice:0,all:0,leave:2,check:0,add:0,excellence:0,cost:0,total:92},
                    {id:1,userCode:'0012',userName:'王五',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:22,fz2:23,fz3:24,fz4:22, notice:5,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:93},
                    {id:1,userCode:'0013',userName:'刘明',KPI:70,lh:26,orderTime:10,keyPoint:10,after:10,
                    unqualified:10,costMoney:10,fz1:22,fz2:24,fz3:23,fz4:25, notice:2,all:2,leave:0,check:0,add:0,excellence:0,cost:0,total:94},
                ]
            }else{
                this.tableData = [
                    {id:1,userCode:'0014',userName:'纪明',KPI:70,lh:26,orderTime:20,keyPoint:18,after:19,
                    unqualified:20,costMoney:18,fz1:25,fz2:22,fz3:24,fz4:25, notice:0,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:97},
                    {id:1,userCode:'0015',userName:'齐磊',KPI:68,lh:26,orderTime:18,keyPoint:17,after:19,
                    unqualified:20,costMoney:19,fz1:22,fz2:24,fz3:23,fz4:21, notice:0,all:0,leave:2,check:0,add:0,excellence:0,cost:0,total:91},
                    {id:1,userCode:'0016',userName:'刘丽丽',KPI:70,lh:26,orderTime:19,keyPoint:17,after:18,
                    unqualified:16,costMoney:18,fz1:22,fz2:23,fz3:24,fz4:22, notice:5,all:0,leave:0,check:0,add:0,excellence:2,cost:0,total:85},
                    {id:1,userCode:'0017',userName:'王凯',KPI:70,lh:26,orderTime:16,keyPoint:19,after:20,
                    unqualified:18,costMoney:20,fz1:22,fz2:24,fz3:23,fz4:25, notice:2,all:2,leave:0,check:0,add:0,excellence:0,cost:0,total:91},
                ]
            }
        },
        // 审批
        examineRow(row){
            this.showExamine = true
        },
        onLoad(){
            this.data = [
                {id:1,taskName:'2025年09月绩效',createName:'2025-10-01',taskUserName:'张三',status:1,
                    children: [
                        {
                            parentId: 1,id:5,taskName:'2025年09月绩效-质量 绩效模板',createName:'2025-10-01',taskUserName:'李四',status:1
                        },
                        {
                            parentId: 1,id:6,taskName:'2025年09月绩效-一线员工 绩效模板',createName:'2025-10-01',taskUserName:'王五',status:1
                        },
                    ]
                },
                {id:2,taskName:'2025年08月绩效',createName:'2025-09-01',taskUserName:'张三',status:2,
                    children: [
                        {
                            parentId: 2,id:7,taskName:'2025年08月绩效-质量 绩效模板',createName:'2025-09-01',taskUserName:'李四',status:6
                        },
                        {
                            parentId: 2,id:8,taskName:'2025年08月绩效-一线员工 绩效模板',createName:'2025-09-01',taskUserName:'王五',status:6
                        },
                    ]
                },
                {id:3,taskName:'2025年07月绩效',createName:'2025-08-01',taskUserName:'张三',status:3,
                    children: [
                        {
                            parentId: 3,id:9,taskName:'2025年07月绩效-质量 绩效模板',createName:'2025-08-01',taskUserName:'李四',status:6
                        },
                        {
                            parentId: 3,id:10,taskName:'2025年07月绩效-一线员工 绩效模板',createName:'2025-08-01',taskUserName:'王五',status:6
                        },
                    ]
                },
                {id:4,taskName:'2025年06月绩效',createName:'2025-07-01',taskUserName:'张三',status:4,
                    children: [
                        {
                            parentId: 3,id:9,taskName:'2025年06月绩效-质量 绩效模板',createName:'2025-07-01',taskUserName:'李四',status:6
                        },
                        {
                            parentId: 3,id:10,taskName:'2025年06月绩效-一线员工 绩效模板',createName:'2025-07-01',taskUserName:'王五',status:6
                        },
                    ]
                },
            ]
            this.page.total = this.data.length
        }
    }
}
</script>

<style></style>