소스 검색

添加修改密码功能

Yue 2 년 전
부모
커밋
f34b1dd9d8

+ 1 - 56
auto-imports.d.ts

@@ -4,60 +4,5 @@
 // Generated by unplugin-auto-import
 export {}
 declare global {
-  const EffectScope: typeof import('vue')['EffectScope']
-  const computed: typeof import('vue')['computed']
-  const createApp: typeof import('vue')['createApp']
-  const customRef: typeof import('vue')['customRef']
-  const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
-  const defineComponent: typeof import('vue')['defineComponent']
-  const effectScope: typeof import('vue')['effectScope']
-  const getCurrentInstance: typeof import('vue')['getCurrentInstance']
-  const getCurrentScope: typeof import('vue')['getCurrentScope']
-  const h: typeof import('vue')['h']
-  const inject: typeof import('vue')['inject']
-  const isProxy: typeof import('vue')['isProxy']
-  const isReactive: typeof import('vue')['isReactive']
-  const isReadonly: typeof import('vue')['isReadonly']
-  const isRef: typeof import('vue')['isRef']
-  const markRaw: typeof import('vue')['markRaw']
-  const nextTick: typeof import('vue')['nextTick']
-  const onActivated: typeof import('vue')['onActivated']
-  const onBeforeMount: typeof import('vue')['onBeforeMount']
-  const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
-  const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
-  const onDeactivated: typeof import('vue')['onDeactivated']
-  const onErrorCaptured: typeof import('vue')['onErrorCaptured']
-  const onMounted: typeof import('vue')['onMounted']
-  const onRenderTracked: typeof import('vue')['onRenderTracked']
-  const onRenderTriggered: typeof import('vue')['onRenderTriggered']
-  const onScopeDispose: typeof import('vue')['onScopeDispose']
-  const onServerPrefetch: typeof import('vue')['onServerPrefetch']
-  const onUnmounted: typeof import('vue')['onUnmounted']
-  const onUpdated: typeof import('vue')['onUpdated']
-  const provide: typeof import('vue')['provide']
-  const reactive: typeof import('vue')['reactive']
-  const readonly: typeof import('vue')['readonly']
-  const ref: typeof import('vue')['ref']
-  const resolveComponent: typeof import('vue')['resolveComponent']
-  const shallowReactive: typeof import('vue')['shallowReactive']
-  const shallowReadonly: typeof import('vue')['shallowReadonly']
-  const shallowRef: typeof import('vue')['shallowRef']
-  const toRaw: typeof import('vue')['toRaw']
-  const toRef: typeof import('vue')['toRef']
-  const toRefs: typeof import('vue')['toRefs']
-  const triggerRef: typeof import('vue')['triggerRef']
-  const unref: typeof import('vue')['unref']
-  const useAttrs: typeof import('vue')['useAttrs']
-  const useCssModule: typeof import('vue')['useCssModule']
-  const useCssVars: typeof import('vue')['useCssVars']
-  const useSlots: typeof import('vue')['useSlots']
-  const watch: typeof import('vue')['watch']
-  const watchEffect: typeof import('vue')['watchEffect']
-  const watchPostEffect: typeof import('vue')['watchPostEffect']
-  const watchSyncEffect: typeof import('vue')['watchSyncEffect']
-}
-// for type re-export
-declare global {
-  // @ts-ignore
-  export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue'
+  const ElSelect: typeof import('element-plus/es')['ElSelect']
 }

+ 21 - 32
src/App.vue

@@ -4,46 +4,35 @@
   </el-config-provider>
 </template>
 
-<script lang="ts">
-import { defineComponent, nextTick, onBeforeMount, onMounted } from "vue"
+<script lang="ts" setup>
+import { nextTick, onBeforeMount, onMounted } from "vue"
 import { RouterView } from "vue-router"
 import appStore from "@/stores"
 import { themeMode } from "@/core/helpers/config"
 import { initializeComponents } from "@/core/plugins/keenthemes"
 import zhCn from "element-plus/lib/locale/lang/zh-cn"
 
