示例#1
0
    def post(self, request):
        queryDict = request.POST.dict()
        _all = request.POST.get('all')
        page = request.POST.get('page')
        limit = request.POST.get('limit')
        begin, end = basicUtils.pageHandle(page, limit)
        returnData = {}

        generater = basicUtils.GenerateReturnData()

        try:
            if _all == 'true':
                allObj = models.SysPurchase.objects.filter(
                    save_status=1).order_by('-id')

            if allObj.count() > 0:
                obj = allObj[begin:end]
                if allObj.count() < int(limit):
                    obj = allObj

                generater.setCount(allObj.count())
                generater.setData(obj)
            generater.generate()
        except Exception as error:
            generater.setStatus(500)
            generater.setMsg(error.__str__())
            Logger.error(request, '访问待采购归档页面时出现错误:%s' % error.__str__())

        returnData = generater.getReturnDate()
        return JsonResponse(returnData)
示例#2
0
    def post(self, request):
        try:
            page = request.POST.get('page')
            limit = request.POST.get('limit')
            _filter = request.POST.get('filter')
            listQuery = request.POST.get('list')
            queryDict = request.POST.dict()
            begin, end = basicUtils.pageHandle(page, limit)
            returnData = {}
            data = []

            FilterObj = ListFilter()
            FilterObj.init(queryDict=queryDict,
                           isFilter=_filter,
                           isListQuery=listQuery)
            logsData = FilterObj.data[begin:end]
            for item in logsData:
                dataTemp = model_to_dict(item)
                dataTemp['desc'] = item.level.desc
                data.append(dataTemp)

            status = 200
            msg = ''

        except Exception as error:
            status = 500
            msg = error.__str__()

        returnData['status'] = status
        returnData['msg'] = msg
        returnData['count'] = FilterObj.count
        returnData['data'] = data

        return JsonResponse(returnData)
    def post(self, request):
        page = request.POST.get('page')
        limit = request.POST.get('limit')
        _all = request.POST.get('all')
        _filter = request.POST.get('filter')
        begin, end = basicUtils.pageHandle(page, limit)
        queryDict = request.POST.dict()

        status = 500
        count = 0
        data = []
        msg = ''
        returnData = {}

        for item in notDbField:
            # 剔除与数据库无关字段
            if item in queryDict:
                queryDict.pop(item)

        try:
            if _all == 'true':
                obj = models.SysUsers.objects.all().order_by('user_group')
            elif _filter == 'true':
                queryDictTemp = {}
                for key, value in queryDict.items():
                    if key == 'user_group' and value:
                        queryDictTemp[key] = value
                        continue
                    queryDictTemp[key + '__icontains'] = value
                obj = models.SysUsers.objects.filter(
                    **queryDictTemp).order_by('user_group')

            userGroupObj = models.SysUserGroup.objects.all().order_by(
                'group_level')

            for item in obj[begin:end]:
                dictTemp = model_to_dict(item)
                user_group = userGroupObj.get(group_level=item.user_group)
                dictTemp['user_group_name'] = user_group.group_name
                dictTemp['reg_time'] = basicUtils.foramtDate(item.reg_time)
                dictTemp['last_time'] = basicUtils.foramtDate(item.last_time)
                dictTemp.pop('password')
                dictTemp.pop('security_password')
                data.append(dictTemp)

                status = 200
                count = obj.count()
        except Exception as error:
            Logger.error(request, '访问系统用户管理页时出现错误:%s' % error.__str__())
            msg = error.__str__()

        returnData['status'] = status
        returnData['count'] = count
        returnData['msg'] = msg
        returnData['data'] = data
        return JsonResponse(returnData)
