luohailiang 2 年之前
父节点
当前提交
8d4a782f9a

+ 1 - 0
package.json

@@ -28,6 +28,7 @@
     "@vitejs/plugin-vue": "^4.1.0",
     "@vue-macros/volar": "^0.9.4",
     "@vue/test-utils": "^2.3.2",
+    "axios": "^1.3.5",
     "eslint": "^8.37.0",
     "husky": "^8.0.0",
     "jsdom": "^21.1.1",

+ 26 - 0
pnpm-lock.yaml

@@ -9,6 +9,7 @@ specifiers:
   '@vue-macros/volar': ^0.9.4
   '@vue/test-utils': ^2.3.2
   '@vueuse/core': ^9.13.0
+  axios: ^1.3.5
   element-plus: ^2.3.2
   eslint: ^8.37.0
   husky: ^8.0.0
@@ -48,6 +49,7 @@ devDependencies:
   '@vitejs/plugin-vue': 4.1.0_vite@4.2.1+vue@3.2.47
   '@vue-macros/volar': 0.9.5_vue-tsc@1.2.0+vue@3.2.47
   '@vue/test-utils': 2.3.2_vue@3.2.47
+  axios: 1.3.5
   eslint: 8.38.0
   husky: 8.0.3
   jsdom: 21.1.1
@@ -1701,6 +1703,16 @@ packages:
     engines: {node: '>= 0.4'}
     dev: true
 
+  /axios/1.3.5:
+    resolution: {integrity: sha512-glL/PvG/E+xCWwV8S6nCHcrfg1exGx7vxyUIivIA1iL7BIh6bePylCfVHwp6k13ao7SATxB6imau2kqY+I67kw==}
+    dependencies:
+      follow-redirects: 1.15.2
+      form-data: 4.0.0
+      proxy-from-env: 1.1.0
+    transitivePeerDependencies:
+      - debug
+    dev: true
+
   /balanced-match/1.0.2:
     resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
     dev: true
@@ -2887,6 +2899,16 @@ packages:
     resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==}
     dev: true
 
+  /follow-redirects/1.15.2:
+    resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
+    engines: {node: '>=4.0'}
+    peerDependencies:
+      debug: '*'
+    peerDependenciesMeta:
+      debug:
+        optional: true
+    dev: true
+
   /for-each/0.3.3:
     resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
     dependencies:
@@ -4586,6 +4608,10 @@ packages:
     resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==}
     dev: true
 
+  /proxy-from-env/1.1.0:
+    resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
+    dev: true
+
   /pseudomap/1.0.2:
     resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==}
     dev: true

二进制
public/images/huaxue.png


二进制
public/images/icon-add.png


二进制
public/images/shengwu.png


二进制
public/images/shuxue.png


二进制
public/images/wuli.png


二进制
public/images/yingyu.png


二进制
public/images/yuwen.png


+ 9 - 1
src/App.vue

@@ -1,3 +1,11 @@
+<script setup lang="ts">
+import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
+// 修改分页器默认文字
+zhCn.el.pagination.goto = '跳至'
+</script>
 <template>
-  <RouterView />
+  <el-config-provider :locale="zhCn">
+    <RouterView/>
+  </el-config-provider>
+
 </template>

+ 0 - 5
src/pages/[...all].vue

@@ -1,5 +0,0 @@
-<template>
-  <div>
-    Not Found
-  </div>
-</template>

+ 11 - 0
src/pages/index/api.js

@@ -0,0 +1,11 @@
+import request from "~/utils/request";
+
+export const process_list = (data = {}) => {
+  return request({
+    url: '/yzy/kmksyjlc/index',
+    data,
+  })
+}
+export default {
+
+}

+ 56 - 20
src/pages/index.vue

@@ -7,6 +7,12 @@
 }
 </route>
 <script setup>
