Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shilixia 2022-02-10 16:07:15 +08:00
commit fab4ef2571
20 changed files with 150 additions and 113 deletions

View File

@ -123,7 +123,7 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<span v-show="item.help_text" class="helpText">说明{{item.help_text}}</span> <span v-show="item.help_text&&item.field_type !== 'draw'" class="helpText">说明{{item.help_text}}</span>
<span v-if="item.need_judge&&item.is_testok===true" class="adoptTip">合格</span> <span v-if="item.need_judge&&item.is_testok===true" class="adoptTip">合格</span>
<span v-if="item.need_judge&&item.is_testok===false" class="failTip">不合格</span> <span v-if="item.need_judge&&item.is_testok===false" class="failTip">不合格</span>
</el-col> </el-col>
@ -144,7 +144,7 @@
<div class="canvasBtn" @click="error1">标记</div> <div class="canvasBtn" @click="error1">标记</div>
<div class="canvasBtn" @click="word1()">文字</div> <div class="canvasBtn" @click="word1()">文字</div>
<div class="canvasBtn" @click="back()">回退</div> <div class="canvasBtn" @click="back()">回退</div>
<div class="canvasBtn" @click="saveTu()">保存</div> <!--<div class="canvasBtn" @click="saveTu()">保存</div>-->
</div> </div>
<div id="res"></div> <div id="res"></div>
</div> </div>
@ -196,11 +196,13 @@
isDisabled:{ isDisabled:{
type:Boolean, type:Boolean,
default:false default:false
},
isMidTesting:{
type:Boolean,
default:false
} }
}, },
mounted() { mounted() {
debugger;
debugger;
let that = this; let that = this;
that.checkForm = {}; that.checkForm = {};
this.form = this.formID; this.form = this.formID;
@ -725,7 +727,7 @@
that.testrecord.record_data = that.field;//检查项列表 that.testrecord.record_data = that.field;//检查项列表
that.testrecord.is_testok = that.is_testok;//检查表检查结果 that.testrecord.is_testok = that.is_testok;//检查表检查结果
that.testrecord.id = that.recordId;//记录id that.testrecord.id = that.recordId;//记录id
if(submit){//提交 if(submit&&that.isMidTesting!==true){//提交
this.$emit('recordSubmit',that.testrecord); this.$emit('recordSubmit',that.testrecord);
}else {//保存 }else {//保存
this.$emit('recordSave',that.testrecord); this.$emit('recordSave',that.testrecord);

View File

@ -282,6 +282,10 @@
hasPicture:{ hasPicture:{
type:Boolean, type:Boolean,
default:false default:false
},
isMidTesting:{
type:Boolean,
default:false
} }
}, },
mounted() { mounted() {
@ -299,7 +303,7 @@
}); });
that.formData=[...that.formData]; that.formData=[...that.formData];
// debugger; // debugger;
console.log(that.formData); // console.log(that.formData);
//当前表的数据存储 //当前表的数据存储
for(let i=0;i<this.results.length;i++){ for(let i=0;i<this.results.length;i++){
let key = this.results[i].field_key; let key = this.results[i].field_key;
@ -316,7 +320,7 @@
obj = item; obj = item;
that.judgeList.push(obj) that.judgeList.push(obj)
}); });
debugger; // debugger;
//图片地址 //图片地址
let imag= this.formData.filter(item => { let imag= this.formData.filter(item => {
return item.field_type === 'draw'; return item.field_type === 'draw';
@ -814,7 +818,7 @@
that.testrecord.is_testok = that.is_testok;//检查表检查结果 that.testrecord.is_testok = that.is_testok;//检查表检查结果
that.testrecord.id = that.recordId; that.testrecord.id = that.recordId;
// debugger; // debugger;
if(submit){//提交 if(submit&&that.isMidTesting!==true){//提交
this.$emit('recordSubmit',that.testrecord); this.$emit('recordSubmit',that.testrecord);
}else {//保存 }else {//保存
this.$emit('recordSave',that.testrecord); this.$emit('recordSave',that.testrecord);

View File

@ -2,10 +2,10 @@
<div style="width: 100%;height: 100%;"> <div style="width: 100%;height: 100%;">
<div> <div>
<div class="video-box"> <div class="video-box">
<video id="video" width="960" height="640" preload autoplay loop muted></video> <video id="video" width="749" height="640" preload autoplay loop muted></video>
<canvas id="canvas" width="960" height="640"></canvas> <canvas id="canvas" width="749" height="640"></canvas>
</div> </div>
<canvas id="screenshotCanvas" width="960" height="640"></canvas> <canvas id="screenshotCanvas" width="749" height="640"></canvas>
</div> </div>
</div> </div>
</template> </template>
@ -147,8 +147,8 @@
.video-box { .video-box {
margin: auto; margin: auto;
position: relative; position: relative;
width: 960px; /*width: 90%;
height: 640px; height: 90%;*/
} }
video, canvas { video, canvas {

View File

@ -307,4 +307,8 @@
.login-code-img { .login-code-img {
height: 38px; height: 38px;
} }
.testTracking{
width:100%;
height: 700px;
}
</style> </style>

View File

@ -406,6 +406,7 @@
:hasPicture="hasPicture" :hasPicture="hasPicture"
:wproduct="wproduct" :wproduct="wproduct"
:recordId="recordId" :recordId="recordId"
:isMidTesting="is_midtesting"
@recordSave="recordSave" @recordSave="recordSave"
@recordSubmit="recordSubmit" @recordSubmit="recordSubmit"
@recordCancel="recordCancel" @recordCancel="recordCancel"
@ -427,6 +428,7 @@
:wproduct="wproduct" :wproduct="wproduct"
:recordId="recordId" :recordId="recordId"
:isDisabled="isDisabled" :isDisabled="isDisabled"
:isMidTesting="is_midtesting"
@recordSubmit="recordSubmit" @recordSubmit="recordSubmit"
@recordSave="recordSave" @recordSave="recordSave"
@recordCancel="recordCancel" @recordCancel="recordCancel"
@ -788,6 +790,7 @@
mutipID: [], mutipID: [],
wproduct: null, wproduct: null,
isPost: false, isPost: false,
is_midtesting: false,
isDisabled: false, isDisabled: false,
origin_test: null, origin_test: null,
hasPicture: false, hasPicture: false,
@ -1008,7 +1011,7 @@
this.innerIndex = index; this.innerIndex = index;
// this.outerVisible = true; // this.outerVisible = true;
this.wproduct = scope.row.id;//半成品ID this.wproduct = scope.row.id;//半成品ID
this.listQueryrecordform.material = scope.row.material_.id;// this.listQueryrecordform.material = scope.row.material_check!==null ? scope.row.material_check :scope.row.material_.id;//
this.listQueryrecordform.type = 2; this.listQueryrecordform.type = 2;
this.listQueryrecordform.enabled = true; this.listQueryrecordform.enabled = true;
this.recordform = null; this.recordform = null;
@ -1073,6 +1076,7 @@
getTestRecordItem(scope.row.id).then((res) => { getTestRecordItem(scope.row.id).then((res) => {
let arr = []; let arr = [];
let fieldList = res.data.record_data; let fieldList = res.data.record_data;
that.is_midtesting = res.data.is_midtesting;
for (let i = 0; i < that.fieldList.length; i++) { for (let i = 0; i < that.fieldList.length; i++) {
let obj = that.fieldList[i]; let obj = that.fieldList[i];
obj.is_testok = null; obj.is_testok = null;

View File

@ -67,11 +67,13 @@ class FIFO(CommonADModel):
FIFO_TYPE_SALE_OUT = 2 FIFO_TYPE_SALE_OUT = 2
FIFO_TYPE_PUR_IN = 3 FIFO_TYPE_PUR_IN = 3
FIFO_TYPE_DO_IN = 4 FIFO_TYPE_DO_IN = 4
FIFO_TYPE_OTHER_IN = 5
type_choices = ( type_choices = (
(FIFO_TYPE_DO_OUT, '生产领料'), (FIFO_TYPE_DO_OUT, '生产领料'),
(FIFO_TYPE_SALE_OUT, '销售提货'), (FIFO_TYPE_SALE_OUT, '销售提货'),
(FIFO_TYPE_PUR_IN, '采购入库'), (FIFO_TYPE_PUR_IN, '采购入库'),
(FIFO_TYPE_DO_IN, '生产入库') (FIFO_TYPE_DO_IN, '生产入库'),
(FIFO_TYPE_OTHER_IN, '其他入库')
) )
number = models.CharField('记录编号', max_length=100) number = models.CharField('记录编号', max_length=100)
type = models.IntegerField('出入库类型', default=1) type = models.IntegerField('出入库类型', default=1)

View File

@ -80,10 +80,12 @@ class FIFOItemCreateSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = FIFOItem model = FIFOItem
fields = ['warehouse', fields = ['warehouse',
'material', 'batch', 'fifo', 'files', 'pu_order_item'] 'material', 'batch', 'fifo', 'files', 'pu_order_item', 'count']
def create(self, validated_data): def create(self, validated_data):
fifo = validated_data['fifo'] fifo = validated_data['fifo']
if fifo.is_audited:
raise ValidationError('该出入库记录已审核')
pu_order_item = validated_data.get('pu_order_item', None) pu_order_item = validated_data.get('pu_order_item', None)
if pu_order_item: if pu_order_item:
if fifo.pu_order != pu_order_item.pu_order: if fifo.pu_order != pu_order_item.pu_order:
@ -97,7 +99,7 @@ class FIFOItemCreateSerializer(serializers.ModelSerializer):
class FIFOItemUpdateSerializer(serializers.ModelSerializer): class FIFOItemUpdateSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = FIFOItem model = FIFOItem
fields = ['warehouse', 'batch', 'files'] fields = ['warehouse', 'batch', 'files', 'count']
class FIFOItemSerializer(serializers.ModelSerializer): class FIFOItemSerializer(serializers.ModelSerializer):
warehouse_ = WareHouseSimpleSerializer(source='warehouse', read_only=True) warehouse_ = WareHouseSimpleSerializer(source='warehouse', read_only=True)
@ -140,12 +142,12 @@ class FIFOInOtherSerializer(serializers.ModelSerializer):
def create(self, validated_data): def create(self, validated_data):
details = validated_data.pop('details') details = validated_data.pop('details')
with transaction.atomic(): with transaction.atomic():
validated_data['type'] = FIFO.FIFO_TYPE_PUR_IN validated_data['type'] = FIFO.FIFO_TYPE_OTHER_IN
validated_data['number'] = 'RK' + ranstr(7)
obj = FIFO(**validated_data) obj = FIFO(**validated_data)
obj.save() obj.save()
for i in details: for i in details:
if 'details' in i: if 'details' in i:
i['number'] = 'RK' + ranstr(7)
p_details = i.pop('details') p_details = i.pop('details')
if len(p_details) != i['count']: if len(p_details) != i['count']:
raise serializers.ValidationError('数目对不上') raise serializers.ValidationError('数目对不上')
@ -160,7 +162,6 @@ class FIFOInOtherSerializer(serializers.ModelSerializer):
FIFOItemProduct.objects.bulk_create(p_list0) FIFOItemProduct.objects.bulk_create(p_list0)
else: else:
i['fifo'] = obj i['fifo'] = obj
i['number'] = 'RK' + ranstr(7)
FIFOItem.objects.create(**i) FIFOItem.objects.create(**i)
return obj return obj
@ -179,6 +180,7 @@ class FIFOInPurSerializer(serializers.ModelSerializer):
pu_order = validated_data['pu_order'] pu_order = validated_data['pu_order']
validated_data['vendor'] = pu_order.vendor validated_data['vendor'] = pu_order.vendor
validated_data['number'] = 'RK' + ranstr(7) validated_data['number'] = 'RK' + ranstr(7)
validated_data['type'] = FIFO.FIFO_TYPE_PUR_IN
obj = FIFO.objects.create(**validated_data) obj = FIFO.objects.create(**validated_data)
return obj return obj

View File

@ -25,7 +25,8 @@ class WarehouseViewSet(CreateUpdateModelAMixin, ModelViewSet):
""" """
仓库-增删改查 仓库-增删改查
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'warehouse_create',
'put':'warehouse_update', 'delete':'warehouse_delete'}
queryset = WareHouse.objects.select_related('create_by').all() queryset = WareHouse.objects.select_related('create_by').all()
serializer_class = WareHouseSerializer serializer_class = WareHouseSerializer
search_fields = ['name', 'number', 'place'] search_fields = ['name', 'number', 'place']
@ -43,7 +44,7 @@ class InventoryViewSet(ListModelMixin, GenericViewSet):
""" """
仓库物料表 仓库物料表
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = Inventory.objects.select_related( queryset = Inventory.objects.select_related(
'material', 'warehouse').filter(count__gt=0).all() 'material', 'warehouse').filter(count__gt=0).all()
serializer_class = InventorySerializer serializer_class = InventorySerializer
@ -54,7 +55,7 @@ class InventoryViewSet(ListModelMixin, GenericViewSet):
class MaterialBatchViewSet(ListModelMixin, GenericViewSet): class MaterialBatchViewSet(ListModelMixin, GenericViewSet):
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = MaterialBatch.objects.select_related( queryset = MaterialBatch.objects.select_related(
'material', 'warehouse').filter(count__gt=0).all() 'material', 'warehouse').filter(count__gt=0).all()
serializer_class = MaterialBatchSerializer serializer_class = MaterialBatchSerializer
@ -81,7 +82,8 @@ class FIFOItemViewSet(ListModelMixin, CreateModelMixin, DestroyModelMixin, Updat
""" """
出入库记录详情表 出入库记录详情表
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'fifoitem_create',
'put':'fifoitem_update', 'delete':'fifoitem_delete'}
queryset = FIFOItem.objects.select_related('material', 'fifo').prefetch_related('files').all() queryset = FIFOItem.objects.select_related('material', 'fifo').prefetch_related('files').all()
serializer_class = FIFOItemSerializer serializer_class = FIFOItemSerializer
filterset_fields = ['material', 'fifo', filterset_fields = ['material', 'fifo',
@ -97,12 +99,6 @@ class FIFOItemViewSet(ListModelMixin, CreateModelMixin, DestroyModelMixin, Updat
return FIFOItemCreateSerializer return FIFOItemCreateSerializer
return super().get_serializer_class() return super().get_serializer_class()
def create(self, request, *args, **kwargs):
obj = self.get_object()
if obj.fifo.is_audited:
raise ValidationError('该出入库记录已审核')
return super().create(request, *args, **kwargs)
def update(self, request, *args, **kwargs): def update(self, request, *args, **kwargs):
obj = self.get_object() obj = self.get_object()
if obj.fifo.is_audited: if obj.fifo.is_audited:
@ -115,7 +111,7 @@ class FIFOItemViewSet(ListModelMixin, CreateModelMixin, DestroyModelMixin, Updat
raise ValidationError('该出入库记录已审核') raise ValidationError('该出入库记录已审核')
return super().destroy(request, *args, **kwargs) return super().destroy(request, *args, **kwargs)
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=InmTestRecordCreateSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'fifoitem_test'}, serializer_class=InmTestRecordCreateSerializer)
def test(self, request, pk=None): def test(self, request, pk=None):
""" """
检验 检验
@ -147,7 +143,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
""" """
出入库记录 出入库记录
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'delete':'fifo_delete'}
queryset = FIFO.objects.select_related('auditor', 'create_by') queryset = FIFO.objects.select_related('auditor', 'create_by')
serializer_class = FIFOListSerializer serializer_class = FIFOListSerializer
filterset_fields = '__all__' filterset_fields = '__all__'
@ -166,7 +162,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
raise exceptions.APIException('该记录已审核,不可删除') raise exceptions.APIException('该记录已审核,不可删除')
return super().destroy(request, *args, **kwargs) return super().destroy(request, *args, **kwargs)
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=FIFOInPurSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'fifo_in_pur'}, serializer_class=FIFOInPurSerializer)
def in_pur(self, request, pk=None): def in_pur(self, request, pk=None):
""" """
采购入库 采购入库
@ -176,7 +172,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
serializer.save(create_by=request.user) serializer.save(create_by=request.user)
return Response() return Response()
@action(methods=['post'], detail=False, perms_map={'post': '*'}, @action(methods=['post'], detail=False, perms_map={'post': 'fifo_in_other'},
serializer_class=FIFOInOtherSerializer) serializer_class=FIFOInOtherSerializer)
def in_other(self, request, pk=None): def in_other(self, request, pk=None):
""" """
@ -187,7 +183,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
serializer.save(create_by=request.user) serializer.save(create_by=request.user)
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=serializers.Serializer) @action(methods=['post'], detail=True, perms_map={'post': 'fifo_audit'}, serializer_class=serializers.Serializer)
def audit(self, request, pk=None): def audit(self, request, pk=None):
""" """
审核通过 审核通过
@ -213,7 +209,7 @@ class IProductViewSet(ListModelMixin, GenericViewSet):
""" """
半成品库存表 半成品库存表
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = IProduct.objects.select_related( queryset = IProduct.objects.select_related(
'material', 'warehouse', 'material', 'warehouse',
'wproduct__subproduction_plan__production_plan__order', 'wproduct__subproduction_plan__production_plan__order',

View File

@ -45,7 +45,7 @@ def get_file_list(file_path):
return dir_list return dir_list
class LogView(APIView): class LogView(APIView):
permission_classes = [IsAuthenticated]
@swagger_auto_schema(manual_parameters=[ @swagger_auto_schema(manual_parameters=[
openapi.Parameter('name', openapi.IN_QUERY, description='日志文件名', type=openapi.TYPE_STRING) openapi.Parameter('name', openapi.IN_QUERY, description='日志文件名', type=openapi.TYPE_STRING)
]) ])
@ -82,7 +82,7 @@ class LogView(APIView):
class LogDetailView(APIView): class LogDetailView(APIView):
permission_classes = [IsAuthenticated]
def get(self, request, name): def get(self, request, name):
""" """
查看日志详情 查看日志详情

View File

@ -42,6 +42,7 @@ class ProcessSimpleSerializer(serializers.ModelSerializer):
model = Process model = Process
fields = ['id', 'name', 'number', 'type'] fields = ['id', 'name', 'number', 'type']
class StepSerializer(serializers.ModelSerializer): class StepSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Step model = Step
@ -138,7 +139,7 @@ class UsedStepCreateSerializer(serializers.ModelSerializer):
""" """
class Meta: class Meta:
model = UsedStep model = UsedStep
fields = ['step', 'subproduction', 'remark'] fields = ['step', 'subproduction', 'remark', 'need_test']
class UsedStepUpdateSerializer(serializers.ModelSerializer): class UsedStepUpdateSerializer(serializers.ModelSerializer):
""" """
@ -146,7 +147,7 @@ class UsedStepUpdateSerializer(serializers.ModelSerializer):
""" """
class Meta: class Meta:
model = UsedStep model = UsedStep
fields = ['remark'] fields = ['remark', 'need_test']
class UsedStepListSerializer(serializers.ModelSerializer): class UsedStepListSerializer(serializers.ModelSerializer):
""" """

View File

@ -58,7 +58,8 @@ class StepViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet):
""" """
子工序-增删改查 子工序-增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'step_create',
'put':'step_update', 'delete':'step_delete'}
queryset = Step.objects.all() queryset = Step.objects.all()
serializer_class = StepSerializer serializer_class = StepSerializer
search_fields = ['name', 'number'] search_fields = ['name', 'number']
@ -74,7 +75,8 @@ class SubProductionViewSet(CreateUpdateModelAMixin, ModelViewSet):
""" """
产品生产分解增删改查 产品生产分解增删改查
""" """
perms_map={'*':'*'} perms_map={'get':'*', 'post':'subproduction_create',
'put':'subproduction_update', 'delete':'subproduction_delete'}
queryset = SubProduction.objects.select_related('process').all() queryset = SubProduction.objects.select_related('process').all()
filterset_fields = ['product', 'process'] filterset_fields = ['product', 'process']
search_fields = ['name'] search_fields = ['name']
@ -89,7 +91,8 @@ class InputMaterialViewSet(CreateUpdateModelAMixin, ModelViewSet):
""" """
输入物料-增删改查 输入物料-增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'subproduction_update',
'put':'subproduction_update', 'delete':'subproduction_update'}
queryset = SubprodctionMaterial.objects.select_related('material').filter(type=SubprodctionMaterial.SUB_MA_TYPE_IN) queryset = SubprodctionMaterial.objects.select_related('material').filter(type=SubprodctionMaterial.SUB_MA_TYPE_IN)
serializer_class = InputMaterialSerializer serializer_class = InputMaterialSerializer
filterset_fields = ['subproduction'] filterset_fields = ['subproduction']
@ -106,7 +109,8 @@ class OutputMaterialViewSet(CreateUpdateModelAMixin, ModelViewSet):
""" """
输出物料-增删改查 输出物料-增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'subproduction_update',
'put':'subproduction_update', 'delete':'subproduction_update'}
queryset = SubprodctionMaterial.objects.select_related('material').filter(type=SubprodctionMaterial.SUB_MA_TYPE_OUT) queryset = SubprodctionMaterial.objects.select_related('material').filter(type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
serializer_class = OutputMaterialSerializer serializer_class = OutputMaterialSerializer
filterset_fields = ['subproduction'] filterset_fields = ['subproduction']
@ -123,7 +127,8 @@ class OtherMaterialViewSet(CreateUpdateModelAMixin, ListModelMixin, DestroyModel
""" """
其他物料-增删改查 其他物料-增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'subproduction_update',
'put':'subproduction_update', 'delete':'subproduction_update'}
queryset = SubprodctionMaterial.objects.select_related('material').filter(type=SubprodctionMaterial.SUB_MA_TYPE_TOOL) queryset = SubprodctionMaterial.objects.select_related('material').filter(type=SubprodctionMaterial.SUB_MA_TYPE_TOOL)
serializer_class = OutputMaterialSerializer serializer_class = OutputMaterialSerializer
filterset_fields = ['subproduction'] filterset_fields = ['subproduction']
@ -138,7 +143,8 @@ class UsedStepViewSet(OptimizationMixin, CreateModelMixin, DestroyModelMixin, Li
""" """
产品生产子工序表 产品生产子工序表
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'subproduction_update',
'put':'subproduction_update', 'delete':'subproduction_update'}
queryset = UsedStep.objects.all() queryset = UsedStep.objects.all()
filterset_fields = ['subproduction', 'step'] filterset_fields = ['subproduction', 'step']
ordering = ['step__sort', '-step__create_time'] ordering = ['step__sort', '-step__create_time']
@ -154,7 +160,8 @@ class RecordFormViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet
""" """
记录表格增删改查 记录表格增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'recordform_create',
'put':'recordform_update', 'delete':'recordform_delete'}
queryset = RecordForm.objects.all() queryset = RecordForm.objects.all()
filterset_fields = ['step', 'type', 'material', 'number', 'enabled'] filterset_fields = ['step', 'type', 'material', 'number', 'enabled']
search_fields = ['name'] search_fields = ['name']
@ -186,7 +193,8 @@ class RecordFormFieldViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelVi
""" """
表格字段表 增删改查 表格字段表 增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'recordform_update',
'put':'recordform_update', 'delete':'recordform_update'}
queryset = RecordFormField.objects.all() queryset = RecordFormField.objects.all()
filterset_fields = ['field_type', 'form'] filterset_fields = ['field_type', 'form']
search_fields = ['field_name', 'field_key'] search_fields = ['field_name', 'field_key']
@ -204,7 +212,8 @@ class TechDocViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet):
""" """
技术文件增删改查 技术文件增删改查
""" """
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'subproduction_update',
'put':'subproduction_update', 'delete':'subproduction_update'}
queryset = TechDoc.objects.select_related('file').all() queryset = TechDoc.objects.select_related('file').all()
filterset_class = TechDocFilterset filterset_class = TechDocFilterset
search_fields = ['name'] search_fields = ['name']

View File

@ -39,7 +39,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
""" """
生产计划 生产计划
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'plan_create'}
queryset = ProductionPlan.objects.select_related('order', 'order__contract', 'product') queryset = ProductionPlan.objects.select_related('order', 'order__contract', 'product')
serializer_class = ProductionPlanSerializer serializer_class = ProductionPlanSerializer
search_fields = ['number', 'order__number', 'order__contract__number', 'product__number'] search_fields = ['number', 'order__number', 'order__contract__number', 'product__number']
@ -69,7 +69,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
updateOrderPlanedCount(instance.order) updateOrderPlanedCount(instance.order)
return Response() return Response()
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=PlanDestorySerializer) @action(methods=['post'], detail=False, perms_map={'post':'plan_delete'}, serializer_class=PlanDestorySerializer)
def deletes(self, request, pk=None): def deletes(self, request, pk=None):
""" """
批量物理删除 批量物理删除
@ -77,7 +77,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
ProductionPlan.objects.filter(id__in=request.data.get('ids', [])).delete(soft=False) ProductionPlan.objects.filter(id__in=request.data.get('ids', [])).delete(soft=False)
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=GenSubPlanSerializer) @action(methods=['post'], detail=True, perms_map={'post':'gen_subplan'}, serializer_class=GenSubPlanSerializer)
@transaction.atomic @transaction.atomic
def gen_subplan(self, request, pk=None): def gen_subplan(self, request, pk=None):
""" """
@ -109,7 +109,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
""" """
子生产计划-列表/修改 子生产计划-列表/修改
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'put':'subplan_update'}
queryset = SubProductionPlan.objects.select_related('process', 'workshop', 'subproduction', 'product', 'production_plan__product') queryset = SubProductionPlan.objects.select_related('process', 'workshop', 'subproduction', 'product', 'production_plan__product')
search_fields = [] search_fields = []
serializer_class = SubProductionPlanListSerializer serializer_class = SubProductionPlanListSerializer
@ -133,7 +133,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
serializer = SubProductionProgressSerializer(instance=obj.progress_subplan, many=True) serializer = SubProductionProgressSerializer(instance=obj.progress_subplan, many=True)
return Response(serializer.data) return Response(serializer.data)
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=serializers.Serializer) @action(methods=['post'], detail=True, perms_map={'post':'subplan_issue'}, serializer_class=serializers.Serializer)
@transaction.atomic @transaction.atomic
def issue(self, request, pk=None): def issue(self, request, pk=None):
""" """
@ -150,7 +150,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
return Response() return Response()
raise APIException('计划状态有误') raise APIException('计划状态有误')
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=serializers.Serializer) @action(methods=['post'], detail=True, perms_map={'post':'subplan_start'}, serializer_class=serializers.Serializer)
def start(self, request, pk=None): def start(self, request, pk=None):
""" """
开始生产 开始生产
@ -197,7 +197,7 @@ class SubProductionProgressViewSet(ListModelMixin, GenericViewSet):
""" """
生产进度 生产进度
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = SubProductionProgress.objects.select_related('material', 'subproduction_plan') queryset = SubProductionProgress.objects.select_related('material', 'subproduction_plan')
search_fields = [] search_fields = []
serializer_class = SubProductionProgressSerializer serializer_class = SubProductionProgressSerializer
@ -208,7 +208,7 @@ class SubProductionProgressViewSet(ListModelMixin, GenericViewSet):
class ResourceViewSet(GenericViewSet): class ResourceViewSet(GenericViewSet):
perms_map = {'*': '*'} perms_map = {'*': '*'}
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=ResourceCalListSerializer) @action(methods=['post'], detail=False, perms_map={'post':'resource_cal'}, serializer_class=ResourceCalListSerializer)
def cal(self, request, pk=None): def cal(self, request, pk=None):
""" """
物料消耗计算 物料消耗计算
@ -240,7 +240,7 @@ class ResourceViewSet(GenericViewSet):
'count_safe':m['material__count_safe']}) 'count_safe':m['material__count_safe']})
return Response(res) return Response(res)
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=ResourceCalListSerializer) @action(methods=['post'], detail=False, perms_map={'post':'resource_cal_equip'}, serializer_class=ResourceCalListSerializer)
def cal_equip(self, request, pk=None): def cal_equip(self, request, pk=None):
""" """
设备状态查看 设备状态查看

