材料管理 变更清单
This commit is contained in:
@ -26,6 +26,9 @@
|
||||
<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">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button>
|
||||
</el-col>
|
||||
@ -86,7 +89,7 @@
|
||||
<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-input v-model="form.name" placeholder="请输入类别名称" :disabled="form.id != null" />
|
||||
</el-form-item>
|
||||
<el-form-item label="计量单位" prop="unit">
|
||||
<el-input v-model="form.unit" placeholder="请输入计量单位" />
|
||||
@ -312,7 +315,7 @@ const toggleExpandAll = (data: ProgressCategoryVO[], status: boolean) => {
|
||||
const isDisabled = ref<boolean>(false);
|
||||
const handleUpdate = async (row: ProgressCategoryVO) => {
|
||||
reset();
|
||||
if (row.unitType == '2') {
|
||||
if (!row.unitType) {
|
||||
isDisabled.value = true;
|
||||
}
|
||||
await getTreeselect();
|
||||
|
310
src/views/progress/progressCategorySystemTemplate/index.vue
Normal file
310
src/views/progress/progressCategorySystemTemplate/index.vue
Normal file
@ -0,0 +1,310 @@
|
||||
<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="name">
|
||||
<el-input v-model="queryParams.name" placeholder="请输入类别名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="施工类型" prop="constructionType">
|
||||
<el-select v-model="queryParams.constructionType" placeholder="请选择施工类型" clearable @change="getList">
|
||||
<el-option v-for="dict in project_category_type" :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:progressCategoryTemplate: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="progressCategoryTemplateTableRef"
|
||||
v-loading="loading"
|
||||
:data="progressCategoryTemplateList"
|
||||
row-key="id"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<el-table-column label="类别名称" prop="name" />
|
||||
<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="workType">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="progress_work_type" :value="row.workType" />
|
||||
</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:progressCategoryTemplate:edit']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="新增" placement="top">
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['progress:progressCategoryTemplate:add']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['progress:progressCategoryTemplate: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="progressCategoryTemplateFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="父类别id" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.parentId"
|
||||
:data="progressCategoryTemplateOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择父类别id"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="施工类型" prop="constructionType">
|
||||
<el-select v-model="form.constructionType" placeholder="请选择施工类型" disabled>
|
||||
<el-option v-for="dict in project_category_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="计量方式" prop="unitType">
|
||||
<el-select v-model="form.unitType" placeholder="请选择关联数据">
|
||||
<el-option v-for="dict in progress_unit_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类别名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入类别名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联数据" prop="workType">
|
||||
<el-select v-model="form.workType" placeholder="请选择关联数据">
|
||||
<el-option v-for="dict in progress_work_type" :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" type="textarea" 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="ProgressCategoryTemplate" lang="ts">
|
||||
import {
|
||||
addProgressCategoryTemplate,
|
||||
delProgressCategoryTemplate,
|
||||
getProgressCategoryTemplate,
|
||||
listProgressCategoryTemplate,
|
||||
updateProgressCategoryTemplate
|
||||
} from '@/api/progress/progressCategoryTemplate';
|
||||
import {
|
||||
ProgressCategoryTemplateForm,
|
||||
ProgressCategoryTemplateQuery,
|
||||
ProgressCategoryTemplateVO
|
||||
} from '@/api/progress/progressCategoryTemplate/types';
|
||||
|
||||
type ProgressCategoryTemplateOption = {
|
||||
id: number;
|
||||
name: string;
|
||||
children?: ProgressCategoryTemplateOption[];
|
||||
};
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const { progress_work_type, progress_unit_type, project_category_type } = toRefs<any>(
|
||||
proxy?.useDict('progress_work_type', 'progress_unit_type', 'project_category_type')
|
||||
);
|
||||
const progressCategoryTemplateList = ref<ProgressCategoryTemplateVO[]>([]);
|
||||
const progressCategoryTemplateOptions = ref<ProgressCategoryTemplateOption[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const showSearch = ref(true);
|
||||
const isExpandAll = ref(true);
|
||||
const loading = ref(false);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const progressCategoryTemplateFormRef = ref<ElFormInstance>();
|
||||
const progressCategoryTemplateTableRef = ref<ElTableInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ProgressCategoryTemplateForm = {
|
||||
id: undefined,
|
||||
parentId: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
workType: undefined,
|
||||
constructionType: undefined,
|
||||
projectId: 0,
|
||||
remark: undefined
|
||||
};
|
||||
|
||||
const data = reactive<PageData<ProgressCategoryTemplateForm, ProgressCategoryTemplateQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
parentId: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
workType: undefined,
|
||||
constructionType: '1',
|
||||
projectId: 0,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
parentId: [{ 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' }],
|
||||
constructionType: [{ required: true, message: '施工类型不能为空', trigger: 'change' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询进度类别模版列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listProgressCategoryTemplate(queryParams.value);
|
||||
const data = proxy?.handleTree<ProgressCategoryTemplateVO>(res.data, 'id', 'parentId');
|
||||
if (data) {
|
||||
progressCategoryTemplateList.value = data;
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询进度类别模版下拉树结构 */
|
||||
const getTreeselect = async () => {
|
||||
const res = await listProgressCategoryTemplate();
|
||||
progressCategoryTemplateOptions.value = [];
|
||||
const data: ProgressCategoryTemplateOption = { id: 0, name: '顶级节点', children: [] };
|
||||
data.children = proxy?.handleTree<ProgressCategoryTemplateOption>(res.data, 'id', 'parentId');
|
||||
progressCategoryTemplateOptions.value.push(data);
|
||||
};
|
||||
|
||||
// 取消按钮
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
// 表单重置
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
progressCategoryTemplateFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = (row?: ProgressCategoryTemplateVO) => {
|
||||
reset();
|
||||
form.value.constructionType = queryParams.value.constructionType;
|
||||
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(progressCategoryTemplateList.value, isExpandAll.value);
|
||||
};
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const toggleExpandAll = (data: ProgressCategoryTemplateVO[], status: boolean) => {
|
||||
data.forEach((item) => {
|
||||
progressCategoryTemplateTableRef.value?.toggleRowExpansion(item, status);
|
||||
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status);
|
||||
});
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row: ProgressCategoryTemplateVO) => {
|
||||
reset();
|
||||
await getTreeselect();
|
||||
if (row != null) {
|
||||
form.value.parentId = row.parentId;
|
||||
}
|
||||
const res = await getProgressCategoryTemplate(row.id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改进度类别模版';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
progressCategoryTemplateFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateProgressCategoryTemplate(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addProgressCategoryTemplate(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row: ProgressCategoryTemplateVO) => {
|
||||
await proxy?.$modal.confirm('是否确认删除进度类别模版编号为"' + row.id + '"的数据项?');
|
||||
loading.value = true;
|
||||
await delProgressCategoryTemplate(row.id).finally(() => (loading.value = false));
|
||||
await getList();
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
@ -4,15 +4,14 @@
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="父类别id" prop="pid">
|
||||
<el-input v-model="queryParams.pid" placeholder="请输入父类别id" clearable @keyup.enter="handleQuery" />
|
||||
<el-form-item label="选择项目" prop="projectId" width="100">
|
||||
<el-select v-model="queryParams.projectId" @change="getList">
|
||||
<el-option v-for="item in projectSon" :label="item.projectName" :value="item.id" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类别名称" prop="name">
|
||||
<el-input v-model="queryParams.name" placeholder="请输入类别名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目id" prop="projectId">
|
||||
<el-input v-model="queryParams.projectId" placeholder="请输入项目id" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
@ -42,10 +41,17 @@
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<el-table-column label="类别名称" align="center" prop="name" />
|
||||
<el-table-column label="计量方式" align="center" prop="unitType" />
|
||||
<el-table-column label="工作类型" align="center" prop="workType" />
|
||||
<el-table-column label="项目id" align="center" prop="projectId" />
|
||||
<el-table-column label="类别名称" prop="name" />
|
||||
<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="workType">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="progress_work_type" :value="row.workType" />
|
||||
</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">
|
||||
@ -56,7 +62,13 @@
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['progress:progressCategoryTemplate:add']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['progress:progressCategoryTemplate:remove']" />
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['progress:progressCategoryTemplate:remove']"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -65,9 +77,9 @@
|
||||
<!-- 添加或修改进度类别模版对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="progressCategoryTemplateFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="父类别id" prop="pid">
|
||||
<el-form-item label="父类别id" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.pid"
|
||||
v-model="form.parentId"
|
||||
:data="progressCategoryTemplateOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
value-key="id"
|
||||
@ -75,11 +87,18 @@
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="计量方式" prop="unitType">
|
||||
<el-select v-model="form.unitType" placeholder="请选择关联数据">
|
||||
<el-option v-for="dict in progress_unit_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类别名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入类别名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目id" prop="projectId">
|
||||
<el-input v-model="form.projectId" placeholder="请输入项目id" />
|
||||
<el-form-item label="关联数据" prop="workType">
|
||||
<el-select v-model="form.workType" placeholder="请选择关联数据">
|
||||
<el-option v-for="dict in progress_work_type" :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" type="textarea" placeholder="请输入内容" />
|
||||
@ -96,18 +115,36 @@
|
||||
</template>
|
||||
|
||||
<script setup name="ProgressCategoryTemplate" lang="ts">
|
||||
import { listProgressCategoryTemplate, getProgressCategoryTemplate, delProgressCategoryTemplate, addProgressCategoryTemplate, updateProgressCategoryTemplate } from "@/api/progress/progressCategoryTemplate";
|
||||
import { ProgressCategoryTemplateVO, ProgressCategoryTemplateQuery, ProgressCategoryTemplateForm } from '@/api/progress/progressCategoryTemplate/types';
|
||||
import {
|
||||
addProgressCategoryTemplate,
|
||||
delProgressCategoryTemplate,
|
||||
getProgressCategoryTemplate,
|
||||
listProgressCategoryTemplate,
|
||||
updateProgressCategoryTemplate
|
||||
} from '@/api/progress/progressCategoryTemplate';
|
||||
import {
|
||||
ProgressCategoryTemplateForm,
|
||||
ProgressCategoryTemplateQuery,
|
||||
ProgressCategoryTemplateVO
|
||||
} from '@/api/progress/progressCategoryTemplate/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { getChildProject } from '@/api/project/project';
|
||||
|
||||
type ProgressCategoryTemplateOption = {
|
||||
id: number;
|
||||
name: string;
|
||||
children?: ProgressCategoryTemplateOption[];
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;;
|
||||
};
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const { progress_work_type, progress_unit_type, project_category_type } = toRefs<any>(
|
||||
proxy?.useDict('progress_work_type', 'progress_unit_type', 'project_category_type')
|
||||
);
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const progressCategoryTemplateList = ref<ProgressCategoryTemplateVO[]>([]);
|
||||
const progressCategoryTemplateOptions = ref<ProgressCategoryTemplateOption[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
@ -117,51 +154,41 @@ const loading = ref(false);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const progressCategoryTemplateFormRef = ref<ElFormInstance>();
|
||||
const progressCategoryTemplateTableRef = ref<ElTableInstance>()
|
||||
|
||||
const progressCategoryTemplateTableRef = ref<ElTableInstance>();
|
||||
const projectSon = ref<any>([]);
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
|
||||
const initFormData: ProgressCategoryTemplateForm = {
|
||||
id: undefined,
|
||||
pid: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
workType: undefined,
|
||||
projectId: undefined,
|
||||
remark: undefined,
|
||||
}
|
||||
id: undefined,
|
||||
parentId: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
workType: undefined,
|
||||
projectId: undefined,
|
||||
constructionType: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
|
||||
const data = reactive<PageData<ProgressCategoryTemplateForm, ProgressCategoryTemplateQuery>>({
|
||||
form: {...initFormData},
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pid: undefined,
|
||||
parentId: undefined,
|
||||
name: undefined,
|
||||
unitType: undefined,
|
||||
workType: undefined,
|
||||
projectId: undefined,
|
||||
params: {
|
||||
}
|
||||
constructionType: 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" }
|
||||
],
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
parentId: [{ 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' }]
|
||||
}
|
||||
});
|
||||
|
||||
@ -171,112 +198,124 @@ const { queryParams, form, rules } = toRefs(data);
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listProgressCategoryTemplate(queryParams.value);
|
||||
const data = proxy?.handleTree<ProgressCategoryTemplateVO>(res.data, "id", "pid");
|
||||
const data = proxy?.handleTree<ProgressCategoryTemplateVO>(res.data, 'id', 'parentId');
|
||||
if (data) {
|
||||
progressCategoryTemplateList.value = data;
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询进度类别模版下拉树结构 */
|
||||
const getTreeselect = async () => {
|
||||
const res = await listProgressCategoryTemplate();
|
||||
progressCategoryTemplateOptions.value = [];
|
||||
const data: ProgressCategoryTemplateOption = { id: 0, name: '顶级节点', children: [] };
|
||||
data.children = proxy?.handleTree<ProgressCategoryTemplateOption>(res.data, "id", "pid");
|
||||
data.children = proxy?.handleTree<ProgressCategoryTemplateOption>(res.data, 'id', 'parentId');
|
||||
progressCategoryTemplateOptions.value.push(data);
|
||||
}
|
||||
};
|
||||
|
||||
// 取消按钮
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 表单重置
|
||||
const reset = () => {
|
||||
form.value = {...initFormData}
|
||||
form.value = { ...initFormData };
|
||||
progressCategoryTemplateFormRef.value?.resetFields();
|
||||
}
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
getList();
|
||||
}
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
queryParams.value.projectId = projectSon.value[0]?.id;
|
||||
handleQuery();
|
||||
}
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = (row?: ProgressCategoryTemplateVO) => {
|
||||
reset();
|
||||
getTreeselect();
|
||||
if (row != null && row.id) {
|
||||
form.value.pid = row.id;
|
||||
form.value.parentId = row.id;
|
||||
} else {
|
||||
form.value.pid = 0;
|
||||
form.value.parentId = 0;
|
||||
}
|
||||
dialog.visible = true;
|
||||
dialog.title = "添加进度类别模版";
|
||||
}
|
||||
dialog.title = '添加进度类别模版';
|
||||
};
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const handleToggleExpandAll = () => {
|
||||
isExpandAll.value = !isExpandAll.value;
|
||||
toggleExpandAll(progressCategoryTemplateList.value, isExpandAll.value)
|
||||
}
|
||||
toggleExpandAll(progressCategoryTemplateList.value, isExpandAll.value);
|
||||
};
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const toggleExpandAll = (data: ProgressCategoryTemplateVO[], status: boolean) => {
|
||||
data.forEach((item) => {
|
||||
progressCategoryTemplateTableRef.value?.toggleRowExpansion(item, status)
|
||||
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
|
||||
})
|
||||
}
|
||||
progressCategoryTemplateTableRef.value?.toggleRowExpansion(item, status);
|
||||
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status);
|
||||
});
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row: ProgressCategoryTemplateVO) => {
|
||||
reset();
|
||||
await getTreeselect();
|
||||
if (row != null) {
|
||||
form.value.pid = row.pid;
|
||||
form.value.parentId = row.parentId;
|
||||
}
|
||||
const res = await getProgressCategoryTemplate(row.id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改进度类别模版";
|
||||
}
|
||||
dialog.title = '修改进度类别模版';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
progressCategoryTemplateFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
form.value.projectId = queryParams.value.projectId;
|
||||
if (form.value.id) {
|
||||
await updateProgressCategoryTemplate(form.value).finally(() => buttonLoading.value = false);
|
||||
await updateProgressCategoryTemplate(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addProgressCategoryTemplate(form.value).finally(() => buttonLoading.value = false);
|
||||
await addProgressCategoryTemplate(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess("操作成功");
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row: ProgressCategoryTemplateVO) => {
|
||||
await proxy?.$modal.confirm('是否确认删除进度类别模版编号为"' + row.id + '"的数据项?');
|
||||
loading.value = true;
|
||||
await delProgressCategoryTemplate(row.id).finally(() => loading.value = false);
|
||||
await delProgressCategoryTemplate(row.id).finally(() => (loading.value = false));
|
||||
await getList();
|
||||
proxy?.$modal.msgSuccess("删除成功");
|
||||
}
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取子项目列表
|
||||
*/
|
||||
const getSubProjectList = async () => {
|
||||
const res = await getChildProject(currentProject.value.id);
|
||||
projectSon.value = res.data;
|
||||
queryParams.value.projectId = projectSon.value[0]?.id;
|
||||
getList();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
getSubProjectList();
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user