提交 a9a72999 编写于 作者: 水晶土豆

Thu Nov 23 19:02:00 CST 2023 inscode

上级 b829dd15
...@@ -11,10 +11,10 @@ import verticalTable from './component/main/verticalTable/verticalTable.vue'; ...@@ -11,10 +11,10 @@ import verticalTable from './component/main/verticalTable/verticalTable.vue';
</script> </script>
<template> <template>
<!-- <contractCategory></contractCategory> <!-- <contractCategory></contractCategory> -->
<contract-list></contract-list> <!-- <contract-list></contract-list> -->
<announcementType></announcementType> <!-- <announcementType></announcementType> -->
<departments></departments> --> <departments></departments>
<empss></empss> <empss></empss>
<!-- <job-title></job-title> --> <!-- <job-title></job-title> -->
<verticalTable></verticalTable> <verticalTable></verticalTable>
......
import request from "./index"; import request from "./index";
import type { IParams } from './index'; import type { IParams } from './index';
import { CONTRACT_CATEGORY, CONTRACT_LIST, CONTRACT_LIST_Type, DEPT_MENU, HUMAN_RESOURCES_DEPARTMENT, JOB_TITLE, LOGIN, TABLE_ANNOUNCEMENT,EMP_LISIT } from "./path"; import { CONTRACT_CATEGORY, CONTRACT_LIST, CONTRACT_LIST_Type, DEPT_MENU, HUMAN_RESOURCES_DEPARTMENT, JOB_TITLE, LOGIN, TABLE_ANNOUNCEMENT, EMP_LISIT } from "./path";
import type { AxiosResponse } from "axios"; import type { AxiosResponse } from "axios";
import { usePromiseStore } from '../storage/promiseStorage'
interface ILoginForm { interface ILoginForm {
username: string; username: string;
...@@ -43,18 +43,30 @@ export function getContractList(body: IParams): Promise<AxiosResponse<IContractC ...@@ -43,18 +43,30 @@ export function getContractList(body: IParams): Promise<AxiosResponse<IContractC
return request.get(CONTRACT_LIST, body); return request.get(CONTRACT_LIST, body);
} }
export function getContractListType(): Promise<AxiosResponse<any>>{ export function getContractListType(): Promise<AxiosResponse<any>> {
return request.get(CONTRACT_LIST_Type, {}); return request.get(CONTRACT_LIST_Type, {});
} }
export function getHumanResourcesDepartment(): Promise<AxiosResponse<any>>{ export function getHumanResourcesDepartment(): Promise<AxiosResponse<any>> {
return request.get(HUMAN_RESOURCES_DEPARTMENT, {}); const send = usePromiseStore();
const requestPromise = request.get(HUMAN_RESOURCES_DEPARTMENT, {});
send.setDepartment(requestPromise);
send.setDepartment(new Promise((resolve, reject) => {
setTimeout(resolve, 5000, "延时测试");
}))
return requestPromise;
} }
export function getJobTiTle() : Promise<AxiosResponse<any>>{ export function getJobTiTle(): Promise<AxiosResponse<any>> {
return request.get(JOB_TITLE,{}); return request.get(JOB_TITLE, {});
} }
export function getEmpList(body:IParams) :Promise<AxiosResponse<any>>{ export function getEmpList(body: IParams): Promise<AxiosResponse<any>> {
return request.get(EMP_LISIT,body); const send = usePromiseStore();
const requestPromise = request.get(EMP_LISIT, body);
send.setEmp(requestPromise);
send.setEmp(new Promise((resolve, reject) => {
setTimeout(resolve, 3000, "延时测试");
}))
return requestPromise;
} }
...@@ -5,18 +5,20 @@ import addDownload from '@/component/main/header/add_download/addDownload.vue'; ...@@ -5,18 +5,20 @@ import addDownload from '@/component/main/header/add_download/addDownload.vue';
import buttoner from '@/component/main/header/add_download/button.vue'; import buttoner from '@/component/main/header/add_download/button.vue';
import downloadItem from '@/component/main/header/add_download/downloadItem.vue'; import downloadItem from '@/component/main/header/add_download/downloadItem.vue';
import ejectDialog from '@/component/main/ejectDialog.vue'; import ejectDialog from '@/component/main/ejectDialog.vue';
import { ref, provide, onMounted } from 'vue'; import { ref, provide, onMounted, watch } from 'vue';
import { getHumanResourcesDepartment } from '@/api/api'; import { getHumanResourcesDepartment } from '@/api/api';
import { FlatToTree } from '@/util/toTree'; import { FlatToTree } from '@/util/toTree';
import { deepClone } from '@/util/deepCode'; import { deepClone } from '@/util/deepCode';
import { computed } from '@vue/reactivity'; import { computed } from '@vue/reactivity';
import loadingComponents from '@/component/loadingComponents/loadingComponents.vue';
import animation2 from '@/component/loadingComponents/animation/animation2.vue'
const addText = ref('添加部门'); const addText = ref('添加部门');
let tableData = ref([ let tableData = ref([
]) ])
let respData = ref(); let respData = ref();
const getData = () => { const getData = () => {
getHumanResourcesDepartment().then((res)=>{ getHumanResourcesDepartment().then((res) => {
respData.value = res.data.data.data; respData.value = res.data.data.data;
tableData.value = FlatToTree(deepClone(res.data.data.data)).tree; tableData.value = FlatToTree(deepClone(res.data.data.data)).tree;
}) })
...@@ -136,9 +138,30 @@ provide("cellSetStyle", ({ row, column, rowIndex, columnIndex }) => { ...@@ -136,9 +138,30 @@ provide("cellSetStyle", ({ row, column, rowIndex, columnIndex }) => {
} }
return; return;
}); });
const size = ref({
offsetWidth: 1,
offsetHeight: 1,
offsetLeft: 1,
offsetTop: 1
});
const commonLayout = ref();
onMounted(() => {
watch(() => tableData.value, (res) => {
setTimeout(() => {
size.value.offsetWidth = commonLayout.value.offsetWidth;
size.value.offsetHeight = commonLayout.value.offsetHeight;
size.value.offsetLeft = commonLayout.value.offsetLeft;
size.value.offsetTop = commonLayout.value.offsetTop;
}, 100)
})
})
</script> </script>
<template> <template>
<div ref="commonLayout" class="root">
<mains :tableType="tableType" :operation="operation"> <mains :tableType="tableType" :operation="operation">
<headers> <headers>
<!-- <headerFmainsorm></headerForm> --> <!-- <headerFmainsorm></headerForm> -->
...@@ -165,9 +188,18 @@ provide("cellSetStyle", ({ row, column, rowIndex, columnIndex }) => { ...@@ -165,9 +188,18 @@ provide("cellSetStyle", ({ row, column, rowIndex, columnIndex }) => {
<template #header>删除</template> <template #header>删除</template>
</ejectDialog> </ejectDialog>
</mains> </mains>
<loadingComponents :width="size.offsetWidth" :height="size.offsetHeight" :top="size.offsetTop" :left="size.offsetLeft" name="department">
<template #animation>
<animation2></animation2>
</template>
</loadingComponents>
</div>
</template> </template>
<style scoped> <style scoped>
.root{
position: relative;
}
.left { .left {
margin-right: auto; margin-right: auto;
} }
......
...@@ -4,7 +4,7 @@ import { deepClone } from '@/util/deepCode' ...@@ -4,7 +4,7 @@ import { deepClone } from '@/util/deepCode'
import { TreeToFlat, FlatToTree } from '@/util/toTree' import { TreeToFlat, FlatToTree } from '@/util/toTree'
import { computed } from '@vue/reactivity'; import { computed } from '@vue/reactivity';
import { getHumanResourcesDepartment, getContractCategory, getEmpList } from '@/api/api'; import { getHumanResourcesDepartment, getContractCategory, getEmpList } from '@/api/api';
import { usePromiseStore } from '@/storage/promiseStorage'
import mains from '@/component/main/main.vue'; import mains from '@/component/main/main.vue';
import ejectDialog from '@/component/main/ejectDialog.vue'; import ejectDialog from '@/component/main/ejectDialog.vue';
...@@ -16,6 +16,7 @@ import empSelectForm from './empSelectForm.vue'; ...@@ -16,6 +16,7 @@ import empSelectForm from './empSelectForm.vue';
import loadingComponents from '@/component/loadingComponents/loadingComponents.vue'; import loadingComponents from '@/component/loadingComponents/loadingComponents.vue';
import animation1 from '@/component/loadingComponents/animation/animation1.vue' import animation1 from '@/component/loadingComponents/animation/animation1.vue'
//树形列表 //树形列表
onMounted(() => { onMounted(() => {
getHumanResourcesDepartment().then((res) => { getHumanResourcesDepartment().then((res) => {
...@@ -52,12 +53,10 @@ const tablePagination = reactive({ ...@@ -52,12 +53,10 @@ const tablePagination = reactive({
pageSize: 10, pageSize: 10,
total: 1 total: 1
}); });
const sendRequestFirst = usePromiseStore();
const getData = () => { const getData = () => {
empSelect.value.page = tablePagination.currentPage; empSelect.value.page = tablePagination.currentPage;
empSelect.value.limit = tablePagination.pageSize; empSelect.value.limit = tablePagination.pageSize;
sendRequestFirst.setSendRequestFirst( getEmpList({ page: tablePagination.currentPage, limit: tablePagination.pageSize, deptName: JSON.stringify(treeValue.value) })); getEmpList({ page: tablePagination.currentPage, limit: tablePagination.pageSize, deptName: JSON.stringify(treeValue.value) }).then((res) => {
sendRequestFirst.getSendRequestFirst().then((res) => {
if (res.data.data.code === 10000) { if (res.data.data.code === 10000) {
tableData.value = res.data.data.data; tableData.value = res.data.data.data;
tablePagination.total = res.data.data.count; tablePagination.total = res.data.data.count;
...@@ -65,10 +64,6 @@ const getData = () => { ...@@ -65,10 +64,6 @@ const getData = () => {
console.log(res.data.data.msg); console.log(res.data.data.msg);
} }
}) })
sendRequestFirst.setSendRequestFirst(new Promise((resolve,reject)=>{
setTimeout(resolve,5000,"延时测试");
}))
} }
onMounted(() => { onMounted(() => {
getData(); getData();
...@@ -217,11 +212,6 @@ onMounted(() => { ...@@ -217,11 +212,6 @@ onMounted(() => {
</script> </script>
<template> <template>
<loadingComponents :width="size.offsetWidth" :height="size.offsetHeight" :top="size.offsetTop" :left="size.offsetLeft">
<template #animation>
<animation1></animation1>
</template>
</loadingComponents>
<div class="common-layout"> <div class="common-layout">
<el-container> <el-container>
<el-aside> <el-aside>
...@@ -231,7 +221,7 @@ onMounted(() => { ...@@ -231,7 +221,7 @@ onMounted(() => {
@check-change="treeCheckChange" /> @check-change="treeCheckChange" />
</el-aside> </el-aside>
<el-main> <el-main>
<div ref="commonLayout"> <div ref="commonLayout" class="commonLayoutCss">
<mains :tableType="tableType" :operation="operation"> <mains :tableType="tableType" :operation="operation">
<headers> <headers>
<forms> <forms>
...@@ -259,6 +249,12 @@ onMounted(() => { ...@@ -259,6 +249,12 @@ onMounted(() => {
@size-change="handleSizeChange" @current-change="handleCurrentChange" /> @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</template> </template>
</mains> </mains>
<loadingComponents :width="size.offsetWidth" :height="size.offsetHeight" :top="size.offsetTop"
:left="size.offsetLeft" name="emp">
<template #animation>
<animation1></animation1>
</template>
</loadingComponents>
</div> </div>
</el-main> </el-main>
</el-container> </el-container>
...@@ -266,4 +262,7 @@ onMounted(() => { ...@@ -266,4 +262,7 @@ onMounted(() => {
</template> </template>
<style scoped> <style scoped>
.commonLayoutCss{
position: relative;
}
</style> </style>
\ No newline at end of file
<script setup></script>
<template>
<div class="loading"></div>
</template>
<style scoped>
.loading {
position: relative;
width: 30px;
height: 30px;
border: 2px solid #000;
border-top-color: transparent;
border-bottom-color: transparent;
border-radius: 100%;
animation: arrow-circle infinite 0.75s linear;
}
.loading:before,
.loading:after {
position: absolute;
top: 24px;
left: -2px;
border-top: 5px solid #000;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
content: "";
transform: rotate(-30deg);
}
.loading:after {
top: 0;
left: 20.5px;
transform: rotate(150deg);
}
@keyframes arrow-circle {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0);
}
}
</style>
\ No newline at end of file
<script></script>
<template>
<div class="loading"></div>
</template>
<style scoped>
.loading {
width: 50px;
height: 50px;
border-radius: 100%;
background-color: #000;
animation: ball-scale infinite linear 0.75s;
}
@keyframes ball-scale {
0% {
transform: scale(0.1);
opacity: 1;
}
100% {
transform: scale(1);
opacity: 0;
}
}
</style>
\ No newline at end of file
<script setup> <script setup>
import { ref } from 'vue'; import { onMounted, ref } from 'vue';
import { usePromiseStore } from '@/storage/promiseStorage'; import { usePromiseStore } from '@/storage/promiseStorage';
import animation1 from './animation/animation1.vue';
const prop = defineProps([ const prop = defineProps([
'width', 'height', 'top', 'left' 'width', 'height', 'top', 'left', 'name'
]); ]);
const isShow = ref(false); const isShow = ref(false);
const exitMask = ref(false); const exitMask = ref(false);
// const promise1 = new Promise((resolve, reject) => {
// setTimeout(resolve, 1000, 'promise 1 resolved');
// });
// const promise2 = new Promise((resolve, reject) => {
// setTimeout(resolve, 3000, 'promise 2 rejected');
// });
const promiseDelayed = new Promise((resolve, reject) => { const promiseDelayed = new Promise((resolve, reject) => {
setTimeout(resolve, 1000, 'promiseDelayed') setTimeout(resolve, 1000, 'promiseDelayed')
}); });
const sendRequestAll = usePromiseStore(); const sendRequestAll = usePromiseStore();
(async () => { onMounted(async () => {
try { try {
for (let index in sendRequestAll) { const nameTemp = 'get' + prop.name.charAt(0).toUpperCase() + prop.name.slice(1)
if (index.slice(0, 1) === '_' || index.slice(0, 1) === '$') { if (sendRequestAll[nameTemp]) {
continue;
} else if (typeof (sendRequestAll[index]) === 'string') {
continue;
} else if (index.slice(0, 3) === 'set') {
} else if (index.slice(0, 3) === 'get') {
setTimeout(() => { setTimeout(() => {
Promise.race([sendRequestAll[index](), promiseDelayed]).then((res) => { Promise.race([sendRequestAll[nameTemp](), promiseDelayed]).then((res) => {
if (res === 'promiseDelayed') { if (res === 'promiseDelayed') {
isShow.value = true; isShow.value = true;
exitMask.value = true; exitMask.value = true;
sendRequestAll[index]().then((res) => { sendRequestAll[nameTemp]().then((res) => {
isShow.value = false; isShow.value = false;
exitMask.value = false; exitMask.value = false;
}) })
} }
}); });
}, 1000); }, 100);
} };
console.log(index);
}
// let result = await Promise.race([promise1, promise2, promiseDelayed]);
// if (result === 'promise 1 resolved') {
// for(let index in prop){
// console.log(prop[index]);
// }
// isShow.value = true;
// exitMask.value = true;
// console.log("please wait...")
// }
// promise2.then((res) => {
// isShow.value = false;
// exitMask.value = false;
// console.log(res);
// })
// console.log(result);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }
})(); });
</script> </script>
<template> <template>
...@@ -78,12 +48,11 @@ const sendRequestAll = usePromiseStore(); ...@@ -78,12 +48,11 @@ const sendRequestAll = usePromiseStore();
<style scoped> <style scoped>
.loading { .loading {
position: absolute; position: absolute;
display: none; display: none;
left: calc(var(--var-left-main) + var(--var-width-main)/2 - 15px); left: calc(var(--var-width-main)/2 - 15px);
top: calc(var(--var-top-main) + var(--var-height-main)/2 - 15px); top: calc(var(--var-height-main)/2 - 15px);
z-index: calc(var(--var-index-main) + 1); z-index: calc(var(--var-index-main) + 1);
} }
...@@ -94,8 +63,8 @@ const sendRequestAll = usePromiseStore(); ...@@ -94,8 +63,8 @@ const sendRequestAll = usePromiseStore();
.mask { .mask {
z-index: var(--var-index-main); z-index: var(--var-index-main);
position: absolute; position: absolute;
left: var(--var-left-main); left: 0;
top: var(--var-top-main); top: 0;
width: var(--var-width-main); width: var(--var-width-main);
height: var(--var-height-main); height: var(--var-height-main);
font-size: 16px; font-size: 16px;
...@@ -106,6 +75,8 @@ const sendRequestAll = usePromiseStore(); ...@@ -106,6 +75,8 @@ const sendRequestAll = usePromiseStore();
} }
.test { .test {
position: relative; position: absolute;
left: 0;
top: 0;
} }
</style> </style>
\ No newline at end of file
...@@ -3,15 +3,22 @@ import { defineStore } from "pinia"; ...@@ -3,15 +3,22 @@ import { defineStore } from "pinia";
export const usePromiseStore = defineStore('promise', { export const usePromiseStore = defineStore('promise', {
state() { state() {
return { return {
sendRequestFirst:'' emp: '',
department: ''
}; };
}, },
actions: { actions: {
setSendRequestFirst(sendRequestFirst){ setEmp(emp) {
this.sendRequestFirst = sendRequestFirst; this.emp = emp;
}, },
getSendRequestFirst(){ getEmp() {
return this.sendRequestFirst; return this.emp;
},
setDepartment(department) {
this.department = department;
},
getDepartment() {
return this.department;
} }
} }
}); });
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册