359 lines
9.7 KiB
Vue
Raw Normal View History

2023-07-19 18:09:20 +08:00
<template>
2023-07-20 17:05:40 +08:00
<div class="warning-page">
<LeftMenu
v-model="active"
:tabs="['项目名称', '工程名称']"
:records="records"
@change-page="onCurChange"
@search="onSearchInput"
:pageable="pages"
class="leftMenu"
2023-07-19 18:09:20 +08:00
>
2023-07-20 17:05:40 +08:00
<template #default="{ data }">
<div class="leftProject" @click="onSearch(data)">
<span class="projectName">{{
(data as any).projectName || (data as any).engineeringName
}}</span>
<div class="leftMenu_item">
<div class="video">
<img style="margin-right: 5px" src="@/assets/images/AIwaring/dustMap.png" alt="" />
<span class="middleSize">{{ data.projectAddress || data.address }}</span>
</div>
</div>
</div>
2023-07-19 18:09:20 +08:00
</template>
2023-07-20 17:05:40 +08:00
</LeftMenu>
<div class="table-box">
<ProTable
ref="proTable"
title="用户列表"
:columns="columns"
:requestApi="getTableList"
:dataCallback="dataCallback"
:tool-button="false"
:pagination="true"
background
:isShowSearch="false"
:onReset="true"
>
<template #operation="{ row }">
<el-button type="primary" link @click="handleShowItem(2, row)">
<img src="@/assets/images/tableIcon/updateIcon.png" alt="" class="configureIcon" />
<span>查看</span>
</el-button>
</template>
2023-07-20 18:23:56 +08:00
<template #state="{ row }">
2023-07-24 10:00:48 +08:00
<span>{{
row.state == 1
? "未开始"
: row.state == 2
? "进行中"
: row.state == 3
? "已完成"
: row.state == 4
? "逾期未开始"
: row.state == 5
? "逾期进行中"
: row.state == 6
? "逾期已完成"
: ""
}}</span>
2023-07-20 18:23:56 +08:00
</template>
2023-07-20 17:05:40 +08:00
<template #slippage="{ row }">
<span :style="{ color: row.slippage ? 'red' : 'var(--el-menu-text-color)' }">{{ row.slippage }}</span>
</template>
</ProTable>
</div>
2023-07-19 18:09:20 +08:00
</div>
</template>
<script setup lang="tsx" name="ProjectSupervisionRecord">
2023-07-20 17:05:40 +08:00
import { ref, reactive, nextTick, computed, onMounted } from "vue";
2023-07-19 18:09:20 +08:00
import { ElMessage, ElMessageBox } from "element-plus";
import { useRouter } from "vue-router";
import { ColumnProps } from "@/components/ProTable/interface";
import ProTable from "@/components/ProTable/index.vue";
import { getRoleList, getTreemRoleList, getTreeByIdList } from "@/api/modules/project";
import { parentItemAll } from "@/api/modules/huizhou";
import { GlobalStore } from "@/stores";
2023-07-20 17:05:40 +08:00
import LeftMenu from "@/components/LeftMenu/LeftMenu.vue";
import { getDustprojectPage, getDustengineeringPage, getAIQuestionPage } from "@/api/modules/goverment";
const pages = ref({
pageNo: 1,
pageSize: 7,
total: 0
});
const pageable = ref({
pageNo: 1,
pageSize: 12,
total: 0
});
const records = ref([]);
const active = ref(1);
2023-07-19 18:09:20 +08:00
const treeRef = ref(null);
const datas = reactive([]);
const router = useRouter();
const globalStore = GlobalStore();
const themeConfig = computed(() => globalStore.themeConfig);
const visible = ref(false);
const drawerVisible = ref(false);
const title = ref("");
const formData = ref({});
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTable = ref();
const getId = ref<number | undefined>(undefined);
// 表格配置项
const columns: ColumnProps[] = [
{ type: "index", label: "序号", width: 80 },
{
prop: "name",
label: "任务名称",
search: { el: "input" }
},
{ prop: "commander", label: "负责人" },
{ prop: "planStartTime", label: "开始日期" },
{ prop: "planEndTime", label: "结束日期" },
{ prop: "completeRatio", label: "完成百分比(%)" },
{ prop: "slippage", label: "逾期情况(天)" },
{
prop: "createTime",
label: "时间筛选",
isShow: false,
search: {
el: "date-picker",
props: {
type: "daterange",
format: "YYYY-MM-DD",
valueFormat: "YYYY-MM-DD"
// defaultTime: defaultTime2
}
}
},
2023-07-20 18:23:56 +08:00
{
prop: "state",
label: "状态",
search: { el: "select" },
enum: [
{ label: "未开始", value: 1 },
{ label: "进行中", value: 2 },
{ label: "已完成", value: 3 },
2023-07-24 10:00:48 +08:00
{ label: "逾期未开始", value: 4 },
{ label: "逾期进行中", value: 5 },
{ label: "逾期已完成", value: 6 }
2023-07-20 18:23:56 +08:00
]
},
2023-07-19 18:09:20 +08:00
{ prop: "operation", label: "操作", fixed: "right", width: 100 }
];
2023-07-20 17:05:40 +08:00
// 项目或者工程名字
const searchName = ref<string>("");
// 搜索用的项目sn或者工程sn
const searchSn = ref("");
// 页面的项目名称和工程名称的div点击事件
const onSearch = async (params: any) => {
// const { result } = await getAIQuestionPage(
// active.value === 0
// ? { projectSn: (params as ResAiProjectPage).projectSn, pageNo: pageable.value.pageNo, pageSize: pageable.value.pageSize }
// : {
// engineeringSn: (params as ResAiEngineerPage).engineeringSn,
// pageNo: pageable.value.pageNo,
// pageSize: pageable.value.pageSize
// }
// );
// pageable.value.total = Number(result.total);
active.value === 0 ? (searchSn.value = params.projectSn) : (searchSn.value = params.engineeringSn);
active.value === 0 ? (searchName.value = params.projectName) : (searchName.value = params.engineeringName);
proTable.value.getTableList();
};
// leftMenu页面的搜索按钮
const onSearchInput = async (params: string) => {
console.log(params);
if (active.value === 0) {
const { result } = await getDustprojectPage({ projectName: params, ...pages.value });
records.value = result.records;
} else {
const { result } = await getDustengineeringPage({ engineeringName: params, ...pages.value });
records.value = result.records;
}
};
// leftMenu页面的分页
const onCurChange = async (params: number) => {
console.log(active.value);
if (active.value === 0) {
const { result } = await getDustprojectPage({ ...pages.value, pageNo: params });
records.value = result.records;
} else {
const { result } = await getDustengineeringPage({ ...pages.value, pageNo: params });
records.value = result.records;
pages.value.total = +result.total;
}
pages.value.total = +res.result.total;
};
2023-07-19 18:09:20 +08:00
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,那么你可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const dataCallback = (data: any) => {
// console.log(data);
return {
list: data.records,
total: Number(data.total),
pageNo: Number(data.current),
pageSize: Number(data.size)
};
};
const transfrom = (arr: Array<any>) => {
const result = [];
return arr
.map(item => {
if (arr.children && Array.isArray(arr.children)) {
result.concat(transfrom(arr.children));
}
return {
authorityId: item.name,
roleId: getId.value,
type: item.type
};
})
.concat(result);
};
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params));
if (newParams.createTime) {
newParams.realEndTime_begin = newParams.createTime[0];
newParams.realEndTime_end = newParams.createTime[1];
delete newParams.createTime;
}
2023-07-20 17:05:40 +08:00
newParams.engineeringSn = searchSn.value;
2023-07-19 18:09:20 +08:00
return parentItemAll(newParams);
};
const handleShowItem = (index: number, row: any) => {
router.push("/hz-project/progressManagement/ganttChart/index");
};
// 修改数据按钮
const handleEditItem = async (row: any) => {
getId.value = row.roleId;
drawerVisible.value = true;
const { result = [] } = await getTreemRoleList();
// console.log("test", result);
datas.push(...result);
const res = await getTreeByIdList({ roleId: row.roleId });
nextTick(() => {
treeRef.value.setCheckedKeys(res.result.map(item => item.authorityId));
});
};
2023-07-20 17:05:40 +08:00
// 获取工程名称分页
const getEngPage = async () => {
const { result } = await getDustengineeringPage(pages.value);
records.value = result.records;
records.value.map(item => {
let showGif = false;
item.showGif = showGif;
});
pages.value.total = +result.total;
};
onMounted(async () => {
await getEngPage();
onSearch(records.value[0]);
searchSn.value = records.value[0].projectSn;
searchName.value = records.value[0].projectName;
});
2023-07-19 18:09:20 +08:00
</script>
<style scoped lang="scss">
2023-07-20 17:05:40 +08:00
.warning-page {
// background-color: blue;
display: flex;
width: 100%;
2023-07-19 18:09:20 +08:00
height: 100%;
2023-07-20 17:05:40 +08:00
.leftMenu {
width: 300px;
// width: 290px;
// 页面的项目工程
:deep(.item) {
height: 78px !important;
}
:deep(.content) {
height: calc(100% - 160px) !important;
}
:deep {
.tab-wrapper {
display: none;
}
}
.leftProject {
// padding: 5px 8px;
font-size: 20px;
color: #333333;
.projectName {
display: block;
width: 100%;
overflow: hidden;
// font-weight: 700;
font-family: "siyuan_Medium";
font-size: 20px;
color: #ffffff;
text-overflow: ellipsis;
white-space: nowrap;
}
.leftMenu_item {
display: flex;
justify-content: space-between;
overflow: hidden;
.video {
display: flex;
align-items: center;
.middleSize {
font-size: 18px;
color: #c4c4c4;
white-space: nowrap;
}
img {
width: 14px;
height: 14px;
margin: 0 4px;
}
}
}
.bottom_item {
.bottomSize {
font-size: 18px !important;
color: #666666;
}
}
}
}
.table-box {
width: calc(100% - 320px);
height: 100%;
margin-left: 20px;
.table {
margin-left: 20px;
height: 100%;
:deep(.table-main) {
height: calc(100% - 82px);
}
}
}
2023-07-19 18:09:20 +08:00
}
:deep() {
.el-form .el-form-item__content .el-range-editor {
width: 300px;
}
.el-range-separator {
color: var(--el-menu-text-color);
}
}
</style>