OA登录弹框
This commit is contained in:
1 parent
d012099013
commit
88051db91e
1 file changed
+111
-32
+111
-32
@@ -593,52 +593,77 @@ const userAgents = ref<Array<{ id: number; name: string; description: string; ic
|
|||||||
const showGeneralFeedbackDialog = ref(false);
|
const showGeneralFeedbackDialog = ref(false);
|
||||||
const showAgentPanel = ref(true);
|
const showAgentPanel = ref(true);
|
||||||
|
|
||||||
const OA_BASE_URL = 'http://oa.well-trust.com:8888';
|
const OA_BASE_URL = 'http://192.168.100.221:8888';
|
||||||
const OA_LOGIN_URL = `${OA_BASE_URL}/login/Login.jsp?logintype=1`;
|
const OA_LOGIN_URL = `${OA_BASE_URL}/login/Login.jsp?logintype=1`;
|
||||||
const OA_VERIFY_LOGIN_URL = `${OA_BASE_URL}/login/VerifyLogin.jsp`;
|
const OA_VERIFY_LOGIN_URL = `${OA_BASE_URL}/login/VerifyLogin.jsp`;
|
||||||
const OA_LEAVE_APPLY_PATH = '/workflow/request/AddRequest.jsp?workflowid=652&isagent=0&beagenter=0&f_weaver_belongto_userid=';
|
const OA_LEAVE_APPLY_PATH = '/workflow/request/AddRequest.jsp?workflowid=652&isagent=0&beagenter=0&f_weaver_belongto_userid=';
|
||||||
const OA_REQUEST_VIEW_PATH = '/workflow/request/ViewRequest.jsp?requestid=';
|
const OA_REQUEST_VIEW_PATH = '/workflow/request/ViewRequest.jsp?requestid=';
|
||||||
const OA_AUTO_LOGIN_USERNAME = '26040006';
|
|
||||||
const OA_AUTO_LOGIN_PASSWORD = '26040006';
|
|
||||||
const OA_AUTO_LOGIN_TARGET = 'hxops-oa-leave-request';
|
const OA_AUTO_LOGIN_TARGET = 'hxops-oa-leave-request';
|
||||||
|
|
||||||
const openOAAutoLoginPage = (gopage: string, target = OA_AUTO_LOGIN_TARGET) => {
|
// OA 登录对话框状态
|
||||||
const popup = window.open(OA_LOGIN_URL, target);
|
const OA_PASSWORD_STORAGE_KEY = 'hxops_oa_login_password';
|
||||||
|
const showOALoginDialog = ref(false);
|
||||||
|
const oaLoginEmployeeId = ref('');
|
||||||
|
const oaLoginPassword = ref(localStorage.getItem(OA_PASSWORD_STORAGE_KEY) || '');
|
||||||
|
const oaLoginGopage = ref('');
|
||||||
|
const oaLoginTarget = ref(OA_AUTO_LOGIN_TARGET);
|
||||||
|
|
||||||
|
const openOAAutoLoginPage = (gopage: string, username: string, password: string, target = OA_AUTO_LOGIN_TARGET) => {
|
||||||
|
// 直接在弹出窗口内写入自动提交表单,避免跨窗口时序问题
|
||||||
|
const popup = window.open('about:blank', target);
|
||||||
if (!popup) {
|
if (!popup) {
|
||||||
showMessageDialog('warning', '浏览器拦截了 OA 页面,请允许弹出窗口后重试。');
|
showMessageDialog('warning', '浏览器拦截了 OA 页面,请允许弹出窗口后重试。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const form = document.createElement('form');
|
const formHtml = `
|
||||||
form.action = OA_VERIFY_LOGIN_URL;
|
<!DOCTYPE html>
|
||||||
form.method = 'POST';
|
<html>
|
||||||
form.target = target;
|
<head><meta charset="utf-8"><title>正在登录OA系统...</title></head>
|
||||||
form.style.display = 'none';
|
<body>
|
||||||
|
<p style="text-align:center;margin-top:100px;font-family:sans-serif;color:#666;">正在登录OA系统,请稍候...</p>
|
||||||
|
<form id="oaLoginForm" action="${OA_VERIFY_LOGIN_URL}" method="POST">
|
||||||
|
<input type="hidden" name="loginid" value="${username}" />
|
||||||
|
<input type="hidden" name="userpassword" value="${password.replace(/"/g, '"')}" />
|
||||||
|
<input type="hidden" name="gopage" value="${gopage}" />
|
||||||
|
<input type="hidden" name="logintype" value="1" />
|
||||||
|
</form>
|
||||||
|
<script>document.getElementById('oaLoginForm').submit();<\/script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
|
||||||
const fields = {
|
popup.document.open();
|
||||||
loginid: OA_AUTO_LOGIN_USERNAME,
|
popup.document.write(formHtml);
|
||||||
userpassword: OA_AUTO_LOGIN_PASSWORD,
|
popup.document.close();
|
||||||
gopage,
|
|
||||||
logintype: '1',
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.entries(fields).forEach(([name, value]) => {
|
|
||||||
const input = document.createElement('input');
|
|
||||||
input.type = 'hidden';
|
|
||||||
input.name = name;
|
|
||||||
input.value = value;
|
|
||||||
form.appendChild(input);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.appendChild(form);
|
|
||||||
window.setTimeout(() => {
|
|
||||||
form.submit();
|
|
||||||
document.body.removeChild(form);
|
|
||||||
}, 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openOALeaveRequestDirectly = () => {
|
const openOALeaveRequestDirectly = () => {
|
||||||
openOAAutoLoginPage(OA_LEAVE_APPLY_PATH);
|
const employeeId = currentUserEmployeeId.value;
|
||||||
|
if (!employeeId || employeeId === '-') {
|
||||||
|
showMessageDialog('warning', '没有工号信息无法登录OA系统!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
oaLoginEmployeeId.value = employeeId;
|
||||||
|
oaLoginPassword.value = localStorage.getItem(OA_PASSWORD_STORAGE_KEY) || '';
|
||||||
|
oaLoginGopage.value = OA_LEAVE_APPLY_PATH;
|
||||||
|
oaLoginTarget.value = OA_AUTO_LOGIN_TARGET;
|
||||||
|
showOALoginDialog.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmOALogin = () => {
|
||||||
|
if (!oaLoginPassword.value.trim()) {
|
||||||
|
showMessageDialog('warning', '请输入OA登录密码!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 记住密码到 localStorage
|
||||||
|
localStorage.setItem(OA_PASSWORD_STORAGE_KEY, oaLoginPassword.value.trim());
|
||||||
|
showOALoginDialog.value = false;
|
||||||
|
openOAAutoLoginPage(oaLoginGopage.value, oaLoginEmployeeId.value, oaLoginPassword.value.trim(), oaLoginTarget.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelOALogin = () => {
|
||||||
|
showOALoginDialog.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const openOARequestDirectly = (requestId: string) => {
|
const openOARequestDirectly = (requestId: string) => {
|
||||||
@@ -647,7 +672,16 @@ const openOARequestDirectly = (requestId: string) => {
|
|||||||
showMessageDialog('warning', '当前未获取到 OA 单据编号,暂时无法打开单据详情。');
|
showMessageDialog('warning', '当前未获取到 OA 单据编号,暂时无法打开单据详情。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openOAAutoLoginPage(`${OA_REQUEST_VIEW_PATH}${encodeURIComponent(normalizedRequestId)}`, `hxops-oa-request-${normalizedRequestId}`);
|
const employeeId = currentUserEmployeeId.value;
|
||||||
|
if (!employeeId || employeeId === '-') {
|
||||||
|
showMessageDialog('warning', '没有工号信息无法登录OA系统!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
oaLoginEmployeeId.value = employeeId;
|
||||||
|
oaLoginPassword.value = localStorage.getItem(OA_PASSWORD_STORAGE_KEY) || '';
|
||||||
|
oaLoginGopage.value = `${OA_REQUEST_VIEW_PATH}${encodeURIComponent(normalizedRequestId)}`;
|
||||||
|
oaLoginTarget.value = `hxops-oa-request-${normalizedRequestId}`;
|
||||||
|
showOALoginDialog.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeFeedbackMessageIndex = ref<number | null>(null);
|
const activeFeedbackMessageIndex = ref<number | null>(null);
|
||||||
@@ -2606,6 +2640,51 @@ const showChatRating = ref(false);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- OA 登录对话框 -->
|
||||||
|
<Teleport to="body">
|
||||||
|
<div v-if="showOALoginDialog" class="fixed inset-0 z-[9999] flex items-center justify-center">
|
||||||
|
<div class="absolute inset-0 bg-black/40" @click="cancelOALogin"></div>
|
||||||
|
<div class="relative w-full max-w-sm rounded-2xl bg-white p-6 shadow-2xl dark:bg-slate-800">
|
||||||
|
<h3 class="mb-4 text-center text-lg font-bold text-slate-800 dark:text-slate-100">登录OA系统</h3>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<label class="block space-y-1.5">
|
||||||
|
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">工号</span>
|
||||||
|
<input
|
||||||
|
v-model="oaLoginEmployeeId"
|
||||||
|
type="text"
|
||||||
|
disabled
|
||||||
|
class="w-full rounded-xl border border-slate-200 bg-slate-100 px-3 py-2.5 text-sm text-slate-600 outline-none dark:border-slate-600 dark:bg-slate-700 dark:text-slate-300"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label class="block space-y-1.5">
|
||||||
|
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">密码</span>
|
||||||
|
<input
|
||||||
|
v-model="oaLoginPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入OA登录密码"
|
||||||
|
class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-800 outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-100 dark:focus:border-brand-500 dark:focus:ring-brand-500/20"
|
||||||
|
@keyup.enter="confirmOALogin"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="mt-6 flex items-center justify-end gap-3">
|
||||||
|
<button
|
||||||
|
@click="cancelOALogin"
|
||||||
|
class="rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-600 transition hover:bg-slate-50 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-700"
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
@click="confirmOALogin"
|
||||||
|
class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-brand-700 dark:bg-brand-500 dark:hover:bg-brand-600"
|
||||||
|
>
|
||||||
|
确认登录
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in new issue
Block a user