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).filter(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 if form.submit: depart = DepartmentInfo() 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)
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)
def manager_listEmployees(): #员工列表 """ 员工列表 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- array_depart = baseClass().getdepart()#调用类 #------------end------------- data = [] 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.filter(DepartmentInfo.Id == item.Department) base['department'] = '' for depar in get_depart: if not depar.Name == '': base['department'] = depar.Name data.append(base) return template(root+"/templates/listEmployess.tpl",array_depart = array_depart,templatedir = root+'/templates/',data=data,companyName=companyName)
def manager_listEmployeesBydepart(Id): """ 根据部门查询 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- array_depart = baseClass().getdepart()#调用类 #------------end------------- data = [] data_em = EmployeesInfo.filter(EmployeesInfo.Company == companyId).filter(EmployeesInfo.Department ==Id) for item in data_em: base = {"Id": item.Id,'Name':item.Name,'Sex':item.Sex,'Phone':item.Phone,'Email':item.Email,'Position':item.Position} get_depart = DepartmentInfo.filter(DepartmentInfo.Id == item.Department) base['department'] = '' for depar in get_depart: if not depar.Name == '': base['department'] = depar.Name data.append(base) return template(root+"/templates/listEmployess.tpl",array_depart = array_depart,templatedir = root+'/templates/',data=data,companyName=companyName)
def del_department(Id): #删除部门信息 """删除部门""" #返回JSON对象 depart = DepartmentInfo.get(Id=Id) if not depart is None: depart.delete_instance() return {"State": "success"}
def del_department(Id): #删除部门信息 """删除部门""" #返回JSON对象 depart = DepartmentInfo.get(Id = Id) if not depart is None: depart.delete_instance() return json.dumps({"State":"success"})
def edi_employees(Id,showDetail): #员工信息管理 """ 员工的添加与编辑 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- data_depart = DepartmentInfo.filter(DepartmentInfo.Company==companyId) array_depart = [] for depart in data_depart: base = {"Id":depart.Id,"Name":depart.Name} array_depart.append(base) #------------end------------- if showDetail =='true': data_employ = EmployeesInfo.filter(EmployeesInfo.Company==companyId).filter(EmployeesInfo.Id==Id) for item in data_employ: data = {"Id":item.Id,"Name":item.Name,"Department":item.Department,"Sex":item.Sex,"IdCard":item.IdCard,"Phone":item.Phone,"Email":item.Email,"Position":item.Position} form = request.forms res_dic = [] if form.submit: EmployeesInfo.update(Name=form.Name,Sex=form.Sex,IdCard=form.IdCard,Phone=form.Phone,Email=form.Email,Position=form.Position).where(EmployeesInfo.Id==int(Id)).execute() redirect("/manager/listemployees/") return template(root+"/templates/edit_employees.tpl",array_depart = array_depart,showDetail= True,templatedir=root+'/templates/',data=data,companyName=companyName) else: form = request.forms if form.submit: #获取员工根据对应的公司Id查找员工总数,新的员工Id:count+1 employe = EmployeesInfo() employe.Name = form.Name employe.LoginName = form.Phone employe.LoginPwd = md5.new("123456").hexdigest() employe.Company = companyId employe.Department = form.department print [form.department] employe.Sex = form.Sex employe.IdCard = form.IdCard employe.Phone = form.Phone employe.Email = form.Email employe.Position = form.Position employe.Imei = "123456xaxahisia" employe.save(force_insert = True)#不管主键是否存在的情况加force_insert = True,相当于id自动递增 redirect("/manager/listemployees/") return template(root+"/templates/edit_employees.tpl",array_depart = array_depart,showDetail = False,templatedir = root+'/templates/',companyName = companyName)
def getdepart(self): app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- data_depart = DepartmentInfo.filter(DepartmentInfo.Company==companyId) array_depart = [] for depart in data_depart: base = {"Id":depart.Id,"Name":depart.Name} array_depart.append(base) return array_depart
def manager_Department(): """部门列表""" data=[] app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') get_department = DepartmentInfo.filter(DepartmentInfo.Company==companyId) for item in get_department: base = {"Id":item.Id,"Name":item.Name,"Phone":item.Phone,"Leader":item.Leader} data.append(base) return template(root+"/templates/listDepartment.tpl",templatedir=root+'/templates/',data=data,companyName=companyName)
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)