示例#4
0
    def post(self, request):
        try:
            page = request.POST.get('page')
            limit = request.POST.get('limit')
            begin, end = basicUtils.pageHandle(page, limit)
            returnData = {}
            data = []
            count = 0
            queryDict = request.POST.dict()
            queryDict.pop('page')
            queryDict.pop('limit')
            queryDict.pop('csrfmiddlewaretoken')

            _filter = request.POST.get('filter')
            if _filter and _filter == 'true':
                # 请求为筛选
                queryDict.pop('filter')

                if request.POST.get('filterEmpty') == 'true':
                    obj = models.SysRepository.objects.filter(
                        count=0).order_by('id')
                else:
                    obj = models.SysRepository.objects.filter(
                        Q(name__icontains=queryDict.get('keyword'))
                        | Q(type__icontains=queryDict.get('keyword')),
                        last_in_user__icontains=queryDict.get('last_in_user'),
                        last_out_user__icontains=queryDict.get(
                            'last_out_user'),
                    ).order_by('id')
            else:
                obj = models.SysRepository.objects.all().order_by('id')

            repositoryData = obj[begin:end]
            for item in repositoryData:
                data.append(model_to_dict(item))

            status = 200
            msg = ''
            count = obj.count()

        except Exception as error:
            Logger.error(request, '访问仓库列表页时出现错误:%s' % error.__str__())
            status = 500
            msg = error

        returnData['status'] = status
        returnData['msg'] = msg
        returnData['count'] = count
        returnData['data'] = data

        return JsonResponse(returnData)
	def post(self, request):
		try:
			page = request.POST.get('page')
			limit = request.POST.get('limit')
			_filter = request.POST.get('filter')
			listQuery = request.POST.get('list')
			isHasPhone = request.POST.get('isHasPhone')
			queryDict = request.POST.dict()

			for item in ['csrfmiddlewaretoken', 'page', 'limit', 'isHasPhone']:
				# 剔除非数据库数据
				if queryDict.get(item):
					queryDict.pop(item)

			begin, end = basicUtils.pageHandle(page, limit)
			returnData = {}
			data = []

			FilterObj = ListFilter()
			FilterObj.init(models = models.SysAsset.objects, queryDict = queryDict, isFilter = _filter, isListQuery = listQuery)

			if isHasPhone and isHasPhone == 'on':
				# 当用户筛选时勾选了显示所有话机记录执行数据替换
				hasPhoneData = FilterObj.data.filter(~Q(ipphone_number = ''))
				hasPhoneDataCount = hasPhoneData.count()
				FilterObj.setAttribute(data = hasPhoneData, count = hasPhoneDataCount)

			assetData = FilterObj.data[begin:end]

			if FilterObj.count <= int(limit):
				# 如果筛选之后数据量小于分页值则返回未切片的所有数据
				assetData = FilterObj.data

			for item in assetData:
				item.use_user = item.use_user + item.english_name
				data.append(model_to_dict(item))

			status = 200
			msg = ''

		except Exception as error:
			Logger.error(request, '固定资产列表页获取数据时出现错误:%s' % error.__str__())
			status = 500
			msg = error.__str__()

		returnData['status'] = status
		returnData['msg'] = msg
		returnData['count'] = FilterObj.count
		returnData['data'] = data

		return JsonResponse(returnData)
	def post(self, request):
		_all = request.POST.get('all')
		page = request.POST.get('page')
		limit = request.POST.get('limit')
		_type = request.POST.get('type')
		_filter = request.POST.get('filter')
		queryDict = request.POST.dict()
		begin, end = basicUtils.pageHandle(page, limit)

		for item in notDbField:
			# 剔除与数据库无关字段
			if queryDict.get(item) == None:
				continue
			queryDict.pop(item)

		status = 500
		msg = ''
		count = 0
		returnData = {}
		_models = ''
		data = []

		try:
			if type(_type) == str:
				if _type.lower() == 'staffs':
					_models = models.SysStaff.objects
				elif _type.lower() == 'department':
					_models = models.SysDepartment.objects

				obj = GetModelData(_models, all = _all, isFilter = _filter, queryDict = queryDict)

				count = obj.count

				staffData = obj.data[begin:end]
				for item in staffData:
					itemDict = model_to_dict(item)
					data.append(itemDict)
				status = 200
		except Exception as error:
			Logger.error(request, '访问员工/部门数据列表页时出现错误:%s' % error.__str__())
			msg = error.__str__()

		returnData['status'] = status
		returnData['msg'] = msg
		returnData['count'] = count
		returnData['data'] = data
		return JsonResponse(returnData)
    def post(self, request):
        page = request.POST.get('page')
        limit = request.POST.get('limit')
        _all = request.POST.get('all')
        begin, end = basicUtils.pageHandle(page, limit)

        generaterObj = basicUtils.GenerateReturnData()
        try:
            if _all == 'true':
                data = models.SysAuthGroup.objects.all().order_by('id')
                if data.count() > 0:
                    generaterObj.setData(data[begin:end])
                    generaterObj.setCount(data.count())

        except Exception as error:
            Logger.error(request, '访问用户权限管理页时出现错误:%s' % error.__str__())
            generaterObj.setMsg(error.__str__())
            generaterObj.setStatus(500)

        return JsonResponse(generaterObj.generate())