CzRger 1 месяц назад
Родитель
Сommit
8e71cbde41

+ 3 - 0
src/api/modules/global/login.ts

@@ -13,3 +13,6 @@ export const systemUserGetInfo = () => get(`/system/user/getInfo`, {}, {})
 // 用户信息
 export const systemStudent = (userId) =>
   get(`/system/student/${userId}`, {}, {})
+// 字典
+export const systemDictDataType = (type) =>
+  get(`/system/dict/data/type/${type}`, {}, {})

+ 1 - 0
src/stores/index.ts

@@ -1,3 +1,4 @@
 export * from './modules/app'
 export * from './modules/dialog'
 export * from './modules/menu'
+export * from './modules/dictionary'

+ 1 - 1
src/stores/modules/app.ts

@@ -1,5 +1,5 @@
 import { defineStore } from 'pinia'
-import { systemStudent, systemUserGetInfo } from '@/api/modules/global/login'
+import { systemStudent, systemUserGetInfo } from '@/api/modules/global'
 import { systemSubjectList } from '@/api/modules/study'
 import router from '@/router'
 

+ 11 - 0
src/stores/modules/dictionary-define.ts

@@ -0,0 +1,11 @@
+export const dictionaryDefine = {
+  //接口参数 : [ '字典数据list名', '字典数据Map名' ],
+  tc_grade: ['tcGradeList', 'tcGradeMap'], //  索引状态
+}
+
+const stateMap = {}
+Object.keys(dictionaryDefine).map((i) => {
+  stateMap[dictionaryDefine[i][0]] = []
+  stateMap[dictionaryDefine[i][1]] = new Map()
+})
+export const dictionary = stateMap

+ 41 - 0
src/stores/modules/dictionary.ts

@@ -0,0 +1,41 @@
+import { defineStore } from 'pinia'
+import { dictionary, dictionaryDefine } from './dictionary-define'
+import { systemDictDataType } from '@/api/modules/global'
+export const useDictionaryStore = defineStore('dictionary', {
+  state: () => ({
+    ...dictionary,
+  }),
+  getters: {
+    // shareConditionsMap() {
+    //   return listToMap((this as any).shareConditions)
+    // },
+  },
+  actions: {
+    initDict(type) {
+      return new Promise((resolve, reject) => {
+        if (this[dictionaryDefine[type][0]].length === 0) {
+          systemDictDataType(type)
+            .then(({ data }: any) => {
+              const map = new Map()
+              const objMap = new Map()
+              if (data.length > 0) {
+                data.forEach((v: any) => {
+                  v.label = v.dictLabel
+                  v.value = v.dictValue
+                  map.set(v.value, v.label)
+                  objMap.set(v.value, v)
+                })
+              }
+              this[dictionaryDefine[type][0]] = data
+              this[dictionaryDefine[type][1]] = map
+              this[dictionaryDefine[type]?.[2]] = objMap
+              resolve(data)
+            })
+            .catch(() => {})
+        } else {
+          resolve(this[dictionaryDefine[type][0]])
+        }
+      })
+    },
+  },
+})

+ 1 - 1
src/views/global/login/index.vue

@@ -119,7 +119,7 @@
 import { onMounted, reactive, ref } from 'vue'
 import { useRouter } from 'vue-router'
 import { Notify } from 'quasar'
-import { authCode, authLogin } from '@/api/modules/global/login'
+import { authCode, authLogin } from '@/api/modules/global'
 import axios from 'axios'
 
 const router = useRouter()

+ 63 - 32
src/views/study/components/study-layout.vue

@@ -55,45 +55,64 @@
 
       <q-card-section class="q-pt-none">
         <div class="flex">
-          <div class="flex-1">
-            <q-card-section class="q-pt-none">
+          <div class="grid flex-1 grid-cols-2">
+            <q-card-section class="q-pt-none col-span-1">
+              <q-input outlined v-model="infoCpt.name" label="姓名" readonly />
+            </q-card-section>
+            <q-card-section class="q-pt-none col-span-1">
+              <q-input outlined v-model="infoCpt.grade" label="年級" readonly />
+            </q-card-section>
+            <q-card-section class="q-pt-none col-span-1">
               <q-input
                 outlined
-                v-model="state.info.phone"
-                label="联系方式"
-                type="tel"
+                v-model="infoCpt.studentDistrict"
+                label="所在区"
+                readonly
               />
             </q-card-section>