View File

@ -2,7 +2,7 @@
from django.shortcuts import render from django.shortcuts import render
from numpy import delete from numpy import delete
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ModelViewSet
from rest_framework.mixins import CreateModelMixin, DestroyModelMixin, ListModelMixin from rest_framework.mixins import CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin
from rest_framework.viewsets import GenericViewSet from rest_framework.viewsets import GenericViewSet
from apps.pum.models import PuOrder, PuOrderItem, Vendor from apps.pum.models import PuOrder, PuOrderItem, Vendor
from apps.pum.serializers import PuOrderCreateUpdateSerializer, PuOrderItemCreateSerializer, PuOrderItemSerializer, PuOrderItemUpdateSerializer, PuOrderSerializer, VendorSerializer from apps.pum.serializers import PuOrderCreateUpdateSerializer, PuOrderItemCreateSerializer, PuOrderItemSerializer, PuOrderItemUpdateSerializer, PuOrderSerializer, VendorSerializer
@ -31,8 +31,8 @@ class PuOrderViewSet(CreateUpdateModelAMixin, ModelViewSet):
""" """
采购订单-增删改查 采购订单-增删改查
""" """
perms_map = {'get': '*', 'post': '*', perms_map = {'get': '*', 'post': 'puorder_create',
'put': '*', 'delete': '*'} 'put': 'puorder_update', 'delete': 'puorder_delete'}
queryset = PuOrder.objects.select_related('vendor').\ queryset = PuOrder.objects.select_related('vendor').\
prefetch_related('item_pu_order').all() prefetch_related('item_pu_order').all()
serializer_class = PuOrderSerializer serializer_class = PuOrderSerializer
@ -57,7 +57,7 @@ class PuOrderViewSet(CreateUpdateModelAMixin, ModelViewSet):
raise ValidationError('该采购订单已审核') raise ValidationError('该采购订单已审核')
return super().destroy(request, *args, **kwargs) return super().destroy(request, *args, **kwargs)
@action(methods=['post'], detail=True, perms_map={'post':'*'}, @action(methods=['post'], detail=True, perms_map={'post':'puorder_audit'},
serializer_class=serializers.Serializer) serializer_class=serializers.Serializer)
def audit(self, request, pk=None): def audit(self, request, pk=None):
obj = self.get_object() obj = self.get_object()
@ -68,12 +68,12 @@ class PuOrderViewSet(CreateUpdateModelAMixin, ModelViewSet):
return Response() return Response()
return Response('订单状态有误', status=status.HTTP_400_BAD_REQUEST) return Response('订单状态有误', status=status.HTTP_400_BAD_REQUEST)
class PuOrderItemViewSet(CreateModelMixin, ListModelMixin, DestroyModelMixin, GenericViewSet): class PuOrderItemViewSet(CreateModelMixin, ListModelMixin, DestroyModelMixin, RetrieveModelMixin, GenericViewSet):
""" """
采购订单条目 采购订单条目
""" """
perms_map = {'get': '*', 'post': '*', perms_map = {'get': '*', 'post': 'puorder_update',
'put': '*', 'delete': '*'} 'put': 'puorder_update', 'delete': 'puorder_update'}
queryset = PuOrderItem.objects.select_related('material').all() queryset = PuOrderItem.objects.select_related('material').all()
serializer_class = PuOrderItemSerializer serializer_class = PuOrderItemSerializer
filterset_fields = ['pu_order', 'material'] filterset_fields = ['pu_order', 'material']

View File

@ -129,13 +129,14 @@ class TestRecordUpdateSerializer(serializers.ModelSerializer):
record_data = validated_data.pop('record_data') record_data = validated_data.pop('record_data')
for attr, value in validated_data.items(): for attr, value in validated_data.items():
setattr(instance, attr, value) setattr(instance, attr, value)
instance.save(update_by=update_by) instance.update_by = update_by
instance.save()
for i in record_data: for i in record_data:
tri = i['id'] tri = i['id']
tri.is_testok = i['is_testok']
tri.is_hidden = i['is_hidden']
tri.field_value = i['field_value']
if i['field_value'] != tri.field_value: if i['field_value'] != tri.field_value:
tri.field_value = i['field_value']
tri.update_by = update_by tri.update_by = update_by
tri.is_testok = i['is_testok'] tri.save()
tri.is_hidden = i['is_hidden']
tri.save()
return instance return instance

View File

@ -52,7 +52,7 @@ class TestRecordViewSet(ListModelMixin, UpdateModelMixin, RetrieveModelMixin, De
""" """
检验记录 检验记录
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'testrecord_update', 'delete':'testrecord_delete'}
queryset = TestRecord.objects.select_related('fifo_item', 'form').prefetch_related('item_test_record').all() queryset = TestRecord.objects.select_related('fifo_item', 'form').prefetch_related('item_test_record').all()
serializer_class = TestRecordListSerializer serializer_class = TestRecordListSerializer
filterset_fields = ['wproduct', 'material', 'step', 'subproduction_plan', 'fifo_item', 'origin_test', 'type'] filterset_fields = ['wproduct', 'material', 'step', 'subproduction_plan', 'fifo_item', 'origin_test', 'type']
@ -80,15 +80,16 @@ class TestRecordViewSet(ListModelMixin, UpdateModelMixin, RetrieveModelMixin, De
WpmService.add_wproduct_flow_log(obj.wproduct, 'test_delete') WpmService.add_wproduct_flow_log(obj.wproduct, 'test_delete')
return super().destroy(request, *args, **kwargs) return super().destroy(request, *args, **kwargs)
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=TestRecordUpdateSerializer) @action(methods=['post'], detail=True, perms_map={'post':'testrecord_submit'}, serializer_class=serializers.Serializer)
def submit(self, request, pk=None): def submit(self, request, pk=None):
obj = self.get_object() obj = self.get_object()
if obj.is_submited and obj.is_midtesting is False: if obj.is_submited and obj.is_midtesting is False:
raise exceptions.APIException('该记录已提交') raise exceptions.APIException('该记录已提交')
# 校验是否有未填项目 # 校验是否有未填项目
if obj.type != TestRecord.TEST_PROCESS_RE and obj.is_midtesting is False: if obj.type != TestRecord.TEST_PROCESS_RE and obj.is_midtesting is False:
if TestRecordItem.objects.filter(field_value__isnull=True, is_hidden=False, test_record=obj).exists(): items_not = TestRecordItem.objects.filter(field_value__isnull=True, is_hidden=False, test_record=obj)
raise exceptions.APIException('存在未填写项目') if items_not.exists():
raise exceptions.APIException('存在未填写项目:'+ ','.join(list(items_not.values_list('form_field__field_name', flat=True))))
with transaction.atomic(): with transaction.atomic():
obj.is_submited=True obj.is_submited=True
obj.save() obj.save()

