diff --git a/client/src/api/qa.js b/client/src/api/qa.js new file mode 100644 index 0000000..1617451 --- /dev/null +++ b/client/src/api/qa.js @@ -0,0 +1,57 @@ +import request from '@/utils/request' + + + +export function getRcs(query) { + return request({ + url: '/info/qa/', + method: 'get', + params: query + }) + } + +export function getMyRcs(query) { + return request({ + url: '/info/qa/activate_info/', + method: 'get', + params: query + }) +} + + export function getRc(id) { + return request({ + url: `/info/qa/${id}/`, + method: 'get' + }) + } + + + export function updateRc(id, data) { + return request({ + url: `/info/qa/${id}/`, + method: 'put', + data + }) + } + + export function createRc(data) { + return request({ + url: `/info/qa/`, + method: 'post', + data + }) + } + +export function getRc_activate() { + return request({ + url: `/info/qa/activate_info/`, + method: 'get' + }) + } + + export function del_activate(id) { + return request({ + url: `/info/qa/${id}/`, + method: 'delete' + }) + } diff --git a/client/src/router/index.js b/client/src/router/index.js index f520003..e2dbd6d 100644 --- a/client/src/router/index.js +++ b/client/src/router/index.js @@ -425,13 +425,13 @@ export const asyncRoutes = [ path: 'qualityCommend', name: 'qualityCommend', component: () => import('@/views/informatiomCollect/qualityCommend.vue'), - meta: { title: '质量表彰', perms: ['infoCollect_QC'] } + meta: { title: '质量活动', perms: ['infoCollect_QC'] } }, { path: 'qualityActive.', name: 'qualityActive.', component: () => import('@/views/informatiomCollect/qualityActive.vue'), - meta: { title: '质量活动', perms: ['infoCollect_QA'] } + meta: { title: '质量表彰', perms: ['infoCollect_QA'] } }, { path: 'laboratoryContact', diff --git a/client/src/views/informatiomCollect/qualityCommend.vue b/client/src/views/informatiomCollect/qualityCommend.vue index c7a3911..1ea4bd6 100644 --- a/client/src/views/informatiomCollect/qualityCommend.vue +++ b/client/src/views/informatiomCollect/qualityCommend.vue @@ -4,23 +4,28 @@ 新增 - - - + + + - - - - - - - + + + + + + + + +
+ 质量活动 +
+ +
- + - - + + - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + +
取消 @@ -66,16 +121,36 @@ import Pagination from "@/components/Pagination"; // secondary package based on import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import { getDictList, getDictTypeList } from "@/api/dict"; +import { getRcs, createRc, del_activate, updateRc, getMyRcs } from "@/api/qa"; import { upUrl, upHeaders } from "@/api/file"; + const defaultContent = { - name: "", - description: "", - file: null -}; + name: "", + roles: "", + collaborators: "", + orgunits: "", + place: "", + activate_time: "", + participations: "", + function: "", + earnings: "" + }; + export default { components: { Pagination, Treeselect }, - data() { + data(){ return { + form: { + name: "", + roles: "", + collaborators: "", + orgunits: "", + place: "", + activate_time: "", + participations: "", + function: "", + earnings: "", + }, upHeaders: upHeaders(), upUrl: upUrl(), fileList: [], @@ -95,30 +170,43 @@ export default { name: [{ required: true, message: "请输入名称", trigger: "blur" }], }, filterOrgText: "", - tableHeight: null, - }; - }, - computed: {}, - watch: { - filterOrgText(val) { - this.$refs.tree.filter(val); - }, - }, - created() { - + // tableHeight: '300px', + activateOptions:[ + {key:'组织方',value:0}, + {key:'参与方',value:1} + ], + ac_options:{0:'组织方', 1:'参与方'} + } }, mounted() { - let that = this; - let height1 = document.getElementsByClassName('app-main')[0].clientHeight; - let height2 = document.getElementsByClassName('elHeader')[0].clientHeight; - that.tableHeight = height1 - height2 - 70; - console.log(that.tableHeight) - that.getList(); + let that = this; + let height1 = document.getElementsByClassName('app-main')[0].clientHeight; + let height2 = document.getElementsByClassName('elHeader')[0].clientHeight; + that.tableHeight = height1 - height2 - 70; + console.log(that.tableHeight) + that.getList(); - }, + }, methods: { - getTableList() { - this.getList(); + + //提交表单 + submitForm(formName) { + this.$refs[formName].validate((valid) => { + if (valid) { + if (this.dialogType == "new") { + this.addData(); + } else { + this.editData(); + } + } else { + console.log("error submit!!"); + return false; + } + }); + }, + getTableList(){ + this.getList() + }, handlePreview(file) { if ("url" in file) { @@ -142,8 +230,18 @@ export default { }, getList() { - }, + this.listLoading = true; + this.tableData.results =[]; + this.tableData.count =0; + getMyRcs(this.listQuery).then((response) => { + console.log(response); + if (response.data) { + this.tableData = response.data; + } + this.listLoading = false; + }); + }, handleFilter() { this.listQuery.page = 1; @@ -181,9 +279,12 @@ export default { type: "error", }) .then(async () => { - // await deleteDoc(scope.row.id); - // this.getList(); - // this.$message.success("成功"); + await del_activate(scope.row.id).then(() => { + this.getList(); + this.$message.success("成功"); + this.getTableList(); + }) + }) .catch((err) => { console.error(err); @@ -195,9 +296,23 @@ export default { const isEdit = this.dialogType === "edit"; if (isEdit) { console.log(this.Content) - + updateRc(this.Content.id, this.Content).then((response) => { + if (response.data) { + this.tableData = response.data; + } + this.listLoading = false; + this.dialogVisible = false; + this.getTableList(); + }); } else { - + createRc(this.Content).then((response) => { + if (response.data) { + this.tableData = response.data; + } + this.listLoading = false; + this.dialogVisible = false; + this.getTableList(); + }); } } else { return false; @@ -205,6 +320,8 @@ export default { }); }, }, + }; +@/api/qa \ No newline at end of file diff --git a/server/apps/information/migrations/0011_rename_organizational_units_qualityactivities_orgunits.py b/server/apps/information/migrations/0011_rename_organizational_units_qualityactivities_orgunits.py new file mode 100644 index 0000000..534c4bd --- /dev/null +++ b/server/apps/information/migrations/0011_rename_organizational_units_qualityactivities_orgunits.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2024-03-29 08:35 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('information', '0010_rename_time_qualityactivities_activate_time'), + ] + + operations = [ + migrations.RenameField( + model_name='qualityactivities', + old_name='organizational_units', + new_name='orgunits', + ), + ] diff --git a/server/apps/information/models.py b/server/apps/information/models.py index 3ad079a..e0cb825 100644 --- a/server/apps/information/models.py +++ b/server/apps/information/models.py @@ -43,7 +43,7 @@ class QualityActivities(models.Model): name = models.CharField(max_length=20, unique=True, verbose_name='活动名称') roles = models.PositiveSmallIntegerField(max_length=20, choices=role, verbose_name='参与角色') collaborators = models.CharField(max_length=20, verbose_name='合作方') - organizational_units = models.CharField(max_length=20, verbose_name='组织单位') + orgunits = models.CharField(max_length=20, verbose_name='组织单位') place = models.CharField(max_length=50, verbose_name='活动地点') activate_time = models.DateField(verbose_name='活动时间', null=True) participations = models.IntegerField(verbose_name='活动参与单位数量', null=True, blank=True) diff --git a/server/apps/information/urls.py b/server/apps/information/urls.py index fcc304d..e76b32b 100644 --- a/server/apps/information/urls.py +++ b/server/apps/information/urls.py @@ -3,11 +3,11 @@ from rest_framework import routers from .views import AbilityReviewViewSet, QualityCommendationViewSet, QualityActivitiesViewSet, ContactViewSet, ExternalAuditorsViewSet router = routers.DefaultRouter() -router.register('abilityreviews', AbilityReviewViewSet, basename='abilityreviews') -router.register('qualitycommendation', QualityCommendationViewSet, basename='qualitycommendation') -router.register('qualityactivities', QualityActivitiesViewSet, basename='qualityactivities') +router.register('ar', AbilityReviewViewSet, basename='abilityreviews') +router.register('qc', QualityCommendationViewSet, basename='qualitycommendation') +router.register('qa', QualityActivitiesViewSet, basename='qualityactivities') router.register('contact', ContactViewSet, basename='contact') -router.register('externalauditors', ExternalAuditorsViewSet, basename='externalauditors') +router.register('ea', ExternalAuditorsViewSet, basename='externalauditors') urlpatterns = [ path('', include(router.urls)) ] \ No newline at end of file diff --git a/server/apps/information/views.py b/server/apps/information/views.py index 761ee5f..bd9230d 100644 --- a/server/apps/information/views.py +++ b/server/apps/information/views.py @@ -145,8 +145,8 @@ class QualityCommendationViewSet(ImpMixin, ModelViewSet): # 查询子以及已经本公司的质量表彰 @action(detail=False, methods=['get']) - def commentdation_info(self, *args, **kwargs): - father_dept = self.request.user.dept + def commentdation_info(self, request, *args, **kwargs): + father_dept = request.user.dept child_dept = get_child_queryset2(father_dept) query = QualityCommendation.objects.filter(department__in=child_dept) serializer = QualityCommendationSerializer(query, many=True) @@ -159,25 +159,27 @@ class QualityActivitiesViewSet(ModelViewSet): serializer_class = QualityActivitiesSerializer def create(self, request): - if Organization.objects.filter(name=self.request.data['organizational_units']).exists(): - department_id = Organization.objects.filter(name=self.request.data['organizational_units']).first().id + print("---------------------", self.request.data) + if Organization.objects.filter(name=self.request.data['orgunits']).exists(): + department_id = Organization.objects.filter(name=self.request.data['orgunits']).first().id self.request.data['department'] = department_id - print("-----------,",self.request.data) serializer = self.get_serializer(data=self.request.data) if serializer.is_valid(raise_exception=True): serializer.save() return Response(serializer.data, status = status.HTTP_201_CREATED) else: - raise ParseError("部门不存在") + raise ParseError("组织单位不存在") # 查询子以及已经本公司的质量活动 @action(detail=False, methods=['get']) - def activate_info(self, *args, **kwargs): - father_dept = self.request.user.dept - child_dept = get_child_queryset2(father_dept) + def activate_info(self, request, *args, **kwargs): + child_dept = get_child_queryset2(request.user.dept) query = QualityActivities.objects.filter(department__in=child_dept) serializer = QualityActivitiesSerializer(query, many=True) - return Response(serializer.data) + data = {'count':len(serializer.data), 'results':serializer.data} + print("return Response(serializer.data)", data) + return Response(data, status = status.HTTP_200_OK) + class ContactViewSet(mixins.CreateModelMixin, mixins.ListModelMixin,