Pārlūkot izejas kodu

reactor:登录新增短信验证码;知识库保存草稿调整;用户手机号必填

zhangchong 1 gadu atpakaļ
vecāks
revīzija
ff46cf99c5

+ 38 - 1
src/App.vue

@@ -19,11 +19,15 @@ import { useThemeConfig } from '@/stores/themeConfig';
 import other from '@/utils/other';
 import checkUpdate from '@/utils/checkUpdate';
 import mittBus from '@/utils/mitt';
-import { Session, Local } from '@/utils/storage';
+import { Session, Local, Cookie } from '@/utils/storage';
 import setIntroduction from '@/utils/setIconfont';
 import { loginPageInfo } from '@/api/login';
 import { getImageUrl } from '@/utils/tools';
 import { useKeepALiveNames } from '@/stores/keepAliveNames';
+import { busyOff, dutyOff } from '@/api/public/wex';
+import { ola } from '@/utils/ola_api';
+import signalR from '@/utils/signalR';
+import { useTelStatus } from '@/stores/telStatus';
 // 引入组件
 const LockScreen = defineAsyncComponent(() => import('@/layout/lockScreen/index.vue'));
 const SetTings = defineAsyncComponent(() => import('@/layout/navBars/breadcrumb/setings.vue'));
@@ -82,6 +86,35 @@ onBeforeMount(async () => {
 	// 设置批量第三方 js
 	setIntroduction.jsCdn();
 });
