<template>
    <div class="employee-detail">
        <employee-info :info="info"></employee-info>
        <div class="btn-box">
            <el-button @click="saveEmployeeInfo" type="primary">保存</el-button>
            <el-button type="primary">保存并继续添加</el-button>
            <el-button>取消</el-button>
        </div>
    </div>
</template>
<script>
import employeeInfo from "components/contacts/employeeInfo";
import { getRequest, postRequest, postJsonRequest } from '@/api/api';
export default {
    name: "employeeDetail",
    components: {
        employeeInfo
    },
    data() {
        return {
            info: {},
            managerMode: false
        };
    },
    methods: {
        getEmployInfo() {
            let that = this;
            let params = {
                id: that.$route.query.employeeClerkId
            };
            getRequest("/haoban-manage-web/emp/findOne", params)
            .then(res => {
                console.log(res, "employeeDetail");
                that.info = res.data.result;
                that.info.managerMode = !!res.data.result.managerMode;
            })
            .catch(e => {
                console.log(e, "error");
            });
        },
        saveEmployeeInfo() {
            let that = this;
            let info = that.info;
            let params = {
                name: info.name,
                phoneNumber: info.phoneNumber,
                positionName: info.positionName,
                employeeClerkId: info.employeeClerkId,
                managerMode: info.managerMode * 1
            };
            console.log(info, params);
            getRequest("/haoban-manage-web/emp/update", params)
            .then(res => {
                console.log(res, "update result");
            })
            .catch(e => {
                console.log(e, "error");
            });
        }
    },
    beforeMount() {
        this.getEmployInfo();
    }
};
</script>
<style lang="scss">
.employee-detail {
    overflow: auto;
    height: 460px;
    .btn-box {
        width: calc(100% - 200px);
        padding: 12px 0;
        background: #fff;
        position: fixed;
        bottom: 0;
        right: 0;
        text-align: center;
    }
}
</style>