View File

@ -12,7 +12,8 @@ class CustomerViewSet(CreateUpdateCustomMixin, ModelViewSet):
""" """
客户-增删改查 客户-增删改查
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'customer_create',
'put':'customer_update', 'delete':'customer_delete'}
queryset = Customer.objects.all() queryset = Customer.objects.all()
serializer_class = CustomerSerializer serializer_class = CustomerSerializer
search_fields = ['name', 'contact'] search_fields = ['name', 'contact']
@ -30,7 +31,8 @@ class ContractViewSet(CreateUpdateCustomMixin, ModelViewSet):
""" """
合同-增删改查 合同-增删改查
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'contract_create',
'put':'contract_update', 'delete':'contract_delete'}
queryset = Contract.objects.select_related('customer').all() queryset = Contract.objects.select_related('customer').all()
serializer_class = ContractSerializer serializer_class = ContractSerializer
search_fields = ['name'] search_fields = ['name']
@ -47,7 +49,8 @@ class OrderViewSet(CreateUpdateCustomMixin, ModelViewSet):
""" """
订单-增删改查 订单-增删改查
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'order_create',
'put':'order_update', 'delete':'order_delete'}
queryset = Order.objects.select_related('contract', 'customer').all() queryset = Order.objects.select_related('contract', 'customer').all()
serializer_class = OrderSerializer serializer_class = OrderSerializer
search_fields = ['number', 'product'] search_fields = ['number', 'product']
@ -60,7 +63,7 @@ class OrderViewSet(CreateUpdateCustomMixin, ModelViewSet):
return OrderCreateUpdateSerializer return OrderCreateUpdateSerializer
return super().get_serializer_class() return super().get_serializer_class()
@action(methods=['get'], detail=False, perms_map={'get':'*'}) @action(methods=['get'], detail=False, perms_map={'get':'order_toplan'})
def toplan(self, request, pk=None): def toplan(self, request, pk=None):
queryset = Order.objects.filter(count__gt=F('planed_count')).order_by('-id') queryset = Order.objects.filter(count__gt=F('planed_count')).order_by('-id')
page = self.paginate_queryset(queryset) page = self.paginate_queryset(queryset)

View File

@ -21,7 +21,7 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
""" """
销售记录 销售记录
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'sale_create', 'delete':'sale_delete'}
queryset = Sale.objects.select_related('customer', 'order', 'product', 'order__contract').all() queryset = Sale.objects.select_related('customer', 'order', 'product', 'order__contract').all()
serializer_class = SaleListSerializer serializer_class = SaleListSerializer
search_fields = ['customer__name', 'order__number'] search_fields = ['customer__name', 'order__number']
@ -57,7 +57,7 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
SaleProduct.objects.bulk_create(i_l) SaleProduct.objects.bulk_create(i_l)
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=serializers.Serializer) @action(methods=['post'], detail=True, perms_map={'post':'sale_audit'}, serializer_class=serializers.Serializer)
@transaction.atomic @transaction.atomic
def audit(self, request, pk=None): def audit(self, request, pk=None):
""" """
@ -124,7 +124,7 @@ class SaleProductViewSet(ListModelMixin, DestroyModelMixin, CreateModelMixin, Ge
""" """
销售记录关联产品 销售记录关联产品
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'sale_update', 'delete':'sale_delete'}
queryset = SaleProduct.objects.select_related('iproduct', 'iproduct__material', 'iproduct__warehouse').all() queryset = SaleProduct.objects.select_related('iproduct', 'iproduct__material', 'iproduct__warehouse').all()
serializer_class = SaleProductListSerializer serializer_class = SaleProductListSerializer
search_fields = [] search_fields = []

