参数模板

This commit is contained in:
wyuu 2025-12-25 19:14:33 +08:00
parent 574fb9bc6e
commit 35c8603002
3 changed files with 134 additions and 207 deletions

View File

@ -133,7 +133,7 @@ aside {
}
.pagination-container {
margin-top: 30px;
margin-top: 10px;
}
.text-center {

View File

@ -4,18 +4,10 @@
<template v-if="values.includes(item.value)">
<span
v-if="(item.elTagType == 'default' || item.elTagType == '') && (item.elTagClass == '' || item.elTagClass == null)"
:key="item.value"
:index="index"
:class="item.elTagClass"
>{{ item.label + " " }}</span>
<el-tag
v-else
:disable-transitions="true"
:key="item.value + ''"
:index="index"
:type="item.elTagType === 'primary' ? '' : item.elTagType"
:class="item.elTagClass"
>{{ item.label + " " }}</el-tag>
:key="item.value" :index="index" :class="item.elTagClass">{{ item.label + " " }}</span>
<el-tag v-else :disable-transitions="true" :key="item.value + ''" :index="index"
:type="item.elTagType === 'primary' ? 'primary' : item.elTagType" :class="item.elTagClass">{{ item.label + " "
}}</el-tag>
</template>
</template>
<template v-if="unmatch && showValue">
@ -76,7 +68,7 @@ function handleArray(array) {
</script>
<style scoped>
.el-tag + .el-tag {
.el-tag+.el-tag {
margin-left: 10px;
}
</style>

View File

@ -1,48 +1,23 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
<el-form-item :label="menuname + '类别'" prop="configType">
<el-select
v-model="queryParams.configType"
:placeholder="`请选择${menuname}类别`"
clearable
style="width: 200px"
@change="handleQuery"
>
<el-option
v-for="item in configTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-form-item :label="menuname + '类别'" prop="configType">
<el-select v-model="queryParams.configType" :placeholder="`请选择${menuname}类别`" clearable style="width: 200px"
@change="handleQuery">
<el-option v-for="item in configTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="menuname + '编码'" prop="configCode">
<el-input
v-model="queryParams.configCode"
:placeholder="`请输入${menuname}编码`"
clearable
style="width: 200px"
@keyup.enter="handleQuery"
/>
<el-form-item :label="menuname + '编码'" prop="configCode">
<el-input v-model="queryParams.configCode" :placeholder="`请输入${menuname}编码`" clearable style="width: 200px"
@keyup.enter="handleQuery" />
</el-form-item>
<el-form-item :label="`${menuname}名称`" prop="configName">
<el-input
v-model="queryParams.configName"
:placeholder="`请输入${menuname}名称`"
clearable
style="width: 200px"
@keyup.enter="handleQuery"
/>
<el-input v-model="queryParams.configName" :placeholder="`请输入${menuname}名称`" clearable style="width: 200px"
@keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="状态" clearable style="width: 200px">
<el-option
v-for="dict in sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
@ -53,111 +28,81 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
>新增</el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
>导出</el-button>
<el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-row :gutter="5" class="table-container">
<el-table v-loading="loading" :data="regdictList" @selection-change="handleSelectionChange" class="config-table" height="100%">
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="`${menuname}编号`" align="center" prop="configId" v-if="false"/>
<el-table-column :label="`${menuname}类别`" align="center" prop="configType" width="100" show-overflow-tooltip>
<template #default="scope">
<span
class="config-type-cell"
:style="{
<div class="table-container">
<el-table v-loading="loading" :data="regdictList" @selection-change="handleSelectionChange" class="config-table"
height="100%">
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="`${menuname}编号`" align="center" prop="configId" v-if="false" />
<el-table-column :label="`${menuname}类别`" align="center" prop="configType" width="100" show-overflow-tooltip>
<template #default="scope">
<span class="config-type-cell" :style="{
backgroundColor: getConfigTypeColor(scope.row.configType),
color: '#fff' // 文字白色,保证对比
}"
>
{{ configTypeOptions.find(item => item.value === scope.row.configType)?.label || scope.row.configType }}
</span>
</template>
</el-table-column>
<el-table-column :label="`${menuname}编码`" align="center" prop="configCode" width="150" show-overflow-tooltip />
<el-table-column :label="`${menuname}名称`" align="left" prop="configName" show-overflow-tooltip />
<el-table-column label="选项类型" align="center" prop="configOptiontype"width="100">
<template #default="scope">
<span
class="config-type-cell"
:style="{
}">
{{configTypeOptions.find(item => item.value === scope.row.configType)?.label || scope.row.configType}}
</span>
</template>
</el-table-column>
<el-table-column :label="`${menuname}编码`" align="center" prop="configCode" width="150" show-overflow-tooltip />
<el-table-column :label="`${menuname}名称`" align="left" prop="configName" show-overflow-tooltip />
<el-table-column label="选项类型" align="center" prop="configOptiontype" width="100">
<template #default="scope">
<span class="config-type-cell" :style="{
backgroundColor: getconfigOptionTypeColor(scope.row.configOptiontype),
color: '#fff' // 文字白色,保证对比
}"
>
{{ configOptiontypeOptions.find(item => item.value === scope.row.configOptiontype)?.label || scope.row.configOptiontype }}
</span>
</template>
</el-table-column>
<el-table-column label="默认值" align="center" prop="configDefvalue" show-overflow-tooltip />
<el-table-column label="值域规则" align="left" prop="remark" show-overflow-tooltip />
<el-table-column label="排序" align="center" prop="configSort" width="80" />
<el-table-column label="状态" align="center" prop="status" width="80">
<template #default="scope">
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="150" show-overflow-tooltip>
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" >修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" >删除</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
}">
{{configOptiontypeOptions.find(item => item.value === scope.row.configOptiontype)?.label ||
scope.row.configOptiontype}}
</span>
</template>
</el-table-column>
<el-table-column label="默认值" align="center" prop="configDefvalue" width="200" show-overflow-tooltip>
<template #default="scope">
<DynamicInput :type="scope.row.configOptiontype" v-model="scope.row.configDefvalue"
:dict-data="scope.row.remark" :placeholder="`请输入${scope.row.configName}值`" class="edit-input" />
</template>
</el-table-column>
<el-table-column label="值域规则" align="left" prop="remark" show-overflow-tooltip />
<el-table-column label="排序" align="center" prop="configSort" width="80" />
<el-table-column label="状态" align="center" prop="status" width="80">
<template #default="scope">
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="150" show-overflow-tooltip>
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改字典对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-dialog :title="title" v-model="open" width="500px">
<el-form ref="configdictRef" :model="form" :rules="rules" label-width="150px">
<el-form-item :label="`${menuname}类别`" prop="configType">
<el-select
v-model="form.configType"
:placeholder="`请选择${menuname}类别`"
style="width: 100%"
>
<el-option
v-for="item in configTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-select v-model="form.configType" :placeholder="`请选择${menuname}类别`" style="width: 100%">
<el-option v-for="item in configTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="`${menuname}编码`" prop="configCode">
@ -167,17 +112,9 @@
<el-input v-model="form.configName" :placeholder="`请输入${menuname}名称`" />
</el-form-item>
<el-form-item :label="`${menuname}选项类型`" prop="configOptiontype">
<el-select
v-model="form.configOptiontype"
:placeholder="`请选择${menuname}选项类型`"
style="width: 100%"
>
<el-option
v-for="item in configOptiontypeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-select v-model="form.configOptiontype" :placeholder="`请选择${menuname}选项类型`" style="width: 100%">
<el-option v-for="item in configOptiontypeOptions" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="`${menuname}默认值`" prop="configDefvalue">
@ -189,11 +126,8 @@
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}</el-radio>
<el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label
}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="值域参数JSON" prop="remark">
@ -217,13 +151,14 @@ import {
listconfigdict,
updateconfigdict
} from "@/api/liswork/xtwh/configdictApi.ts";
import DynamicInput from "@/views/liswork/xtwh/localconfig/components/DynamicInput.vue"
// 1. 定义类别下拉选项(根据实际业务调整)
const configTypeOptions = ref([
{ label: "仪器全局设置", value: "SYSTEM",color: "#E6A23C" },
{ label: "仪器全局设置", value: "SYSTEM", color: "#E6A23C" },
{ label: "仪器界面设置", value: "INPUT", color: "#67C23A" },
{ label: "本地选项设置", value: "LOCAL" , color: "#409EFF" },
{ label: "本院特殊设置", value: "HISOPT", color: "#909399" },
{ label: "门诊采血设置", value: "_MZCX_", color: "#C74127" }
{ label: "本地选项设置", value: "LOCAL", color: "#409EFF" },
{ label: "本院特殊设置", value: "HISOPT", color: "#909399" },
{ label: "门诊采血设置", value: "_MZCX_", color: "#C74127" }
]);
// 2. 定义获取类别对应颜色的方法
function getConfigTypeColor(type) {
@ -233,15 +168,15 @@ function getConfigTypeColor(type) {
}
// 2. 定义参数类别下拉选项(根据实际业务调整)
const configOptiontypeOptions = ref([
{ label: "单选框", value: "0",color: "#56BBBD" },
{ label: "下拉框", value: "1",color: "#67C23A" },
{ label: "字典单选", value: "2",color: "#FF443F" },
{ label: "字典多选", value: "3",color: "#F08784" },
{ label: "特殊", value: "4",color: "#909399" },
{ label: "文本框", value: "5",color: "#3282F6" },
{ label: "数字框", value: "6",color: "#507F80" },
{ label: "日期框", value: "7",color: "#7E84F7" },
{ label: "时间框", value: "8",color: "#377D22" },
{ label: "单选框", value: "0", color: "#56BBBD" },
{ label: "下拉框", value: "1", color: "#67C23A" },
{ label: "字典单选", value: "2", color: "#FF443F" },
{ label: "字典多选", value: "3", color: "#F08784" },
{ label: "特殊", value: "4", color: "#909399" },
{ label: "文本框", value: "5", color: "#3282F6" },
{ label: "数字框", value: "6", color: "#507F80" },
{ label: "日期框", value: "7", color: "#7E84F7" },
{ label: "时间框", value: "8", color: "#377D22" },
]);
function getconfigOptionTypeColor(type) {
// 匹配对应类别的颜色,无匹配时用默认色
@ -265,26 +200,26 @@ const data = reactive({
queryParams: {
configCode: undefined,
configName: undefined,
configType:undefined,
status: undefined
configType: undefined,
status: undefined,
pageNum: 1,
pageSize: 30
},
rules: {
configType: [{ required: true, message: menuname.value+"类别不能为空", trigger: "blur" }],
configName: [{ required: true, message: menuname.value+"名称不能为空", trigger: "blur" }],
configCode: [{ required: true, message: menuname.value+"编码不能为空", trigger: "blur" }],
configSort: [{ required: true, message: menuname.value+"顺序不能为空", trigger: "blur" }],
configType: [{ required: true, message: menuname.value + "类别不能为空", trigger: "blur" }],
configName: [{ required: true, message: menuname.value + "名称不能为空", trigger: "blur" }],
configCode: [{ required: true, message: menuname.value + "编码不能为空", trigger: "blur" }],
configSort: [{ required: true, message: menuname.value + "顺序不能为空", trigger: "blur" }],
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询字典列表 */
function getList() {
loading.value = true;
listconfigdict(queryParams.value).then(response => {
console.log('response:', response);
regdictList.value = response.data;
total.value = response.data.length;
regdictList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
@ -301,7 +236,7 @@ function reset() {
configName: undefined,
configType: configTypeOptions.value[0]?.value || "",
configOptiontype: configOptiontypeOptions.value[0]?.value || "",
configDefvalue:undefined,
configDefvalue: undefined,
configSort: 0,
status: "0",
remark: undefined
@ -328,7 +263,7 @@ function handleSelectionChange(selection) {
function handleAdd() {
reset();
open.value = true;
title.value = "添加"+menuname.value;
title.value = "添加" + menuname.value;
}
/** 修改按钮操作 */
function handleUpdate(row) {
@ -337,25 +272,28 @@ function handleUpdate(row) {
getconfigdict(configId).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改"+menuname.value;
title.value = "修改" + menuname.value;
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["configdictRef"].validate(valid => {
if (valid) {
if (form.value.configId != undefined) {
updateconfigdict(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
if (response.code == 200) {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
}
});
} else {
addconfigdict(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
if (response.code == 200) {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
}
});
}
}
@ -364,13 +302,12 @@ function submitForm() {
/** 删除按钮操作 */
function handleDelete(row) {
const configIds = row.configId || ids.value;
proxy.$modal.confirm('是否确认删除"' + menuname.value + '"编号为"' + configIds + '"的数据项?').then(function() {
proxy.$modal.confirm('是否确认删除"' + menuname.value + '"编号为"' + configIds + '"的数据项?').then(function () {
return delconfigdict(configIds);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}).catch(() => { });
}
/** 导出按钮操作 */
function handleExport() {
@ -381,42 +318,40 @@ function handleExport() {
getList();
</script>
<style scoped>
.app-container {
display: flex;
flex-direction: column;
height: 90vh;
/* 容器高度等于窗口高度 */
overflow: hidden;
}
.mb8 {
height: 30px;
/* 固定高度 */
}
.table-container {
flex: 1;
/* 占满剩余高度 */
overflow: hidden;
/* 避免表格超出容器 */
height: calc(100% - 150px);
}
/* 1. 减小表格行高(核心) */
:deep(.config-table .el-table__row) {
height: 30px !important; /* 原默认行高约40px,按需调整(建议28-35px) */
line-height: 30px !important; /* 行高与height一致,保证垂直居中 */
height: 30px !important;
/* 原默认行高约40px,按需调整(建议28-35px) */
line-height: 30px !important;
/* 行高与height一致,保证垂直居中 */
}
/* 2. 减小单元格内边距(配合行高优化) */
:deep(.config-table .el-table__cell) {
padding: 2px 4px !important;
height: 30px !important; /* 单元格高度与行高一致 */
line-height: 1.2 !important; /* 文字行高适配矮行 */
vertical-align: middle !important; /* 强制垂直居中 */
height: 30px !important;
/* 单元格高度与行高一致 */
line-height: 1.2 !important;
/* 文字行高适配矮行 */
vertical-align: middle !important;
/* 强制垂直居中 */
}
/* 3. 类别单元格适配矮行高 */
.config-type-cell {
width: 100%;
height: 100%;
min-height: 26px; /* 适配30px行高,略小一点 */
min-height: 26px;
/* 适配30px行高,略小一点 */
display: flex;
align-items: center;
justify-content: center;