配置智能柜锁
This commit is contained in:
parent
522eff97f8
commit
1c23d04690
|
@ -7,7 +7,7 @@
|
|||
<meta name="renderer" content="webkit" />
|
||||
<meta name="viewport"
|
||||
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" />
|
||||
<title>微商城管理系统</title>
|
||||
<title>借还柜</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<script>
|
||||
window.process = {};
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"Version": "4.4.0",
|
||||
"Title": "微商城后台管理系统",
|
||||
"Title": "借还柜",
|
||||
"FixedHeader": true,
|
||||
"HiddenSideBar": false,
|
||||
"MultiTagsCache": false,
|
||||
"KeepAlive": true,
|
||||
"Layout": "vertical",
|
||||
"Theme": "default",
|
||||
"Layout": "horizontal",
|
||||
"Theme": "light",
|
||||
"DarkMode": false,
|
||||
"Grey": false,
|
||||
"Weak": false,
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
import { http } from '@/utils/http';
|
||||
|
||||
export interface CabinetCellQuery extends BasePageQuery {
|
||||
cabinetId?: number;
|
||||
cellNo?: number;
|
||||
cellType?: number;
|
||||
}
|
||||
|
||||
export interface CabinetCellDTO {
|
||||
cellId?: number;
|
||||
cabinetId: number;
|
||||
cellNo: number;
|
||||
pinNo: number;
|
||||
cellType: number;
|
||||
usageStatus: number;
|
||||
availableStatus: number;
|
||||
operator?: string;
|
||||
}
|
||||
|
||||
export interface AddCabinetCellCommand {
|
||||
cabinetId: number;
|
||||
cellNo: number;
|
||||
pinNo: number;
|
||||
cellType: number;
|
||||
usageStatus: number;
|
||||
availableStatus: number;
|
||||
}
|
||||
|
||||
export interface UpdateCabinetCellCommand extends AddCabinetCellCommand {
|
||||
usageStatus: number;
|
||||
availableStatus: number;
|
||||
}
|
||||
|
||||
export const getCabinetCellList = (params?: CabinetCellQuery) => {
|
||||
return http.request<ResponseData<PageDTO<CabinetCellDTO>>>('get', '/cabinet/cell', {
|
||||
params
|
||||
});
|
||||
};
|
||||
|
||||
export const addCabinetCell = (data: AddCabinetCellCommand) => {
|
||||
return http.request<ResponseData<void>>('post', '/cabinet/cell', {
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCabinetCell = (cellId: number, data: UpdateCabinetCellCommand) => {
|
||||
return http.request<ResponseData<void>>('put', `/cabinet/cell/${cellId}`, {
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteCabinetCell = (ids: string) => {
|
||||
return http.request<ResponseData<void>>('delete', `/cabinet/cell/${ids}`);
|
||||
};
|
||||
|
||||
export interface ConfigureGoodsCellsCommand {
|
||||
goodsId: number;
|
||||
cellId: number;
|
||||
}
|
||||
|
||||
export const configureGoodsCells = (cellId: number, goodsId: number) => {
|
||||
return http.request<ResponseData<void>>('put', `/cabinet/cell/configureGoodsCells/${cellId}/${goodsId}`);
|
||||
};
|
|
@ -0,0 +1,60 @@
|
|||
import { http } from '@/utils/http';
|
||||
import { CabinetCellDTO } from './cabinet-cell';
|
||||
|
||||
export interface SmartCabinetQuery extends BasePageQuery {
|
||||
cabinetName?: string;
|
||||
cabinetType?: number;
|
||||
templateNo?: string;
|
||||
}
|
||||
|
||||
export interface SmartCabinetDTO {
|
||||
cabinetId?: number;
|
||||
cabinetName: string;
|
||||
cabinetType: number;
|
||||
templateNo: string;
|
||||
lockControlNo: number;
|
||||
location: number;
|
||||
operator?: string;
|
||||
}
|
||||
|
||||
export interface AddSmartCabinetCommand {
|
||||
cabinetName: string;
|
||||
cabinetType: number;
|
||||
templateNo: string;
|
||||
lockControlNo: number;
|
||||
location: number;
|
||||
}
|
||||
|
||||
export interface UpdateSmartCabinetCommand extends AddSmartCabinetCommand {
|
||||
}
|
||||
|
||||
export interface AllCabinetDataDTO {
|
||||
smartCabinetList: SmartCabinetDTO[];
|
||||
cells: CabinetCellDTO[];
|
||||
}
|
||||
|
||||
export const getSmartCabinetList = (params?: SmartCabinetQuery) => {
|
||||
return http.request<ResponseData<PageDTO<SmartCabinetDTO>>>('get', '/cabinet/smartCabinet', {
|
||||
params
|
||||
});
|
||||
};
|
||||
|
||||
export const addSmartCabinet = (data: AddSmartCabinetCommand) => {
|
||||
return http.request<ResponseData<void>>('post', '/cabinet/smartCabinet', {
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
export const updateSmartCabinet = (id: number, data: UpdateSmartCabinetCommand) => {
|
||||
return http.request<ResponseData<void>>('put', `/cabinet/smartCabinet/${id}`, {
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteSmartCabinet = (ids: string) => {
|
||||
return http.request<ResponseData<void>>('delete', `/cabinet/smartCabinet/${ids}`);
|
||||
};
|
||||
|
||||
export const getAllCabinetsWithCells = () => {
|
||||
return http.request<ResponseData<AllCabinetDataDTO>>('get', '/cabinet/smartCabinet/all');
|
||||
};
|
|
@ -23,6 +23,8 @@ export interface GoodsDTO {
|
|||
updateTime?: Date;
|
||||
remark?: string;
|
||||
deleted?: number;
|
||||
cabinetName?: string;
|
||||
cellNo?: number;
|
||||
}
|
||||
|
||||
/** 商品请求参数 */
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<template>
|
||||
<div class="qr-container w-[40px] h-[48px] flex-c navbar-bg-hover" @mouseenter="showQr = true"
|
||||
@mouseleave="showQr = false">
|
||||
<el-icon :size="20">
|
||||
<IconifyIconOffline :icon="Iphone" />
|
||||
</el-icon>
|
||||
<div v-if="showQr" class="qr-popover">
|
||||
<ReQrcode text="http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth" :options="{ width: 200 }" />
|
||||
<div class="qr-tip">微信扫码访问</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import ReQrcode from '@/components/ReQrcode'
|
||||
import Iphone from "@iconify-icons/ep/iphone";
|
||||
|
||||
const showQr = ref(false)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.qr-container {
|
||||
position: relative;
|
||||
|
||||
.qr-popover {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
padding: 12px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.qr-tip {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -1,6 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import Search from "./search/index.vue";
|
||||
import Notice from "./notice/index.vue";
|
||||
import QrCodeHover from "@/components/QrCodeHover/index.vue";
|
||||
import mixNav from "./sidebar/mixNav.vue";
|
||||
import { useNav } from "@/layout/hooks/useNav";
|
||||
import Breadcrumb from "./sidebar/breadCrumb.vue";
|
||||
|
@ -23,24 +24,17 @@ const {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="navbar bg-[#fff] shadow-sm shadow-[rgba(0, 21, 41, 0.08)] dark:shadow-[#0d0d0d]"
|
||||
>
|
||||
<topCollapse
|
||||
v-if="device === 'mobile'"
|
||||
class="hamburger-container"
|
||||
:is-active="pureApp.sidebar.opened"
|
||||
@toggleClick="toggleSideBar"
|
||||
/>
|
||||
<div class="navbar bg-[#fff] shadow-sm shadow-[rgba(0, 21, 41, 0.08)] dark:shadow-[#0d0d0d]">
|
||||
<topCollapse v-if="device === 'mobile'" class="hamburger-container" :is-active="pureApp.sidebar.opened"
|
||||
@toggleClick="toggleSideBar" />
|
||||
|
||||
<Breadcrumb
|
||||
v-if="layout !== 'mix' && device !== 'mobile'"
|
||||
class="breadcrumb-container"
|
||||
/>
|
||||
<Breadcrumb v-if="layout !== 'mix' && device !== 'mobile'" class="breadcrumb-container" />
|
||||
|
||||
<mixNav v-if="layout === 'mix'" />
|
||||
|
||||
<div v-if="layout === 'vertical'" class="vertical-header-right">
|
||||
<!-- 二维码 -->
|
||||
<QrCodeHover />
|
||||
<!-- 菜单搜索 -->
|
||||
<Search />
|
||||
<!-- 通知 -->
|
||||
|
@ -54,29 +48,19 @@ const {
|
|||
<template #dropdown>
|
||||
<el-dropdown-menu class="logout">
|
||||
<el-dropdown-item @click="userProfile">
|
||||
<IconifyIconOffline
|
||||
:icon="LogoutCircleRLine"
|
||||
style="margin: 5px"
|
||||
/>
|
||||
<IconifyIconOffline :icon="LogoutCircleRLine" style="margin: 5px" />
|
||||
个人中心
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
<el-dropdown-menu class="logout">
|
||||
<el-dropdown-item @click="logout">
|
||||
<IconifyIconOffline
|
||||
:icon="LogoutCircleRLine"
|
||||
style="margin: 5px"
|
||||
/>
|
||||
<IconifyIconOffline :icon="LogoutCircleRLine" style="margin: 5px" />
|
||||
退出系统
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<span
|
||||
class="set-icon navbar-bg-hover"
|
||||
title="打开项目配置"
|
||||
@click="onPanel"
|
||||
>
|
||||
<span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel">
|
||||
<IconifyIconOffline :icon="Setting" />
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -8,6 +8,7 @@ import { useNav } from "@/layout/hooks/useNav";
|
|||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||
import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
|
||||
import Setting from "@iconify-icons/ri/settings-3-line";
|
||||
import QrCodeHover from "@/components/QrCodeHover/index.vue";
|
||||
|
||||
const menuRef = ref();
|
||||
|
||||
|
@ -32,29 +33,18 @@ nextTick(() => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-loading="usePermissionStoreHook().wholeMenus.length === 0"
|
||||
class="horizontal-header"
|
||||
>
|
||||
<div v-loading="usePermissionStoreHook().wholeMenus.length === 0" class="horizontal-header">
|
||||
<div class="horizontal-header-left" @click="backTopMenu">
|
||||
<img src="/logo.svg" alt="logo" />
|
||||
<span>{{ title }}</span>
|
||||
</div>
|
||||
<el-menu
|
||||
router
|
||||
ref="menuRef"
|
||||
mode="horizontal"
|
||||
class="horizontal-header-menu"
|
||||
:default-active="defaultActive"
|
||||
>
|
||||
<sidebar-item
|
||||
v-for="route in usePermissionStoreHook().wholeMenus"
|
||||
:key="route.path"
|
||||
:item="route"
|
||||
:base-path="route.path"
|
||||
/>
|
||||
<el-menu router ref="menuRef" mode="horizontal" class="horizontal-header-menu" :default-active="defaultActive">
|
||||
<sidebar-item v-for="route in usePermissionStoreHook().wholeMenus" :key="route.path" :item="route"
|
||||
:base-path="route.path" />
|
||||
</el-menu>
|
||||
<div class="horizontal-header-right">
|
||||
<!-- 二维码 -->
|
||||
<QrCodeHover />
|
||||
<!-- 菜单搜索 -->
|
||||
<Search />
|
||||
<!-- 通知 -->
|
||||
|
@ -68,20 +58,13 @@ nextTick(() => {
|
|||
<template #dropdown>
|
||||
<el-dropdown-menu class="logout">
|
||||
<el-dropdown-item @click="logout">
|
||||
<IconifyIconOffline
|
||||
:icon="LogoutCircleRLine"
|
||||
style="margin: 5px"
|
||||
/>
|
||||
<IconifyIconOffline :icon="LogoutCircleRLine" style="margin: 5px" />
|
||||
退出系统
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<span
|
||||
class="set-icon navbar-bg-hover"
|
||||
title="打开项目配置"
|
||||
@click="onPanel"
|
||||
>
|
||||
<span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel">
|
||||
<IconifyIconOffline :icon="Setting" />
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getParentPaths, findRouteByPath } from "@/router/utils";
|
|||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||
import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
|
||||
import Setting from "@iconify-icons/ri/settings-3-line";
|
||||
import QrCodeHover from "@/components/QrCodeHover/index.vue";
|
||||
|
||||
const menuRef = ref();
|
||||
const defaultActive = ref(null);
|
||||
|
@ -52,31 +53,14 @@ watch(
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="device !== 'mobile'"
|
||||
class="horizontal-header"
|
||||
v-loading="usePermissionStoreHook().wholeMenus.length === 0"
|
||||
>
|
||||
<el-menu
|
||||
router
|
||||
ref="menuRef"
|
||||
mode="horizontal"
|
||||
class="horizontal-header-menu"
|
||||
:default-active="defaultActive"
|
||||
>
|
||||
<el-menu-item
|
||||
v-for="route in usePermissionStoreHook().wholeMenus"
|
||||
:key="route.path"
|
||||
:index="resolvePath(route) || route.redirect"
|
||||
>
|
||||
<div v-if="device !== 'mobile'" class="horizontal-header"
|
||||
v-loading="usePermissionStoreHook().wholeMenus.length === 0">
|
||||
<el-menu router ref="menuRef" mode="horizontal" class="horizontal-header-menu" :default-active="defaultActive">
|
||||
<el-menu-item v-for="route in usePermissionStoreHook().wholeMenus" :key="route.path"
|
||||
:index="resolvePath(route) || route.redirect">
|
||||
<template #title>
|
||||
<div
|
||||
v-if="toRaw(route.meta.icon)"
|
||||
:class="['sub-menu-icon', route.meta.icon]"
|
||||
>
|
||||
<component
|
||||
:is="useRenderIcon(route.meta && toRaw(route.meta.icon))"
|
||||
/>
|
||||
<div v-if="toRaw(route.meta.icon)" :class="['sub-menu-icon', route.meta.icon]">
|
||||
<component :is="useRenderIcon(route.meta && toRaw(route.meta.icon))" />
|
||||
</div>
|
||||
<div :style="getDivStyle">
|
||||
<span class="select-none">
|
||||
|
@ -88,6 +72,8 @@ watch(
|
|||
</el-menu-item>
|
||||
</el-menu>
|
||||
<div class="horizontal-header-right">
|
||||
<!-- 二维码 -->
|
||||
<QrCodeHover />
|
||||
<!-- 菜单搜索 -->
|
||||
<Search />
|
||||
<!-- 通知 -->
|
||||
|
@ -101,20 +87,13 @@ watch(
|
|||
<template #dropdown>
|
||||
<el-dropdown-menu class="logout">
|
||||
<el-dropdown-item @click="logout">
|
||||
<IconifyIconOffline
|
||||
:icon="LogoutCircleRLine"
|
||||
style="margin: 5px"
|
||||
/>
|
||||
<IconifyIconOffline :icon="LogoutCircleRLine" style="margin: 5px" />
|
||||
退出系统
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<span
|
||||
class="set-icon navbar-bg-hover"
|
||||
title="打开项目配置"
|
||||
@click="onPanel"
|
||||
>
|
||||
<span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel">
|
||||
<IconifyIconOffline :icon="Setting" />
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { updateCabinetCell } from "@/api/cabinet/cabinet-cell";
|
||||
import Confirm from "@iconify-icons/ep/check";
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
export interface FormDTO {
|
||||
cellId?: number;
|
||||
cabinetId: number;
|
||||
cellNo: number;
|
||||
pinNo: number;
|
||||
cellType: number;
|
||||
availableStatus: number;
|
||||
usageStatus: number;
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
row: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:visible", "refresh"]);
|
||||
|
||||
const formRef = ref();
|
||||
const formData = reactive<FormDTO>({
|
||||
cabinetId: null,
|
||||
cellNo: null,
|
||||
pinNo: null,
|
||||
cellType: 1,
|
||||
availableStatus: 1,
|
||||
usageStatus: 1
|
||||
});
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
cabinetId: [
|
||||
{ required: true, message: "柜体ID必填", trigger: "blur" },
|
||||
{ type: 'number', message: '必须为数字类型' }
|
||||
],
|
||||
cellNo: [
|
||||
{ required: true, message: "单元格号必填", trigger: "blur" },
|
||||
{ type: 'number', message: '必须为数字类型' }
|
||||
],
|
||||
pinNo: [
|
||||
{ required: true, message: "针脚号必填", trigger: "blur" },
|
||||
{ type: 'number', message: '必须为数字类型' }
|
||||
],
|
||||
cellType: [
|
||||
{ required: true, message: "请选择单元格类型", trigger: "change" }
|
||||
],
|
||||
availableStatus: [
|
||||
{ required: true, message: "请选择可用状态", trigger: "change" }
|
||||
],
|
||||
usageStatus: [
|
||||
{ required: true, message: "请选择使用状态", trigger: "change" }
|
||||
]
|
||||
});
|
||||
|
||||
const handleConfirm = async () => {
|
||||
try {
|
||||
await formRef.value.validate();
|
||||
await updateCabinetCell(formData.cellId!, formData);
|
||||
ElMessage.success("修改成功");
|
||||
emit("refresh");
|
||||
closeDialog();
|
||||
} catch (error) {
|
||||
console.error("表单提交失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
formRef.value.resetFields();
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
watch(() => props.row, (val) => {
|
||||
if (val) {
|
||||
Object.assign(formData, val);
|
||||
}
|
||||
}, { immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog title="编辑单元格" :model-value="visible" width="600px" @close="closeDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
<el-form-item label="柜体ID" prop="cabinetId">
|
||||
<el-input v-model.number="formData.cabinetId" placeholder="请输入柜体ID" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="单元格号" prop="cellNo">
|
||||
<el-input v-model.number="formData.cellNo" placeholder="请输入单元格号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="针脚号" prop="pinNo">
|
||||
<el-input v-model.number="formData.pinNo" placeholder="请输入针脚号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="单元格类型" prop="cellType">
|
||||
<el-select v-model="formData.cellType" placeholder="请选择类型">
|
||||
<el-option label="小格" :value="1" />
|
||||
<el-option label="中格" :value="2" />
|
||||
<el-option label="大格" :value="3" />
|
||||
<el-option label="超大格" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="使用状态" prop="usageStatus">
|
||||
<el-select v-model="formData.usageStatus" placeholder="请选择状态">
|
||||
<el-option label="空闲" :value="1" />
|
||||
<el-option label="已占用" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="可用状态" prop="availableStatus">
|
||||
<el-select v-model="formData.availableStatus" placeholder="请选择状态">
|
||||
<el-option label="正常" :value="1" />
|
||||
<el-option label="故障" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
<el-button type="primary" :icon="useRenderIcon(Confirm)" @click="handleConfirm">
|
||||
确认
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
|
@ -0,0 +1,127 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { addCabinetCell } from "@/api/cabinet/cabinet-cell";
|
||||
import Confirm from "@iconify-icons/ep/check";
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
export interface FormDTO {
|
||||
cabinetId: number;
|
||||
cellNo: number;
|
||||
pinNo: number;
|
||||
cellType: number;
|
||||
availableStatus: number;
|
||||
usageStatus: number;
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
initialCabinetId: {
|
||||
type: Number,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
|
||||
(window as any).cellProps = props;
|
||||
|
||||
const emit = defineEmits(["update:visible", "refresh"]);
|
||||
|
||||
const formRef = ref();
|
||||
const formData = reactive<FormDTO>({
|
||||
cabinetId: props.initialCabinetId,
|
||||
cellNo: null,
|
||||
pinNo: null,
|
||||
cellType: 1,
|
||||
availableStatus: 1,
|
||||
usageStatus: 1
|
||||
});
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
cabinetId: [],
|
||||
cellNo: [
|
||||
{ required: true, message: "单元格号必填", trigger: "blur" },
|
||||
{ type: 'number', message: '必须为数字类型' }
|
||||
],
|
||||
pinNo: [
|
||||
{ required: true, message: "针脚号必填", trigger: "blur" },
|
||||
{ type: 'number', message: '必须为数字类型' }
|
||||
],
|
||||
cellType: [
|
||||
{ required: true, message: "请选择单元格类型", trigger: "change" }
|
||||
],
|
||||
availableStatus: [
|
||||
{ required: true, message: "请选择可用状态", trigger: "change" }
|
||||
],
|
||||
usageStatus: [
|
||||
{ required: true, message: "请选择使用状态", trigger: "change" }
|
||||
]
|
||||
});
|
||||
|
||||
const handleConfirm = async () => {
|
||||
try {
|
||||
formData.cabinetId = props.initialCabinetId;
|
||||
await formRef.value.validate();
|
||||
await addCabinetCell(formData);
|
||||
ElMessage.success("新增成功");
|
||||
emit("refresh");
|
||||
closeDialog();
|
||||
} catch (error) {
|
||||
console.error("表单提交失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
formRef.value.resetFields();
|
||||
emit("update:visible", false);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog title="新增单元格" :model-value="visible" width="600px" @close="closeDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
|
||||
|
||||
<el-form-item label="单元格号" prop="cellNo">
|
||||
<el-input v-model.number="formData.cellNo" placeholder="请输入单元格号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="针脚号" prop="pinNo">
|
||||
<el-input v-model.number="formData.pinNo" placeholder="请输入针脚号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="单元格类型" prop="cellType">
|
||||
<el-select v-model="formData.cellType" placeholder="请选择类型">
|
||||
<el-option label="小格" :value="1" />
|
||||
<el-option label="中格" :value="2" />
|
||||
<el-option label="大格" :value="3" />
|
||||
<el-option label="超大格" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="使用状态" prop="usageStatus">
|
||||
<el-select v-model="formData.usageStatus" placeholder="请选择状态">
|
||||
<el-option label="空闲" :value="1" />
|
||||
<el-option label="已占用" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="可用状态" prop="availableStatus">
|
||||
<el-select v-model="formData.availableStatus" placeholder="请选择状态">
|
||||
<el-option label="正常" :value="1" />
|
||||
<el-option label="故障" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
<el-button type="primary" :icon="useRenderIcon(Confirm)" @click="handleConfirm">
|
||||
确认
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
|
@ -0,0 +1,228 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { PureTableBar } from "@/components/RePureTableBar";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { getCabinetCellList, deleteCabinetCell, CabinetCellDTO } from "@/api/cabinet/cabinet-cell";
|
||||
import EditPen from "@iconify-icons/ep/edit-pen";
|
||||
import Delete from "@iconify-icons/ep/delete";
|
||||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
||||
import Search from "@iconify-icons/ep/search";
|
||||
import Refresh from "@iconify-icons/ep/refresh";
|
||||
import CellFormModal from "./cell-form-modal.vue";
|
||||
import CellEditModal from "./cell-edit-modal.vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
|
||||
defineOptions({
|
||||
name: "CabinetCell"
|
||||
});
|
||||
|
||||
const formRef = ref();
|
||||
const tableRef = ref();
|
||||
const modalVisible = ref(false);
|
||||
|
||||
const searchFormParams = ref({
|
||||
cabinetId: null,
|
||||
cellNo: null,
|
||||
cellType: null
|
||||
});
|
||||
|
||||
const pagination = ref({
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const dataList = ref([]);
|
||||
const multipleSelection = ref<number[]>([]);
|
||||
const editVisible = ref(false);
|
||||
const currentRow = ref<CabinetCellDTO>();
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
onMounted(() => {
|
||||
if (route.query.cabinetId) {
|
||||
searchFormParams.value.cabinetId = Number(route.query.cabinetId);
|
||||
getList();
|
||||
}
|
||||
});
|
||||
|
||||
const getList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const { data } = await getCabinetCellList({
|
||||
...searchFormParams.value,
|
||||
pageSize: pagination.value.pageSize,
|
||||
pageNum: pagination.value.currentPage
|
||||
});
|
||||
dataList.value = data.rows;
|
||||
pagination.value.total = data.total;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onSearch = () => {
|
||||
pagination.value.currentPage = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value.resetFields();
|
||||
onSearch();
|
||||
};
|
||||
|
||||
const onSizeChange = (val: number) => {
|
||||
pagination.value.pageSize = val;
|
||||
getList();
|
||||
};
|
||||
|
||||
const onCurrentChange = (val: number) => {
|
||||
pagination.value.currentPage = val;
|
||||
getList();
|
||||
};
|
||||
|
||||
const handleDelete = async (row: CabinetCellDTO) => {
|
||||
try {
|
||||
await deleteCabinetCell(row.cellId!.toString());
|
||||
ElMessage.success("删除成功");
|
||||
getList();
|
||||
} catch (error) {
|
||||
console.error("删除失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleBulkDelete = async () => {
|
||||
if (multipleSelection.value.length === 0) return;
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认删除选中的${multipleSelection.value.length}项单元格吗?`,
|
||||
"警告",
|
||||
{ confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }
|
||||
);
|
||||
|
||||
await deleteCabinetCell(multipleSelection.value.join(","));
|
||||
ElMessage.success("批量删除成功");
|
||||
multipleSelection.value = [];
|
||||
getList();
|
||||
} catch (error) {
|
||||
console.error("删除取消或失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectionChange = (rows: CabinetCellDTO[]) => {
|
||||
multipleSelection.value = rows.map(row => row.cellId!);
|
||||
};
|
||||
|
||||
const handleEdit = (row: CabinetCellDTO) => {
|
||||
currentRow.value = row;
|
||||
editVisible.value = true;
|
||||
};
|
||||
|
||||
const switchCellType = (cellType: number) => {
|
||||
switch (cellType) {
|
||||
case 1:
|
||||
return "小格";
|
||||
case 2:
|
||||
return "中格";
|
||||
case 3:
|
||||
return "大格";
|
||||
case 4:
|
||||
return "超大格";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
};
|
||||
|
||||
getList();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
||||
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
||||
<el-form-item label="柜体ID:" prop="cabinetId">
|
||||
<el-input v-model.number="searchFormParams.cabinetId" placeholder="请输入柜体ID" clearable class="!w-[200px]" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单元格号:" prop="cellNo">
|
||||
<el-input v-model.number="searchFormParams.cellNo" placeholder="请输入单元格号" clearable class="!w-[180px]" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单元格类型:" prop="cellType">
|
||||
<el-select v-model="searchFormParams.cellType" placeholder="请选择类型" clearable class="!w-[180px]">
|
||||
<el-option label="小格" :value="1" />
|
||||
<el-option label="中格" :value="2" />
|
||||
<el-option label="大格" :value="3" />
|
||||
<el-option label="超大格" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
||||
重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<PureTableBar title="柜体单元格管理" @refresh="getList">
|
||||
<template #buttons>
|
||||
<el-button type="primary" :icon="useRenderIcon(AddFill)" @click="modalVisible = true">
|
||||
新增单元格
|
||||
</el-button>
|
||||
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
|
||||
@click="handleBulkDelete">
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId"
|
||||
@selection-change="handleSelectionChange" border>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="柜体ID" prop="cabinetId" width="100" />
|
||||
<el-table-column label="单元格号" prop="cellNo" width="120" />
|
||||
<el-table-column label="针脚号" prop="pinNo" width="120" />
|
||||
<el-table-column label="单元格类型" prop="cellType">
|
||||
<template #default="{ row }">
|
||||
{{ switchCellType(row.cellType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="使用状态" prop="usageStatus" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ { 1: '空闲', 2: '已占用' }[row.usageStatus] || '未知' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可用状态" prop="availableStatus" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.availableStatus === 1 ? 'success' : 'danger'">
|
||||
{{ { 1: '正常', 2: '故障' }[row.availableStatus] || '未知' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-popconfirm :title="`确认删除【${row.cellNo}】号单元格?`" @confirm="handleDelete(row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
|
||||
@size-change="onSizeChange" @current-change="onCurrentChange" />
|
||||
</PureTableBar>
|
||||
<cell-form-modal v-model:visible="modalVisible" :initial-cabinet-id="searchFormParams.cabinetId"
|
||||
@refresh="getList" />
|
||||
<cell-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
|
@ -0,0 +1,207 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { PureTableBar } from "@/components/RePureTableBar";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { getSmartCabinetList, SmartCabinetDTO } from "@/api/cabinet/smart-cabinet";
|
||||
import EditPen from "@iconify-icons/ep/edit-pen";
|
||||
import Delete from "@iconify-icons/ep/delete";
|
||||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
||||
import Search from "@iconify-icons/ep/search";
|
||||
import Refresh from "@iconify-icons/ep/refresh";
|
||||
import SmartCabinetFormModal from "./smart-cabinet-form-modal.vue";
|
||||
import SmartCabinetEditModal from "./smart-cabinet-edit-modal.vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import router from "@/router";
|
||||
import { deleteSmartCabinet } from "@/api/cabinet/smart-cabinet";
|
||||
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||
|
||||
defineOptions({
|
||||
name: "SmartCabinet"
|
||||
});
|
||||
|
||||
const formRef = ref();
|
||||
const tableRef = ref();
|
||||
const modalVisible = ref(false);
|
||||
|
||||
const searchFormParams = ref({
|
||||
cabinetName: "",
|
||||
cabinetType: null
|
||||
});
|
||||
|
||||
const pagination = ref({
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const dataList = ref([]);
|
||||
const multipleSelection = ref<number[]>([]);
|
||||
const editVisible = ref(false);
|
||||
const currentRow = ref<SmartCabinetDTO>();
|
||||
|
||||
const getList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const { data } = await getSmartCabinetList({
|
||||
...searchFormParams.value,
|
||||
pageSize: pagination.value.pageSize,
|
||||
pageNum: pagination.value.currentPage
|
||||
});
|
||||
dataList.value = data.rows;
|
||||
pagination.value.total = data.total;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onSearch = () => {
|
||||
pagination.value.currentPage = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value.resetFields();
|
||||
onSearch();
|
||||
};
|
||||
|
||||
const onSizeChange = (val: number) => {
|
||||
pagination.value.pageSize = val;
|
||||
getList();
|
||||
};
|
||||
|
||||
const onCurrentChange = (val: number) => {
|
||||
pagination.value.currentPage = val;
|
||||
getList();
|
||||
};
|
||||
|
||||
const handleDelete = async (row: SmartCabinetDTO) => {
|
||||
try {
|
||||
await deleteSmartCabinet(row.cabinetId!.toString());
|
||||
ElMessage.success("删除成功");
|
||||
getList();
|
||||
} catch (error) {
|
||||
console.error("删除失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleBulkDelete = async () => {
|
||||
if (multipleSelection.value.length === 0) return;
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认删除选中的${multipleSelection.value.length}项设备吗?`,
|
||||
"警告",
|
||||
{ confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }
|
||||
);
|
||||
|
||||
await deleteSmartCabinet(multipleSelection.value.join(","));
|
||||
ElMessage.success("批量删除成功");
|
||||
multipleSelection.value = [];
|
||||
getList();
|
||||
} catch (error) {
|
||||
console.error("删除取消或失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectionChange = (rows: SmartCabinetDTO[]) => {
|
||||
multipleSelection.value = rows.map(row => row.cabinetId!);
|
||||
};
|
||||
|
||||
const goCellManagement = (row: SmartCabinetDTO) => {
|
||||
// 保存信息到标签页
|
||||
useMultiTagsStoreHook().handleTags("push", {
|
||||
path: `/cabinet/cabinet-cell/index`,
|
||||
name: "CabinetCell",
|
||||
query: { cabinetId: row.cabinetId },
|
||||
meta: {
|
||||
title: `柜机${row.cabinetId} - 格口信息`,
|
||||
dynamicLevel: 3
|
||||
}
|
||||
});
|
||||
router.push({
|
||||
path: '/cabinet/cabinet-cell/index',
|
||||
query: { cabinetId: row.cabinetId }
|
||||
});
|
||||
};
|
||||
|
||||
const handleEdit = (row: SmartCabinetDTO) => {
|
||||
currentRow.value = row;
|
||||
editVisible.value = true;
|
||||
};
|
||||
|
||||
getList();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
||||
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
||||
<el-form-item label="柜体名称:" prop="cabinetName">
|
||||
<el-input v-model="searchFormParams.cabinetName" placeholder="请输入柜体名称" clearable class="!w-[200px]" />
|
||||
</el-form-item>
|
||||
<el-form-item label="柜体类型:" prop="cabinetType">
|
||||
<el-select v-model="searchFormParams.cabinetType" placeholder="请选择类型" clearable class="!w-[180px]">
|
||||
<el-option label="主柜" :value="0" />
|
||||
<el-option label="副柜" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
||||
重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<PureTableBar title="智能柜管理" @refresh="getList">
|
||||
<template #buttons>
|
||||
<el-button type="primary" :icon="useRenderIcon(AddFill)" @click="modalVisible = true">
|
||||
新增设备
|
||||
</el-button>
|
||||
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
|
||||
@click="handleBulkDelete">
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="id"
|
||||
@selection-change="handleSelectionChange" border>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="柜体名称" prop="cabinetName" />
|
||||
<el-table-column label="柜体类型" prop="cabinetType" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ row.cabinetType === 0 ? '主柜' : '副柜' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="模板编号" prop="templateNo" width="180" />
|
||||
<el-table-column label="锁控编号" prop="lockControlNo" width="120" />
|
||||
<el-table-column label="位置" prop="location" width="120" />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="warning" link :icon="useRenderIcon('fluent:cell-phone-arrow-right-20-regular')"
|
||||
@click="goCellManagement(row)">
|
||||
格口
|
||||
</el-button>
|
||||
<el-popconfirm :title="`确认删除【${row.cabinetName}】?`" @confirm="handleDelete(row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
|
||||
@size-change="onSizeChange" @current-change="onCurrentChange" />
|
||||
</PureTableBar>
|
||||
<smart-cabinet-form-modal v-model:visible="modalVisible" @refresh="getList" />
|
||||
<smart-cabinet-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
|
||||
</div>
|
||||
</template>
|
|
@ -0,0 +1,117 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { updateSmartCabinet } from "@/api/cabinet/smart-cabinet";
|
||||
import Confirm from "@iconify-icons/ep/check";
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
export interface FormDTO {
|
||||
cabinetId?: number;
|
||||
cabinetName: string;
|
||||
cabinetType: number;
|
||||
templateNo: string;
|
||||
lockControlNo: number;
|
||||
location: number;
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
row: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:visible", "refresh"]);
|
||||
|
||||
const formRef = ref();
|
||||
const formData = reactive<FormDTO>({
|
||||
cabinetName: "",
|
||||
cabinetType: 1,
|
||||
templateNo: "",
|
||||
lockControlNo: 0,
|
||||
location: 0
|
||||
});
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
cabinetName: [{ required: true, message: "柜体名称必填", trigger: "blur" }],
|
||||
cabinetType: [{ required: true, message: "请选择柜体类型", trigger: "change" }],
|
||||
templateNo: [{ required: true, message: "请选择模板编号", trigger: "change" }],
|
||||
lockControlNo: [
|
||||
{ required: true, message: "锁控板序号", trigger: "blur" }
|
||||
],
|
||||
location: [
|
||||
{ required: true, message: "位置信息必填", trigger: "blur" },
|
||||
{ type: 'number', min: 0, message: '位置编号不能为负数' }
|
||||
]
|
||||
});
|
||||
|
||||
const handleConfirm = async () => {
|
||||
try {
|
||||
await formRef.value.validate();
|
||||
await updateSmartCabinet(formData.cabinetId!, formData);
|
||||
ElMessage.success("修改成功");
|
||||
emit("refresh");
|
||||
closeDialog();
|
||||
} catch (error) {
|
||||
console.error("表单提交失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
formRef.value.resetFields();
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
watch(() => props.row, (val) => {
|
||||
if (val) {
|
||||
Object.assign(formData, val);
|
||||
}
|
||||
}, { immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog title="编辑智能柜" :model-value="visible" width="600px" @close="closeDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
<el-form-item label="柜体名称" prop="cabinetName">
|
||||
<el-input v-model="formData.cabinetName" placeholder="请输入柜体名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="柜体类型" prop="cabinetType">
|
||||
<el-select v-model="formData.cabinetType" placeholder="请选择类型">
|
||||
<el-option label="主柜" :value="0" />
|
||||
<el-option label="副柜" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="模板编号" prop="templateNo">
|
||||
<el-select v-model="formData.templateNo" placeholder="请选择模板编号">
|
||||
<el-option label="模板一" :value="1" />
|
||||
<el-option label="模板二" :value="2" />
|
||||
<el-option label="模板三" :value="3" />
|
||||
<el-option label="模板四" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="锁控板序号" prop="lockControlNo">
|
||||
<el-input v-model="formData.lockControlNo" placeholder="请输入锁控板序号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="位置" prop="location">
|
||||
<el-input-number v-model="formData.location" :min="0" controls-position="right" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
<el-button type="primary" :icon="useRenderIcon(Confirm)" @click="handleConfirm">
|
||||
确认
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
|
@ -0,0 +1,105 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { addSmartCabinet } from "@/api/cabinet/smart-cabinet";
|
||||
import Confirm from "@iconify-icons/ep/check";
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
export interface FormDTO {
|
||||
cabinetName: string;
|
||||
cabinetType: number;
|
||||
templateNo: string;
|
||||
lockControlNo: number;
|
||||
location: number;
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:visible", "refresh"]);
|
||||
|
||||
const formRef = ref();
|
||||
const formData = reactive<FormDTO>({
|
||||
cabinetName: "",
|
||||
cabinetType: 1,
|
||||
templateNo: "",
|
||||
lockControlNo: 0,
|
||||
location: 0
|
||||
});
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
cabinetName: [{ required: true, message: "柜体名称必填", trigger: "blur" }],
|
||||
cabinetType: [{ required: true, message: "请选择柜体类型", trigger: "change" }],
|
||||
templateNo: [{ required: true, message: "请选择模板编号", trigger: "change" }],
|
||||
lockControlNo: [
|
||||
{ required: true, message: "锁控板序号", trigger: "blur" }
|
||||
],
|
||||
location: [
|
||||
{ required: true, message: "位置信息必填", trigger: "blur" },
|
||||
{ type: 'number', min: 0, message: '位置编号不能为负数', trigger: 'blur' }
|
||||
]
|
||||
});
|
||||
|
||||
const handleConfirm = async () => {
|
||||
try {
|
||||
await formRef.value.validate();
|
||||
await addSmartCabinet(formData);
|
||||
ElMessage.success("新增成功");
|
||||
emit("refresh");
|
||||
closeDialog();
|
||||
} catch (error) {
|
||||
console.error("表单提交失败", error);
|
||||
}
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
formRef.value.resetFields();
|
||||
emit("update:visible", false);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog title="新增智能柜" :model-value="visible" width="600px" @close="closeDialog">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
<el-form-item label="柜体名称" prop="cabinetName">
|
||||
<el-input v-model="formData.cabinetName" placeholder="请输入柜体名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="柜体类型" prop="cabinetType">
|
||||
<el-select v-model="formData.cabinetType" placeholder="请选择类型">
|
||||
<el-option label="主柜" :value="0" />
|
||||
<el-option label="副柜" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="模板编号" prop="templateNo">
|
||||
<el-select v-model="formData.templateNo" placeholder="请选择模板编号">
|
||||
<el-option label="模板一" :value="1" />
|
||||
<el-option label="模板二" :value="2" />
|
||||
<el-option label="模板三" :value="3" />
|
||||
<el-option label="模板四" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="锁控板序号" prop="lockControlNo">
|
||||
<el-input v-model="formData.lockControlNo" placeholder="请输入锁控板序号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="位置" prop="location">
|
||||
<el-input-number v-model="formData.location" :min="0" controls-position="right" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
<el-button type="primary" :icon="useRenderIcon(Confirm)" @click="handleConfirm">
|
||||
确认
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
|
@ -0,0 +1,89 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { getAllCabinetsWithCells, AllCabinetDataDTO } from '@/api/cabinet/smart-cabinet'
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
import type { GoodsDTO } from '@/api/shop/goods'
|
||||
import { configureGoodsCells } from '@/api/cabinet/cabinet-cell';
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
rowData: GoodsDTO
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['update:visible', 'refresh'])
|
||||
|
||||
const loading = ref(false)
|
||||
const treeData = ref<Array<any>>([])
|
||||
const selectedCell = ref<number | null>(null)
|
||||
|
||||
// 转换柜机格口数据结构
|
||||
const transformCabinetData = (data: AllCabinetDataDTO) => {
|
||||
return data.smartCabinetList.map(cabinet => ({
|
||||
id: cabinet.cabinetId,
|
||||
label: cabinet.cabinetName,
|
||||
disabled: true,
|
||||
children: data.cells
|
||||
.filter(cell => cell.cabinetId === cabinet.cabinetId)
|
||||
.map(cell => ({
|
||||
id: cell.cellId,
|
||||
label: `格口${cell.cellNo}`,
|
||||
disabled: cell.availableStatus !== 1
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
// 获取柜机格口数据
|
||||
const fetchCabinetData = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const { data } = await getAllCabinetsWithCells()
|
||||
treeData.value = transformCabinetData(data)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
fetchCabinetData()
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await configureGoodsCells(selectedCell.value, props.rowData.goodsId)
|
||||
ElMessage.success('配置成功')
|
||||
emit('update:visible', false)
|
||||
emit('refresh')
|
||||
} catch (error) {
|
||||
console.error('配置失败', error)
|
||||
}
|
||||
}
|
||||
const handleNodeClick = (data: { id: number; disabled: boolean }) => {
|
||||
if (!data.disabled) {
|
||||
selectedCell.value = data.id
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (newVal) {
|
||||
selectedCell.value = null
|
||||
fetchCabinetData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog :model-value="visible" title="柜机格口配置" width="600px" @close="emit('update:visible', false)">
|
||||
<el-scrollbar height="400px">
|
||||
<el-tree :data="treeData" highlight-current node-key="id" :props="{
|
||||
label: 'label',
|
||||
children: 'children'
|
||||
}" v-model:current-node-key="selectedCell" :default-expand-all="true" @node-click="handleNodeClick"
|
||||
class="p-4" />
|
||||
</el-scrollbar>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="emit('update:visible', false)">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit" :disabled="!selectedCell">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
|
@ -8,8 +8,10 @@ import Delete from "@iconify-icons/ep/delete";
|
|||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
||||
import Search from "@iconify-icons/ep/search";
|
||||
import Refresh from "@iconify-icons/ep/refresh";
|
||||
import Setting from "@iconify-icons/ep/setting";
|
||||
import GoodsFormModal from "./goods-form-modal.vue";
|
||||
import GoodsEditModal from "./goods-edit-modal.vue";
|
||||
import GoodsCabinetConfigModal from "./goods-cabinet-config-modal.vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { deleteGoodsApi } from "@/api/shop/goods";
|
||||
|
||||
|
@ -39,6 +41,7 @@ const loading = ref(false);
|
|||
const dataList = ref([]);
|
||||
const multipleSelection = ref<number[]>([]);
|
||||
const editVisible = ref(false);
|
||||
const configVisible = ref(false);
|
||||
const currentRow = ref<GoodsDTO>();
|
||||
|
||||
const getList = async () => {
|
||||
|
@ -178,14 +181,23 @@ const handleEdit = (row: GoodsDTO) => {
|
|||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="柜口" prop="cellNo" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ !row.cellNo ? '未配置' : row.cabinetName + ' 格口' + row.cellNo }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)">
|
||||
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)" class="right-btn">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="warning" link :icon="useRenderIcon(Setting)" class="right-btn"
|
||||
@click="currentRow = row; configVisible = true">
|
||||
配置格口
|
||||
</el-button>
|
||||
<el-popconfirm :title="`确认删除【${row.goodsName}】?`" @confirm="handleDelete(row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
||||
<el-button type="danger" link :icon="useRenderIcon(Delete)" class="right-btn">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
@ -200,6 +212,7 @@ const handleEdit = (row: GoodsDTO) => {
|
|||
<!-- 新增商品弹窗 -->
|
||||
<goods-form-modal v-model:visible="modalVisible" @refresh="getList" />
|
||||
<goods-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
|
||||
<goods-cabinet-config-modal v-model:visible="configVisible" :row-data="currentRow" @refresh="getList" />
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
|
@ -212,4 +225,8 @@ const handleEdit = (row: GoodsDTO) => {
|
|||
opacity: 1;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.right-btn {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue