<template>
    <div class="full_page">
        <div class="top">
            <img src="@/assets/images/agent/arrow_left.png">
            <div class="spans">
                <span>项目管理</span>
                <span class="last">&nbsp;/&nbsp;添加团队</span>
            </div>
        </div>
        <div class="content">
            <div class="form">
                <el-form :model="teamDto" :rules="rules" ref="teamDtoRef" label-width="130px">
                    <div class="f_title">添加团队</div>
                    <el-row style="width: 100%;">
                        <el-col :span="8">
                            <el-form-item label="所属项目" prop="aaa">
                                <el-select v-model="teamDto.aaa" placeholder="请选择所属项目" style="width: 100%;"></el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="团队名称" prop="bbb">
                                <el-input v-model="teamDto.bbb" clearable placeholder="请输入团队名称"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="工作任务" prop="ccc">
                                <el-input v-model="teamDto.ccc" clearable placeholder="请输入工作任务"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row style="width: 100%;">
                        <el-col :span="24">
                            <el-form-item label="团队介绍" prop="ddd">
                                <el-input type="textarea" v-model="teamDto.ddd" clearable placeholder="请输入团队介绍"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row style="width: 100%;">
                        <el-col :span="24">
                            <el-form-item label="团队项目情况" prop="eee">
                                <el-input type="textarea" v-model="teamDto.eee" clearable placeholder="请输入团队项目情况"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <div class="f_title" style="margin-top: 31px;">添加成员</div>
                    <el-row style="width: 100%;">
                        <el-col :span="24">
                            <el-form-item label="团队成员" prop="">
                                <div class="f_type">
                                    <el-radio-group v-model="addType">
                                        <el-radio :label="1">批量导入</el-radio>
                                        <el-radio :label="2">手动录入</el-radio>
                                    </el-radio-group>
                                </div>
                                <template v-if="addType===1">
                                    <div class="f_pldr">
                                        <div class="fp_box">
                                            <div class="fpb_pre">
                                                <div class="fpbp_btn">下载Excel示例文件</div>
                                            </div>
                                            <img src="@/assets/images/agent/arrow_right_two.png">
                                            <div class="fpb_pre sc">
                                                <div class="fpbp_btn">上传Excel文件</div>
                                            </div>
                                        </div>
                                        <p>
                                            1、Excel文件后缀名为xls或者xlsx，文件中所含烈数请勿超过20列<br>
                                            2、模版中用户姓名为必填，其他为选填，且不能对已有字段进行删除、修改<br>
                                            3、部门：上下级部门间用“/”符号隔开，且从最上级部门开始，例如“产品部门/设计”。若存在属于多个部门的情况，不同部门之间用 ; 隔开。
                                        </p>
                                    </div>
                                </template>
                                <template v-else-if="addType===2">
                                    <div class="f_sdlr">
                                        <div class="fs_item" v-for="(item,index) in teamDto.userList" :key="index">
                                            <el-form :model="teamDto.userList[index]" label-width="100px">
                                                <el-row style="width: 100%;">
                                                    <el-col :span="8">
                                                        <el-form-item label="姓名" prop="aa">
                                                            <el-input v-model="teamDto.userList[index].aa" clearable placeholder="请输入"></el-input>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="性别" prop="bb">
                                                            <el-select v-model="teamDto.userList[index].bb" placeholder="请选择" style="width: 100%;"></el-select>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="出生日期" prop="cc">
                                                            <el-select v-model="teamDto.userList[index].cc" placeholder="请选择" style="width: 100%;"></el-select>
                                                        </el-form-item>
                                                    </el-col>
                                                </el-row>
                                                <el-row style="width: 100%;">
                                                    <el-col :span="8">
                                                        <el-form-item label="手机号码" prop="dd">
                                                            <el-input v-model="teamDto.userList[index].dd" clearable placeholder="请输入"></el-input>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="所属部门" prop="ee">
                                                            <el-input v-model="teamDto.userList[index].ee" clearable placeholder="请输入"></el-input>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="职位" prop="ff">
                                                            <el-select v-model="teamDto.userList[index].ff" placeholder="请选择" style="width: 100%;"></el-select>
                                                        </el-form-item>
                                                    </el-col>
                                                </el-row>
                                                <el-row style="width: 100%;">
                                                    <el-col :span="8">
                                                        <el-form-item label="分工" prop="gg">
                                                            <el-input v-model="teamDto.userList[index].gg" clearable placeholder="请输入"></el-input>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="上级" prop="hh">
                                                            <el-input v-model="teamDto.userList[index].hh" clearable placeholder="请输入"></el-input>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="教育程度" prop="ii">
                                                            <el-select v-model="teamDto.userList[index].ii" placeholder="请选择" style="width: 100%;"></el-select>
                                                        </el-form-item>
                                                    </el-col>
                                                </el-row>
                                                <el-row style="width: 100%;">
                                                    <el-col :span="8">
                                                        <el-form-item label="级别" prop="jj">
                                                            <el-select v-model="teamDto.userList[index].jj" placeholder="请选择" style="width: 100%;"></el-select>
                                                        </el-form-item>
                                                    </el-col>
                                                    <el-col :span="8">
                                                        <el-form-item label="" prop="">
                                                            <div class="fs_add del" @click="handleDeleteItem(item,index)">x 删除</div>
                                                        </el-form-item>
                                                    </el-col>
                                                </el-row>
                                            </el-form>
                                        </div>
                                        <div class="fs_add" @click="handleAddItem">+ 添加</div>
                                    </div>
                                </template>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
            <div class="btns">
                <div class="btn">确认</div>
                <div class="btn">取消</div>
            </div>
        </div>
    </div>
</template>

<script setup name="">
    import { ref, getCurrentInstance } from 'vue'
    const { proxy } = getCurrentInstance();
    
    const teamDto = ref({
        aaa: '',
        bbb: '',
        ccc: '',
        ddd: '',
        eee: '',
        userList:[]
    })
    const addType = ref(1)
    const teamDtoRef = ref(null)
    const rules = ref({
        aaa: [
            { required: true, message: '请选择所属项目', trigger: 'change' }
        ],
        bbb: [
            { required: true, message: '请输入团队名称', trigger: 'blur' }
        ],
        ccc: [
            { required: true, message: '请输入工作任务', trigger: 'blur' }
        ],
        ddd: [
            { required: true, message: '请输入团队介绍', trigger: 'blur' }
        ],
        eee: [
            { required: true, message: '请输入团队项目情况', trigger: 'blur' }
        ]
    })

    const handleAddItem = () => {
        teamDto.value.userList.push({
            aa: '',
            bb: '',
            cc: '',
            dd: '',
            ee: '',
            ff: '',
            gg: '',
            hh: '',
            ii: '',
            jj: ''
        })
    }

    const handleDeleteItem = (item,index) => {
        teamDto.value.userList.splice(index,1)
    }
</script>

<style scoped lang="scss">
    .full_page{
        background: #FAFAFA;
        .top{
            width: 100%;
            height: 64px;
            background: #FFFFFF;
            border-bottom: 1px solid #F3F4F6;
            display: flex;
            align-items: center;
            img{
                width: 36px;
                height: 36px;
                margin-left: 16px;
                cursor: pointer;
            }
            .spans{
                display: flex;
                align-items: center;
                margin-left: 23px;
                span{
                    font-family: PingFangSC, PingFang SC;
                    font-weight: 400;
                    font-size: 14px;
                    color: #6B7280;
                    line-height: 14px;
                    &.last{
                        color: #111111;
                    }
                }
            }
        }

        .content{
            width: calc(100% - 24px);
            height: calc(100vh - 88px);
            margin: 12px;
            background: #FFFFFF;
            border-radius: 6px 6px 0px 0px;
            border: 1px solid #F3F4F6;
            position: relative;
            .form{
                width: 100%;
                height: calc(100% - 81px);
                overflow-y: auto;
                padding: 20px;
                box-sizing: border-box;
            }
            .btns{
                width: 100%;
                height: 80px;
                border-top: 1px solid #E5E7EB;
                display: flex;
                align-items: center;
                position: absolute;
                left: 0;
                bottom: 0;
                .btn{
                    width: 80px;
                    height: 32px;
                    background: #1C4ED8;
                    border-radius: 6px;
                    font-family: PingFangSC, PingFang SC;
                    font-weight: 400;
                    font-size: 14px;
                    color: #FFFFFF;
                    line-height: 32px;
                    text-align: center;
                    margin-left: 20px;
                    cursor: pointer;
                    &:last-child{
                        background: #FFFFFF;
                        border: 1px solid #E5E7EB;
                        color: #9CA3AF;
                    }
                }
            }
        }

        .f_title{
            font-family: PingFangSC, PingFang SC;
            font-weight: 600;
            font-size: 16px;
            color: #0D162A;
            line-height: 16px;
            margin-bottom: 20px;
        }

        .f_pldr{
            margin-top: 20px;
            .fp_box{
                display: flex;
                width: 526px;
                height: 125px;
                border-radius: 4px;
                border: 1px solid #EDEEF0;
                position: relative;
                .fpb_pre{
                    width: calc(50% - 1px);
                    height: 100%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    .fpbp_btn{
                        width: 140px;
                        height: 36px;
                        border-radius: 6px;
                        border: 1px solid #E5E7EB;
                        font-family: PingFangSC, PingFang SC;
                        font-weight: 400;
                        font-size: 12px;
                        color: #2E69EB;
                        line-height: 36px;
                        text-align: center;
                        cursor: pointer;
                    }
                    &.sc{
                        border-left: 1px solid #EDEEF0;
                        .fpbp_btn{
                            background: #1C4ED8;
                            border: 1px solid #1C4ED8;
                            color: #FFFFFF;
                        }
                    }
                }
                img{
                    width: 50px;
                    height: 20px;
                    position: absolute;
                    left: 50%;
                    margin-left: -25px;
                    top: 50%;
                    margin-top: -10px;
                }
            }
            p{
                margin-top: 11px;
                font-family: PingFangSC, PingFang SC;
                font-weight: 400;
                font-size: 12px;
                color: #C1C7D2;
                line-height: 20px;
                text-align: justify;
            }
        }

        .f_sdlr{
            padding-top: 10px;

            .fs_add{
                width: 80px;
                height: 32px;
                background: #1C4ED8;
                border-radius: 6px;
                font-family: PingFangSC, PingFang SC;
                font-weight: 400;
                font-size: 14px;
                color: #FFFFFF;
                line-height: 32px;
                text-align: center;
                margin-top: 20px;
                cursor: pointer;
                &.del{
                    background: rgb(212, 96, 96);
                    margin: 0;
                    margin-top: 5px;
                }
            }
        }
    }

    ::v-deep .el-form-item{
        margin-bottom: 20px !important;
    }
</style>