View File

@ -24,6 +24,7 @@ from .scripts import GetParticipants, HandleScripts
# Create your views here. # Create your views here.
class FromCodeListView(APIView): class FromCodeListView(APIView):
perms_map = {'*':'*'}
def get(self, request, format=None): def get(self, request, format=None):
""" """
获取处理人代码列表 获取处理人代码列表
@ -88,7 +89,8 @@ class WorkflowViewSet(CreateUpdateModelAMixin, ModelViewSet):
return Response(ret) return Response(ret)
class StateViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet): class StateViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'workflow_update',
'put':'workflow_update', 'delete':'workflow_delete'}
queryset = State.objects.all() queryset = State.objects.all()
serializer_class = StateSerializer serializer_class = StateSerializer
search_fields = ['name'] search_fields = ['name']
@ -96,7 +98,8 @@ class StateViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, Destr
ordering = ['sort'] ordering = ['sort']
class TransitionViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet): class TransitionViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'workflow_update',
'put':'workflow_update', 'delete':'workflow_delete'}
queryset = Transition.objects.all() queryset = Transition.objects.all()
serializer_class = TransitionSerializer serializer_class = TransitionSerializer
search_fields = ['name'] search_fields = ['name']
@ -104,7 +107,8 @@ class TransitionViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin,
ordering = ['id'] ordering = ['id']
class CustomFieldViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet): class CustomFieldViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'workflow_update',
'put':'workflow_update', 'delete':'workflow_delete'}
queryset = CustomField.objects.all() queryset = CustomField.objects.all()
serializer_class = CustomFieldSerializer serializer_class = CustomFieldSerializer
search_fields = ['field_name'] search_fields = ['field_name']
@ -117,7 +121,7 @@ class CustomFieldViewSet(CreateModelMixin, UpdateModelMixin, RetrieveModelMixin,
return super().get_serializer_class() return super().get_serializer_class()
class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin, ListModelMixin, RetrieveModelMixin, GenericViewSet): class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin, ListModelMixin, RetrieveModelMixin, GenericViewSet):
perms_map = {'*':'*'} perms_map = {'get':'*', 'post':'ticket_create'}
queryset = Ticket.objects.all() queryset = Ticket.objects.all()
serializer_class = TicketSerializer serializer_class = TicketSerializer
search_fields = ['title'] search_fields = ['title']
@ -348,7 +352,7 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
else: else:
return Response('工单不可关闭', status=status.HTTP_400_BAD_REQUEST) return Response('工单不可关闭', status=status.HTTP_400_BAD_REQUEST)
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=TicketDestorySerializer) @action(methods=['post'], detail=False, perms_map={'post':'ticket_deletes'}, serializer_class=TicketDestorySerializer)
def destory(self, request, pk=None): def destory(self, request, pk=None):
""" """
批量物理删除 批量物理删除
@ -362,7 +366,7 @@ class TicketFlowViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
""" """
工单日志 工单日志
""" """
perms_map = {'*':'*'} perms_map = {'get':'*'}
queryset = TicketFlow.objects.all() queryset = TicketFlow.objects.all()
serializer_class = TicketFlowSerializer serializer_class = TicketFlowSerializer
search_fields = ['suggestion'] search_fields = ['suggestion']

