Browse Source

fix: 列表显示bug

lvkun996 3 months ago
parent
commit
7f1f8ce9b6

+ 10 - 0
auto-imports.d.ts

@@ -0,0 +1,10 @@
+/* eslint-disable */
+/* prettier-ignore */
+// @ts-nocheck
+// noinspection JSUnusedGlobalSymbols
+// Generated by unplugin-auto-import
+export {}
+declare global {
+  const closeToast: typeof import('vant/es')['closeToast']
+  const showToast: typeof import('vant/es')['showToast']
+}

+ 26 - 0
components.d.ts

@@ -0,0 +1,26 @@
+/* eslint-disable */
+// @ts-nocheck
+// Generated by unplugin-vue-components
+// Read more: https://github.com/vuejs/core/pull/3399
+export {}
+
+/* prettier-ignore */
+declare module 'vue' {
+  export interface GlobalComponents {
+    ExamineFlow: typeof import('./src/components/examineFlow/index.vue')['default']
+    ExamineHandle: typeof import('./src/components/examineHandle/index.vue')['default']
+    OrderCom: typeof import('./src/components/order-com/index.vue')['default']
+    RouterLink: typeof import('vue-router')['RouterLink']
+    RouterView: typeof import('vue-router')['RouterView']
+    VanField: typeof import('vant/es')['Field']
+    VanIcon: typeof import('vant/es')['Icon']
+    VanOverlay: typeof import('vant/es')['Overlay']
+    VanPopup: typeof import('vant/es')['Popup']
+    VanRadio: typeof import('vant/es')['Radio']
+    VanRadioGroup: typeof import('vant/es')['RadioGroup']
+    VanStep: typeof import('vant/es')['Step']
+    VanSteps: typeof import('vant/es')['Steps']
+    VanTabbar: typeof import('vant/es')['Tabbar']
+    VanTabbarItem: typeof import('vant/es')['TabbarItem']
+  }
+}

File diff suppressed because it is too large
+ 619 - 124
package-lock.json


+ 6 - 1
package.json

@@ -16,6 +16,7 @@
     "pinia": "^2.2.0",
     "pinia-plugin-persistedstate": "^3.2.1",
     "qrcodejs2": "0.0.2",
+    "typescript": "~4.5.5",
     "vant": "^4.9.3",
     "vue": "^3.0.0",
     "vue-hooks-plus": "^2.2.1",
@@ -30,6 +31,7 @@
     "@vue/cli-service": "~4.5.12",
     "@vue/compiler-sfc": "^3.0.0",
     "@vue/eslint-config-standard": "^5.1.2",
+    "@vue/tsconfig": "^0.7.0",
     "babel-eslint": "^10.1.0",
     "eslint": "^6.7.2",
     "eslint-plugin-import": "^2.20.2",
@@ -41,8 +43,11 @@
     "less-loader": "^5.0.0",
     "lint-staged": "^9.5.0",
     "postcss-px-to-viewport": "^1.1.1",
+    "ts-loader": "^9.5.2",
     "unplugin-auto-import": "^0.18.0",
