进度管理产值管理
This commit is contained in:
362
src/views/progress/constructionSchedulePlan/index.vue
Normal file
362
src/views/progress/constructionSchedulePlan/index.vue
Normal file
@ -0,0 +1,362 @@
|
||||
<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="nodeName">
|
||||
<el-input v-model="queryParams.nodeName" placeholder="请输入节点名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option v-for="dict in project_construction_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</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:constructionSchedulePlan: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="constructionSchedulePlanTableRef"
|
||||
v-loading="loading"
|
||||
:data="constructionSchedulePlanList"
|
||||
row-key="id"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<!-- <el-table-column label="序号" type="id" /> -->
|
||||
<el-table-column label="节点名称" prop="nodeName" />
|
||||
<el-table-column label="对应项目结构" align="center" prop="projectStructure" />
|
||||
<el-table-column label="预计开始时间" align="center" prop="planStartDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.planStartDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="预计结束时间" align="center" prop="planEndDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.planEndDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实际开始时间" align="center" prop="practicalStartDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.practicalStartDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实际结束时间" align="center" prop="practicalEndDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.practicalEndDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="project_construction_status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['progress:constructionSchedulePlan:edit']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="新增" placement="top">
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['progress:constructionSchedulePlan:add']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['progress:constructionSchedulePlan:remove']"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<!-- 添加或修改施工进度计划对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="constructionSchedulePlanFormRef" :model="form" :rules="rules" label-width="110px">
|
||||
<el-form-item label="父节点" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.parentId"
|
||||
:data="constructionSchedulePlanOptions"
|
||||
:props="{ value: 'id', label: 'nodeName', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择父节点"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="节点名称" prop="nodeName">
|
||||
<el-input v-model="form.nodeName" placeholder="请输入节点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="对应项目结构" prop="projectStructure">
|
||||
<el-input v-model="form.projectStructure" placeholder="请输入对应项目结构" />
|
||||
</el-form-item>
|
||||
<el-form-item label="预计开始时间" prop="planStartDate">
|
||||
<el-date-picker clearable v-model="form.planStartDate" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="选择预计开始时间" />
|
||||
</el-form-item>
|
||||
<el-form-item label="预计结束时间" prop="planEndDate">
|
||||
<el-date-picker clearable v-model="form.planEndDate" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="选择预计结束时间" />
|
||||
</el-form-item>
|
||||
<el-form-item label="实际开始时间" prop="practicalStartDate">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.practicalStartDate"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择实际开始时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="实际结束时间" prop="practicalEndDate">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.practicalEndDate"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择实际结束时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态">
|
||||
<el-option v-for="dict in project_construction_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="ConstructionSchedulePlan" lang="ts">
|
||||
import {
|
||||
listConstructionSchedulePlan,
|
||||
getConstructionSchedulePlan,
|
||||
delConstructionSchedulePlan,
|
||||
addConstructionSchedulePlan,
|
||||
updateConstructionSchedulePlan
|
||||
} from '@/api/progress/constructionSchedulePlan';
|
||||
import {
|
||||
ConstructionSchedulePlanVO,
|
||||
ConstructionSchedulePlanQuery,
|
||||
ConstructionSchedulePlanForm
|
||||
} from '@/api/progress/constructionSchedulePlan/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
type ConstructionSchedulePlanOption = {
|
||||
id: number;
|
||||
nodeName: string;
|
||||
children?: ConstructionSchedulePlanOption[];
|
||||
};
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
const { project_construction_status } = toRefs<any>(proxy?.useDict('project_construction_status'));
|
||||
|
||||
const constructionSchedulePlanList = ref<ConstructionSchedulePlanVO[]>([]);
|
||||
const constructionSchedulePlanOptions = ref<ConstructionSchedulePlanOption[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const showSearch = ref(true);
|
||||
const isExpandAll = ref(true);
|
||||
const loading = ref(false);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const constructionSchedulePlanFormRef = ref<ElFormInstance>();
|
||||
const constructionSchedulePlanTableRef = ref<ElTableInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ConstructionSchedulePlanForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value.id,
|
||||
parentId: undefined,
|
||||
nodeName: undefined,
|
||||
projectStructure: undefined,
|
||||
planStartDate: undefined,
|
||||
planEndDate: undefined,
|
||||
practicalStartDate: undefined,
|
||||
practicalEndDate: undefined,
|
||||
status: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
|
||||
const data = reactive<PageData<ConstructionSchedulePlanForm, ConstructionSchedulePlanQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
projectId: currentProject.value.id,
|
||||
parentId: undefined,
|
||||
nodeName: undefined,
|
||||
status: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目ID不能为空', trigger: 'blur' }],
|
||||
parentId: [{ required: true, message: '父ID不能为空', trigger: 'blur' }],
|
||||
nodeName: [{ required: true, message: '节点名称不能为空', trigger: 'blur' }],
|
||||
planStartDate: [{ required: true, message: '预计开始时间不能为空', trigger: 'blur' }],
|
||||
planEndDate: [{ required: true, message: '预计结束时间不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询施工进度计划列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listConstructionSchedulePlan(queryParams.value);
|
||||
const data = proxy?.handleTree<ConstructionSchedulePlanVO>(res.data, 'id', 'parentId');
|
||||
console.log('🚀 ~ getList ~ data:', data);
|
||||
|
||||
if (data) {
|
||||
constructionSchedulePlanList.value = data;
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询施工进度计划下拉树结构 */
|
||||
const getTreeselect = async () => {
|
||||
const res = await listConstructionSchedulePlan();
|
||||
constructionSchedulePlanOptions.value = [];
|
||||
const data: ConstructionSchedulePlanOption = { id: 0, nodeName: '顶级节点', children: [] };
|
||||
data.children = proxy?.handleTree<ConstructionSchedulePlanOption>(res.data, 'id', 'parentId');
|
||||
constructionSchedulePlanOptions.value.push(data);
|
||||
};
|
||||
|
||||
// 取消按钮
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
// 表单重置
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
constructionSchedulePlanFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = (row?: ConstructionSchedulePlanVO) => {
|
||||
reset();
|
||||
getTreeselect();
|
||||
if (row != null && row.id) {
|
||||
form.value.parentId = row.id;
|
||||
} else {
|
||||
form.value.parentId = 0;
|
||||
}
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加施工进度计划';
|
||||
};
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const handleToggleExpandAll = () => {
|
||||
isExpandAll.value = !isExpandAll.value;
|
||||
toggleExpandAll(constructionSchedulePlanList.value, isExpandAll.value);
|
||||
};
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const toggleExpandAll = (data: ConstructionSchedulePlanVO[], status: boolean) => {
|
||||
data.forEach((item) => {
|
||||
constructionSchedulePlanTableRef.value?.toggleRowExpansion(item, status);
|
||||
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status);
|
||||
});
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row: ConstructionSchedulePlanVO) => {
|
||||
reset();
|
||||
await getTreeselect();
|
||||
if (row != null) {
|
||||
form.value.parentId = row.parentId;
|
||||
}
|
||||
const res = await getConstructionSchedulePlan(row.id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改施工进度计划';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
constructionSchedulePlanFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateConstructionSchedulePlan(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addConstructionSchedulePlan(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row: ConstructionSchedulePlanVO) => {
|
||||
await proxy?.$modal.confirm('是否确认删除施工进度计划编号为"' + row.id + '"的数据项?');
|
||||
loading.value = true;
|
||||
await delConstructionSchedulePlan(row.id).finally(() => (loading.value = false));
|
||||
await getList();
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
@ -288,11 +288,9 @@ const getList = async () => {
|
||||
}
|
||||
}
|
||||
loading.value = true;
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const res = await listProgressCategory(queryParams.value);
|
||||
const data = proxy?.handleTree<ProgressCategoryVO>(res.data, 'id', 'pid');
|
||||
const data = proxy?.handleTree<ProgressCategoryVO>(res.data, 'id', 'parentId');
|
||||
if (data) {
|
||||
progressCategoryList.value = data;
|
||||
}
|
||||
|
371
src/views/progress/progressCategory/index.vue
Normal file
371
src/views/progress/progressCategory/index.vue
Normal file
@ -0,0 +1,371 @@
|
||||
<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 /> -->
|
||||
<el-cascader
|
||||
:options="matrixOptions"
|
||||
placeholder="请选择"
|
||||
@change="handleChange"
|
||||
:props="{ value: 'matrixId', label: 'name' }"
|
||||
v-model="queryParams.matrixId"
|
||||
clearable
|
||||
/>
|
||||
<!-- <el-select v-model="matrixValue" placeholder="请选择" @change="handleChange" clearable>
|
||||
<el-option v-for="item in matrixOptions" :key="item.id" :label="item.matrixName" :value="item.id" />
|
||||
</el-select> -->
|
||||
</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="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' }"
|
||||
>
|
||||
<!-- <el-table-column label="父类别id" prop="parentId" /> -->
|
||||
<el-table-column label="类别名称" prop="name" />
|
||||
<el-table-column label="计量方式" align="center" prop="unitType">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="progress_unit_type" :value="row.unitType" v-if="row.parentId != 0" />
|
||||
<span v-else></span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计量单位" align="center" prop="unit">
|
||||
<template #default="{ row }">
|
||||
{{ row.parentId == 0 ? '' : row.unit }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="综合单价" align="center" prop="unitPrice">
|
||||
<template #default="{ row }">
|
||||
{{ row.parentId == 0 ? '' : row.unitPrice }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产值金额" align="center" prop="outputValue">
|
||||
<template #default="{ row }">
|
||||
{{ row.parentId == 0 ? '' : row.outputValue }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总数量/百分比" align="center" prop="total">
|
||||
<template #default="{ row }">
|
||||
{{ row.parentId == 0 ? '' : row.total }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.parentId">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['progress:progressCategory:edit']">
|
||||
修改
|
||||
</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['progress:progressCategory:remove']">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<!-- 添加或修改分项工程单价对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="progressCategoryFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="类别名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入类别名称" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="计量单位" prop="unit">
|
||||
<el-input v-model="form.unit" placeholder="请输入计量单位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="综合单价" prop="unitPrice">
|
||||
<el-input v-model="form.unitPrice" placeholder="请输入综合单价" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="总数量/百分比" prop="total">
|
||||
<el-input v-model="form.total" placeholder="请输入总数量/百分比" />
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="ProgressCategory" lang="ts">
|
||||
import { getProjectSquare } from '@/api/progress/plan';
|
||||
import {
|
||||
listProgressCategory,
|
||||
getProgressCategory,
|
||||
delProgressCategory,
|
||||
addProgressCategory,
|
||||
updateProgressCategory
|
||||
} from '@/api/progress/progressCategory';
|
||||
import { ProgressCategoryVO, ProgressCategoryQuery, ProgressCategoryForm } from '@/api/progress/progressCategory/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { progress_unit_type, progress_status } = toRefs<any>(proxy?.useDict('progress_unit_type', 'progress_status'));
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
type ProgressCategoryOption = {
|
||||
id: number;
|
||||
name: string;
|
||||
children?: ProgressCategoryOption[];
|
||||
};
|
||||
|
||||
const matrixOptions = ref([]);
|
||||
|
||||
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 queryFormRef = ref<ElFormInstance>();
|
||||
const progressCategoryFormRef = ref<ElFormInstance>();
|
||||
const progressCategoryTableRef = ref<ElTableInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ProgressCategoryForm = {
|
||||
id: undefined,
|
||||
parentId: undefined,
|
||||
projectId: currentProject.value.id,
|
||||
matrixId: undefined,
|
||||
matrixName: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
unit: undefined,
|
||||
unitPrice: undefined,
|
||||
outputValue: undefined,
|
||||
total: undefined,
|
||||
completed: undefined,
|
||||
planTotal: undefined,
|
||||
isDelay: undefined,
|
||||
workType: undefined,
|
||||
status: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
|
||||
const data = reactive<PageData<ProgressCategoryForm, ProgressCategoryQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
parentId: undefined,
|
||||
projectId: currentProject.value.id,
|
||||
matrixId: undefined,
|
||||
matrixName: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
unit: undefined,
|
||||
unitPrice: undefined,
|
||||
outputValue: undefined,
|
||||
total: undefined,
|
||||
completed: undefined,
|
||||
planTotal: undefined,
|
||||
isDelay: undefined,
|
||||
workType: undefined,
|
||||
status: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
parentId: [{ required: true, message: '父类别id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }],
|
||||
matrixId: [{ required: true, message: '方阵id不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '类别名称不能为空', trigger: 'blur' }],
|
||||
unitType: [{ required: true, message: '计量方式不能为空', trigger: 'change' }],
|
||||
unitPrice: [{ required: true, message: '综合单价不能为空', trigger: 'blur' }],
|
||||
outputValue: [{ required: true, message: '产值金额不能为空', trigger: 'blur' }],
|
||||
isDelay: [{ required: true, message: '是否超期不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '完成状态不能为空', trigger: 'change' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询分项工程单价列表 */
|
||||
const getList = async () => {
|
||||
if (!queryParams.value.matrixId) {
|
||||
const res = await getProjectSquare(currentProject.value.id);
|
||||
if (res.data.length === 0) {
|
||||
proxy?.$modal.msgWarning('当前项目下没有方阵,请先创建方阵');
|
||||
} else {
|
||||
let matrixList = res.data.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
matrixId: item.projectId
|
||||
};
|
||||
});
|
||||
if (!matrixValue.value) matrixValue.value = matrixList[0].id;
|
||||
matrixOptions.value = matrixList;
|
||||
queryParams.value.matrixId = matrixList[0].children[0].matrixId;
|
||||
}
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await listProgressCategory(queryParams.value);
|
||||
const data = proxy?.handleTree<ProgressCategoryVO>(res.data, 'id', 'parentId');
|
||||
if (data) {
|
||||
progressCategoryList.value = data;
|
||||
loading.value = false;
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询分项工程单价下拉树结构 */
|
||||
const getTreeselect = async () => {
|
||||
const res = await listProgressCategory(queryParams.value);
|
||||
progressCategoryOptions.value = [];
|
||||
const data: ProgressCategoryOption = { id: 0, name: '顶级节点', children: [] };
|
||||
data.children = proxy?.handleTree<ProgressCategoryOption>(res.data, 'id', 'parentId');
|
||||
progressCategoryOptions.value.push(data);
|
||||
};
|
||||
|
||||
// 取消按钮
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
// 表单重置
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
progressCategoryFormRef.value?.resetFields();
|
||||
};
|
||||
/** 级联选择器改变事件 */
|
||||
const handleChange = (value: number) => {
|
||||
queryParams.value.matrixId = value[1];
|
||||
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = (row?: ProgressCategoryVO) => {
|
||||
reset();
|
||||
getTreeselect();
|
||||
if (row != null && row.id) {
|
||||
form.value.parentId = row.id;
|
||||
} else {
|
||||
form.value.parentId = 0;
|
||||
}
|
||||
dialog.visible = true;
|
||||
dialog.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.parentId = row.parentId;
|
||||
}
|
||||
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 matrixValue = ref<number | undefined>(matrixOptions.value.length > 0 ? matrixOptions.value[0].id : undefined);
|
||||
const resetMatrix = () => {
|
||||
matrixValue.value = undefined;
|
||||
queryParams.value.matrixId = undefined;
|
||||
matrixOptions.value = [];
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
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(
|
||||
() => currentProject.value.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
resetMatrix();
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user