feat(qms): 重构检测项类别页面,改为树形结构

- 将检测项类别页面改为树形结构展示
- 添加检测类型筛选功能
- 优化表单布局和字段
- 新增展开/折叠功能
- 修改检测单类型和检测项类别的顺序
master
zch 6 days ago
parent a55f2851b9
commit 9580957610

@ -104,8 +104,8 @@
<el-table-column label="检测项编码" align="center" prop="itemCode" v-if="columns[1].visible"/>
<el-table-column label="检测项名称" align="center" prop="itemName" v-if="columns[2].visible"/>
<el-table-column label="检测位置" align="center" prop="inspectionPosition" v-if="columns[3].visible"/>
<el-table-column label="检测项类别" align="center" prop="categoryId" v-if="columns[4].visible"/>
<el-table-column label="检测单类型" align="center" prop="inspectionType" v-if="columns[5].visible"/>
<el-table-column label="检测单类型" align="center" prop="inspectionType" v-if="columns[4].visible"/>
<el-table-column label="检测项类别" align="center" prop="categoryId" v-if="columns[5].visible"/>
<el-table-column label="检测方法" align="center" prop="method" v-if="columns[6].visible">
<template #default="scope">
<dict-tag :options="qc_methond" :value="scope.row.method"/>
@ -182,16 +182,16 @@
<el-row>
<el-col :span="6">
<el-form-item label="检测项类别" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择检测项类别">
<el-option v-for="item in qcInspectionItemCategoryList" :key="item.categoryId" :label="item.categoryName" :value="item.categoryId" />
<el-form-item label="检测类型" prop="inspectionType">
<el-select v-model="form.inspectionType" placeholder="请选择检测类型">
<el-option v-for="item in qcInspectionTypeList" :key="item.typeId" :label="item.typeName" :value="item.typeId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="检测单类型" prop="inspectionType">
<el-select v-model="form.inspectionType" placeholder="请选择检测单类型">
<el-option v-for="item in qcInspectionTypeList" :key="item.typeId" :label="item.typeName" :value="item.typeId" />
<el-form-item label="检测项类别" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择检测项类别">
<el-option v-for="item in qcInspectionItemCategoryList" :key="item.categoryId" :label="item.categoryName" :value="item.categoryId" />
</el-select>
</el-form-item>
</el-col>
@ -325,8 +325,8 @@ const columns = ref<FieldOption[]>([
{ key: 1, label: `检测项编码`, visible: true },
{ key: 2, label: `检测项名称`, visible: true },
{ key: 3, label: `检测位置`, visible: true },
{ key: 4, label: `检测项类别`, visible: true },
{ key: 5, label: `检测单类型`, visible: true },
{ key: 4, label: `检测单类型`, visible: true },
{ key: 5, label: `检测项类别`, visible: true },
{ key: 6, label: `检测方法`, visible: true },
{ key: 7, label: `检测方式`, visible: true },
{ key: 8, label: `控制类型`, visible: true },

@ -1,43 +1,33 @@
<template>
<div class="p-2">
<el-row :gutter="20">
<!--部门树-->
<el-col :lg="4" :xs="24" style="">
<el-card shadow="hover">
<el-input v-model="inspectionTypeName" placeholder="请输入检测类型名称" clearable prefix-icon="Search" />
<el-tree
ref="inspectionTypeTreeRef"
class="mt-2"
:data="qcInspectionTypeList"
:props="{ label: 'typeName', children: 'children' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
highlight-current
default-expand-all
@node-click="handleNodeClick"
/>
</el-card>
</el-col>
<el-col :lg="20" :xs="24">
<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" label-width='120px'>
<!-- <el-form-item label="检测项类别主键" prop="categoryId">
<el-input v-model="queryParams.categoryId" placeholder="请输入检测项类别主键" clearable @keyup.enter="handleQuery" />
</el-form-item> -->
<el-form-item label="检测项类别编码" prop="categoryCode">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<!-- <el-form-item label="检测项类别主键" prop="categoryId">-->
<!-- <el-input v-model="queryParams.categoryId" placeholder="请输入检测项类别主键" clearable @keyup.enter="handleQuery" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="父级ID" prop="parentId">-->
<!-- <el-input v-model="queryParams.parentId" placeholder="请输入父级ID" clearable @keyup.enter="handleQuery" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="祖级列表" prop="ancestors">-->
<!-- <el-input v-model="queryParams.ancestors" placeholder="请输入祖级列表" clearable @keyup.enter="handleQuery" />-->
<!-- </el-form-item>-->
<el-form-item label="检测项类别编码" prop="categoryCode" label-width="120px">
<el-input v-model="queryParams.categoryCode" placeholder="请输入检测项类别编码" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="检测项类别名称" prop="categoryName">
<el-form-item label="检测项类别名称" prop="categoryName" label-width="120px">
<el-input v-model="queryParams.categoryName" placeholder="请输入检测项类别名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<!-- <el-form-item label="检测单类型" prop="typeId">
<el-input v-model="queryParams.typeId" placeholder="请输入检测单类型" clearable @keyup.enter="handleQuery" />
</el-form-item> -->
<!-- <el-form-item label="描述" prop="description">
<el-input v-model="queryParams.description" placeholder="请输入描述" clearable @keyup.enter="handleQuery" />
</el-form-item> -->
<el-form-item label="检测类型" prop="typeId" label-width="120px">
<!-- <el-input v-model="queryParams.typeId" placeholder="请输入检测单类型" clearable @keyup.enter="handleQuery" />-->
<el-select v-model="queryParams.typeId" placeholder="请选择检测类型">
<el-option v-for="item in qcInspectionTypeList" :key="item.typeId" :label="item.typeName" :value="item.typeId" />
</el-select>
</el-form-item>
<!-- <el-form-item label="描述" prop="description">-->
<!-- <el-input v-model="queryParams.description" placeholder="请输入描述" 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>
@ -51,63 +41,72 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['qms:qcInspectionItemCategory:add']"></el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['qms:qcInspectionItemCategory:add']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['qms:qcInspectionItemCategory:edit']"></el-button>
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">/</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['qms:qcInspectionItemCategory:remove']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['qms:qcInspectionItemCategory:export']"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" :data="qcInspectionItemCategoryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- 页面自动序号 -->
<el-table-column label="序号" align="center" prop="categoryId" v-if="columns[0].visible">
<template #default="scope">
{{ scope.$index + 1 }}
</template>
</el-table-column>
<!-- <el-table-column label="检测项类别主键" align="center" prop="categoryId" v-if="columns[1].visible"/> -->
<el-table-column label="检测项类别编码" align="center" prop="categoryCode" v-if="columns[1].visible"/>
<el-table-column label="检测项类别名称" align="center" prop="categoryName" v-if="columns[2].visible"/>
<el-table-column label="检测单类型" align="center" prop="typeId" v-if="columns[3].visible"/>
<el-table-column label="描述" align="center" prop="description" v-if="columns[4].visible"/>
<el-table
ref="qcInspectionItemCategoryTableRef"
v-loading="loading"
:data="qcInspectionItemCategoryList"
row-key="categoryId"
:default-expand-all="isExpandAll"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<!-- <el-table-column label="检测项类别主键" align="center" prop="categoryId" />-->
<!-- <el-table-column label="父级ID" align="center" prop="parentId" />-->
<!-- <el-table-column label="祖级列表" align="center" prop="ancestors" />-->
<el-table-column label="检测项类别编码" align="center" prop="categoryCode" />
<el-table-column label="检测项类别名称" align="center" prop="categoryName" />
<el-table-column label="检测类型" align="center" prop="typeName" />
<el-table-column label="描述" align="center" prop="description" />
<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="['qms:qcInspectionItemCategory:edit']"></el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['qms:qcInspectionItemCategory:edit']" />
</el-tooltip>
<el-tooltip content="新增" placement="top">
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['qms:qcInspectionItemCategory:add']" />
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['qms:qcInspectionItemCategory:remove']"></el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['qms:qcInspectionItemCategory:remove']" />
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改检测项类别对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="qcInspectionItemCategoryFormRef" :model="form" :rules="rules" label-width="120px">
<!-- <el-form-item label="检测项类别主键" prop="categoryId">
<el-input v-model="form.categoryId" placeholder="请输入检测项类别主键" />
</el-form-item> -->
<!-- <el-form-item label="检测项类别主键" prop="categoryId">-->
<!-- <el-input v-model="form.categoryId" placeholder="请输入检测项类别主键" />-->
<!-- </el-form-item>-->
<el-form-item label="父级" prop="parentId">
<el-tree-select
v-model="form.parentId"
:data="qcInspectionItemCategoryOptions"
:props="{ value: 'categoryId', label: 'categoryName', children: 'children' }"
value-key="categoryId"
placeholder="请选择父级"
check-strictly
/>
</el-form-item>
<!-- <el-form-item label="祖级列表" prop="ancestors">-->
<!-- <el-input v-model="form.ancestors" placeholder="请输入祖级列表" />-->
<!-- </el-form-item>-->
<el-form-item label="检测项类别编码" prop="categoryCode">
<el-input v-model="form.categoryCode" placeholder="请输入检测项类别编码" />
</el-form-item>
<el-form-item label="检测项类别名称" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入检测项类别名称" />
</el-form-item>
<el-form-item label="检测单类型" prop="typeId">
<el-form-item label="检测类型" prop="typeId">
<!-- <el-input v-model="form.typeId" placeholder="请输入检测单类型" /> -->
<el-select v-model="form.typeId" placeholder="请选择检测单类型">
<el-select v-model="form.typeId" placeholder="请选择检测类型">
<el-option v-for="item in qcInspectionTypeList" :key="item.typeId" :label="item.typeName" :value="item.typeId" />
</el-select>
</el-form-item>
@ -122,8 +121,6 @@
</div>
</template>
</el-dialog>
</el-col>
</el-row>
</div>
</template>
@ -135,12 +132,21 @@ import { QcInspectionTypeVO } from '@/api/qms/qcInspectionType/types';
import type { TreeInstance } from 'element-plus';
import { watch } from "vue";
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
type QcInspectionItemCategoryOption = {
categoryId: number;
categoryName: string;
children?: QcInspectionItemCategoryOption[];
}
const { proxy } = getCurrentInstance() as ComponentInternalInstance;;
const qcInspectionItemCategoryList = ref<QcInspectionItemCategoryVO[]>([]);
const qcInspectionItemCategoryOptions = ref<QcInspectionItemCategoryOption[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const isExpandAll = ref(true);
const loading = ref(false);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
@ -148,42 +154,32 @@ const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const qcInspectionItemCategoryFormRef = ref<ElFormInstance>();
// const qcInspectionItemCategoryTableRef = ref<ElTableInstance>();
const inspectionTypeTreeRef = ref<TreeInstance>();
const inspectionTypeName = ref('');
const dialog = reactive<DialogOption>({
visible: false,
title: ''
visible: false,
title: ''
});
//
const columns = ref<FieldOption[]>([
{ key: 0, label: `序号`, visible: true },
// { key: 1, label: ``, visible: false },
{ key: 1, label: `检测项类别编码`, visible: true },
{ key: 2, label: `检测项类别名称`, visible: true },
{ key: 3, label: `检测单类型`, visible: true },
{ key: 4, label: `描述`, visible: true },
// { key: 6, label: ``, visible: true },
// { key: 7, label: ``, visible: true },
// { key: 8, label: ``, visible: true },
// { key: 9, label: ``, visible: true },
// { key: 10, label: ``, visible: true },
]);
const initFormData: QcInspectionItemCategoryForm = {
categoryId: undefined,
categoryCode: undefined,
categoryName: undefined,
typeId: undefined,
description: undefined,
categoryId: undefined,
parentId: undefined,
ancestors: undefined,
categoryCode: undefined,
categoryName: undefined,
typeId: undefined,
description: undefined,
}
const data = reactive<PageData<QcInspectionItemCategoryForm, QcInspectionItemCategoryQuery>>({
form: {...initFormData},
queryParams: {
pageNum: 1,
pageSize: 10,
categoryId: undefined,
parentId: undefined,
ancestors: undefined,
categoryCode: undefined,
categoryName: undefined,
typeId: undefined,
@ -195,6 +191,9 @@ const data = reactive<PageData<QcInspectionItemCategoryForm, QcInspectionItemCat
// categoryId: [
// { required: true, message: "", trigger: "blur" }
// ],
parentId: [
{ required: true, message: "父级不能为空", trigger: "blur" }
],
}
});
@ -204,56 +203,80 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listQcInspectionItemCategory(queryParams.value);
qcInspectionItemCategoryList.value = res.rows;
total.value = res.total;
loading.value = false;
const data = proxy?.handleTree<QcInspectionItemCategoryVO>(res.data, "categoryId", "parentId");
if (data) {
qcInspectionItemCategoryList.value = data;
loading.value = false;
}
}
/** 取消按钮 */
/** 查询检测项类别下拉树结构 */
const getTreeselect = async () => {
const res = await listQcInspectionItemCategory();
qcInspectionItemCategoryOptions.value = [];
const data: QcInspectionItemCategoryOption = { categoryId: 0, categoryName: '顶级节点', children: [] };
data.children = proxy?.handleTree<QcInspectionItemCategoryOption>(res.data, "categoryId", "parentId");
qcInspectionItemCategoryOptions.value.push(data);
}
//
const cancel = () => {
reset();
dialog.visible = false;
}
/** 表单重置 */
//
const reset = () => {
form.value = {...initFormData};
form.value = {...initFormData}
qcInspectionItemCategoryFormRef.value?.resetFields();
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
queryParams.value.typeId = undefined;
inspectionTypeTreeRef.value?.setCurrentKey(null);
handleQuery();
}
/** 多选框选中数据 */
const handleSelectionChange = (selection: QcInspectionItemCategoryVO[]) => {
ids.value = selection.map(item => item.categoryId);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
const handleAdd = () => {
const handleAdd = (row?: QcInspectionItemCategoryVO) => {
reset();
getTreeselect();
if (row != null && row.categoryId) {
form.value.parentId = row.categoryId;
} else {
form.value.parentId = 0;
}
dialog.visible = true;
dialog.title = "添加检测项类别";
}
/** 展开/折叠操作 */
const handleToggleExpandAll = () => {
isExpandAll.value = !isExpandAll.value;
toggleExpandAll(qcInspectionItemCategoryList.value, isExpandAll.value)
}
/** 展开/折叠操作 */
const toggleExpandAll = (data: QcInspectionItemCategoryVO[], status: boolean) => {
data.forEach((item) => {
qcInspectionItemCategoryTableRef.value?.toggleRowExpansion(item, status)
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
})
}
/** 修改按钮操作 */
const handleUpdate = async (row?: QcInspectionItemCategoryVO) => {
const handleUpdate = async (row: QcInspectionItemCategoryVO) => {
reset();
const _categoryId = row?.categoryId || ids.value[0]
const res = await getQcInspectionItemCategory(_categoryId);
await getTreeselect();
if (row != null) {
form.value.parentId = row.parentId;
}
const res = await getQcInspectionItemCategory(row.categoryId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = "修改检测项类别";
@ -265,35 +288,28 @@ const submitForm = () => {
if (valid) {
buttonLoading.value = true;
if (form.value.categoryId) {
await updateQcInspectionItemCategory(form.value).finally(() => buttonLoading.value = false);
await updateQcInspectionItemCategory(form.value).finally(() => buttonLoading.value = false);
} else {
await addQcInspectionItemCategory(form.value).finally(() => buttonLoading.value = false);
await addQcInspectionItemCategory(form.value).finally(() => buttonLoading.value = false);
}
proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false;
await getList();
getList();
}
});
}
/** 删除按钮操作 */
const handleDelete = async (row?: QcInspectionItemCategoryVO) => {
const _categoryIds = row?.categoryId || ids.value;
await proxy?.$modal.confirm('是否确认删除检测项类别编号为"' + _categoryIds + '"的数据项?').finally(() => loading.value = false);
await delQcInspectionItemCategory(_categoryIds);
proxy?.$modal.msgSuccess("删除成功");
const handleDelete = async (row: QcInspectionItemCategoryVO) => {
await proxy?.$modal.confirm('是否确认删除检测项类别编号为"' + row.categoryId + '"的数据项?');
loading.value = true;
await delQcInspectionItemCategory(row.categoryId).finally(() => loading.value = false);
await getList();
}
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download('qms/qcInspectionItemCategory/export', {
...queryParams.value
}, `qcInspectionItemCategory_${new Date().getTime()}.xlsx`)
proxy?.$modal.msgSuccess("删除成功");
}
//
let qcInspectionTypeList = ref<QcInspectionTypeVO[]>([]);
let qcInspectionTypeList = ref([]);
const getInspectionTypeList = async () => {
const res = await getQcInspectionTypeList(null);
qcInspectionTypeList.value = proxy?.handleTree(res.data, "typeId", "parentId") || [];

Loading…
Cancel
Save