+const logOut = () => {
+  if (telStatusInfo.value.isRest === 'resting') {
+    // 小休中 结束小休(调用业务系统接口,统计需要)
+    busyOff(); // 结束小休(调用业务系统接口,统计需要)
+  }
+	// 执行退出登录
+	dutyOff(); // 呼叫中心签出
+	ola.logout(); // 呼叫中心退出登录
+	ola.close(); // 呼叫中心关闭
+	signalR.leaveAllGroupAndStop(); // 退出所有组
+	// 重置所有状态
+	useTelStatusStore.resetState();
+	// 清除缓存/token等
+	Local.clear();
+	Session.clear();
+	Cookie.clear();
+};
+const beforeunloadHandler = (e: BeforeUnloadEvent) => {
+  // 用户关闭标签页或者浏览器时
+  e.preventDefault();
+  e.returnValue = '';
+  console.log('21321')
+};
+// 用户关闭标签页或者浏览器时
+const useTelStatusStore = useTelStatus();
+const { telStatusInfo } = storeToRefs(useTelStatusStore);
+const unloadHandler = async () => {
+	logOut();
+};
 // 页面加载时
 onMounted(() => {
 	nextTick(async () => {
@@ -122,6 +155,8 @@ onMounted(() => {
 			console.log(error);
 		}
 	});
+	window.addEventListener('beforeunload', (e) => beforeunloadHandler(e));
+	window.addEventListener('unload', (e) => unloadHandler);
 });
 // 清除缓存 name
 const clearCacheTagsView = async (routeName: string) => {
@@ -139,6 +174,8 @@ const clearCacheTagsView = async (routeName: string) => {
 onUnmounted(() => {
 	mittBus.off('openSetTingsDrawer', () => {});
 	mittBus.off('clearCache', () => {});
+	window.removeEventListener('beforeunload', (e) => beforeunloadHandler(e));
+	window.removeEventListener('unload', (e) => unloadHandler);
 });
 // 监听路由的变化,设置网站标题
 watch(

+ 1 - 2
src/views/knowledge/index/edit.vue

@@ -399,7 +399,7 @@ const onSaveOnly = throttle(async (formEl: FormInstance | undefined) => {
 		Reflect.deleteProperty(submitObj, 'creationTime');
 		if (route.params.id) {
 			// 更新
-			KnowledgeUpdate({ data: submitObj })
+			KnowledgeUpdate({ data: {...submitObj,status:0} })
 				.then(handleSuccess)
 				.catch(() => {
 					state.loading = false;
@@ -467,7 +467,6 @@ const getDetail = async () => {
 			state.ruleForm.keywordsName = state.ruleForm.keywordsDto.map((item: any) => item.tag).join(',');
 		}
     state.ruleForm.knowledgeTypeId = state.ruleForm.knowledgeType.map((item: any) => item.key);
-    console.log(state.ruleForm.knowledgeTypeId)
 	}
 };
 onMounted(() => {

+ 57 - 7
src/views/login/component/Account.vue

@@ -67,6 +67,31 @@
 				</el-col>
 			</el-form-item>
 		</motion>
+    <motion :delay="400">
+    <el-form-item prop="code" class="mb30" :rules="[{ required: false, message: '请输入短信验证码', trigger: 'blur' }]">
+      <el-col :span="15">
+        <el-input
+          type="text"
+          maxlength="4"
+          placeholder="请输入短信验证码"
+          v-model="state.ruleForm.code"
+          clearable
+          autocomplete="off"
+          class="inputDeep"
+        >
+          <template #prefix>
+            <SvgIcon name="ele-ChatDotSquare" class="el-input__icon" />
+          </template>
+        </el-input>
+      </el-col>
+      <el-col :span="1"></el-col>
+      <el-col :span="8">
+        <el-button class="login-content-code" :disabled="isDisabled" @click="getIdentifyCodeBtn">{{
+            isDisabled ? count + 's后重新获取' : click
+          }}</el-button>
+      </el-col>
+    </el-form-item>
+  </motion>
 		<motion :delay="400">
 			<el-form-item>
 				<el-button type="primary" class="login-content-submit" round @click="onSignIn(ruleFormRef)" :loading="state.loading">登录</el-button>
@@ -100,6 +125,7 @@ import { signIn } from '@/api/login';
 import { JSEncrypt } from 'jsencrypt'; // rsa加密
 import { throttle } from '@/utils/tools';
 import Motion from '@/utils/motion';
+import { verifyPhone } from "@/utils/toolsValidate";
 
 const ReImageVerify = defineAsyncComponent(() => import('@/components/ImgVerify/index.vue'));
 
@@ -135,6 +161,37 @@ const validatePass = (rule: any, value: any, callback: any) => {
 };
 // 验证码
 const verifyCode = ref<string>(''); // 验证码
+const count = ref(60);
+const click = ref('获取验证码');
+const isDisabled = ref(false);
+const getIdentifyCodeBtn = () => {
+  if(!state.ruleForm.userName) {
+    ruleFormRef.value?.validateField('userName');
+    return;
+  }
+  if (!verifyPhone(state.ruleForm.userName)) {
+    ruleFormRef.value?.validateField('userName');
+    return;
+  }
+  // state.loading = true;
+  countDown();
+};
+// 倒计时
+const countDown = () => {
+  if (count.value === 0) {
+    isDisabled.value = false;
+    click.value = '获取验证码';
+    count.value = 60;
+    return;
+  } else {
+    count.value--;
+    click.value = count.value + 's后重新获取';
+    isDisabled.value = true;
+    setTimeout(() => {
+      countDown();
+    }, 1000);
+  }
+};
 // 登录
 const onSignIn = throttle(async (formEl: FormInstance | undefined) => {
 	if (!formEl) return;
@@ -240,13 +297,6 @@ const signInSuccess = (isNoPower: boolean | undefined) => {
     font-size: var(--el-font-size-medium);
 	}
 
-	.login-content-code {
-		width: 100%;
-		padding: 0;
-		font-weight: bold;
-		letter-spacing: 5px;
-	}
-
 	.login-content-submit {
 		width: 100%;
 		margin-top: 45px;

+ 3 - 3
src/views/login/component/Mobile.vue

@@ -129,9 +129,6 @@ const validatePass = (rule: any, value: any, callback: any) => {
 		callback();
 	}
 };
-const count = ref(60);
-const click = ref('获取验证码');
-const isDisabled = ref(false);
 const checkPhone = (rule, value, callback) => {
 	if (!value) {
 		return callback(new Error('手机号不能为空'));
@@ -143,6 +140,9 @@ const checkPhone = (rule, value, callback) => {
 		}
 	}
 };
+const count = ref(60);
+const click = ref('获取验证码');
+const isDisabled = ref(false);
 const getIdentifyCodeBtn = () => {
   if(!state.ruleForm.userName) {
     ruleFormRef.value?.validateField('userName');

+ 4 - 4
src/views/login/index.vue

@@ -7,14 +7,14 @@
 				</Motion>
         <Motion>
 <!--          <div v-if="!state.isScan">-->
-            <el-tabs v-model="state.tabsActiveName">
-              <el-tab-pane label="账号登录" name="account">
+<!--            <el-tabs v-model="state.tabsActiveName">
+              <el-tab-pane label="账号登录" name="account">-->
                 <account />
-              </el-tab-pane>
+<!--              </el-tab-pane>
               <el-tab-pane label="手机号登录" name="mobile">
                 <Mobile />
               </el-tab-pane>
-            </el-tabs>
+            </el-tabs>-->
 <!--          </div>-->
         </Motion>
 <!--				<Scan v-if="state.isScan" />

+ 2 - 2
src/views/system/user/component/User-add.vue

@@ -16,8 +16,8 @@
 					</el-form-item>
 				</el-col>
 				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
-					<el-form-item label="电话号码" prop="phoneNo" :rules="[{ required: false, message: '请输入电话号码', trigger: 'blur' }]">
-						<el-input v-model="state.ruleForm.phoneNo" placeholder="请输入电话号码" clearable></el-input>
+					<el-form-item label="手机号" prop="phoneNo" :rules="[{ required: true, message: '请输入手机号', trigger: 'blur' }]">
+						<el-input v-model="state.ruleForm.phoneNo" placeholder="请输入手机号" clearable></el-input>
 					</el-form-item>
 				</el-col>
 				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">

+ 2 - 2
src/views/system/user/component/User-edit.vue

@@ -18,8 +18,8 @@
 					</el-form-item>
 				</el-col>
 				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
-					<el-form-item label="电话号码" prop="phoneNo" :rules="[{ required: false, message: '请输入电话号码', trigger: 'blur' }]">
-						<el-input v-model="state.ruleForm.phoneNo" placeholder="请输入电话号码" clearable></el-input>
+					<el-form-item label="手机号" prop="phoneNo" :rules="[{ required: true, message: '请输入手机号', trigger: 'blur' }]">
+						<el-input v-model="state.ruleForm.phoneNo" placeholder="请输入手机号" clearable></el-input>
 					</el-form-item>
 				</el-col>
 				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">