feat:卡片页滚动与通过后状态修改 #196

Merged
zhaohui merged 1 commits from fix/change_task into test 1 year ago

@ -19,9 +19,10 @@ const sortorder = ref("asc");
const sortname = ref("states"); const sortname = ref("states");
const loading = ref(true); const loading = ref(true);
const total = ref(0); const total = ref(0);
const scrollContainer=ref(null);
const tableData = ref<any>([]); const tableData = ref<any>([]);
const finalStore = useFinal(); const finalStore = useFinal();
let num = 1;
const pagination = reactive({ const pagination = reactive({
page: 1, page: 1,
pageCount: 20, pageCount: 20,
@ -40,8 +41,40 @@ const initRem = () => {
document.documentElement.style.fontSize = scale * rempPx + "px"; document.documentElement.style.fontSize = scale * rempPx + "px";
}; };
function initData() { async function initData( page: number,
query(1, 10); pageSize: number,
filterId?: any,
taskName?: string) {
const asideParmas = unref(finalStore.getAsideValue);
// 使使
// let params = filterId ? { userSearchId: filterId } : asideParmas
let params = asideParmas;
params = params?.izshowall ? {} : params;
const result = await getFinalList({
sortorder: sortorder.value,
pageSize,
currPage: page,
sortname: sortname.value,
taskName,
//isFail: true,
...params,
});
const { data, pageCount, totalCount } = result;
console.log(data, pageCount, totalCount);
//tableData.value = tableData.value.concat(data);
tableData.value = data;
console.log(tableData.value)
total.value = totalCount;
pagination.page = page;
pagination.pageCount = Math.ceil(totalCount / pageSize);
loading.value = false;
tableData.value.map((item) => {
if(isValidTimestamp(item.createdate)){
item.createdate = formatToDateHMS(item.createdate);
}});
tableData.value = chunk(tableData.value, 4);
} }
async function query( async function query(
page: number, page: number,
@ -63,23 +96,51 @@ async function query(
currPage: page, currPage: page,
sortname: sortname.value, sortname: sortname.value,
taskName, taskName,
//isFail: true,
...params, ...params,
}); });
const { data, pageCount, totalCount } = result; const { data, pageCount, totalCount } = result;
console.log(data, pageCount, totalCount); console.log(data, pageCount, totalCount);
let newlist=[]
tableData.value = data; let oldlist= tableData.value
if(oldlist.length>0){
oldlist.map((item)=>{
console.log(item)
if(item.length>0){
item.map((itemx:any)=>{
newlist.push(itemx)
})
}
})
data.map((item)=>{
newlist.push(item)
})
}else{
newlist=data
}
//tableData.value = tableData.value.concat(data);
tableData.value = newlist;
console.log(tableData.value)
total.value = totalCount; total.value = totalCount;
pagination.page = page; pagination.page = page;
pagination.pageCount = Math.ceil(totalCount / pageSize); pagination.pageCount = Math.ceil(totalCount / pageSize);
loading.value = false; loading.value = false;
tableData.value.map((item) => { tableData.value.map((item) => {
if(isValidTimestamp(item.createdate)){
item.createdate = formatToDateHMS(item.createdate); item.createdate = formatToDateHMS(item.createdate);
}); }});
tableData.value = chunk(tableData.value, 4); tableData.value = chunk(tableData.value, 4);
} }
function isValidTimestamp(value) {
if (typeof value !== 'number' || !Number.isInteger(value)) {
return false; //
}
const date = new Date(value);
return !isNaN(date.getTime()); //
}
// //
function goDetail(row) { function goDetail(row) {
router.push({ router.push({
@ -113,7 +174,7 @@ function showModal(modalRef: any) {
} }
onMounted(() => { onMounted(() => {
initRem(); initRem();
initData(); initData(1,20);
}); });
const item = { const item = {
img: testImg, img: testImg,
@ -175,7 +236,8 @@ function doAudit(param: any, row: any) {
if (code === "OK") { if (code === "OK") {
message.success(res.message); message.success(res.message);
//changecardstatus(3, row); //changecardstatus(3, row);
query(1, 10); initData(1,20);
num=1
reload(); reload();
} else { } else {
message.error(res.message); message.error(res.message);
@ -206,6 +268,35 @@ function reload() {
// const { page, pageSize } = unref(tableRef.value?.pagination) as PaginationProps // const { page, pageSize } = unref(tableRef.value?.pagination) as PaginationProps
// query(page!, pageSize!) // query(page!, pageSize!)
} }
let debounceTimer;
//
function checkBottom() {
const container = scrollContainer.value;
// console.log(1)
if (!container) return;
// const { scrollTop, clientHeight, scrollHeight } = container;
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
//
const clientHeight =
window.innerHeight || document.documentElement.clientHeight;
//
const scrollHeight = document.documentElement.scrollHeight;
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
if (scrollTop + clientHeight >= scrollHeight - 10) {
num = num + 1;
console.log(num);
query(num, 20)
// fetchData(); //
}
}, 500);
}
</script> </script>
<template> <template>
@ -304,107 +395,108 @@ function reload() {
<div class="header_data"> <div class="header_data">
<DataHeader :hasColor="true" /> <DataHeader :hasColor="true" />
</div> </div>
<div class="cotnet_wrapeer" @scroll="checkBottom" ref="scrollContainer">
<div
class="data_wrapper"
v-for="(sitem, sindex) in tableData"
:key="sindex"
:style="
sitem.length == 1
? { width: '25%' }
: sitem.length == 2
? { width: '50%' }
: sitem.length == 3
? { width: '75%' }
: {}
"
>
<div <div
class="item" class="data_wrapper"
v-for="(item, index) in sitem" v-for="(sitem, sindex) in tableData"
:key="index" :key="sindex"
:style=" :style="
sitem.length == 1 sitem.length == 1
? { width: '25%' } ? { width: '25%' }
: sitem.length == 2 : sitem.length == 2
? { margin: '0 2% 0 2%' } ? { width: '50%' }
: sitem.length == 3 : sitem.length == 3
? { width: '75%' } ? { width: '75%' }
: {} : {}
" "
> >
<div class="top"> <div
<div class="item"
class="img" v-for="(item, index) in sitem"
:style="`background:url(${item.img});background-size:100%;background-repeat: no-repeat;`" :key="index"
> :style="
<div class="check_box" v-show="item.states == 2"> sitem.length == 1
<n-checkbox size="medium" label=" " /> ? { margin: '0 4% 0 4%' }
</div> : sitem.length == 2
</div> ? { margin: '0 2% 0 2%' }
<div class="content"> : sitem.length == 3
<div class="title"> ? { margin: '0 1.2% 0 1.2%' }
<n-ellipsis style="max-width: 8.5vw"> : {}
任务ID{{ item.fromtaskid }} "
</n-ellipsis> >
</div> <div class="top">
<div class="date"> <div
<n-ellipsis style="max-width: 8.5vw" class="img"
>{{ item.createdate }} :style="`background:url(${item.serverThumbnailUrl});background-size:100%;background-repeat: no-repeat;`"
</n-ellipsis> >
<div class="check_box" v-show="item.states == 2">
<n-checkbox size="medium" label=" " />
</div>
</div> </div>
<div class="tag_box"> <div class="content">
<div <div class="title">
class="tag_item" <n-ellipsis style="max-width: 8.5vw">
v-for="index in 2" 任务ID{{ item.fromtaskid }}
:key="index" </n-ellipsis>
:style=" </div>
index == 2 || item.states == 3 <div class="date">
? 'color:#02C984' <n-ellipsis style="max-width: 8.5vw"
: item.states == 2 >{{ item.createdate }}
? 'color: #fe9800;background:#f7eac0' </n-ellipsis>
: item.states == 5 </div>
? 'color:#FF4E4F;background:#f7c0c0' <div class="tag_box">
: 'color:#02C984' <div
" class="tag_item"
> v-for="index in 2"
{{ :key="index"
index == 1 :style="
? item.states == 3 index == 2 || item.states == 3
? "通过" ? 'color:#02C984'
: item.states == 2 : item.states == 2
? "待审核" ? 'color: #fe9800;background:#f7eac0'
: item.states == 5 : item.states == 5
? "未通过" ? 'color:#FF4E4F;background:#f7c0c0'
: "" : 'color:#02C984'
: item.fromusername "
}} >
{{
index == 1
? item.states == 3
? "通过"
: item.states == 2
? "待审核"
: item.states == 5
? "未通过"
: ""
: item.fromusername
}}
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <div class="bottom">
<div class="bottom"> <!-- <div class="reset_action">重置审批</div>-->
<!-- <div class="reset_action">重置审批</div>--> <div
<div class="resovle_action"
class="resovle_action" v-show="item.states != 2"
v-show="item.states != 2" @click="goDetail(item)"
@click="goDetail(item)" >
> 查看
查看 </div>
</div> <div
<div class="resovle_action"
class="resovle_action" v-show="item.states == 2"
v-show="item.states == 2" @click="actionHandler({ key: 'approval' }, item)"
@click="actionHandler({ key: 'approval' }, item)" >
> 通过
通过 </div>
</div> <div
<div class="reject_action"
class="reject_action" v-show="item.states == 2"
v-show="item.states == 2" @click="actionHandler({ key: 'reject' }, [item])"
@click="actionHandler({ key: 'reject' }, [item])" >
> 不通过
不通过 </div>
</div> </div>
</div> </div>
</div> </div>
@ -525,7 +617,9 @@ function reload() {
width: 100%; width: 100%;
} }
.data_wrapper { .data_wrapper {
// padding-right: 10px;
display: flex; display: flex;
//box-sizing: border-box;
flex-flow: row wrap; flex-flow: row wrap;
align-items: center; align-items: center;
// justify-content: flex-start; // justify-content: flex-start;
@ -630,5 +724,39 @@ function reload() {
} }
} }
} }
.cotnet_wrapeer {
width: 100%;
height: 70vh;
//padding-right: 10px; /* */
overflow: hidden; /* 默认隐藏滚动条 */
}
.cotnet_wrapeer:hover {
overflow: auto;
width: calc(100% + 5px);
}
/* 定义滚动条的宽度及背景颜色 */
::-webkit-scrollbar {
position: fixed;
width: 5px; /* for vertical scrollbars */
height: 10px; /* for horizontal scrollbars */
background: #f1f1f1;
}
/* 定义滚动条轨道的样式 */
::-webkit-scrollbar-track {
background-color: #e1e1e1;
border-radius: 10px; /* 圆角 */
}
/* 定义滚动条滑块的样式 */
::-webkit-scrollbar-thumb {
background-color: #888;
border-radius: 10px; /* 圆角 */
}
/* 滑块hover时的样式 */
::-webkit-scrollbar-thumb:hover {
background-color: #555;
}
} }
</style> </style>

Loading…
Cancel
Save