-export default defineComponent({
-  name: "app",
-  components: {
-    RouterView,
-  },
-  setup() {
-    const configBodyStore = appStore.bodyConfigStore
-    const locale = zhCn
-    onBeforeMount(() => {
-      /**
-       * Overrides the layout config using saved data from localStorage
-       * remove this to use static config (@/core/config/DefaultLayoutConfig.ts)
-       */
-      configBodyStore.overrideLayoutConfig()
-
-      /**
-       *  Sets a mode from configuration
-       */
-      configBodyStore.setThemeMode(themeMode.value)
-    })
+const configBodyStore = appStore.bodyConfigStore
+const locale = zhCn
+onBeforeMount(() => {
+  /**
+   * Overrides the layout config using saved data from localStorage
+   * remove this to use static config (@/core/config/DefaultLayoutConfig.ts)
+   */
+  configBodyStore.overrideLayoutConfig()
+
+  /**
+   *  Sets a mode from configuration
+   */
+  configBodyStore.setThemeMode(themeMode.value)
+})
 
-    onMounted(() => {
-      nextTick(() => {
-        initializeComponents()
+onMounted(() => {
+  nextTick(() => {
+    initializeComponents()
 
-        configBodyStore.removeBodyClassName("page-loading")
-      })
-    })
-    return {
-      locale,
-    }
-  },
+    configBodyStore.removeBodyClassName("page-loading")
+  })
 })
 </script>
 

+ 1 - 0
src/components/Forms/VbFormItem.vue

@@ -102,6 +102,7 @@ onMounted(() => {
           :class="item.class"
           :style="item.style"
           :size="item.size"
+          :placeholder="item.placeholder ?? item.label"
           v-bind="item.props"
           v-on="item.listeners"
         >

+ 89 - 3
src/layouts/main-layout/menus/UserAccountMenu.vue

@@ -17,7 +17,7 @@
         <div class="d-flex flex-column">
           <div class="fw-bold d-flex align-items-center fs-5">
             {{ store.user?.userName }}
-            <span class="badge badge-light-success fw-bold fs-8 px-2 py-1 ms-2">Pro</span>
+            <span class="badge badge-light-success fw-bold fs-8 px-2 py-1 ms-2">{{ store.user?.orgId }}</span>
           </div>
         </div>
         <!--end::Username-->
@@ -37,23 +37,109 @@
 
     <!--begin::Menu item-->
     <div class="menu-item px-5">
+      <a @click="password()" class="menu-link px-5">修改密码</a>
       <a @click="signOut()" class="menu-link px-5">注销</a>
     </div>
     <!--end::Menu item-->
   </div>
+  <Teleport to="body">
+    <VbModal
+      id="change-password"
+      modal-style="z-index:10000"
+      title="修改密码"
+      v-model:modal="pwdModal"
+      v-model:form-data="formData"
+      :form-items="items"
+      @confirm="changePassword"
+    ></VbModal>
+  </Teleport>
+
   <!--end::Menu-->
 </template>
 
 <script lang="ts" setup>
+import { ref } from "vue"
 import { getAssetPath } from "@/core/helpers/assets"
 import appStore from "@/stores"
 import { useRouter } from "vue-router"
 import configs from "@/core/config/Index"
+import type { VbFormItem } from "@/components/Forms/models"
+import Rs from "@/core/services/RequestService"
+import { ElInput } from "element-plus"
+import { dialog } from "@/core/utils/message"
 const router = useRouter()
 const store = appStore.authStore
 
 const signOut = () => {
-  store.logout()
-  router.push({ name: configs.SIGN_ROUTE_NAME })
+  dialog.confirm("确定要注销登录吗?", "注销", (confirm: any) => {
+    if (confirm.isConfirmed) {
+      store.logout()
+      router.push({ name: configs.SIGN_ROUTE_NAME })
+    }
+  })
+}
+const pwdModal = ref()
+const formData = ref({
+  oldPassword: "",
+  cPassword: "",
+  password: "",
+})
+const validatePass = (rule: any, value: any, callback: any) => {
+  if (
+    formData.value.password !== "" &&
+    formData.value.cPassword !== "" &&
+    formData.value.cPassword != formData.value.password
+  ) {
+    callback(new Error("密码不一致,请重新输入"))
+  }
+  callback()
+}
+const items: Array<VbFormItem> = [
+  {
+    field: "oldPassword",
+    label: "原密码",
+    required: true,
+    component: ElInput,
+    type: "password",
+    class: "w-100",
+    placeholder: "请输入原密码",
+  },
+  {
+    field: "password",
+    label: "新密码",
+    required: true,
+    component: ElInput,
+    type: "password",
+    class: "w-100",
+    placeholder: "请输入新密码",
+    rules: [{ validator: validatePass, trigger: "blur" }],
+  },
+  {
+    field: "cPassword",
+    label: "确认密码",
+    required: true,
+    component: ElInput,
+    type: "password",
+    class: "w-100",
+    placeholder: "请输入确认密码",
+    rules: [{ validator: validatePass, trigger: "blur" }],
+  },
+]
+function password() {
+  formData.value = {
+    oldPassword: "",
+    cPassword: "",
+    password: "",
+  }
+  pwdModal.value.show()
+}
+function changePassword() {
+  Rs.post("auth/users/changePassWord", {
+    data: {
+      oldPassword: formData.value.oldPassword,
+      userName: store.user?.userName,
+      password: formData.value.password,
+    },
+  })
 }
 </script>

+ 3 - 1
src/views/dashboard/Screen/Alarm.vue

@@ -86,7 +86,9 @@ function scroll() {
   }
 }
 function init() {
-  Rs.post("sys/pushEvent/getList", { data: { pageIndex: 1, pageSize: props.max, params: {} } }).then((res) => {
+  Rs.post("sys/pushEvent/getList", {
+    data: { pageIndex: 1, pageSize: props.max, params: {}, successAlert: false },
+  }).then((res) => {
     alarmData.value = res.data
     if (alarmData.value.length > props.scrollLength) {
       clearInterval(scorllTimer)

+ 1 - 1
src/views/dashboard/Screen/Map.vue

@@ -87,7 +87,7 @@ const getCompany = () => {
 
   //   renderMap()
   // })
-  Rs.post("sys/query/getCompany", { data: companySearch }).then((res: any) => {
+  Rs.post("sys/query/getCompany", { data: companySearch, successAlert: false }).then((res: any) => {
     companyList.value = res.data
     companyTotal.value = Number(res.total)
     renderMap()