-    "unplugin-vue-components": "^0.27.3"
+    "unplugin-vue-components": "^0.27.3",
+    "vue-loader": "^17.3.1",
+    "vue-tsc": "^2.2.0"
   },
   "gitHooks": {
     "pre-commit": "lint-staged"

+ 5 - 0
shims-vue.d.ts

@@ -0,0 +1,5 @@
+declare module '*.vue' {
+  import type { DefineComponent } from 'vue';
+  const component: DefineComponent<{}, {}, any>;
+  export default component;
+}

+ 13 - 7
src/App.vue

@@ -1,32 +1,38 @@
 <template>
   <router-view/>
-  <!-- <van-tabbar v-model="active" v-if="route.path !== '/login' && route.path !== '/forget-pwd'">
-  <van-tabbar-item icon="home-o" @click="pushHomePage" >首页</van-tabbar-item>
-  <van-tabbar-item icon="friends-o" @click="pushMePage">我的</van-tabbar-item>
-</van-tabbar> -->
+  <van-tabbar v-model="active" v-if="route.path !== '/login' && route.path !== '/forget-pwd' && route.path !== '/orderDetail'">
+    <van-tabbar-item icon="home-o" name="/todo" @click="pushHomePage" >首页</van-tabbar-item>
+    <van-tabbar-item icon="friends-o" name="/my" @click="pushMePage">我的</van-tabbar-item>
+  </van-tabbar>
 </template>
 <script setup >
 import { ref } from 'vue'
 import { useRouter, useRoute } from 'vue-router'
+import rootRouter from '@/router'
 
 const router = useRouter()
 
 const route = useRoute()
 
-const active = ref(0)
+const active = ref('/todo')
 
 const pushMePage = () => {
   router.push({
-    path: '/me'
+    path: '/my'
   })
 }
 
 const pushHomePage = () => {
   router.push({
-    path: '/record'
+    path: '/'
   })
 }
 
+rootRouter.afterEach(() => {
+  active.value = route.path === '/' ? '/todo' : route.path
+  console.log('active:', active.value);
+})
+
 </script>
 <style lang="less">
 #app {

+ 7 - 2
src/components/examineHandle/index.vue

@@ -147,15 +147,20 @@ const confirm = async () => {
     remarks: content.value
   }
   if (code === 0) {
+    // if (props.status == 1 && props.examineType == 2) {
+    //   if (this.handleType != 1) {
+    //     params['nextUserId'] = this.selectUsers[0].userId;
+    //   }
+    // }
     crmExamineFlowAuditExamine(params)
-    cancel()
+    emits('cancel', true)
     // eslint-disable-next-line no-undef
     closeToast()
   }
 }
 
 const cancel = () => {
-  emits('cancel')
+  emits('cancel', false)
 }
 
 </script>

+ 8 - 0
src/router/index.js

@@ -39,6 +39,14 @@ const routes = [
       title: '产品列表'
     },
     component: () => import('@/views/productList.vue')
+  },
+  {
+    path: '/my',
+    name: 'my',
+    meta: {
+      title: '我的'
+    },
+    component: () => import('@/views/my/index.vue')
   }
 ]
 

+ 2 - 1
src/server/index.js

