|
@@ -21,6 +21,7 @@ from apps.tenant.notices.filters import NoticesFilter
|
|
|
from utils.permission import isLogin
|
|
|
from utils.wx.WXBizDataCrypt import WXBizDataCrypt
|
|
|
from apps.tenant.poster.serializer import PosterSerializer, Poster
|
|
|
+from apps.tenant.device.models import DeviceModel
|
|
|
|
|
|
from .serializers import *
|
|
|
|
|
@@ -203,3 +204,26 @@ class BuildingView(APIView):
|
|
|
data.append(build_dict)
|
|
|
|
|
|
return response_ok(data)
|
|
|
+
|
|
|
+class DeviceView(APIView):
|
|
|
+ permission_classes = [isLogin, ]
|
|
|
+ def get(self, request):
|
|
|
+ param = request.GET.get('param')
|
|
|
+ data = []
|
|
|
+ rows = DeviceModel.objects.filter(tenant=request.user.employee.tenant)
|
|
|
+ if param:
|
|
|
+ rows = rows.filter(Q(name=param) | Q(device_no=param) | Q(device_model=param))
|
|
|
+ else:
|
|
|
+ rows = rows[:10]
|
|
|
+ for item in rows:
|
|
|
+ build_dict = {
|
|
|
+ 'id': item.name,
|
|
|
+ 'name':item.name,
|
|
|
+ 'device_no':item.device_no,
|
|
|
+ 'device_model':item.device_model,
|
|
|
+ 'branch':item.branch,
|
|
|
+ 'address':item.address,
|
|
|
+ }
|
|
|
+ data.append(build_dict)
|
|
|
+
|
|
|
+ return response_ok(data)
|