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