Procházet zdrojové kódy

project attendance sheet notation

hgh před 1 rokem
rodič
revize
b965f9e2c8

+ 19 - 1
src/api/models/ProjectAttendanceSheets.js

@@ -10,7 +10,8 @@ export default class ProjectAttendanceSheetsAPI extends APIRepository {
       project_sheets: '/lma/project_attendance_sheets/project_sheets',
       byId: (id) => '/lma/project_attendance_sheets/' + id,
       verify: (id) => '/lma/project_attendance_sheets/' + id + '/verify',
-      notVerify: (id) => '/lma/project_attendance_sheets/' + id + '/not_verify'
+      notVerify: (id) => '/lma/project_attendance_sheets/' + id + '/not_verify',
+      saveNotation: (id) => '/lma/project_attendance_sheets/' + id + '/save_notation'
     }
     this.CacheList = {
       base: this.name + this.APIAdresses.base,
@@ -111,4 +112,21 @@ export default class ProjectAttendanceSheetsAPI extends APIRepository {
       }
     })
   }
+
+  saveNotation (projectAttendanceSheetsId, notation) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.saveNotation(projectAttendanceSheetsId),
+      data: {
+        notation
+      },
+      resolveCallback: (response) => {
+        return new ProjectAttendanceSheets(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
 }

+ 38 - 40
src/components/Widgets/ProjectAttendanceSheet/AdminProjectAttendanceSheetShow/AdminProjectAttendanceSheetShow.vue

@@ -7,8 +7,8 @@
       >
     </q-btn>
   </div>
-  <entity-show v-if="mounted"
-               ref="entityShow"
+  <entity-edit v-if="mounted"
+               ref="entityEdit"
                v-model:value="inputs"
                title="جزییات پروژه"
                :api="api"
@@ -21,11 +21,16 @@
                :after-load-input-data="afterLoadInputData">
     <template #after-form-builder>
       <div class="flex justify-end q-mt-md">
+        <q-btn color="secondary"
+               label="ثبت توضیحات"
+               :loading="loading"
+               class="q-mr-sm"
+               @click="saveNotation" />
         <q-btn color="red"
                outline
                label="انجام نشده"
                :loading="loading"
-               class="q-mr-md"
+               class="q-mr-sm"
                @click="notVerify" />
         <q-btn color="primary"
                label="انجام شده"
@@ -33,44 +38,23 @@
                @click="verify" />
       </div>
     </template>
-  </entity-show>
-  <entity-edit v-if="mounted"
-               ref="entityEdit"
-               v-model:value="editInputs"
-               title="توضیحات تصحیح"
-               :api="api"
-               :show-close-button="false"
-               :show-edit-button="false"
-               :show-expand-button="false"
-               :show-save-button="false"
-               :show-index-button="false"
-               :show-reload-button="false"
-               :after-load-input-data="afterLoadInputData">
-    <template #after-form-builder>
-      <div class="flex justify-end q-mt-md">
-        <q-btn color="primary"
-               label="ثبت توضیحات"
-               :loading="loading"
-               @click="saveNotation" />
-      </div>
-    </template>
   </entity-edit>
 </template>
 
 <script>
 import { shallowRef } from 'vue'
-import { EntityShow, EntityEdit } from 'quasar-crud'
+import { EntityEdit } from 'quasar-crud'
 import { Project } from 'src/models/Project.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { ProjectAttendanceSheets } from 'src/models/ProjectAttendanceSheets.js'
 import ContentsSelector from 'src/components/FormBuilderCustumComponents/ContentsSelector/ContentsSelector.vue'
+import { FormBuilderAssist } from 'quasar-form-builder'
 
 const ContentsSelectorComp = shallowRef(ContentsSelector)
 
 export default {
   name: 'AdminProjectAttendanceSheetShow',
   components: {
-    EntityShow,
     EntityEdit
   },
   data () {
@@ -83,11 +67,11 @@ export default {
       api: APIGateway.projectAttendanceSheets.APIAdresses.byId(projectAttendanceSheetsId),
       inputs: [
         { type: 'separator', name: 'space', label: 'مشخصات اندیشه جو', className: 'custom-separator', col: 'col-12' },
-        { type: 'input', name: 'owner_info.firstname', responseKey: 'owner_info.firstname', label: 'نام', placeholder: ' ', col: 'col-md-6 col-12' },
-        { type: 'input', name: 'owner_info.lastname', responseKey: 'owner_info.lastname', label: 'نام خانوادگی', placeholder: ' ', col: 'col-md-6 col-12' },
+        { type: 'input', name: 'owner_info.firstname', responseKey: 'owner_info.firstname', label: 'نام', placeholder: ' ', col: 'col-md-6 col-12', readonly: true },
+        { type: 'input', name: 'owner_info.lastname', responseKey: 'owner_info.lastname', label: 'نام خانوادگی', placeholder: ' ', col: 'col-md-6 col-12', readonly: true },
 
         { type: 'separator', name: 'space', label: 'مشخصات پروژه', className: 'custom-separator', col: 'col-12' },
-        { type: 'input', name: 'project_info.title', responseKey: 'project_info.title', label: 'عنوان پروژه', placeholder: ' ', col: 'col-md-9 col-12' },
+        { type: 'input', name: 'project_info.title', responseKey: 'project_info.title', label: 'عنوان پروژه', placeholder: ' ', col: 'col-md-9 col-12', readonly: true },
         {
           type: 'select',
           name: 'project_info.type',
@@ -95,13 +79,14 @@ export default {
           label: 'نوع پروژه',
           options: (new Project()).typeEnums,
           placeholder: ' ',
-          col: 'col-md-3 col-12'
+          col: 'col-md-3 col-12',
+          readonly: true
         },
-        { type: 'inputEditor', name: 'project_info.description', responseKey: 'project_info.description', label: 'توضیحات پروژه', placeholder: ' ', col: 'col-12' },
+        { type: 'inputEditor', name: 'project_info.description', responseKey: 'project_info.description', label: 'توضیحات پروژه', placeholder: ' ', col: 'col-12', readonly: true },
 
         { type: 'separator', name: 'space', label: 'پاسخ اندیشه چو', className: 'custom-separator', col: 'col-12' },
-        { type: 'inputEditor', name: 'answer_text', responseKey: 'answer_text', label: 'پاسخ کاربر', placeholder: ' ', col: 'col-12' },
-        { type: 'file', name: 'answer_attachment', responseKey: 'answer_attachment', label: 'فایل ضمیمه کاربر', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'inputEditor', name: 'answer_text', responseKey: 'answer_text', label: 'پاسخ کاربر', placeholder: ' ', col: 'col-12', readonly: true },
+        { type: 'file', name: 'answer_attachment', responseKey: 'answer_attachment', label: 'فایل ضمیمه کاربر', placeholder: ' ', col: 'col-md-3 col-12', readonly: true },
         {
           type: 'select',
           name: 'answer_status',
@@ -109,7 +94,8 @@ export default {
           label: 'وضعیت',
           options: (new ProjectAttendanceSheets()).answer_statusEnums,
           placeholder: ' ',
-          col: 'col-md-3 col-12'
+          col: 'col-md-3 col-12',
+          readonly: true
         },
         {
           type: 'select',
@@ -118,15 +104,13 @@ export default {
           label: 'نتیجه',
           options: (new ProjectAttendanceSheets()).is_answer_verifiedEnums,
           placeholder: ' ',
-          col: 'col-md-3 col-12'
+          col: 'col-md-3 col-12',
+          readonly: true
         },
         { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
 
-        { type: ContentsSelectorComp, name: 'project_info.contents_info', responseKey: 'project_info.contents_info', col: 'col-12' },
-        { type: 'inputEditor', name: 'project_info.correct_answer', responseKey: 'project_info.correct_answer', label: 'پاسخ صحیح', placeholder: ' ', col: 'col-12' },
-        { type: 'inputEditor', name: 'notation', responseKey: 'notation', label: 'توضیحات تصحیح کننده', placeholder: ' ', col: 'col-12' }
-      ],
-      editInputs: [
+        { type: ContentsSelectorComp, name: 'project_info.contents_info', responseKey: 'project_info.contents_info', col: 'col-12', readonly: true },
+        { type: 'inputEditor', name: 'project_info.correct_answer', responseKey: 'project_info.correct_answer', label: 'پاسخ صحیح', placeholder: ' ', col: 'col-12', readonly: true },
         { type: 'inputEditor', name: 'notation', responseKey: 'notation', label: 'توضیحات تصحیح کننده', placeholder: ' ', col: 'col-12' }
       ]
     }
@@ -166,6 +150,20 @@ export default {
           this.loading = false
           this.reloadData()
         })
+    },
+    saveNotation () {
+      this.loading = true
+      const notation = FormBuilderAssist.getInputsByName(this.inputs, 'notation')?.value
+      APIGateway.projectAttendanceSheets.saveNotation(this.$route.params.project_attendance_sheets_id, notation)
+        .then(() => {
+          this.loading = false
+          this.reloadData()
+          // this.$router.go(-1)
+        })
+        .catch(() => {
+          this.loading = false
+          this.reloadData()
+        })
     }
   }
 }

+ 3 - 1
src/pages/User/Profile/projectInfo.vue

@@ -114,7 +114,9 @@ export default {
       attendanceSheetsShowInputs: [
         { type: 'separator', name: 'space', label: 'انجام پروژه', className: 'custom-separator', col: 'col-12' },
         { type: 'inputEditor', name: 'answer_text', responseKey: 'answer_text', label: 'متن پاسخ', placeholder: ' ', col: 'col-12' },
-        { type: 'file', name: 'answer_attachment', responseKey: 'answer_attachment', label: 'فایل ضمیمه', placeholder: ' ', col: 'col-md-4 col-12' }
+        { type: 'file', name: 'answer_attachment', responseKey: 'answer_attachment', label: 'فایل ضمیمه', placeholder: ' ', col: 'col-md-4 col-12' },
+        { type: 'separator', name: 'space', label: 'توضیحات مصحح', className: 'custom-separator', col: 'col-12' },
+        { type: 'inputEditor', name: 'notation', responseKey: 'notation', label: '', placeholder: ' ', col: 'col-12' }
       ]
     }
   },