コード例 #1
0
def showOneTable(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("用户尚未登录!", status=403)

    if (request.method != "POST"):
        return HttpResponse("访问类型错误!", status=403)

    strPageType = request.POST.get('pageType')
    if (strPageType == ""):
        return HttpResponse("页面类型无效!", status=403)

    context = {}  #一个字典对象
    context["pageType"] = strPageType

    if (strPageType == ""):
        return HttpResponse("")
    elif (strPageType == "importMatterDetails"):
        context["btnText"] = "载入预采购单"
        return render_to_response("showOneTablesTwoBtns.html", context)
    elif (strPageType == "exportMatterDetails"):
        context["btnText"] = "载入预约单"
        return render_to_response("showOneTablesTwoBtns.html", context)
    elif (strPageType == "perchaseMatterDetails"):
        context["btnText"] = "导入文件"
        return render_to_response("showOneTablesTwoBtns.html", context)
    elif (strPageType == "reserveMatterDetails"):
        context["btnText"] = "导入文件"
        return render_to_response("showOneTablesTwoBtns.html", context)
    else:
        return render_to_response("showOneTable.html", context)
コード例 #2
0
def censoreForm(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("当前用户不存在或未登录!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法不正确!", status=403)

    #从session中获取当前入库单id和用户所属列
    curFormTableName = request.session.get('curFormTableName', default="")
    curFormId = int(request.session.get('curFormId', default=0))
    curUserIndexId = int(request.session.get('curUserIndexId', default=0))
    del request.session['curFormTableName']
    del request.session['curFormId']
    del request.session['curUserIndexId']

    if (curFormTableName == "" or curFormId < 1 or curUserIndexId < 1):
        return HttpResponse("清单无效!", status=403)

    #获取当前选中的审核状态、下一个审核人与评论
    selCensoreStateId = int(request.POST.get('censoreStateId'))
    if (selCensoreStateId < 1):
        return HttpResponse("状态无效!", status=403)

    nextCensoreUserId = int(request.POST.get('nextCensoreUserId'))
    strComment = request.POST.get('strComment')

    #通过表名获取数据库对象
    curFormModel = getFormObject(curFormTableName)
    if (curFormModel == ""):
        return HttpResponse("传入的数据表名无效!", status=403)

    curFormItem = curFormModel.objects.get(id=curFormId)
    strCurCensoreStateField = "EF_CensoreStateId%d" % (curUserIndexId)
    setattr(curFormItem, strCurCensoreStateField, selCensoreStateId)
    strCurCommentField = "EF_CensoreComment%d" % (curUserIndexId)
    setattr(curFormItem, strCurCommentField, strComment)

    strNextUserIdField = "EF_UserId%d" % (curUserIndexId + 1)
    strNextCensoreStateIdField = "EF_CensoreStateId%d" % (curUserIndexId + 1)

    #审核通过则传递给下一个,并置状态为审核中
    if (selCensoreStateId == 3):
        if (nextCensoreUserId > 0):
            setattr(curFormItem, strNextUserIdField, nextCensoreUserId)
            setattr(curFormItem, strNextCensoreStateIdField, 6)
            setattr(curFormItem, "EF_FormStateId", 2)
        else:
            setattr(curFormItem, "EF_FormStateId", 3)
    #审核未通过,则不进行传递,且置状态为己拒绝
    elif (selCensoreStateId == 5):
        setattr(curFormItem, strNextUserIdField, 0)
        setattr(curFormItem, strNextCensoreStateIdField, 0)
        setattr(curFormItem, "EF_FormStateId", 5)

    curFormItem.save()

    return HttpResponse("审核成功!", None, 200)
コード例 #3
0
def formOption(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("用户未登录或无效!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法不正确!", status=403)

    context = {}  #一个字典对象
    context['jsFileName'] = request.POST.get("jsFileName", "")
    return render_to_response("formOption.html", context, status=200)
コード例 #4
0
def showCensoreDialog(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("当前用户不存在或未登录!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法不正确!", status=403)

    curCensoreUserTypeId = request.POST.get('curCensoreUserTypeId')
    curCensoreUserId = request.POST.get('curCensoreUserId')
    #判断当前用户是否为审核用户
    if (int(curCensoreUserTypeId) != int(userDict["typeId"])
            or int(curCensoreUserId) != int(userDict["id"])):
        return HttpResponse("您无权代替他人进行审核!", status=403)

    curCensoreStateId = request.POST.get('curCensoreStateId')
    nextUserTypeId = request.POST.get('nextUserTypeId')

    #获取所有的审核状态
    censoreStates = CensoreStates.objects.all()

    #获取下一个人
    strNextCensoreType = ""
    arrCensores = []
    if (nextUserTypeId != "" and int(nextUserTypeId) > 0):
        strNextCensoreType = UserTypes.objects.get(
            id=nextUserTypeId).EF_TypeName
        if (strNextCensoreType == SuperAdministrators.Type):
            arrCensores = SuperAdministrators.objects.all()
        elif (strNextCensoreType == Administrators.Type):
            arrCensores = Administrators.objects.all()
        elif (strNextCensoreType == ChiefCollegeLeaders.Type):
            arrCensores = ChiefCollegeLeaders.objects.all()
        elif (strNextCensoreType == CollegeLeaders.Type):
            arrCensores = CollegeLeaders.objects.all()
        elif (strNextCensoreType == Teachers.Type):
            arrCensores = Teachers.objects.all()

    #将当前审核的入库单ID和审核的用户列名写入session
    request.session['curFormTableName'] = request.POST.get('curFormTableName')
    request.session['curFormId'] = request.POST.get('curFormId')
    request.session['curUserIndexId'] = request.POST.get('curUserIndexId')
    request.session.set_expiry(0)

    context = {}  #一个字典对象
    context['censoreStates'] = censoreStates  #传入模板中的变量
    context['nextCensoreTypeName'] = strNextCensoreType  #传入模板中的变量
    context['arrCensores'] = arrCensores  #传入模板中的变量
    return render_to_response("censoreDialog.html", context, status=200)
コード例 #5
0
def createNewForm(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("当前用户不存在或未登录!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法出错!", status=403)

    #通过表名获取数据库对象
    curFormModel = getFormObject(request.POST.get("formTableName"))
    if (curFormModel == ""):
        return HttpResponse("传入的数据表名无效!", status=403)

    curDetailModel = getFormObject(request.POST.get("detailTableName"))
    if (curDetailModel == ""):
        return HttpResponse("传入的材料信息数据表名无效!", status=403)

    #从session中获取己计算出的审核模型ID
    censorePatternId = request.session.get('censorePatternId', default=0)
    del request.session['censorePatternId']

    #获取用户选择的第一个审核人
    censoreUserId = request.POST.get('censoreUserId')

    #获取当前时间,并格式化为数据库中格式
    timeNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

    #创建一个新的入库单
    newForm = curFormModel.objects.create(EF_UserTypeId=userDict["typeId"],
                                          EF_UserId=userDict["id"],
                                          EF_FormStateId="1",
                                          EF_Time=timeNow,
                                          EF_CensorePatternId=censorePatternId,
                                          EF_UserId1=censoreUserId,
                                          EF_CensoreStateId1=6)

    #更新临时的药品明细列表中的入库单ID
    arrValidItems = curDetailModel.objects.all().filter(EF_FormId=0)
    for item in arrValidItems:
        item.EF_FormId = newForm.id
        item.save()

    return HttpResponse("添加成功!")
コード例 #6
0
def showTwoTables(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("用户尚未登录!", status=403)

    if (request.method != "POST"):
        return HttpResponse("访问类型错误!", status=403)

    strPageType = request.POST.get('pageType')
    if (strPageType == ""):
        return HttpResponse("页面类型无效!", status=403)

    context = {}  #一个字典对象
    context["pageType"] = strPageType

    if (strPageType == ""):
        return HttpResponse("")
    else:
        return render_to_response("showTwoTables.html", context)
コード例 #7
0
def deleteFromOneTable(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("删除失败!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法出错!", status=403)

    #通过表名获取数据库对象
    curModel = getFormObject(request.POST.get("tableName"))
    if (curModel == ""):
        return HttpResponse("传入的数据表名无效!", status=403)

    strFieldMethod = request.POST.get("fieldMethod")
    methodValues = request.POST.get("methodValue")
    condition = {strFieldMethod: methodValues}

    curModel.objects.all().filter(**condition).delete()

    return HttpResponse("删除成功!")
コード例 #8
0
def genPerchaseMatterDetails(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("用户未登录或无效!", status=403)

    #删除旧的临时数据
    PerchaseMatterDetails.objects.all().filter(EF_FormId=0).delete()

    #创建所有的
    arrCandidates = MatterMinRemains.objects.all()
    for item in arrCandidates:
        curMatter = Matters.objects.get(id=item.EF_MatterId)
        intNeedAmount = item.EF_MinRemain - curMatter.EF_Amount
        if (intNeedAmount < 1):
            continue

        newPerchaseItem = PerchaseMatterDetails.objects.create(
            EF_FormId=0,
            EF_MatterId=item.EF_MatterId,
            EF_MatterCount=intNeedAmount)

    return HttpResponse("初始化采购单成功!")
コード例 #9
0
def copyMatterDetails(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("用户未登录或无效!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法不正确!", status=403)

    fromTable = getFormObject(request.POST.get("fromTableName", ""))
    toTable = getFormObject(request.POST.get("toTableName", ""))
    if (fromTable == "" or toTable == ""):
        return HttpResponse("传入的表名有误!", status=403)

    fromTableFormId = request.POST.get("fromTableFormId", 0)
    toTableFormId = request.POST.get("toTableFormId", 0)

    arrFromItems = fromTable.objects.all().filter(EF_FormId=fromTableFormId)
    for item in arrFromItems:
        toTable.objects.create(EF_FormId=toTableFormId,
                               EF_MatterId=item.EF_MatterId,
                               EF_MatterCount=item.EF_MatterCount)

    return HttpResponse("复制完成")
コード例 #10
0
def calculateCensorePattern(request):
    userDict = getCurUser(request)
    curUser = userDict["curUser"]
    if (curUser == ""):
        return HttpResponse("当前用户不存在或未登录!", status=403)

    if request.method != 'POST':
        return HttpResponse("访问方法出错!", status=403)

    #通过表名获取数据库对象
    strTableName = request.POST.get("tableName")
    curModel = getFormObject(strTableName)
    if (curModel == ""):
        return HttpResponse("传入的数据表名无效!", status=403)

    #如果当前用户为学生,则应添加其导师
    arrValues = []
    if (userDict["type"] == "Student"):
        arrValues.append("教师")

    #并检查是否存在有毒,燃,爆的类型
    bIsDangerous = False
    arrValidItems = curModel.objects.all().filter(EF_FormId=0)
    for item in arrValidItems:
        if (bIsDangerous):
            break
        else:
            curMatter = Matters.objects.get(id=item.EF_MatterId)
            bIsDangerous = (curMatter.EF_TypeId != 1)

    if (bIsDangerous):
        arrValues.append("院长")
    else:
        arrValues.append("副院长")

    strField = "EF_TypeName__in"
    strCondition = {strField: arrValues}
    #修改为倒序排列,因为设置审核流程时,职位低的肯定在前面
    arrCensoreTypeIds = UserTypes.objects.all().order_by('-id').filter(
        **strCondition)

    #确定审核模型ID
    arrCensorePatterns = CensorePatterns.objects.all().filter(
        EF_StepsCount=len(arrCensoreTypeIds))

    nIndex = 0
    for item in arrCensoreTypeIds:
        nIndex += 1
        strField = "EF_UserTypeId%d" % (nIndex)
        strCondition = {strField: item.id}
        arrCensorePatterns = arrCensorePatterns.filter(**strCondition)

    #设置入库单的审核ID
    if (len(arrCensorePatterns) < 1):
        return HttpResponse("没有审核人!", status=403)

    #将审核模型写入session
    request.session['censorePatternId'] = arrCensorePatterns[0].id
    request.session.set_expiry(0)

    #获取第一个审核人
    arrCensores = []
    strFirstCensoreType = UserTypes.objects.get(
        id=arrCensoreTypeIds[0].id).EF_TypeName
    if (strFirstCensoreType == SuperAdministrators.Type):
        arrCensores = SuperAdministrators.objects.all()
    elif (strFirstCensoreType == Administrators.Type):
        arrCensores = Administrators.objects.all()
    elif (strFirstCensoreType == ChiefCollegeLeaders.Type):
        arrCensores = ChiefCollegeLeaders.objects.all()
    elif (strFirstCensoreType == CollegeLeaders.Type):
        arrCensores = CollegeLeaders.objects.all()
    elif (strFirstCensoreType == Teachers.Type):
        arrCensores = Teachers.objects.all()

    #获取当前的对应的js
    jsFileName = ""
    if (strTableName == "ImportMatterDetails"):
        jsFileName = "importFirstCensoreOption"
    elif (strTableName == "ExportMatterDetails"):
        jsFileName = "exportFirstCensoreOption"
    elif (strTableName == "PerchaseMatterDetails"):
        jsFileName = "perchaseFirstCensoreOption"
    elif (strTableName == "ReserveMatterDetails"):
        jsFileName = "reserveFirstCensoreOption"

    context = {}  #一个字典对象
    context['censoreTypeName'] = strFirstCensoreType  #传入模板中的变量
    context['arrCensores'] = arrCensores  #传入模板中的变量
    context['jsFileName'] = jsFileName  #传入模板中的变量
    return render_to_response("firstCensoreOption.html", context)