Example #1
0
def manager_listEmployees():  #员工列表
    """
    员工列表
    """
    data = []
    app_session = bottle.request.environ.get('beaker.session')
    companyId = app_session.get('company')
    companyName = app_session.get('companyName')

    get_em = EmployeesInfo.filter(EmployeesInfo.Company == companyId)
    for item in get_em:
        base = {
            "Id": item.Id,
            'Name': item.Name,
            'Sex': item.Sex,
            'Phone': item.Phone,
            'Email': item.Email,
            'Position': item.Position
        }
        get_depart = DepartmentInfo.select().where(
            DepartmentInfo.Id == item.Department
            and DepartmentInfo.Company == companyId)
        base['department'] = ''
        for depar in get_depart:
            if not depar.Name == '':
                base['department'] = depar.Name
        data.append(base)

    return template(root + "/templates/listEmployess.tpl",
                    templatedir=root + '/templates/',
                    data=data,
                    companyName=companyName)
Example #2
0
def edi_department(Id, showDetail):
    """
    部门的添加与编辑
    """
    app_session = bottle.request.environ.get('beaker.session')
    companyId = app_session.get('company')
    companyName = app_session.get('companyName')

    if showDetail == 'true':  #编辑部门信息

        get_data = DepartmentInfo.filter(DepartmentInfo.Company == companyId
                                         and DepartmentInfo.Id == Id)
        for d in get_data:
            data = {
                "Id": d.Id,
                "Name": d.Name,
                "Phone": d.Phone,
                "Leader": d.Leader
            }
        form = request.forms
        res_dic = []

        if form.submit:
            DepartmentInfo.update(
                Name=form.Name, Phone=form.Phone,
                Leader=form.Leader).where(DepartmentInfo.Id == Id).execute()
            redirect("/manager/listdepartment/")

        return template(root + "/templates/edit_depart.tpl",
                        showDetail=True,
                        data=data,
                        templatedir=root + '/templates/',
                        companyName=companyName)

    else:  #添加部门信息

        form = request.forms
        count = DepartmentInfo.select().count()
        print count
        if form.submit:
            depart = DepartmentInfo()
            depart.Id = count + 1
            depart.Name = form.Name
            depart.Company = companyId
            depart.Phone = form.Phone
            depart.Leader = form.Leader
            depart.save(force_insert=True)
            redirect("/manager/listdepartment/")  #跳转到部门列表

        return template(root + "/templates/edit_depart.tpl",
                        showDetail=False,
                        templatedir=root + '/templates/',
                        companyName=companyName)
Example #3
0
def manager_listEmployees(): #员工列表
    """
    员工列表
    """
    data = []
    app_session = bottle.request.environ.get('beaker.session')
    companyId = app_session.get('company')
    companyName = app_session.get('companyName')
    
    get_em = EmployeesInfo.filter(EmployeesInfo.Company == companyId)
    for item in get_em:
        base = {"Id": item.Id,'Name':item.Name,'Sex':item.Sex,'Phone':item.Phone,'Email':item.Email,'Position':item.Position}
        get_depart = DepartmentInfo.select().where(DepartmentInfo.Id == item.Department and DepartmentInfo.Company==companyId)
        base['department'] = ''
        for depar in get_depart:
            if not depar.Name == '':
                base['department'] = depar.Name
        data.append(base)
            
    return template(root+"/templates/listEmployess.tpl",templatedir=root+'/templates/',data=data,companyName=companyName)
Example #4
0
def edi_department(Id,showDetail):
    """
    部门的添加与编辑
    """
    app_session = bottle.request.environ.get('beaker.session')
    companyId = app_session.get('company')
    companyName = app_session.get('companyName') 
    
    if showDetail =='true': #编辑部门信息

        get_data = DepartmentInfo.filter(DepartmentInfo.Company==companyId and DepartmentInfo.Id==Id)
        for d in get_data:
            data = {"Id":d.Id,"Name":d.Name,"Phone":d.Phone,"Leader":d.Leader}
        form = request.forms        
        res_dic =[]
       
        if form.submit:
            DepartmentInfo.update(Name=form.Name,Phone=form.Phone,Leader=form.Leader).where(DepartmentInfo.Id==Id).execute()
            redirect("/manager/listdepartment/")

        return template(root+"/templates/edit_depart.tpl",showDetail=True,data=data,templatedir=root+'/templates/',companyName=companyName)
       
    else:           #添加部门信息
        
        form = request.forms
        count = DepartmentInfo.select().count()
        print count
        if form.submit:            
            depart = DepartmentInfo()
            depart.Id = count + 1
            depart.Name = form.Name
            depart.Company = companyId
            depart.Phone = form.Phone
            depart.Leader = form.Leader           
            depart.save(force_insert=True)
            redirect("/manager/listdepartment/") #跳转到部门列表
        
        return template(root+"/templates/edit_depart.tpl",showDetail=False,templatedir=root+'/templates/',companyName=companyName)