我参与的,检索与重置

This commit is contained in:
“XCYH” 2024-04-17 23:57:25 +08:00
parent 7e1dc44569
commit dd85d5eea4
5 changed files with 120 additions and 98 deletions

View File

@ -12,7 +12,7 @@ const api = 'http://nbxt.oa.x-lf.cn'
* @param token 访问令牌 * @param token 访问令牌
* @returns {Promise<AxiosResponse<any>> | *} * @returns {Promise<AxiosResponse<any>> | *}
*/ */
const getChargeProjectList = (token)=> { export const getChargeProjectList = (token)=> {
return axios({ return axios({
method: 'get', method: 'get',
url: `${api}/project/participate/get`, url: `${api}/project/participate/get`,
@ -22,3 +22,6 @@ const getChargeProjectList = (token)=> {
} }
}) })
} }

View File

@ -5,15 +5,15 @@
<div style="display:flex;flex-direction:row;justify-content: space-around "> <div style="display:flex;flex-direction:row;justify-content: space-around ">
<div> <div>
名称 名称
<el-input v-model="input" style="width: 240px;margin-left:0.5vw" placeholder="请输入" /> <el-input v-model="input1" style="width: 240px;margin-left:0.5vw" placeholder="请输入" />
</div> </div>
<div> <div>
状态 状态
<el-input v-model="input" style="width: 240px;margin-left:0.5vw" placeholder="请输入" /> <el-input v-model="input2" style="width: 240px;margin-left:0.5vw" placeholder="请输入" />
</div> </div>
<div> <div>
<el-button type="primary" style="width:80px">查询</el-button> <el-button type="primary" style="width:80px" @click="search">查询</el-button>
<el-button style="width:80px">重置</el-button> <el-button style="width:80px" @click="reset">重置</el-button>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -23,15 +23,15 @@
</div> </div>
<el-table ref="multipleTableRef" :data="tableData" style="max-width: 100vw;" <el-table ref="multipleTableRef" :data="tableData" style="max-width: 100vw;"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" />--> <el-table-column type="selection" width="55" />
<el-table-column label="序号" width="120"> <el-table-column label="序号" width="120">
<template #default="scope">{{ scope.row.date }}</template> <template #default="scope">{{ scope.row.date }}</template>
</el-table-column> </el-table-column>
<el-table-column property="name" label="项目名称" width="120" /> <el-table-column property="name" label="项目名称" width="120" />
<el-table-column property="address" label="工作量" show-overflow-tooltip /> <el-table-column property="workLoad" label="工作量" show-overflow-tooltip />
<el-table-column property="address" label="周期" /> <el-table-column property="cycle" label="周期" />
<el-table-column property="address" label="负责人" /> <el-table-column property="principalUser" label="负责人" />
<el-table-column property="address" label="状态"/> <el-table-column property="isFinish" label="状态" />
<el-table-column property="address" label="项目简介" /> <el-table-column property="address" label="项目简介" />
@ -51,16 +51,11 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { ElTable } from 'element-plus'; import { ElTable } from 'element-plus';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { getManageList } from '@/api/manage.js'; import { getChargeProjectList } from '@/api/charge.js';
import { getToken } from '@/utils/auth'; import { getToken } from '@/utils/auth';
const router = useRouter(); const router = useRouter();
//
const toChildSystem = () => {
router.push({ name: 'ChildSysCharge' }); //
};
const input = ref('');
@ -68,30 +63,21 @@ const input = ref('');
interface User { interface User {
id: number id: number;
cycle: number cycle: number;
name: string name: string;
description: string description: string;
workLoad: number workLoad: number;
card: string card: string;
isFinish: number isFinish: number;
principalUser: string principalUser: string;
dateline: string dateline: string;
} }
const multipleTableRef = ref<InstanceType<typeof ElTable>>(); //
const multipleSelection = ref<User[]>([]); const input1 = ref('');
const input2 = ref('');
const handleSelectionChange = (val: User[]) => {
multipleSelection.value = val;
};
//
const project = getManageList(getToken());
//
const tableData = ref<User[]>([ const tableData = ref<User[]>([
//
{ {
id: 4, id: 4,
cycle: 2, cycle: 2,
@ -99,7 +85,7 @@ const tableData = ref<User[]>([
description: "xxxxxxx", description: "xxxxxxx",
workLoad: 12, workLoad: 12,
card: "java", card: "java",
isFinish: 2, isFinish: 3,
principalUser: "teacher_user", principalUser: "teacher_user",
dateline: "2021-12-31" dateline: "2021-12-31"
}, },
@ -110,26 +96,25 @@ const tableData = ref<User[]>([
description: "xxxxxxx", description: "xxxxxxx",
workLoad: 12, workLoad: 12,
card: "java", card: "java",
isFinish: 2, isFinish: 1,
principalUser: "teacher_user", principalUser: "teacher_user",
dateline: "2021-12-31" dateline: "2021-12-31"
}, }
]); ]);
const initialTableData = ref<User[]>([]);
// //
project.then(res => { const fetchData = () => {
const project = getChargeProjectList(getToken());
project.then(res => {
const data = res.data; const data = res.data;
console.log(data);
if (data) { if (data) {
// data
const dataProject: User = { const dataProject: User = {
id: 4, id: 4,
cycle: 2, cycle: 2,
name: "项目2", name: "项目3",
description: "xxxxxxx", description: "xxxxxxx",
workLoad: 12, workLoad: 12,
card: "java", card: "java",
@ -137,18 +122,59 @@ project.then(res => {
principalUser: "teacher_user", principalUser: "teacher_user",
dateline: "2021-12-31" dateline: "2021-12-31"
}; };
// 使 tableData.value
tableData.value.push(dataProject); tableData.value.push(dataProject);
initialTableData.value = tableData.value.slice(); // tableDatainitialTableData
} else { } else {
console.log("没有数据"); console.log("没有数据");
} }
}) }).catch(err => {
.catch(err => {
console.log(err); console.log(err);
}); });
};
//
fetchData();
//
const toChildSystem = () => {
router.push({ name: 'ChildSysCharge' });
};
//
const multipleTableRef = ref<InstanceType<typeof ElTable>>();
const multipleSelection = ref<User[]>([]);
const handleSelectionChange = (val: User[]) => {
multipleSelection.value = val;
};
//
const search = () => {
const keyword = input1.value.trim().toLowerCase();
const status = parseInt(input2.value);
//
if (keyword === '' && isNaN(status)) {
tableData.value = initialTableData.value.slice();
return;
}
//
tableData.value = initialTableData.value.filter(item => {
const matchKeyword = (keyword === '' || item.name.toLowerCase().includes(keyword));
const matchStatus = (isNaN(status) || item.isFinish === status);
return matchKeyword && matchStatus;
});
};
//
const reset = () => {
input1.value = '';
input2.value = '';
tableData.value = initialTableData.value.slice(); //
};
</script> </script>
<style> <style>

View File

@ -25,10 +25,7 @@
>子模块列表</el-button >子模块列表</el-button
> >
<div>
<el-button type="primary" style="width:80px">新增</el-button>
<el-button style="width:80px ;background-color: #bd3124;color: azure;">删除</el-button>
</div>
</div> </div>
<el-table <el-table
ref="multipleTableRef" ref="multipleTableRef"

View File

@ -36,7 +36,7 @@
style="max-width: 100vw;" style="max-width: 100vw;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<!-- <el-table-column type="selection" width="55" />--> <el-table-column type="selection" width="55" />
<el-table-column label="序号" width="120"> <el-table-column label="序号" width="120">
<template #default="scope">{{ scope.row.date }}</template> <template #default="scope">{{ scope.row.date }}</template>
</el-table-column> </el-table-column>

View File

@ -36,11 +36,7 @@
</el-row> </el-row>
</el-card> </el-card>
<div style="display: flex; justify-content: center;">
<el-button type="primary" style="width:80px">编辑</el-button>
<el-button style="width:80px ;background-color: #bd3124;color: azure;">删除</el-button>
</div>