-            <q-card-section class="q-pt-none">
+            <q-card-section class="q-pt-none col-span-1">
               <q-input
                 outlined
-                v-model="state.info.email"
-                label="邮箱"
-                type="email"
+                v-model="infoCpt.studentClass"
+                label="所属届"
+                readonly
               />
             </q-card-section>
-            <q-card-section class="q-pt-none">
-              <q-input outlined v-model="state.info.name" label="姓名" />
+            <q-card-section class="q-pt-none col-span-1">
+              <q-input
+                outlined
+                v-model="infoCpt.studentSchool"
+                label="所在学校"
+                readonly
+              />
+            </q-card-section>
+            <q-card-section class="q-pt-none col-span-1">
+              <q-input
+                outlined
+                v-model="infoCpt.storeName"
+                label="所属店面"
+                readonly
+              />
             </q-card-section>
           </div>
-          <div class="">
-            <el-upload
-              class="avatar-uploader"
-              action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
-              :show-file-list="false"
-              accept=".png,.jpg,.jpeg"
-              :on-success="handleAvatarSuccess"
-              :before-upload="beforeAvatarUpload"
-            >
-              <img v-if="state.avatar" :src="state.avatar" class="avatar" />
-              <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
-            </el-upload>
-          </div>
+          <!--          <div class="">-->
+          <!--            <el-upload-->
+          <!--              class="avatar-uploader"-->
+          <!--              action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"-->
+          <!--              :show-file-list="false"-->
+          <!--              accept=".png,.jpg,.jpeg"-->
+          <!--              :on-success="handleAvatarSuccess"-->
+          <!--              :before-upload="beforeAvatarUpload"-->
+          <!--            >-->
+          <!--              <img v-if="state.avatar" :src="state.avatar" class="avatar" />-->
+          <!--              <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>-->
+          <!--            </el-upload>-->
+          <!--          </div>-->
         </div>
       </q-card-section>
 
       <q-card-actions align="right" class="text-teal bg-white">
-        <q-btn flat label="确定" v-close-popup />
+        <!--        <q-btn flat label="确定" v-close-popup />-->
         <q-btn flat label="取消" v-close-popup />
       </q-card-actions>
     </q-card>
@@ -101,23 +120,32 @@
 </template>
 
 <script setup lang="ts">
-import { computed, reactive } from 'vue'
+import { computed, onMounted, reactive } from 'vue'
 import { useRouter } from 'vue-router'
 import { Plus } from '@element-plus/icons-vue'
 import { Notify } from 'quasar'
 import { ElMessageBox } from 'element-plus'
-import { authLogout } from '@/api/modules/global/login'
+import { authLogout } from '@/api/modules/global'
+import { useAppStore, useDictionaryStore } from '@/stores'
 
+const AppStore = useAppStore()
+const DictionaryStore = useDictionaryStore()
 const router = useRouter()
 const state: any = reactive({
   showInfo: false,
-  info: {
-    name: '张三',
-    phone: '13112345678',
-    email: 'email@qq.com',
-  },
   avatar: '',
 })
+const infoCpt = computed(() => {
+  const obj = {
+    name: AppStore.userInfo?.nickName,
+    grade: DictionaryStore.tcGradeMap.get(AppStore.studentInfo?.grade),
+    studentDistrict: AppStore.studentInfo?.studentDistrict,
+    studentClass: AppStore.studentInfo?.studentClass,
+    studentSchool: AppStore.studentInfo?.studentSchool,
+    storeName: AppStore.studentInfo?.storeName,
+  }
+  return obj
+})
 const menusCpt = computed(() => {
   return router.getRoutes().filter((v) => v.meta?.isMenu)
 })
@@ -188,6 +216,9 @@ const onLogout = () => {
     })
     .catch(() => {})
 }
+onMounted(() => {
+  DictionaryStore.initDict('tc_grade')
+})
 </script>
 
 <style lang="scss" scoped>

+ 1 - 0
src/views/study/subject/question/only.vue

@@ -211,6 +211,7 @@ const initQuestion = () => {
     pageSize: state.question.size,
     category: AppStore.studentInfo?.grade,
     subject: route.meta.subjectId,
+    planId: route.query.planId || '',
     correct: state.question.type !== '错题',
     studentId: AppStore.studentInfo?.studentId,
   })