Prechádzať zdrojové kódy

Merge branch 'dev' of http://192.168.0.115:3000/bill/4pc into dev

bill 1 rok pred
rodič
commit
56c64c3725

+ 14 - 4
src/request/index.ts

@@ -23,7 +23,7 @@ import {
 
 const error = throttle((msg: string) => ElMessage.error(msg), 2000);
 
-type Other = { params?: Param; paths?: Param; useResult?: boolean };
+type Other = { params?: Param; paths?: Param; useResult?: boolean, noToken?: boolean };
 export const sendFetch = <T>(
   url: string,
   init: RequestInit,
@@ -41,6 +41,9 @@ export const sendFetch = <T>(
       sendUrl =
         sendUrl + "?" + new URLSearchParams({ ...gParams, ...other.params });
     }
+    if (other.noToken) {
+      delete gHeaders.token
+    }
   }
   lifeHook.forEach(({ start }) => start());
 
@@ -48,9 +51,9 @@ export const sendFetch = <T>(
     ...init,
     headers: headers
       ? {
-          ...headers,
-          ...gHeaders,
-        }
+        ...headers,
+        ...gHeaders,
+      }
       : gHeaders,
   })
     .then((res) => {
@@ -89,6 +92,13 @@ export const loginFetch = (props: LoginProps) =>
     body: JSON.stringify(props),
   });
 
+  export const loginOutFetch = () =>
+    sendFetch<{ user: UserInfo; token: string }>(URL.logout, {
+      method: "post",
+      body: JSON.stringify({}),
+    });
+  
+
 export const userInfoFetch = () =>
   sendFetch<UserInfo>(URL.getUserInfo, { method: "post" });
 

+ 2 - 0
src/request/organization.ts

@@ -73,6 +73,8 @@ export const registerOrganization = (params: any) => {
     return sendFetch<ResResult>(URL.registerOrganization, {
         method: "post",
         body: JSON.stringify({ ...params, password, confirmPwd: password }),
+    }, {
+        noToken: true
     });
 
 }

+ 3 - 2
src/store/user.ts

@@ -1,4 +1,4 @@
-import { LoginProps, loginFetch, userInfoFetch } from "@/request";
+import { LoginProps, loginFetch, userInfoFetch, loginOutFetch } from "@/request";
 import { errorHook, gHeaders } from "@/request/state";
 import { UserInfo } from "@/request/type";
 import { encodePwd } from "@/util";
@@ -25,7 +25,8 @@ export const login = async (props: LoginProps) => {
   await getUserInfo();
 };
 
-export const logout = () => {
+export const logout = async () => {
+  await loginOutFetch();
   localStorage.removeItem("token");
   userStatus.value = UserStatus.NOT_LOGIN;
 };

+ 1 - 1
src/view/pano/pano.vue

@@ -25,7 +25,7 @@
         @click="update = true"
         v-if="router.currentRoute.value.name === 'pano'"
       >
-        修改名称
+        测点说明
       </el-button>
     </div>
   </div>

+ 13 - 4
src/view/register/register.vue

@@ -9,12 +9,11 @@
       <el-form-item
         class="panel-form-item"
         label="单位名称"
-        :maxlength="50"
         prop="orgName"
         required
       >
         <el-input
-          :maxlength="11"
+          :maxlength="50"
           v-model.trim="form.orgName"
           placeholder="请输入"
         ></el-input>
@@ -37,7 +36,7 @@
         required
       >
         <el-input
-          :maxlength="100"
+          :maxlength="50"
           v-model.trim="form.contact"
           placeholder="请选择"
         ></el-input>
@@ -145,6 +144,12 @@
           >注册</el-button
         >
       </el-form-item>
+
+      <el-form-item class="panel-form-item">
+        <el-button text plain type="default" class="fill text-btn" @click="toLogin"
+          >已注册,去登录</el-button
+        >
+      </el-form-item>
     </el-form>
   </div>
 </template>
@@ -180,7 +185,7 @@ const equalToPassword = (_, value: any, callback: any) => {
 };
 
 const rules = reactive<FormRules>({
-  orgName: [{ required: true, message: "请选择单位名称", trigger: "select" }],
+  orgName: [{ required: true, message: "请选择单位名称", trigger: "blur" }],
   msgAuthCode: [{ required: true, message: "请输入验证码", trigger: "change" }],
   contact: [{ required: true, message: "请输入姓名", trigger: "blur" }],
   userName: [
@@ -267,6 +272,10 @@ const submitClick = async () => {
     throw "";
   }
 };
+
+const toLogin = () => {
+  emit('done')
+};
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
src/view/users.vue

@@ -45,7 +45,7 @@
             <el-button link type="primary" @click="editHandler(row)" size="small">
               编辑
             </el-button>
-            <el-button link type="danger" @click="delHandler(row)" size="small" v-if="isSuper && !isMe(row.userId)">
+            <el-button link type="danger" @click="delHandler(row)" size="small" v-if="!isMe(row.userId)">
               删除
             </el-button>
           </template>