feat: 合同模块优化
This commit is contained in:
parent
1392cf5441
commit
d3c107f2ff
|
@ -14,6 +14,17 @@ export async function authLogin(body: API.LoginDto, options?: RequestOptions) {
|
|||
});
|
||||
}
|
||||
|
||||
/** 解锁屏幕 POST /api/auth/unlock */
|
||||
export async function unlock(body: API.LoginDto, options?: RequestOptions) {
|
||||
return request<API.LoginToken>('/api/auth/unlock', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
/** 注册 POST /api/auth/register */
|
||||
export async function authRegister(body: API.RegisterDto, options?: RequestOptions) {
|
||||
return request<any>('/api/auth/register', {
|
||||
|
|
|
@ -352,9 +352,9 @@ declare namespace API {
|
|||
/** 密码 */
|
||||
password: string;
|
||||
/** 验证码标识 */
|
||||
captchaId: string;
|
||||
captchaId?: string;
|
||||
/** 用户输入的验证码 */
|
||||
verifyCode: string;
|
||||
verifyCode?: string;
|
||||
};
|
||||
|
||||
type LoginLogInfo = {
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
WifiOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { Avatar, message } from 'ant-design-vue';
|
||||
import HuaweiCharge from './huawei-charge.vue';
|
||||
import XiaomiCharge from './xiaomi-charge.vue';
|
||||
|
@ -85,7 +84,6 @@
|
|||
import { useBattery } from '@/hooks/useBattery';
|
||||
import { useLockscreenStore } from '@/store/modules/lockscreen';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { LOGIN_NAME } from '@/router/constant';
|
||||
|
||||
const lockscreenStore = useLockscreenStore();
|
||||
const userStore = useUserStore();
|
||||
|
@ -94,9 +92,6 @@
|
|||
const { month, day, hour, minute, week } = useTime();
|
||||
const { online } = useOnline();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const { battery, batteryStatus, calcDischargingTime } = useBattery();
|
||||
|
||||
const randomCompName = Math.random() > 0.48 ? XiaomiCharge : HuaweiCharge;
|
||||
|
@ -116,33 +111,20 @@
|
|||
// 登录
|
||||
const onLogin = async () => {
|
||||
if (state.loginForm.password.trim() == '') return message.warn('请填写密码');
|
||||
// const params = { ...state.loginForm };
|
||||
const params = { ...state.loginForm };
|
||||
state.loginLoading = true;
|
||||
// params.password = md5(params.password)
|
||||
// const { code, message: msg } = await userStore.login(params).finally(() => {
|
||||
// state.loginLoading = false;
|
||||
// message.destroy();
|
||||
// });
|
||||
// if (code == 0) {
|
||||
// Modal.destroyAll();
|
||||
// message.success('登录成功!');
|
||||
// unLockLogin(false);
|
||||
// lockscreenStore.setLock(false);
|
||||
// } else {
|
||||
// message.info(msg || '登录失败');
|
||||
// }
|
||||
await userStore.unlock(params).finally(() => {
|
||||
state.loginLoading = false;
|
||||
});
|
||||
message.destroy();
|
||||
unLockLogin(false);
|
||||
lockscreenStore.setLock(false);
|
||||
};
|
||||
|
||||
const nav2login = () => {
|
||||
unLockLogin(false);
|
||||
lockscreenStore.setLock(false);
|
||||
router.replace({
|
||||
name: LOGIN_NAME,
|
||||
query: {
|
||||
redirect: route.fullPath,
|
||||
},
|
||||
});
|
||||
userStore.logout();
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import { computed, nextTick, type CSSProperties } from 'vue';
|
||||
import { computed, type CSSProperties } from 'vue';
|
||||
import { useRouter, useRoute, type RouteRecordRaw } from 'vue-router';
|
||||
import {
|
||||
QuestionCircleOutlined,
|
||||
|
@ -72,7 +72,6 @@
|
|||
} from '@ant-design/icons-vue';
|
||||
import {
|
||||
Layout,
|
||||
message,
|
||||
Modal,
|
||||
Dropdown,
|
||||
Menu,
|
||||
|
@ -85,9 +84,7 @@
|
|||
import { Search, FullScreen, ProjectSetting } from './components/';
|
||||
import { LocalePicker } from '@/components/basic/locale-picker';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { useKeepAliveStore } from '@/store/modules/keepAlive';
|
||||
import { useLockscreenStore } from '@/store/modules/lockscreen';
|
||||
import { LOGIN_NAME } from '@/router/constant';
|
||||
import { TitleI18n } from '@/components/basic/title-i18n';
|
||||
import { useLayoutSettingStore } from '@/store/modules/layoutSetting';
|
||||
|
||||
|
@ -103,7 +100,6 @@
|
|||
const userStore = useUserStore();
|
||||
const layoutSettingStore = useLayoutSettingStore();
|
||||
const lockscreenStore = useLockscreenStore();
|
||||
const keepAliveStore = useKeepAliveStore();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
@ -192,17 +188,6 @@
|
|||
// logout({})
|
||||
await userStore.logout();
|
||||
}
|
||||
keepAliveStore.clear();
|
||||
// 移除标签页
|
||||
localStorage.clear();
|
||||
message.success('成功退出登录');
|
||||
await nextTick();
|
||||
router.replace({
|
||||
name: LOGIN_NAME,
|
||||
query: {
|
||||
redirect: route.fullPath,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
@ -2,4 +2,4 @@ import dashboard from './dashboard';
|
|||
// import demos from './demos';
|
||||
import account from './account';
|
||||
|
||||
export default [/* ...demos, */ ...dashboard, ...account];
|
||||
export default [/* ...demos, */ /* ...dashboard, */ ...account];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ref, watch } from 'vue';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useDictStore } from './dict';
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { useRouter, type RouteRecordRaw, useRoute } from 'vue-router';
|
||||
import { store } from '@/store';
|
||||
import Api from '@/api/';
|
||||
import { ACCESS_TOKEN_KEY } from '@/enums/cacheEnum';
|
||||
|
@ -9,6 +9,9 @@ import { Storage } from '@/utils/Storage';
|
|||
import { resetRouter } from '@/router';
|
||||
import { generateDynamicRoutes } from '@/router/helper/routeHelper';
|
||||
import { uniqueSlash } from '@/utils/urlUtils';
|
||||
import { useKeepAliveStore } from './keepAlive';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { LOGIN_NAME } from '@/router/constant';
|
||||
|
||||
export type MessageEvent = {
|
||||
data?: any;
|
||||
|
@ -94,6 +97,15 @@ export const useUserStore = defineStore('user', () => {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
/** 解锁屏幕 */
|
||||
const unlock = async (params: API.LoginDto) => {
|
||||
try {
|
||||
const data = await Api.auth.unlock(params);
|
||||
return data;
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
/** 登录成功之后, 获取用户信息以及生成权限路由 */
|
||||
const afterLogin = async () => {
|
||||
try {
|
||||
|
@ -121,12 +133,25 @@ export const useUserStore = defineStore('user', () => {
|
|||
perms.value = permsData;
|
||||
menus.value = generateDynamicRoutes(menusData as unknown as RouteRecordRaw[]);
|
||||
};
|
||||
const keepAliveStore = useKeepAliveStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
/** 登出 */
|
||||
const logout = async () => {
|
||||
await Api.account.accountLogout();
|
||||
closeEventSource();
|
||||
resetToken();
|
||||
resetRouter();
|
||||
keepAliveStore.clear();
|
||||
// 移除标签页
|
||||
localStorage.clear();
|
||||
await nextTick();
|
||||
router.replace({
|
||||
name: LOGIN_NAME,
|
||||
query: {
|
||||
redirect: route.fullPath,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -136,6 +161,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
menus,
|
||||
userInfo,
|
||||
login,
|
||||
unlock,
|
||||
afterLogin,
|
||||
logout,
|
||||
resetToken,
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
width: 50,
|
||||
maxWidth: 50,
|
||||
hideInSearch: true,
|
||||
fixed:'right',
|
||||
fixed: 'right',
|
||||
dataIndex: 'files',
|
||||
customRender: ({ record }) => <FilesRender {...record} />,
|
||||
},
|
||||
|
@ -176,7 +176,10 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
function delRowConfirm(record) {}
|
||||
const delRowConfirm = async (record) => {
|
||||
await Api.contract.contractDelete({ id: record });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
|
||||
const FilesRender: FunctionalComponent<TableListItem> = (contract: API.ContractEntity) => {
|
||||
const [fnModal] = useModal();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<DynamicTable :search="false" :data-source="fileList" :columns="columns" />
|
||||
|
||||
<a-flex justify="flex-end" gap="10">
|
||||
<Button @click="onCancel">取消</Button>
|
||||
<Button @click="onCancel">关闭</Button>
|
||||
<Button :type="'primary'" @click="onOk" :disabled="disabledUpload">上传</Button></a-flex
|
||||
>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue