Browse Source

upload TranscriptSheetHistory exel

hgh 1 year ago
parent
commit
2ac357374f
2 changed files with 41 additions and 1 deletions
  1. 2 1
      src/api/models/TranscriptSheetHistory.js
  2. 39 0
      src/pages/Admin/Unit/show.vue

+ 2 - 1
src/api/models/TranscriptSheetHistory.js

@@ -8,7 +8,8 @@ export default class TranscriptSheetHistoryAPI extends APIRepository {
     this.APIAdresses = {
       base: '/lma/transcript_sheet_histories',
       byId: (id) => '/lma/transcript_sheet_histories/' + id,
-      appendQuestion: (id) => '/lma/transcript_sheet_histories/' + id + '/append_question'
+      appendQuestion: (id) => '/lma/transcript_sheet_histories/' + id + '/append_question',
+      importList: '/lma/transcript_sheet_histories/import_list'
     }
     this.CacheList = {
       base: this.name + this.APIAdresses.base,

+ 39 - 0
src/pages/Admin/Unit/show.vue

@@ -157,6 +157,18 @@
                      :to="{name: 'Admin.Unit.TranscriptSheetHistory.Create', params: {unit_id: $route.params.id}}" />
             </div>
           </template>
+          <template #after-index-table>
+            <q-separator class="q-my-lg" />
+            <entity-edit ref="uploadExcelEntity"
+                         v-model:value="uploadInputs"
+                         title="ارسال لیست نمرات"
+                         :loaded-data="{}"
+                         :api="uploadAPI"
+                         :show-reload-button="false"
+                         :show-expand-button="false"
+                         :show-save-button="false"
+                         :show-close-button="false" />
+          </template>
           <template #entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
             <template v-if="inputData.col.name === 'actions'">
               <div class="q-gutter-md">
@@ -188,10 +200,14 @@ import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
 import { UnitCategoryList } from 'src/models/UnitCategory.js'
 import PostRequisites from 'src/components/Control/PostRequisites.vue'
 import FormBuilderInputEditor from 'src/components/FormBuilderCustumComponents/FormBuilderInputEditor.vue'
+import { FormBuilderAssist } from 'quasar-form-builder'
+import BtnControl from 'src/components/Control/btn.vue'
 
 const PostRequisitesComp = shallowRef(PostRequisites)
 const FormBuilderInputEditorComp = shallowRef(FormBuilderInputEditor)
 
+const BtnControlComp = shallowRef(BtnControl)
+
 export default {
   name: 'Admin.Category.Index',
   components: {
@@ -219,6 +235,13 @@ export default {
         { type: 'hidden', name: 'category', responseKey: 'category_info.id' }
       ],
 
+      uploadInputs: [
+        { type: 'hidden', name: 'type', value: 'excel' },
+        { type: 'file', name: 'file', label: 'انتخاب فایل', placeholder: ' ', value: null, col: 'col-md-8 col-12' },
+        { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ارسال', placeholder: ' ', atClick: () => {}, col: 'col-md-4 col-12' }
+      ],
+      uploadAPI: APIGateway.transcriptSheetHistory.APIAdresses.importList,
+
       categories: new UnitCategoryList(),
       units: new UnitCategoryList(),
       prerequisite: {
@@ -399,6 +422,7 @@ export default {
   },
   mounted () {
     // this.getCategories()
+    this.setActionBtn()
     this.mounted = true
   },
   methods: {
@@ -446,6 +470,21 @@ export default {
         .catch(() => {
           this.newSessionLoading = false
         })
+    },
+    setActionBtn () {
+      FormBuilderAssist.setAttributeByName(this.uploadInputs, 'btn', 'atClick', this.uploadExcelEntity)
+    },
+    search () {
+      this.$refs.entityIndex.search()
+    },
+    uploadExcelEntity () {
+      this.$refs.uploadExcelEntity.editEntity(false)
+        .then(() => {
+          this.search()
+        })
+        .catch(() => {
+          this.search()
+        })
     }
   }
 }