@@ -2,6 +2,7 @@ import { useUserStore } from '@/store'
 import axios from 'axios'
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
 const instance = axios.create({
+  // baseURL: process.env.NODE_ENV === 'development' ? '/zd-api' : '/crm-api',
   // baseURL: process.env.NODE_ENV === 'development' ? '/zd-api' : '/crm-api',
   baseURL: process.env.NODE_ENV === 'development' ? '/zd-api' : '/crm-api',
   timeout: 30000,
@@ -16,7 +17,7 @@ const instance = axios.create({
  * @returns `catchErr` 函数返回一个被拒绝的 Promise,并传递了 `error` 参数作为拒绝的原因。
  */
 const catchErr = (response) => {
-  console.log('response:', response);
+  console.log('response:', response)
   if (response === undefined) return
   const data = response.data
   console.log('data', data)

+ 24 - 8
src/store/useUserStore.js

@@ -1,24 +1,40 @@
 import { defineStore } from 'pinia'
 import { ref } from 'vue'
-import { login } from '@/api/user'
+import { login, adminUsersRead } from '@/api/user'
 import router from '@/router'
+import { showLoadingToast, closeToast } from 'vant'
 
 export const useUserStore = defineStore('useUserStore', () => {
   const userInfo = ref({
-    token: ''
+    token: '',
+    realname: '',
+    deptName: '',
+    email: ''
   })
 
   const code = ref('')
   const _login = async (_data) => {
+    showLoadingToast({
+      message: '登录中...',
+      forbidClick: true,
+      loadingType: 'spinner',
+    });
     const data = await login(_data)
+
     if (data.code === 0) {
+      userInfo.value.token = data['Admin-Token']
       // eslint-disable-next-line no-undef
-      userInfo.value = {
-        ...data,
-        token: data['Admin-Token']
-      }
-      router.push({
-        path: '/todo'
+      adminUsersRead().then(res => {
+        closeToast()
+        userInfo.value = {
+          ...res.data,
+          token: data['Admin-Token']
+        }
+        console.log('跳转啊');
+        
+        router.push({
+          path: '/todo'
+        })
       })
     }
     return data.code

+ 2 - 0
src/styles/index.less

@@ -2,4 +2,6 @@
 
 @main-color: rgb(7, 65, 161);
 
+@page-color: rgb(245, 245, 245);
+
 

+ 117 - 0
src/views/my/index.vue

@@ -0,0 +1,117 @@
+<template>
+  <div class="my-page" >
+    <div class="user-info" >  
+      <div class="ava" >
+        {{userStore.userInfo.realname}}
+      </div>
+      <div class="dept" >
+        <div class="dept-item deptName" >
+          <div class="title" >部门名称:</div>
+          <div class="value" > {{userStore.userInfo.deptName}}</div>
+        </div>
+        <div class="dept-item email" >
+          <div class="title" >邮箱:</div>
+          <div class="value" > {{userStore.userInfo.email}}</div>
+        </div>
+      </div>
+    </div>
+
+    <div class="logout-btn" @click="logout" >
+      退出登录
+    </div>
+  </div>
+</template>
+<script lang='js' setup >
+ import { adminUsersRead } from '@/api/user'
+ import { onMounted, ref } from 'vue';
+ import { useUserStore } from '@/store/index'
+
+ const userStore = useUserStore()
+
+ const userInfo = ref({
+  realname: '',
+  deptName: '',
+  email: ''
+ })
+
+ const _adminUsersRead = async () => {
+   const { data } = await adminUsersRead()
+   console.log('data:', data)
+   userInfo.value = data
+ }
+
+ const logout = () => {
+  userStore.logout()
+ }
+
+
+ onMounted(() => {
+  // _adminUsersRead()
+ })
+</script>
+<style lang='less' scoped >
+@import '../../styles/index.less';
+
+.my-page {
+  width: 100vw;
+  height: 100vh;
+  background-color: @page-color;
+  padding-top: 120px;
+  .user-info {
+    width: 702px;
+    height: 300px;
+    background-color: #fff;
+    border-radius: 24px;
+    margin: 0 auto;
+    padding: 24px;
+    box-sizing: border-box;
+    display: flex;
+    align-items: center;
+    // justify-content: space-between;
+   
+    .ava {
+      width: 186px;
+      height: 186px;
+      background-color: rgb(1, 137, 255);
+      border-radius: 50%;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      color: #fff;
+      font-weight: 600;
+      font-size: 40px;
+      margin-right: 48px;
+    }
+    .dept {
+      .dept-item {
+        width: 100%;
+        margin-bottom: 12px;
+        display: flex;
+        .title {
+          width: 160px;
+          text-align: right;
+          margin-right: 12px;
+        }
+      }
+    }
+  }
+  .logout-btn {
+    width: 702px;
+    height: 96px;
+    background-color: @main-color;
+    border-radius: 48px;
+    margin: 24px auto;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    color: #fff;
+    font-size: 24px;
+    font-weight: 600;
+    cursor: pointer;
+    position: fixed;
+    bottom: 120px;
+    left: 50%;
+    transform: translateX(-50%);
+  }
+}
+</style>

+ 1 - 1
src/views/productList.vue

@@ -21,7 +21,7 @@
       </div>
       <div class="warehouse" >
         <div class="count" >数量: {{item.num}}</div>
-        <div class="unit" >装箱规格(箱):{{item.boxNumber}}</div>
+        <div class="unit" >装箱规格(箱):{{item.totalBox}}</div>
         <div class="reduce-count" >余数量(件): {{item.remainder}}</div>
       </div>
       <div class="real-price" >

+ 3 - 4
src/views/todo.vue

@@ -29,13 +29,12 @@ const count = ref(0)
 
 const loading = ref(false)
 
-const reload =  () => {
+const reload = () => {
   loading.value = true
-  useSchedulerOnce( async () => {
+  useSchedulerOnce(async () => {
     await getCrmMessagNumAPI()
     loading.value = false
-  }, 100)
-
+  }, 100)
 }
 
 const getCrmMessagNumAPI = async () => {

+ 10 - 4
src/views/todoDetail.vue

@@ -63,7 +63,8 @@ const pushOrderDetail = (orderId) => {
 const _crmMessageCheckOrderAPI = async () => {
   const { data } = await crmMessageCheckOrderAPI(queryParams.value)
   list.value.push(...data.list)
-  queryParams.value = data.total
+  queryParams.value.total = data.total
+  show.value = false
 }
 
 const refuse = (record) => {
@@ -93,9 +94,14 @@ const cancel = (record) => {
   show.value = true
 }
 
-const closeModal = () => {
-  list.value = []
-  _crmMessageCheckOrderAPI()
+const closeModal = (b) => {
+  if (b) {
+    list.value = []
+    _crmMessageCheckOrderAPI()
+  } else {
+    show.value = false
+  }
+
 }
 
 onMounted(() => {

+ 41 - 0
tsconfig.json

@@ -0,0 +1,41 @@
+{
+  "compilerOptions": {
+    "target": "esnext",
+    "module": "esnext",
+    "strict": true,
+    "jsx": "preserve",
+    "moduleResolution": "node",
+    "experimentalDecorators": true,
+    "skipLibCheck": true,
+    "esModuleInterop": true,
+    "allowSyntheticDefaultImports": true,
+    "forceConsistentCasingInFileNames": true,
+    "useDefineForClassFields": true,
+    "sourceMap": true,
+    "baseUrl": ".",
+    "types": [
+      "webpack-env"
+    ],
+    "paths": {
+      "@/*": [
+        "src/*"
+      ]
+    },
+    "lib": [
+      "esnext",
+      "dom",
+      "dom.iterable",
+      "scripthost"
+    ]
+  },
+  "include": [
+    "src/**/*.ts",
+    "src/**/*.tsx",
+    "src/**/*.vue",
+    "tests/**/*.ts",
+    "tests/**/*.tsx"
+, "src/main.js"  ],
+  "exclude": [
+    "node_modules"
+  ]
+}

+ 29 - 9
vue.config.js

@@ -1,6 +1,7 @@
 const { VantResolver } = require('@vant/auto-import-resolver')
 const AutoImport = require('unplugin-auto-import/webpack')
 const Components = require('unplugin-vue-components/webpack')
+const { VueLoaderPlugin } = require('vue-loader');
 
 module.exports = {
   publicPath: './',
@@ -10,9 +11,30 @@ module.exports = {
       AutoImport.default({
         resolvers: [VantResolver()]
       }),
-      Components.default({ resolvers: [VantResolver()] })
-    ]
+      Components.default({ resolvers: [VantResolver()] }),
+      // new VueLoaderPlugin()
+    ],
+    // resolve: {
+    //   extensions: ['.ts', '.tsx', '.js', '.vue', '.json'],
+    // },
+    // module: {
+    //   rules: [
+    //     {
+    //       test: /\.vue$/,
+    //       loader: 'vue-loader',
+    //     },
+    //     {
+    //       test: /\.ts$/,
+    //       loader: 'ts-loader',
+    //       options: {
+    //         appendTsSuffixTo: [/\.vue$/], // 允许 Vue 组件使用 TypeScript
+    //       },
+    //       exclude: /node_modules/,
+    //     },
+    //   ],
+    // },
   },
+
   devServer: {
     proxy: {
       '/zd-api': {
@@ -20,6 +42,11 @@ module.exports = {
         changeOrigin: true,
         pathRewrite: { '^/zd-api': '' }
       }
+      // '/zd-api': {
+      //   target: 'http://192.168.1.105:15555',
+      //   changeOrigin: true,
+      //   pathRewrite: { '^/zd-api': '' }
+      // }
       // '/api': {
       //   target: 'http://192.168.1.105:15555',
       //   changeOrigin: true,
@@ -27,11 +54,4 @@ module.exports = {
       // },
     }
   }
-  // plugins: [
-
-  //   AutoImport.default({
-  //     resolvers: [VantResolver()]
-  //   }),
-  //   Components.default({ resolvers: [VantResolver()] })
-  // ]
 }

File diff suppressed because it is too large
+ 298 - 313
yarn.lock


Some files were not shown because too many files changed in this diff