refactor(智能柜卡片): 优化智能柜卡片表单模态框的显示方式
将智能柜卡片表单模态框从`el-dialog`改为`el-drawer`,提升用户体验。同时修复了重复显示登录提示的问题,并优化了代码格式。
This commit is contained in:
parent
a742b56413
commit
9fb6bb0ed6
|
@ -49,6 +49,9 @@ class PureHttp {
|
||||||
/** 防止重复刷新token */
|
/** 防止重复刷新token */
|
||||||
private static isRefreshing = false;
|
private static isRefreshing = false;
|
||||||
|
|
||||||
|
/** 防止重复显示登录提示 */
|
||||||
|
private static isShowingLogin = false;
|
||||||
|
|
||||||
/** 初始化配置对象 */
|
/** 初始化配置对象 */
|
||||||
private static initConfig: PureHttpRequestConfig = {};
|
private static initConfig: PureHttpRequestConfig = {};
|
||||||
|
|
||||||
|
@ -137,6 +140,8 @@ class PureHttp {
|
||||||
if (response.data.code !== 0) {
|
if (response.data.code !== 0) {
|
||||||
// token失效时弹出过期提示
|
// token失效时弹出过期提示
|
||||||
if (response.data.code === 106) {
|
if (response.data.code === 106) {
|
||||||
|
if (!PureHttp.isShowingLogin) {
|
||||||
|
PureHttp.isShowingLogin = true;
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm(
|
||||||
"登录状态已过期,您可以继续留在该页面,或者重新登录",
|
"登录状态已过期,您可以继续留在该页面,或者重新登录",
|
||||||
"系统提示",
|
"系统提示",
|
||||||
|
@ -145,14 +150,15 @@ class PureHttp {
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}
|
}
|
||||||
)
|
).then(() => {
|
||||||
.then(() => {
|
|
||||||
removeToken();
|
removeToken();
|
||||||
router.push("/login");
|
router.push("/login");
|
||||||
})
|
}).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
message("取消重新登录", { type: "info" });
|
message("取消重新登录", { type: "info" });
|
||||||
|
}).finally(() => {
|
||||||
|
PureHttp.isShowingLogin = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
return Promise.reject(msg);
|
return Promise.reject(msg);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,8 +125,7 @@ onMounted(() => {
|
||||||
<el-col v-for="(item, index) in dataList" :key="item.cabinetId" :xs="24" :sm="12" :md="8" :lg="4" :xl="4">
|
<el-col v-for="(item, index) in dataList" :key="item.cabinetId" :xs="24" :sm="12" :md="8" :lg="4" :xl="4">
|
||||||
<el-card class="cabinet-card" :body-style="{ padding: '8px 20px' }">
|
<el-card class="cabinet-card" :body-style="{ padding: '8px 20px' }">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<img
|
<img :src="`${IMG_PATH}img/cabinet/${CabinetImgMap[item.templateNo]?.img || 'default.jpg'}`"
|
||||||
:src="`${IMG_PATH}img/cabinet/${CabinetImgMap[item.templateNo]?.img || 'default.jpg'}`"
|
|
||||||
class="cabinet-image" />
|
class="cabinet-image" />
|
||||||
<el-descriptions class="cabinet-info" :column="2">
|
<el-descriptions class="cabinet-info" :column="2">
|
||||||
<el-descriptions-item class="name" :span="2">柜体名称:{{ item.cabinetName }}
|
<el-descriptions-item class="name" :span="2">柜体名称:{{ item.cabinetName }}
|
||||||
|
@ -150,7 +149,9 @@ onMounted(() => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<smart-cabinet-card-form-modal v-model:visible="modalVisible" @refresh="getList" />
|
<el-drawer v-model="modalVisible" title="新增智能柜" size="30%" direction="rtl">
|
||||||
|
<smart-cabinet-card-form-modal v-model="modalVisible" @refresh="getList" />
|
||||||
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ const props = defineProps({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["update:visible", "refresh"]);
|
const emit = defineEmits(["update:modelValue", "refresh"]);
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const formData = reactive<FormDTO>({
|
const formData = reactive<FormDTO>({
|
||||||
|
@ -60,7 +60,7 @@ const handleConfirm = async () => {
|
||||||
|
|
||||||
const closeDialog = () => {
|
const closeDialog = () => {
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields();
|
||||||
emit("update:visible", false);
|
emit("update:modelValue", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const templateOptions = Object.entries(CabinetImgMap).map(([value, item]) => ({
|
const templateOptions = Object.entries(CabinetImgMap).map(([value, item]) => ({
|
||||||
|
@ -70,7 +70,6 @@ const templateOptions = Object.entries(CabinetImgMap).map(([value, item]) => ({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-dialog title="新增智能柜" :model-value="visible" width="600px" @close="closeDialog">
|
|
||||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||||
<el-form-item label="柜体名称" prop="cabinetName">
|
<el-form-item label="柜体名称" prop="cabinetName">
|
||||||
<el-input v-model="formData.cabinetName" placeholder="请输入柜体名称" />
|
<el-input v-model="formData.cabinetName" placeholder="请输入柜体名称" />
|
||||||
|
@ -85,17 +84,13 @@ const templateOptions = Object.entries(CabinetImgMap).map(([value, item]) => ({
|
||||||
|
|
||||||
<el-form-item label="模板编号" prop="templateNo">
|
<el-form-item label="模板编号" prop="templateNo">
|
||||||
<el-select v-model="formData.templateNo" placeholder="请选择模板编号">
|
<el-select v-model="formData.templateNo" placeholder="请选择模板编号">
|
||||||
<el-option v-for="option in templateOptions" :key="option.value" :label="option.label"
|
<el-option v-for="option in templateOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
:value="option.value" />
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
<el-form-item>
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="closeDialog">取消</el-button>
|
|
||||||
<el-button type="primary" :icon="useRenderIcon(Confirm)" @click="handleConfirm">
|
<el-button type="primary" :icon="useRenderIcon(Confirm)" @click="handleConfirm">
|
||||||
确认
|
确认
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</el-form-item>
|
||||||
</el-dialog>
|
</el-form>
|
||||||
</template>
|
</template>
|
Loading…
Reference in New Issue