From 6a72da7900390c3048d7eb07a8e93ed776f5676b Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期四, 16 一月 2025 13:28:22 +0800 Subject: [PATCH] 修改指标分类为选择tree,增加选择框可编辑 --- src/views/data/ind/item/CalIndDefineForm.vue | 35 ++++++++++++++++++++++------------- 1 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/views/data/ind/item/CalIndDefineForm.vue b/src/views/data/ind/item/CalIndDefineForm.vue index 0d5fc81..52d78cc 100644 --- a/src/views/data/ind/item/CalIndDefineForm.vue +++ b/src/views/data/ind/item/CalIndDefineForm.vue @@ -20,14 +20,14 @@ <el-row> <el-col :span="12"> <el-form-item label="指标分类" prop="itemCategory"> - <el-select v-model="formData.itemCategory" clearable placeholder="请选择指标分类"> - <el-option - v-for="item in dataCategoryList" - :key="item.id" - :label="item.label" - :value="item.id + ''" - /> - </el-select> + <el-tree-select + v-model="formData.itemCategory" + :data="dataCategoryList" + :default-expanded-keys="[0]" + :props="defaultProps" + check-strictly + node-key="id" + /> </el-form-item> </el-col> <el-col :span="12"> @@ -139,6 +139,7 @@ import * as ItemApi from '@/api/data/ind/item/item' import { ElMessage } from 'element-plus' import * as CategoryApi from '@/api/data/ind/category/index' + import {handleTree} from "@/utils/tree"; defineOptions({name: 'IndDataSetForm'}) @@ -183,14 +184,22 @@ const operatorList = ref(['+', '-', '*', '/', '&', '|', '!', '>', '<']) const formRules = reactive({ itemName: [{required: true, message: '指标名称不能为空', trigger: 'blur'}], - itemCategory: [{required: true, message: '指标类型不能为空', trigger: 'blur'}], - precision: [{validator: validateAsNumber, trigger: 'blur' }], - coefficient: [{validator: validateAsNumber, trigger: 'blur' }], + itemCategory: [{required: true, message: '指标类型不能为空', trigger: 'blur'}] + // precision: [{validator: validateAsNumber, trigger: 'blur' }], + // coefficient: [{validator: validateAsNumber, trigger: 'blur' }], }) const formRef = ref() // 表单 Ref const dataSourceList = ref([] as DataSourceConfigApi.DataSourceConfigVO[]) const queryParams = reactive({}) - const dataCategoryList = ref([] as CategoryApi.IndItemCategoryVO[]) + + const dataCategoryList = ref<Tree[]>([]) + const getCategoryTree = async () => { + dataCategoryList.value = [] + const res = await CategoryApi.getCategoryListAllSimple() + let category: Tree = {id: 0, label: '主类目', children: []} + category.children = handleTree(res, 'id', 'pid') + dataCategoryList.value.push(category) + } /** 打开弹窗 */ const open = async (type: string, id?: number) => { dialogVisible.value = true @@ -199,7 +208,7 @@ resetForm() // 加载数据源列表 - dataCategoryList.value = await CategoryApi.getCategoryListAllSimple() + await getCategoryTree() itemList.value = await ItemApi.getItemList(queryParams) // 修改时,设置数据 if (id) { -- Gitblit v1.9.3