Files
td_official/src/views/progress/plan/index.vue

440 lines
16 KiB
Vue
Raw Normal View History

2025-05-27 09:16:44 +08:00
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="请选择方阵:" prop="pid" label-width="100">
<!-- <el-input v-model="queryParams.pid" placeholder="请选择" clearable /> -->
2025-06-06 20:03:35 +08:00
<el-cascader
2025-05-27 09:16:44 +08:00
:options="matrixOptions"
placeholder="请选择"
@change="handleChange"
2025-06-17 09:49:15 +08:00
:props="{ value: 'matrixId', label: 'name' }"
v-model="queryParams.matrixId"
2025-05-27 09:16:44 +08:00
clearable
2025-06-06 20:03:35 +08:00
/>
<!-- <el-select v-model="matrixValue" placeholder="请选择" @change="handleChange" clearable>
2025-05-28 19:52:30 +08:00
<el-option v-for="item in matrixOptions" :key="item.id" :label="item.matrixName" :value="item.id" />
2025-06-06 20:03:35 +08:00
</el-select> -->
2025-05-27 09:16:44 +08:00
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Download" @click="handleQuery">导出周报</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<!-- <template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['progress:progressCategory:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template> -->
<el-table
ref="progressCategoryTableRef"
v-loading="loading"
:data="progressCategoryList"
row-key="id"
:default-expand-all="isExpandAll"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
border
>
<el-table-column label="" width="50" type="expand">
2025-05-30 19:51:35 +08:00
<template #header>
<el-icon
class="cursor-pointer text-4! transform-rotate-z--90 transition-all-300"
:class="!isExpandAll ? 'transform-rotate-z--90' : 'transform-rotate-z-90'"
@click="handleToggleExpandAll"
><Expand
/></el-icon>
</template>
2025-05-27 09:16:44 +08:00
<template #default="scope">
<el-card class="pl-25" shadow="hover">
<el-table :data="scope.row.children" border>
2025-05-30 19:51:35 +08:00
<el-table-column label="名称" align="center" prop="name" width="170">
<template #default="{ row }">
<el-tooltip :content="row.remark" placement="top" effect="dark" v-if="row.remark">
<span class="flex items-center justify-center"
><i class="iconfont icon-wenhao mr-0.5 text-3.5! text-#999"></i>{{ row.name }}</span
>
</el-tooltip>
<span v-else>{{ row.name }}</span>
</template>
</el-table-column>
2025-05-27 09:16:44 +08:00
<el-table-column label="状态" align="center" prop="status" width="100">
<template #default="{ row }">
<dict-tag :options="progress_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="是否延期" align="center" prop="isDelay" width="100">
<template #default="{ row }">
<el-tag :type="row.isDelay == '1' ? 'danger' : 'primary'">{{ row.isDelay == '1' ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="计量方式" align="center" prop="unitType" width="100">
<template #default="{ row }">
<dict-tag :options="progress_unit_type" :value="row.unitType" />
</template>
</el-table-column>
<el-table-column label="总量" align="center" prop="total" width="100" />
<el-table-column label="总进度" align="center" prop="projectId">
<template #default="{ row }">
2025-05-27 19:53:19 +08:00
<el-progress :text-inside="true" :stroke-width="20" :percentage="row.completedPercentage" status="success" />
2025-05-27 09:16:44 +08:00
</template>
</el-table-column>
<el-table-column label="计划总量" align="center" prop="planTotal" width="100" />
<el-table-column label="计划中" align="center" prop="projectId">
<template #default="{ row }">
2025-05-27 19:53:19 +08:00
<el-progress :text-inside="true" :stroke-width="20" :percentage="row.planTotalPercentage" />
</template>
</el-table-column>
<el-table-column label="对比" align="center" prop="unitType" width="100">
<template #default="{ row }">
{{ row.completed + '/' + row.total }}
2025-05-27 09:16:44 +08:00
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
<template #default="scope">
2025-05-30 19:51:35 +08:00
<!-- <el-button
2025-05-27 09:16:44 +08:00
type="warning"
icon="Download"
link
size="small"
@click="openDialog(scope.row, 'importDataStatus', '上传数据')"
v-hasPermi="['progress:progressCategory:add']"
>
导入数据
2025-05-30 19:51:35 +08:00
</el-button> -->
2025-05-27 09:16:44 +08:00
<el-button
type="warning"
icon="Download"
link
size="small"
2025-05-30 19:51:35 +08:00
v-if="scope.row.name === '光伏板'"
2025-05-27 09:16:44 +08:00
@click="openDialog(scope.row, 'importTableStatus', '上传表格')"
v-hasPermi="['progress:progressCategory:add']"
>
导入表格
</el-button>
<el-button
type="success"
icon="Plus"
link
size="small"
2025-05-27 19:53:19 +08:00
@click="planRef.openDialog(scope.row)"
2025-05-27 09:16:44 +08:00
v-hasPermi="['progress:progressCategory:add']"
>
计划
</el-button>
<el-button
type="primary"
icon="Plus"
link
size="small"
2025-05-28 19:52:30 +08:00
@click="handleDayAdd(scope.row)"
2025-05-27 09:16:44 +08:00
v-hasPermi="['progress:progressCategory:add']"
>
日报
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</template>
</el-table-column>
<el-table-column label="名称" align="center" prop="name" width="150" />
<el-table-column label="状态" align="center" prop="status" width="100">
<template #default="{ row }">
<dict-tag :options="progress_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="总进度" align="center" prop="projectId">
<template #default="{ row }">
2025-05-27 19:53:19 +08:00
<el-progress :text-inside="true" :stroke-width="20" :percentage="row.completedPercentage" status="success" />
2025-05-27 09:16:44 +08:00
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 导入数据对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.importDataStatus" width="500px" append-to-body>
<file-upload class="pl-20 pt" v-model="dialog.file" :limit="20" :file-size="50" :file-type="['shp', 'shx', 'dbf']" />
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
2025-05-27 19:53:19 +08:00
<el-button @click="cancel('importDataStatus')"> </el-button>
2025-05-27 09:16:44 +08:00
</div>
</template>
</el-dialog>
<!-- 导入表格对话框 -->
2025-05-27 19:53:19 +08:00
<el-dialog :title="dialog.title" v-model="dialog.importTableStatus" width="500px" append-to-body>
2025-05-27 09:16:44 +08:00
<file-upload class="pl-20 pt" v-model="dialog.file" :limit="20" :file-size="50" :file-type="['xls', 'xlsx']" />
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
2025-05-27 19:53:19 +08:00
<el-button @click="cancel('importTableStatus')"> </el-button>
2025-05-27 09:16:44 +08:00
</div>
</template>
</el-dialog>
<!-- 创建计划对话框 -->
2025-05-28 19:52:30 +08:00
<CreatePlan ref="planRef" @getProgressList="getList"></CreatePlan>
<CreateDaily ref="dailyRef" @getProgressList="getList"></CreateDaily>
<CreateDailyRate ref="dailyRateRef" @getProgressList="getList"></CreateDailyRate>
2025-05-27 09:16:44 +08:00
</div>
</template>
<script setup name="ProgressCategory" lang="ts">
import {
listProgressCategory,
getProgressCategory,
delProgressCategory,
addProgressCategory,
updateProgressCategory,
getProjectSquare
} from '@/api/progress/plan/index';
import { ProgressCategoryVO, ProgressCategoryQuery, ProgressCategoryForm } from '@/api/progress/plan/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { progress_unit_type, progress_status } = toRefs<any>(proxy?.useDict('progress_unit_type', 'progress_status'));
2025-08-02 15:31:28 +08:00
2025-05-27 09:16:44 +08:00
import CreatePlan from './component/createPlan.vue';
import CreateDaily from './component/createDaily.vue';
2025-05-28 19:52:30 +08:00
import CreateDailyRate from './component/createDailyRate.vue';
2025-05-27 09:16:44 +08:00
type ProgressCategoryOption = {
id: number;
name: string;
children?: ProgressCategoryOption[];
};
2025-08-02 15:31:28 +08:00
import { useUserStoreHook } from '@/store/modules/user';
2025-05-27 09:16:44 +08:00
// 获取用户 store
const userStore = useUserStoreHook();
// 从 store 中获取项目列表和当前选中的项目
const currentProject = computed(() => userStore.selectedProject);
const progressCategoryList = ref<ProgressCategoryVO[]>([]);
const progressCategoryOptions = ref<ProgressCategoryOption[]>([]);
const buttonLoading = ref(false);
const showSearch = ref(true);
const isExpandAll = ref(true);
const loading = ref(false);
const planRef = ref<InstanceType<typeof CreatePlan>>();
const dailyRef = ref<InstanceType<typeof CreateDaily>>();
2025-05-28 19:52:30 +08:00
const dailyRateRef = ref<InstanceType<typeof CreateDailyRate>>();
2025-05-27 09:16:44 +08:00
const queryFormRef = ref<ElFormInstance>();
const progressCategoryFormRef = ref<ElFormInstance>();
const progressCategoryTableRef = ref<ElTableInstance>();
2025-05-28 19:52:30 +08:00
const matrixOptions = ref([]);
2025-05-27 09:16:44 +08:00
const dialog = reactive<any>({
dailyStatus: false,
planStatus: false,
importDataStatus: false,
importTableStatus: false,
title: '',
file: ''
});
2025-05-28 19:52:30 +08:00
const matrixValue = ref<number | undefined>(matrixOptions.value.length > 0 ? matrixOptions.value[0].id : undefined);
2025-05-27 09:16:44 +08:00
const initFormData: ProgressCategoryForm = {
id: undefined,
pid: undefined,
name: undefined,
matrixId: undefined,
unitType: undefined,
2025-08-14 01:58:00 +08:00
projectId: currentProject.value?.id
2025-05-27 09:16:44 +08:00
};
const data = reactive<PageData<ProgressCategoryForm, ProgressCategoryQuery>>({
form: { ...initFormData },
queryParams: {
pid: undefined,
name: undefined,
unitType: undefined,
2025-08-14 01:58:00 +08:00
projectId: currentProject.value?.id,
2025-05-27 09:16:44 +08:00
matrixId: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
pid: [{ required: true, message: '父类别id不能为空', trigger: 'blur' }],
name: [{ required: true, message: '类别名称不能为空', trigger: 'blur' }],
unitType: [{ required: true, message: '计量方式不能为空', trigger: 'change' }],
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询进度类别列表 */
const getList = async () => {
if (!queryParams.value.matrixId) {
2025-08-14 01:58:00 +08:00
const res = await getProjectSquare(currentProject.value?.id);
2025-08-02 15:31:28 +08:00
if (!res.data || res.data.length === 0) {
2025-05-30 19:51:35 +08:00
proxy?.$modal.msgWarning('当前项目下没有方阵,请先创建方阵');
} else {
2025-06-17 09:49:15 +08:00
let matrixList = res.data.map((item) => {
return {
...item,
matrixId: item.projectId
};
});
2025-08-02 15:31:28 +08:00
try {
if (!matrixValue.value) matrixValue.value = matrixList[0].id;
matrixOptions.value = matrixList;
queryParams.value.matrixId = matrixList[0].children[0].matrixId;
} catch (error) {
proxy?.$modal.msgError('获取方阵失败');
}
2025-05-30 19:51:35 +08:00
}
2025-05-27 09:16:44 +08:00
}
loading.value = true;
2025-07-14 16:10:03 +08:00
try {
const res = await listProgressCategory(queryParams.value);
2025-08-01 20:09:57 +08:00
const data = proxy?.handleTree<ProgressCategoryVO>(res.data, 'id', 'parentId');
2025-07-14 16:10:03 +08:00
if (data) {
progressCategoryList.value = data;
}
} finally {
// 不管成功或失败,最后都设置为 false
2025-05-27 09:16:44 +08:00
loading.value = false;
}
};
/** 查询进度类别下拉树结构 */
const getTreeselect = async () => {
const res = await listProgressCategory();
progressCategoryOptions.value = [];
const data: ProgressCategoryOption = { id: 0, name: '顶级节点', children: [] };
data.children = proxy?.handleTree<ProgressCategoryOption>(res.data, 'id', 'pid');
progressCategoryOptions.value.push(data);
};
// 取消按钮
2025-05-27 19:53:19 +08:00
const cancel = (visible) => {
2025-05-27 09:16:44 +08:00
reset();
2025-05-27 19:53:19 +08:00
dialog[visible] = false;
2025-05-27 09:16:44 +08:00
};
// 表单重置
const reset = () => {
form.value = { ...initFormData };
progressCategoryFormRef.value?.resetFields();
};
2025-05-30 19:51:35 +08:00
//切换项目重置方阵
const resetMatrix = () => {
matrixValue.value = undefined;
queryParams.value.matrixId = undefined;
matrixOptions.value = [];
};
2025-05-27 09:16:44 +08:00
/** 搜索按钮操作 */
const handleQuery = () => {
getList();
};
/** 级联选择器改变事件 */
2025-05-28 19:52:30 +08:00
const handleChange = (value: number) => {
2025-06-17 09:49:15 +08:00
queryParams.value.matrixId = value[1];
2025-05-27 09:16:44 +08:00
getList();
};
2025-05-28 19:52:30 +08:00
const handleDayAdd = (row: ProgressCategoryVO) => {
if (row.unitType === '2') {
dailyRef.value.openDialog(row);
} else {
dailyRateRef.value.openDialog(row);
}
};
2025-05-27 09:16:44 +08:00
/** 导入按钮操作 */
const openDialog = (row: ProgressCategoryVO, status: string, title: string) => {
reset();
// getTreeselect();
if (row != null && row.id) {
form.value.pid = row.id;
} else {
form.value.pid = 0;
}
dialog[status] = true;
dialog.title = title;
};
/** 展开/折叠操作 */
const handleToggleExpandAll = () => {
isExpandAll.value = !isExpandAll.value;
toggleExpandAll(progressCategoryList.value, isExpandAll.value);
};
/** 展开/折叠操作 */
const toggleExpandAll = (data: ProgressCategoryVO[], status: boolean) => {
data.forEach((item) => {
progressCategoryTableRef.value?.toggleRowExpansion(item, status);
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status);
});
};
/** 修改按钮操作 */
const handleUpdate = async (row: ProgressCategoryVO) => {
reset();
await getTreeselect();
if (row != null) {
form.value.pid = row.pid;
}
const res = await getProgressCategory(row.id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改进度类别';
};
/** 提交按钮 */
const submitForm = () => {
progressCategoryFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateProgressCategory(form.value).finally(() => (buttonLoading.value = false));
} else {
await addProgressCategory(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row: ProgressCategoryVO) => {
await proxy?.$modal.confirm('是否确认删除进度类别编号为"' + row.id + '"的数据项?');
loading.value = true;
await delProgressCategory(row.id).finally(() => (loading.value = false));
await getList();
proxy?.$modal.msgSuccess('删除成功');
};
onMounted(() => {
getList();
});
//监听项目id刷新数据
const listeningProject = watch(
2025-08-14 01:58:00 +08:00
() => currentProject.value?.id,
2025-05-27 09:16:44 +08:00
(nid, oid) => {
queryParams.value.projectId = nid;
form.value.projectId = nid;
2025-05-30 19:51:35 +08:00
resetMatrix();
2025-05-27 09:16:44 +08:00
getList();
}
);
onUnmounted(() => {
listeningProject();
});
</script>