View File

@ -55,7 +55,7 @@ class WpmService(object):
wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT
elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST and \ elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST and \
test.is_midtesing is True: test.is_midtesting is True:
wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT
test_i = test test_i = test

View File

@ -47,7 +47,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
""" """
车间生产计划 车间生产计划
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = SubProductionPlan.objects.select_related( queryset = SubProductionPlan.objects.select_related(
'process', 'workshop', 'subproduction', 'product').exclude(state=0) 'process', 'workshop', 'subproduction', 'product').exclude(state=0)
search_fields = [] search_fields = []
@ -57,7 +57,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
ordering_fields = [] ordering_fields = []
ordering = ['-update_time'] ordering = ['-update_time']
@action(methods=['post', 'get'], detail=True, perms_map={'post': '*', 'get': '*'}, serializer_class=PickHalfsSerializer) @action(methods=['post', 'get'], detail=True, perms_map={'post': 'pick_half', 'get': '*'}, serializer_class=PickHalfsSerializer)
@transaction.atomic @transaction.atomic
def pick_half(self, request, pk=None): def pick_half(self, request, pk=None):
""" """
@ -124,7 +124,7 @@ class WMaterialViewSet(CreateUpdateModelAMixin, ListModelMixin, GenericViewSet):
""" """
车间物料表 车间物料表
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = WMaterial.objects.select_related( queryset = WMaterial.objects.select_related(
'material', 'subproduction_plan').filter(count__gt=0) 'material', 'subproduction_plan').filter(count__gt=0)
serializer_class = WMaterialListSerializer serializer_class = WMaterialListSerializer
@ -132,7 +132,7 @@ class WMaterialViewSet(CreateUpdateModelAMixin, ListModelMixin, GenericViewSet):
ordering_fields = ['material__number'] ordering_fields = ['material__number']
ordering = ['material__number'] ordering = ['material__number']
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=PickSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'pick'}, serializer_class=PickSerializer)
def pick(self, request, pk=None): def pick(self, request, pk=None):
""" """
领料 领料
@ -148,7 +148,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
""" """
半成品 半成品
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = WProduct.objects.select_related('step', 'material', queryset = WProduct.objects.select_related('step', 'material',
'subproduction_plan', 'warehouse', 'subproduction_plan__production_plan__order', 'subproduction_plan', 'warehouse', 'subproduction_plan__production_plan__order',
'to_order').prefetch_related('wp_child') 'to_order').prefetch_related('wp_child')
@ -169,7 +169,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
queryset = queryset.filter(is_hidden=False) queryset = queryset.filter(is_hidden=False)
return queryset return queryset
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=WpmTestFormInitSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'wp_test_init'}, serializer_class=WpmTestFormInitSerializer)
@transaction.atomic @transaction.atomic
def test_init(self, request, pk=None): def test_init(self, request, pk=None):
""" """
@ -228,7 +228,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
return Response(TestRecordDetailSerializer(instance=tr).data) return Response(TestRecordDetailSerializer(instance=tr).data)
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=WproductPutInsSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'wp_putins'}, serializer_class=WproductPutInsSerializer)
@transaction.atomic @transaction.atomic
def putins(self, request, pk=None): def putins(self, request, pk=None):
""" """
@ -287,7 +287,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
WpmService.add_wproduct_flow_log(i, 'putins') WpmService.add_wproduct_flow_log(i, 'putins')
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=WproductPutInSerializer) @action(methods=['post'], detail=True, perms_map={'post': 'wp_putin'}, serializer_class=WproductPutInSerializer)
@transaction.atomic @transaction.atomic
def putin(self, request, pk=None): def putin(self, request, pk=None):
""" """
@ -334,7 +334,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
WpmService.add_wproduct_flow_log(wproduct, 'putin') WpmService.add_wproduct_flow_log(wproduct, 'putin')
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=ScrapSerializer) @action(methods=['post'], detail=True, perms_map={'post': 'wp_scrap'}, serializer_class=ScrapSerializer)
def scrap(self, request, pk=None): def scrap(self, request, pk=None):
""" """
报废操作 报废操作
@ -399,7 +399,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
else: else:
raise exceptions.APIException('未找到对应审批流程') raise exceptions.APIException('未找到对应审批流程')
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=WproductMtestSerializer) @action(methods=['post'], detail=True, perms_map={'post': 'wp_mtest'}, serializer_class=WproductMtestSerializer)
@transaction.atomic @transaction.atomic
def mtest(self, request, pk=None): def mtest(self, request, pk=None):
""" """
@ -424,7 +424,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
WpmService.add_wproduct_flow_log(instance=obj, change_str=change_str) WpmService.add_wproduct_flow_log(instance=obj, change_str=change_str)
return Response() return Response()
@action(methods=['get'], detail=True, perms_map={'get': '*'}) @action(methods=['get'], detail=True, perms_map={'get': 'wp_card'})
def card(self, request, pk=None): def card(self, request, pk=None):
""" """
流程卡 流程卡
@ -449,7 +449,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
ret.append([str(index + 1), item['step_name'], item['actions']]) ret.append([str(index + 1), item['step_name'], item['actions']])
return Response(ret) return Response(ret)
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=WproductNeedToOrderSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'wp_need_to_order'}, serializer_class=WproductNeedToOrderSerializer)
@transaction.atomic @transaction.atomic
def need_to_order(self, request, pk=None): def need_to_order(self, request, pk=None):
""" """
@ -467,7 +467,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
WpmService.add_wproduct_flow_log(i, change_str='need_to_order') WpmService.add_wproduct_flow_log(i, change_str='need_to_order')
return Response() return Response()
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=WproductToOrderSerializer) @action(methods=['post'], detail=False, perms_map={'post': 'wp_to_order'}, serializer_class=WproductToOrderSerializer)
@transaction.atomic @transaction.atomic
def to_order(self, request, pk=None): def to_order(self, request, pk=None):
""" """
@ -496,7 +496,7 @@ class WproductTicketViewSet(ListModelMixin, GenericViewSet):
""" """
玻璃审批工单 玻璃审批工单
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = WprouctTicket.objects.select_related('step', 'material', 'subproduction_plan', queryset = WprouctTicket.objects.select_related('step', 'material', 'subproduction_plan',
'resp_process', 'subproduction_plan__production_plan__order', 'resp_process', 'subproduction_plan__production_plan__order',
'subproduction_plan__production_plan') 'subproduction_plan__production_plan')
@ -512,7 +512,8 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
""" """
生产操作记录 生产操作记录
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_create',
'put':'operation_update', 'delete':'operation_delete'}
queryset = Operation.objects.select_related('step').prefetch_related( queryset = Operation.objects.select_related('step').prefetch_related(
'ow_operation', 'oe_operation', 'or_operation').all() 'ow_operation', 'oe_operation', 'or_operation').all()
serializer_class = OperationListSerializer serializer_class = OperationListSerializer
@ -622,7 +623,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
opm.save() opm.save()
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=serializers.Serializer) @action(methods=['post'], detail=True, perms_map={'post': 'operation_submit'}, serializer_class=serializers.Serializer)
@transaction.atomic @transaction.atomic
def submit(self, request, pk=None): def submit(self, request, pk=None):
""" """
@ -775,7 +776,8 @@ class OperationWproductViewSet(ListModelMixin, DestroyModelMixin, UpdateModelMix
""" """
操作使用的半成品 操作使用的半成品
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_update',
'put':'operation_update', 'delete':'operation_delete'}
queryset = OperationWproduct.objects.select_related( queryset = OperationWproduct.objects.select_related(
'subproduction_plan', 'material').all() 'subproduction_plan', 'material').all()
serializer_class = OperationWproductListSerializer serializer_class = OperationWproductListSerializer
@ -804,7 +806,8 @@ class OperationEquipViewSet(ListModelMixin, DestroyModelMixin, UpdateModelMixin,
""" """
操作使用的设备 操作使用的设备
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_update',
'put':'operation_update', 'delete':'operation_delete'}
queryset = OperationEquip.objects.select_related( queryset = OperationEquip.objects.select_related(
'operation', 'equip').all() 'operation', 'equip').all()
serializer_class = OperationEquipListSerializer serializer_class = OperationEquipListSerializer
@ -836,7 +839,8 @@ class OperationRecordViewSet(ListModelMixin, DestroyModelMixin, UpdateModelMixin
""" """
操作使用的自定义表格 操作使用的自定义表格
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_update',
'put':'operation_update', 'delete':'operation_delete'}
queryset = OperationRecord.objects.select_related( queryset = OperationRecord.objects.select_related(
'operation', 'form').all() 'operation', 'form').all()
serializer_class = OperationRecordListSerializer serializer_class = OperationRecordListSerializer
@ -880,7 +884,7 @@ class OperationMaterialInputViewSet(ListModelMixin, CreateModelMixin, DestroyMod
""" """
消耗物料 消耗物料
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_update', 'delete':'operation_delete'}
queryset = OperationMaterial.objects.select_related( queryset = OperationMaterial.objects.select_related(
'operation', 'subproduction_plan').filter(type=SubprodctionMaterial.SUB_MA_TYPE_IN) 'operation', 'subproduction_plan').filter(type=SubprodctionMaterial.SUB_MA_TYPE_IN)
serializer_class = OperationMaterialListSerializer serializer_class = OperationMaterialListSerializer
@ -893,7 +897,7 @@ class OperationMaterialInputViewSet(ListModelMixin, CreateModelMixin, DestroyMod
return OperationMaterialCreate1Serailizer return OperationMaterialCreate1Serailizer
return super().get_serializer_class() return super().get_serializer_class()
@action(methods=['post'], detail=False, perms_map={'post': '*'}, @action(methods=['post'], detail=False, perms_map={'post': 'operation_update'},
serializer_class=OperationMaterialCreate1ListSerailizer) serializer_class=OperationMaterialCreate1ListSerailizer)
def creates(self, request, pk=None): def creates(self, request, pk=None):
""" """
@ -917,7 +921,7 @@ class CuttingListViewSet(ListModelMixin, GenericViewSet):
""" """
下料清单 下料清单
""" """
perms_map = {'*': '*'} perms_map = {'get': '*'}
queryset = OperationMaterial.objects.select_related('operation', queryset = OperationMaterial.objects.select_related('operation',
'subproduction_plan', 'material', 'subproduction_plan', 'material',
'operation__create_by').filter(operation__step__id=1, 'operation__create_by').filter(operation__step__id=1,
@ -932,7 +936,7 @@ class OperationMaterialOutputViewSet(ListModelMixin, CreateModelMixin, DestroyMo
""" """
产出物料 产出物料
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_update', 'delete':'operation_delete'}
queryset = OperationMaterial.objects.select_related( queryset = OperationMaterial.objects.select_related(
'operation', 'subproduction_plan').filter(type=SubprodctionMaterial.SUB_MA_TYPE_OUT) 'operation', 'subproduction_plan').filter(type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
serializer_class = OperationMaterialListSerializer serializer_class = OperationMaterialListSerializer
@ -945,7 +949,7 @@ class OperationMaterialOutputViewSet(ListModelMixin, CreateModelMixin, DestroyMo
return OperationMaterialCreate2Serailizer return OperationMaterialCreate2Serailizer
return super().get_serializer_class() return super().get_serializer_class()
@action(methods=['post'], detail=False, perms_map={'post': '*'}, @action(methods=['post'], detail=False, perms_map={'post': 'operation_update'},
serializer_class=OperationMaterialCreate2ListSerailizer) serializer_class=OperationMaterialCreate2ListSerailizer)
def creates(self, request, pk=None): def creates(self, request, pk=None):
""" """
@ -969,7 +973,7 @@ class OperationMaterialToolViewSet(ListModelMixin, CreateModelMixin, DestroyMode
""" """
工具工装 工具工装
""" """
perms_map = {'*': '*'} perms_map = {'get': '*', 'post':'operation_update', 'delete':'operation_delete'}
queryset = OperationMaterial.objects.select_related( queryset = OperationMaterial.objects.select_related(
'operation', 'subproduction_plan').filter(type=SubprodctionMaterial.SUB_MA_TYPE_TOOL) 'operation', 'subproduction_plan').filter(type=SubprodctionMaterial.SUB_MA_TYPE_TOOL)
serializer_class = OperationMaterialListSerializer serializer_class = OperationMaterialListSerializer