优化仓库、库区和库位管理功能的状态处理逻辑,统一状态值命名规范将enabled/disabled改为enable/disable,修改updateWarehouseStatus、updateZoneStatus和updateLocationStatus接口参数类型将id从数组改为字符串,在库位管理中将状态开关改为标签展示并新增状态选择功能支持空闲/占用/锁定/维护四种状态,在编辑表单中添加状态选择项,同时在开发环境配置文件中添加备用开发地址注释
This commit is contained in:
@@ -5,13 +5,13 @@ ENV = 'development'
|
|||||||
# 后端服务地址配置
|
# 后端服务地址配置
|
||||||
# 切换环境时,修改下面两个地址的 IP 即可
|
# 切换环境时,修改下面两个地址的 IP 即可
|
||||||
# 当前环境: 192.168.3.11(本地开发地址)
|
# 当前环境: 192.168.3.11(本地开发地址)
|
||||||
|
# 当前环境: 192.168.3.94(本地开发地址)王楠
|
||||||
# 备用环境: 192.168.3.200(服务器地址)
|
# 备用环境: 192.168.3.200(服务器地址)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
# 主服务地址(端口8808)
|
# 主服务地址(端口8808)
|
||||||
# 用途: 系统管理、用户认证、权限控制、模块开通等原有功能
|
# 用途: 系统管理、用户认证、权限控制、模块开通等原有功能
|
||||||
VITE_API_URL = 'http://192.168.3.200:8808/'
|
VITE_API_URL = 'http://192.168.3.200:8808/'
|
||||||
|
|
||||||
# 新功能服务地址(端口8000)
|
# 新功能服务地址(端口8000)
|
||||||
# 用途: 资产管理、分类、SKU、订单等新业务模块
|
# 用途: 资产管理、分类、SKU、订单等新业务模块
|
||||||
VITE_NEW_API_URL = 'http://192.168.3.200:8000/'
|
VITE_NEW_API_URL = 'http://192.168.3.200:8000/'
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function deleteLocation(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新库位状态
|
// 更新库位状态
|
||||||
export function updateLocationStatus(data: { id: string[]; status: string }) {
|
export function updateLocationStatus(data: { id: string; status: string }) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/assets/location/updateLocationStatus',
|
url: '/assets/location/updateLocationStatus',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export function deleteWarehouse(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新仓库状态
|
// 更新仓库状态
|
||||||
export function updateWarehouseStatus(data: { id: string[]; status: string }) {
|
export function updateWarehouseStatus(data: { id: string; status: string }) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/assets/warehouse/updateWarehouseStatus',
|
url: '/assets/warehouse/updateWarehouseStatus',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export function deleteZone(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新库区状态
|
// 更新库区状态
|
||||||
export function updateZoneStatus(data: { id: string[]; status: string }) {
|
export function updateZoneStatus(data: { id: string; status: string }) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/assets/zone/updateZoneStatus',
|
url: '/assets/zone/updateZoneStatus',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|||||||
@@ -46,6 +46,18 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="ruleForm.status" placeholder="请选择状态" clearable style="width: 100%">
|
||||||
|
<el-option label="空闲" value="idle" />
|
||||||
|
<el-option label="占用" value="occupied" />
|
||||||
|
<el-option label="锁定" value="locked" />
|
||||||
|
<el-option label="维护" value="maintenance" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="最大容量" prop="maxCapacity">
|
<el-form-item label="最大容量" prop="maxCapacity">
|
||||||
<el-input-number v-model="ruleForm.maxCapacity" :min="0" placeholder="请输入最大容量" style="width: 100%" />
|
<el-input-number v-model="ruleForm.maxCapacity" :min="0" placeholder="请输入最大容量" style="width: 100%" />
|
||||||
@@ -106,6 +118,7 @@ const ruleForm = reactive({
|
|||||||
locationType: '',
|
locationType: '',
|
||||||
warehouseId: '',
|
warehouseId: '',
|
||||||
zoneId: '',
|
zoneId: '',
|
||||||
|
status: 'idle',
|
||||||
maxCapacity: 0,
|
maxCapacity: 0,
|
||||||
remark: '',
|
remark: '',
|
||||||
});
|
});
|
||||||
@@ -137,6 +150,7 @@ const resetForm = () => {
|
|||||||
ruleForm.locationType = '';
|
ruleForm.locationType = '';
|
||||||
ruleForm.warehouseId = '';
|
ruleForm.warehouseId = '';
|
||||||
ruleForm.zoneId = '';
|
ruleForm.zoneId = '';
|
||||||
|
ruleForm.status = 'idle';
|
||||||
ruleForm.maxCapacity = 0;
|
ruleForm.maxCapacity = 0;
|
||||||
ruleForm.remark = '';
|
ruleForm.remark = '';
|
||||||
};
|
};
|
||||||
@@ -156,6 +170,7 @@ const openDialog = async (row?: any) => {
|
|||||||
ruleForm.locationType = data.locationType || '';
|
ruleForm.locationType = data.locationType || '';
|
||||||
ruleForm.warehouseId = data.warehouseId || '';
|
ruleForm.warehouseId = data.warehouseId || '';
|
||||||
ruleForm.zoneId = data.zoneId || '';
|
ruleForm.zoneId = data.zoneId || '';
|
||||||
|
ruleForm.status = data.status || 'idle';
|
||||||
ruleForm.maxCapacity = data.maxCapacity || 0;
|
ruleForm.maxCapacity = data.maxCapacity || 0;
|
||||||
ruleForm.remark = data.remark || '';
|
ruleForm.remark = data.remark || '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -188,6 +203,7 @@ const onSubmit = async () => {
|
|||||||
locationType: ruleForm.locationType,
|
locationType: ruleForm.locationType,
|
||||||
warehouseId: ruleForm.warehouseId,
|
warehouseId: ruleForm.warehouseId,
|
||||||
zoneId: ruleForm.zoneId,
|
zoneId: ruleForm.zoneId,
|
||||||
|
status: ruleForm.status,
|
||||||
maxCapacity: ruleForm.maxCapacity,
|
maxCapacity: ruleForm.maxCapacity,
|
||||||
remark: ruleForm.remark,
|
remark: ruleForm.remark,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
||||||
<el-option label="启用" value="enabled" />
|
<el-option label="空闲" value="idle" />
|
||||||
<el-option label="禁用" value="disabled" />
|
<el-option label="占用" value="occupied" />
|
||||||
|
<el-option label="锁定" value="locked" />
|
||||||
|
<el-option label="维护" value="maintenance" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -47,15 +49,9 @@
|
|||||||
<el-table-column prop="warehouseName" label="所属仓库" width="150" show-overflow-tooltip />
|
<el-table-column prop="warehouseName" label="所属仓库" width="150" show-overflow-tooltip />
|
||||||
<el-table-column prop="zoneName" label="所属库区" width="150" show-overflow-tooltip />
|
<el-table-column prop="zoneName" label="所属库区" width="150" show-overflow-tooltip />
|
||||||
<el-table-column prop="maxCapacity" label="最大容量" width="100" align="center" />
|
<el-table-column prop="maxCapacity" label="最大容量" width="100" align="center" />
|
||||||
<el-table-column prop="status" label="状态" width="80" align="center">
|
<el-table-column prop="status" label="状态" width="100" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-switch
|
<el-tag :type="getStatusTagType(scope.row.status)">{{ getStatusText(scope.row.status) }}</el-tag>
|
||||||
v-model="scope.row.statusEnabled"
|
|
||||||
inline-prompt
|
|
||||||
active-text="启"
|
|
||||||
inactive-text="停"
|
|
||||||
@change="onStatusChange(scope.row)"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="createdAt" label="创建时间" width="170" show-overflow-tooltip />
|
<el-table-column prop="createdAt" label="创建时间" width="170" show-overflow-tooltip />
|
||||||
@@ -96,7 +92,7 @@ export default {
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, computed, onMounted } from 'vue';
|
import { ref, reactive, computed, onMounted } from 'vue';
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
import { listLocations, deleteLocation, updateLocationStatus } from '/@/api/assets/location';
|
import { listLocations, deleteLocation } from '/@/api/assets/location';
|
||||||
import { listWarehouses } from '/@/api/assets/warehouse';
|
import { listWarehouses } from '/@/api/assets/warehouse';
|
||||||
import { listZones } from '/@/api/assets/zone';
|
import { listZones } from '/@/api/assets/zone';
|
||||||
import EditLocation from './component/editLocation.vue';
|
import EditLocation from './component/editLocation.vue';
|
||||||
@@ -173,7 +169,6 @@ const getLocationList = async () => {
|
|||||||
...item,
|
...item,
|
||||||
warehouseName: item.warehouseName || warehouseMap.get(item.warehouseId) || '',
|
warehouseName: item.warehouseName || warehouseMap.get(item.warehouseId) || '',
|
||||||
zoneName: item.zoneName || zoneMap.get(item.zoneId) || '',
|
zoneName: item.zoneName || zoneMap.get(item.zoneId) || '',
|
||||||
statusEnabled: item.status === 'enabled',
|
|
||||||
}));
|
}));
|
||||||
tableData.total = res.data?.total || 0;
|
tableData.total = res.data?.total || 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -203,17 +198,35 @@ const onEdit = (row: any) => {
|
|||||||
editLocationRef.value.openDialog(row);
|
editLocationRef.value.openDialog(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 状态切换
|
// 获取状态标签类型
|
||||||
const onStatusChange = async (row: any) => {
|
const getStatusTagType = (status: string) => {
|
||||||
const newStatus = row.statusEnabled ? 'enabled' : 'disabled';
|
switch (status) {
|
||||||
const statusText = row.statusEnabled ? '启用' : '禁用';
|
case 'idle':
|
||||||
try {
|
return 'success';
|
||||||
await updateLocationStatus({ id: [row.id], status: newStatus });
|
case 'occupied':
|
||||||
ElMessage.success(`${statusText}成功`);
|
return 'warning';
|
||||||
} catch (error) {
|
case 'locked':
|
||||||
console.error('状态更新失败:', error);
|
return 'danger';
|
||||||
// 失败时恢复原状态
|
case 'maintenance':
|
||||||
row.statusEnabled = !row.statusEnabled;
|
return 'info';
|
||||||
|
default:
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取状态文本
|
||||||
|
const getStatusText = (status: string) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'idle':
|
||||||
|
return '空闲';
|
||||||
|
case 'occupied':
|
||||||
|
return '占用';
|
||||||
|
case 'locked':
|
||||||
|
return '锁定';
|
||||||
|
case 'maintenance':
|
||||||
|
return '维护';
|
||||||
|
default:
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
||||||
<el-option label="启用" value="enabled" />
|
<el-option label="启用" value="enable" />
|
||||||
<el-option label="禁用" value="disabled" />
|
<el-option label="禁用" value="disable" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -116,7 +116,7 @@ const getWarehouseList = async () => {
|
|||||||
// 添加 statusEnabled 字段用于开关组件
|
// 添加 statusEnabled 字段用于开关组件
|
||||||
tableData.data = list.map((item: any) => ({
|
tableData.data = list.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
statusEnabled: item.status === 'enabled' || item.status === '1' || item.status === 1,
|
statusEnabled: item.status === 'enable' || item.status === '1' || item.status === 1,
|
||||||
}));
|
}));
|
||||||
tableData.total = res.data?.total || 0;
|
tableData.total = res.data?.total || 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -146,10 +146,10 @@ const onEdit = (row: any) => {
|
|||||||
|
|
||||||
// 状态切换
|
// 状态切换
|
||||||
const onStatusChange = async (row: any) => {
|
const onStatusChange = async (row: any) => {
|
||||||
const newStatus = row.statusEnabled ? 'enabled' : 'disabled';
|
const newStatus = row.statusEnabled ? 'enable' : 'disable';
|
||||||
const statusText = row.statusEnabled ? '启用' : '禁用';
|
const statusText = row.statusEnabled ? '启用' : '禁用';
|
||||||
try {
|
try {
|
||||||
await updateWarehouseStatus({ id: [row.id], status: newStatus });
|
await updateWarehouseStatus({ id: row.id, status: newStatus });
|
||||||
ElMessage.success(`${statusText}成功`);
|
ElMessage.success(`${statusText}成功`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('状态更新失败:', error);
|
console.error('状态更新失败:', error);
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
||||||
<el-option label="启用" value="enabled" />
|
<el-option label="启用" value="enable" />
|
||||||
<el-option label="禁用" value="disabled" />
|
<el-option label="禁用" value="disable" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -138,7 +138,7 @@ const getZoneList = async () => {
|
|||||||
tableData.data = list.map((item: any) => ({
|
tableData.data = list.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
warehouseName: item.warehouseName || warehouseMap.get(item.warehouseId) || '',
|
warehouseName: item.warehouseName || warehouseMap.get(item.warehouseId) || '',
|
||||||
statusEnabled: item.status === 'enabled',
|
statusEnabled: item.status === 'enable',
|
||||||
}));
|
}));
|
||||||
tableData.total = res.data?.total || 0;
|
tableData.total = res.data?.total || 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -169,10 +169,10 @@ const onEdit = (row: any) => {
|
|||||||
|
|
||||||
// 状态切换
|
// 状态切换
|
||||||
const onStatusChange = async (row: any) => {
|
const onStatusChange = async (row: any) => {
|
||||||
const newStatus = row.statusEnabled ? 'enabled' : 'disabled';
|
const newStatus = row.statusEnabled ? 'enable' : 'disable';
|
||||||
const statusText = row.statusEnabled ? '启用' : '禁用';
|
const statusText = row.statusEnabled ? '启用' : '禁用';
|
||||||
try {
|
try {
|
||||||
await updateZoneStatus({ id: [row.id], status: newStatus });
|
await updateZoneStatus({ id: row.id, status: newStatus });
|
||||||
ElMessage.success(`${statusText}成功`);
|
ElMessage.success(`${statusText}成功`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('状态更新失败:', error);
|
console.error('状态更新失败:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user