Merge branch 'main' of http://47.97.125.165:8902/jiangs/lis8.0-vue3
This commit is contained in:
commit
15608dcc80
53
src/hooks/messageBox.ts
Normal file
53
src/hooks/messageBox.ts
Normal file
@ -0,0 +1,53 @@
|
||||
// 兼容verbatimModuleSyntax:拆分/标记类型与值导入
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import type { ElMessageBoxOptions } from "element-plus";
|
||||
|
||||
/**
|
||||
* 极简删除确认框封装(支持返回值判断)
|
||||
* @param {string} [message] - 自定义删除提示信息(可选)
|
||||
* @param {Partial<MessageBoxConfirmOptions>} [customOptions] - 自定义配置(可选)
|
||||
* @returns {Promise<boolean>} 确认返回true,取消/关闭返回false
|
||||
*/
|
||||
export const deleteConfirm = (
|
||||
message?: string,
|
||||
customOptions?: Partial<ElMessageBoxOptions>
|
||||
) => {
|
||||
// 删除场景默认配置
|
||||
const defaultOptions: ElMessageBoxOptions = {
|
||||
title: "删除确认",
|
||||
message: message || "此操作将永久删除该数据,无法恢复,是否继续?",
|
||||
confirmButtonText: "确认删除",
|
||||
cancelButtonText: "取消",
|
||||
type: "error",
|
||||
//center: true,
|
||||
};
|
||||
|
||||
// 合并默认配置与自定义配置
|
||||
const finalOptions = { ...defaultOptions, ...customOptions };
|
||||
|
||||
// 核心修改:无论确认/取消,都resolve布尔值,不触发reject
|
||||
return new Promise<boolean>((resolve) => {
|
||||
ElMessageBox.confirm(finalOptions.message, finalOptions.title, finalOptions)
|
||||
.then(() => resolve(true)) // 确认:返回true
|
||||
.catch(() => resolve(false)); // 取消/关闭:返回false(不再reject)
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 使用示例
|
||||
const handleDelete = async (id: number) => {
|
||||
// 直接获取返回值:true=确认,false=取消
|
||||
const isConfirmed = await deleteConfirm('是否删除数据?', { title: '自定义标题', type: 'warning' })
|
||||
|
||||
if (isConfirmed) {
|
||||
// 确认删除:执行业务逻辑
|
||||
// await api.deleteData(id) // 真实接口请求
|
||||
ElMessage.success(`ID为${id}的数据删除成功!`)
|
||||
console.log(`执行删除操作,数据ID:${id}`)
|
||||
} else {
|
||||
// 取消删除:给出提示(可选)
|
||||
ElMessage.info('已取消删除操作')
|
||||
console.log('用户取消删除')
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -4,14 +4,12 @@
|
||||
<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="success" plain icon="Edit" :disabled="single" @click="handleUpdateBatch">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDeleteBatch">删除</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="Edit" @click="router.push('/liswork/reportdict')">编辑模板
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" icon="Refresh" @click="handleQuery">刷新</el-button>
|
||||
@ -72,14 +70,14 @@
|
||||
</el-row>
|
||||
|
||||
<!-- 添加或修改字典对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="reportinstrRef" :model="form" :rules="rules" label-width="150px">
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-form ref="reportinstrRef" :model="form" :rules="rules" label-width="120px">
|
||||
|
||||
<el-form-item :label="`${menuname}模板`" prop="reportBgdh">
|
||||
<el-form-item label="模板编码" prop="reportBgdh">
|
||||
<el-select
|
||||
v-model="form.reportBgdh"
|
||||
:placeholder="`请选择${menuname}模板`"
|
||||
style="width: 100%"
|
||||
placeholder="请选择模板"
|
||||
style="width: 70%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dictOptions"
|
||||
@ -89,11 +87,11 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`${menuname}类别`" prop="reportType">
|
||||
<el-form-item label="类别" prop="reportType">
|
||||
<el-select
|
||||
v-model="form.reportType"
|
||||
:placeholder="`请选择${menuname}类别`"
|
||||
style="width: 100%"
|
||||
placeholder="请选择类别"
|
||||
style="width: 50%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reportTypeOptions"
|
||||
@ -101,13 +99,13 @@
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-select><span class="static-text blue-text">细菌仪必选</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`${menuname}纸张类型`" prop="reportSize">
|
||||
<el-form-item label="纸张类型" prop="reportSize">
|
||||
<el-select
|
||||
v-model="form.reportSize"
|
||||
:placeholder="`请选择${menuname}纸张类型`"
|
||||
style="width: 100%"
|
||||
placeholder="请选择纸张类型"
|
||||
style="width: 50%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reportSizeOptions"
|
||||
@ -117,17 +115,17 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`${menuname}固定行数`" prop="reportRows">
|
||||
<el-input v-model.number="form.reportRows" :placeholder="`请输入${menuname}固定行数`" />
|
||||
<el-form-item label="固定行数" prop="reportRows">
|
||||
<el-input v-model.number="form.reportRows" placeholder="请输入固定行数" style="width: 50%"/><span class="static-text blue-text">用于固定报告单高度</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`${menuname}最小行数`" prop="reportMinrows">
|
||||
<el-input v-model.number="form.reportMinrows" :placeholder="`请输入${menuname}最小行数`" />
|
||||
<el-form-item label="最小行数" prop="reportMinrows">
|
||||
<el-input v-model.number="form.reportMinrows" placeholder="请输入最小行数" style="width: 50%"/><span class="static-text blue-text">超过此行数使用该报告</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`${menuname}最大行数`" prop="reportMaxrows">
|
||||
<el-input v-model.number="form.reportMaxrows" :placeholder="`请输入${menuname}最大行数`" />
|
||||
<el-form-item label="最大行数" prop="reportMaxrows">
|
||||
<el-input v-model.number="form.reportMaxrows" placeholder="请输入最大行数" style="width: 50%"/><span class="static-text blue-text">不超过此行数使用该报告</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`${menuname}指定项目`" prop="reportItems">
|
||||
<el-input v-model="form.reportItems" :placeholder="`请输入${menuname}指定项目`" />
|
||||
<el-form-item label="指定项目" prop="reportItems">
|
||||
<DynamicInput type="3" v-model="form.reportItems" :dict-data="`item:${form.reportYq}`" placeholder="请输入指定项目" class="edit-input" style="width: 70%"/><span class="static-text blue-text">项目专用报告单</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="顺序" prop="reportSort">
|
||||
<el-input-number v-model="form.reportSort" controls-position="right" :min="0" />
|
||||
@ -139,7 +137,7 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" style="width: 70%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -155,8 +153,8 @@
|
||||
<script setup name="reportinstr" lang="ts">
|
||||
import { ref, reactive, toRefs, watch, onMounted } from 'vue';
|
||||
import { ElMessage, ElMessageBox, ElForm } from 'element-plus';
|
||||
// 导入类型定义(若项目有axios封装,需补充AxiosResponse类型)
|
||||
// 导入API(确保API返回Promise<AxiosResponse>)
|
||||
import { useRouter } from 'vue-router'
|
||||
const router = useRouter()
|
||||
import {
|
||||
addreportinstr,
|
||||
delreportinstr,
|
||||
@ -167,6 +165,7 @@ import {
|
||||
import {optionselect} from "@/api/liswork/xtwh/reportdictApi";
|
||||
// 导入时间格式化工具(确保存在)
|
||||
import { parseTime } from "@/utils/ruoyi.js";
|
||||
import DynamicInput from "@/views/liswork/xtwh/localconfig/components/DynamicInput.vue"
|
||||
// ========== 1. 修正:TypeScript 类型定义 ==========
|
||||
interface ReportItem {
|
||||
reportId: number;
|
||||
@ -360,17 +359,11 @@ const handleAdd = () => {
|
||||
title.value = `添加${menuname.value}`;
|
||||
};
|
||||
|
||||
/** 批量修改按钮(原handleUpdate重名,拆分) */
|
||||
const handleUpdateBatch = () => {
|
||||
if (ids.value.length !== 1) {
|
||||
ElMessage.warning("请选择一条数据进行修改");
|
||||
return;
|
||||
}
|
||||
handleUpdate({ reportId: ids.value[0] } as ReportItem);
|
||||
};
|
||||
|
||||
|
||||
/** 单行修改按钮 */
|
||||
const handleUpdate = async (row: ReportItem) => {
|
||||
loadApiDict();
|
||||
reset();
|
||||
const reportId = row.reportId;
|
||||
try {
|
||||
@ -440,13 +433,6 @@ const handleDelete = async (row: ReportItem) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 导出按钮操作(修正:参数传递 + 接口路径) */
|
||||
const handleExport = () => {
|
||||
};
|
||||
|
||||
// ========== 4. 修正:生命周期 + 监听 ==========
|
||||
// 补充:获取当前实例(用于proxy)
|
||||
import { getCurrentInstance } from 'vue';
|
||||
|
||||
// 监听yq变化
|
||||
watch(yq, (newVal) => {
|
||||
@ -507,4 +493,27 @@ onMounted(() => {
|
||||
.dialog-footer {
|
||||
text-align: center;
|
||||
}
|
||||
/* 输入框+静态文本的容器布局 */
|
||||
.input-with-text {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px; /* 输入框和文本的间距 */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 静态文本通用样式 */
|
||||
.static-text {
|
||||
font-size: 12px;
|
||||
white-space: nowrap; /* 防止文本换行 */
|
||||
}
|
||||
|
||||
/* 红色文本 */
|
||||
.red-text {
|
||||
color: #ff4949; /* 适配Element Plus危险色,和开关关闭色一致 */
|
||||
}
|
||||
|
||||
/* 蓝色文本 */
|
||||
.blue-text {
|
||||
color: #1989fa; /* 适配Element Plus主要色,也可改用#409eff */
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user