+// import {process_list} from "~/pages/index/api";
+import { useRouter } from "vue-router";
+const router = useRouter();
+const linkTo = (name) => {
+  router.push({ name });
+};
 let exam_time = $ref('')
 let exam_form = $ref('')
 let exam_type = $ref('')
@@ -39,6 +45,19 @@ let listData = $ref([]);
 function chooseAll() {
 
 }
+// function getListData() {
+//   let data = {
+//     page:cur_page,
+//     limit:limit,
+//   };
+//   process_list(data).then(res=>{
+//     if(res.code === '1') {
+//       listData = res.data.page_data;
+//       total = Number(res.data.total_rows);
+//       cur_page = Number(res.data.page_now);
+//     }
+//   })
+// }
 </script>
 <template>
   <NavHeader/>
@@ -148,8 +167,10 @@ function chooseAll() {
           <div class="down pt-15px pl-35px">
             <ul class="subject-list">
               <li>
-                <div class="pt-10px">
-                  <div class="w-140px h-195px m-auto bg-red-500"></div>
+                <div>
+                  <div class="w-140px h-195px m-auto">
+                    <img src="/images/yuwen.png" class="w-full" alt="">
+                  </div>
                   <div class="mt-5px">
                     <div class="inline-block align-middle process-state">
                       <h3 class="state-line">
@@ -164,8 +185,10 @@ function chooseAll() {
                 </div>
               </li>
               <li>
-                <div class="pt-10px">
-                  <div class="w-140px h-195px m-auto bg-red-500"></div>
+                <div>
+                  <div class="w-140px h-195px m-auto">
+                    <img src="/images/shuxue.png" class="w-full" alt="">
+                  </div>
                   <div class="mt-5px">
                     <div class="inline-block align-middle process-state">
                       <h3 class="state-line">
@@ -180,8 +203,10 @@ function chooseAll() {
                 </div>
               </li>
               <li>
-                <div class="pt-10px">
-                  <div class="w-140px h-195px m-auto bg-red-500"></div>
+                <div>
+                  <div class="w-140px h-195px m-auto">
+                    <img src="/images/yingyu.png" class="w-full" alt="">
+                  </div>
                   <div class="mt-5px">
                     <div class="inline-block align-middle process-state">
                       <h3 class="state-line">
@@ -196,8 +221,10 @@ function chooseAll() {
                 </div>
               </li>
               <li>
-                <div class="pt-10px">
-                  <div class="w-140px h-195px m-auto bg-red-500"></div>
+                <div>
+                  <div class="w-140px h-195px m-auto">
+                    <img src="/images/wuli.png" class="w-full" alt="">
+                  </div>
                   <div class="mt-5px">
                     <div class="inline-block align-middle process-state">
                       <h3 class="state-line">
@@ -212,8 +239,10 @@ function chooseAll() {
                 </div>
               </li>
               <li>
-                <div class="pt-10px">
-                  <div class="w-140px h-195px m-auto bg-red-500"></div>
+                <div>
+                  <div class="w-140px h-195px m-auto">
+                    <img src="/images/huaxue.png" class="w-full" alt="">
+                  </div>
                   <div class="mt-5px">
                     <div class="inline-block align-middle process-state">
                       <h3 class="state-line">
@@ -228,8 +257,10 @@ function chooseAll() {
                 </div>
               </li>
               <li>
-                <div class="pt-10px">
-                  <div class="w-140px h-195px m-auto bg-red-500"></div>
+                <div>
+                  <div class="w-140px h-195px m-auto">
+                    <img src="/images/shengwu.png" class="w-full" alt="">
+                  </div>
                   <div class="mt-5px">
                     <div class="inline-block align-middle process-state">
                       <h3 class="state-line">
@@ -243,6 +274,9 @@ function chooseAll() {
                   </div>
                 </div>
               </li>
+              <li class="cursor-pointer">
+                <div class="subject-add-btn"></div>
+              </li>
             </ul>
           </div>
         </div>
@@ -296,10 +330,10 @@ function chooseAll() {
 </template>
 <style lang="scss" scoped>
 $color: #003eee;
-.el-pagination.is-background .btn-next.is-active,
-.el-pagination.is-background .btn-prev.is-active,
-.el-pagination.is-background .el-pager li.is-active{
-  background-color: $color!important;
+::v-deep .el-pagination.is-background .btn-next.is-active,
+::v-deep .el-pagination.is-background .btn-prev.is-active,
+::v-deep .el-pagination.is-background .el-pager li.is-active{
+  background-color: $color;
 }
 .add-btn {
   width: 129px;
@@ -549,15 +583,17 @@ $color: #003eee;
   li{
     width: 205px;
     height: 280px;
-    margin: 0 27px 23px 0;
+    margin: 0 28px 23px 0;
     border: 2px solid $color;
     border-radius: 10px;
     display: flex;
     justify-content: center;
     align-items: center;
   }
-  .subject-img{
-
-  }
+}
+.subject-add-btn{
+  width: 57px;
+  height: 57px;
+  background: url("/images/icon-add.png") center no-repeat;
 }
 </style>

+ 30 - 0
src/utils/common-util.ts

@@ -0,0 +1,30 @@
+// 将数字转换成大写中文
+export const dealFigureToChinese = (figure: string) => {
+  figure = `${figure}`
+  const len = figure.length - 1
+  const idxs = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿']
+  const num = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
+  return figure.replace(/([1-9]|0+)/g, (data, data1, idx, full) => {
+    let pos = 0
+    if (data1[0] != '0') {
+      pos = len - idx
+      if (idx == 0 && data1[0] == 1 && idxs[len - idx] == '十')
+        return idxs[len - idx]
+
+      return num[data1[0]] + idxs[len - idx]
+    }
+    else {
+      const left = len - idx
+      const right = len - idx + data1.length
+      if (Math.floor(right / 4) - Math.floor(left / 4) > 0)
+        pos = left - left % 4
+
+      if (pos)
+        return idxs[pos] + num[data1[0]]
+      else if (idx + data1.length >= len)
+        return ''
+      else
+        return num[data1[0]]
+    }
+  })
+}

+ 30 - 0
src/utils/helper.ts

@@ -0,0 +1,30 @@
+export function resolveFileString(str: string) {
+  return str ? str.split(';').map(s => resolveSingleFileString(s)) : []
+}
+
+export function resolveSingleFileString(str: string, sign = '|') {
+  const [url, name] = str.split(sign)
+  return {
+    name,
+    url: url.startsWith('http') ? url : `${window.GLOBAL_CONFIG.oss}/${url}`,
+    origin: url,
+  }
+}
+
+// 获取完整文件地址
+export function getFullUrl(url: string) {
+  if (!url)
+    return ''
+  return url.startsWith('http') ? url : `${window.GLOBAL_CONFIG.oss}/${url}`
+}
+
+// 获取不完整文件地址
+export function getPartUrl(url: string) {
+  if (!url)
+    return ''
+  return url.startsWith('http') ? url.startsWith(window.GLOBAL_CONFIG.oss) ? url.substring(window.GLOBAL_CONFIG.oss.length) : Error('oss 地址错误') : url
+}
+
+export function getAvatarUrl(id: string) {
+  return `${window.GLOBAL_CONFIG.oss}/user/main/user_avatar?user_id=${id}`
+}

+ 97 - 0
src/utils/request.ts

@@ -0,0 +1,97 @@
+import axios from 'axios'
+import type { AxiosRequestConfig } from 'axios'
+import { ElMessage } from 'element-plus'
+import { user } from '~/store/index'
+const token = user.value?.token
+export interface Response {
+  code: string
+  data: any
+  msg: string
+}
+
+const instance = axios.create({
+  baseURL: window.GLOBAL_CONFIG.api,
+  timeout: 180 * 1000,
+  headers: {
+    'Content-Type': 'application/x-www-form-urlencoded',
+  },
+  method: 'post',
+})
+
+instance.interceptors.request.use(
+  async (config) => {
+    if (config.method?.toLocaleLowerCase() === 'get') {
+      config.params = Object.assign({ token }, config.params)
+    }
+    else {
+      config.data = Object.assign(
+        {
+          token,
+          client: 'web',
+          api: 'json',
+          site: 'txwx',
+          issubmit: (config.url?.endsWith('add') || config.url?.endsWith('edit')) ? '1' : undefined,
+        },
+        config.data)
+    }
+    return config
+  },
+  (error) => {
+    console.error('request error: ', error)
+    return Promise.reject(error)
+  },
+)
+
+// response interceptor
+instance.interceptors.response.use(
+  (response: { data: Response }) => {
+    response.data.code = response.data?.code?.toString()
+    response.data.msg = response.data.msg.replaceAll(/<.*?>/g, ' ')
+    const { code, msg } = response.data
+    if (code !== '1')
+      ElMessage.error(msg)
+
+    return response.data
+  },
+  (error) => {
+    console.error(`response error: ${error}`)
+    return Promise.reject(error)
+  },
+)
+
+export default (config: AxiosRequestConfig): Promise<Response> => instance.request(config)
+
+const obj2form = (data: { [key: string]: any }) => {
+  const formData = new FormData()
+  Object.keys(data).forEach(key => formData.append(key, data[key]))
+  return formData
+}
+
+export const REQUEST = {
+  empty: axios,
+  default: instance,
+  import: (c: Partial<AxiosRequestConfig>) => instance({
+    timeout: 10 * 60 * 1000,
+    transformRequest: [obj2form],
+    ...c,
+  }),
+  upload: (c: Partial<AxiosRequestConfig>) => instance({
+    timeout: 3 * 60 * 1000,
+    transformRequest: [obj2form],
+    ...c,
+  }),
+  download: (c: Partial<AxiosRequestConfig>) => instance({
+    timeout: 1 * 60 * 1000,
+    method: 'get',
+    params: { token, limit: 10000, page: 1, api: 'xls', ...c },
+  }),
+}
+
+export function download(url: string, data?: object | null) {
+  const params = Object.assign({ token, limit: 10000, page: 1, api: 'xls' }, data)
+  const paramsStr = Object.entries(params).map(([k, v]) => `${k}=${v}`).join('&')
+  const el = document.createElement('a')
+  const href = `${window.GLOBAL_CONFIG.api}${url}?${paramsStr}`
+  el.setAttribute('href', href)
+  el.click()
+}

+ 13 - 0
src/utils/size.ts

@@ -0,0 +1,13 @@
+let fontSize = $ref(16)
+
+export function initFontSize() {
+  const designSize = 1920 // 设计图尺寸
+  const cW = document.documentElement.clientWidth// 窗口宽度
+  fontSize = cW / designSize * 16
+  document.documentElement.style.fontSize = `${fontSize}px`
+  return fontSize
+}
+
+export function getTrueSize(n: number): number {
+  return n / 16 * fontSize
+}

+ 11 - 0
src/utils/string.ts

@@ -0,0 +1,11 @@
+export function paddingLeft(str: string, length = 2, pad = '0'): string {
+  str = str.toString()
+  if (str.length >= length)
+    return str
+
+  return paddingLeft(pad + str, length, pad)
+}
+
+export function timestamp2string(timestamp: string | number | Date) {
+  return (new Date(timestamp)).toLocaleString()
+}

+ 8 - 0
src/utils/validate.ts

@@ -0,0 +1,8 @@
+/**
+ * @param {string} path
+ * @returns {Boolean}
+ */
+export function isExternal(path: string) {
+  return /^(https?:|mailto:|tel:)/.test(path)
+}
+