优化仓库和库区管理功能,将状态字段类型从number改为string,移除编辑表单中的状态选择项,在列表页面将状态标签改为开关组件支持直接切换状态,新增updateWarehouseStatus和updateZoneStatus接口用于批量更新状态,同时在操作列新增日志按钮并集成操作日志对话框组件,在列表中添加修改时间列,优化查询参数将name改为keyword统一搜索字段命名
This commit is contained in:
@@ -45,14 +45,6 @@
|
||||
<el-input-number v-model="ruleForm.capacity" :min="0" placeholder="请输入容量" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="ruleForm.status">
|
||||
<el-radio :value="1">启用</el-radio>
|
||||
<el-radio :value="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
@@ -107,7 +99,6 @@ const ruleForm = reactive({
|
||||
zoneType: '',
|
||||
warehouseId: '',
|
||||
capacity: 0,
|
||||
status: 1,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
@@ -125,7 +116,6 @@ const resetForm = () => {
|
||||
ruleForm.zoneType = '';
|
||||
ruleForm.warehouseId = '';
|
||||
ruleForm.capacity = 0;
|
||||
ruleForm.status = 1;
|
||||
ruleForm.remark = '';
|
||||
};
|
||||
|
||||
@@ -144,7 +134,6 @@ const openDialog = async (row?: any) => {
|
||||
ruleForm.zoneType = data.zoneType || '';
|
||||
ruleForm.warehouseId = data.warehouseId || '';
|
||||
ruleForm.capacity = data.capacity || 0;
|
||||
ruleForm.status = (data.status === '1' || data.status === 1 || data.status === true) ? 1 : 0;
|
||||
ruleForm.remark = data.remark || '';
|
||||
} catch (error) {
|
||||
console.error('获取库区详情失败:', error);
|
||||
@@ -176,7 +165,6 @@ const onSubmit = async () => {
|
||||
zoneType: ruleForm.zoneType,
|
||||
warehouseId: ruleForm.warehouseId,
|
||||
capacity: ruleForm.capacity,
|
||||
status: ruleForm.status,
|
||||
remark: ruleForm.remark,
|
||||
};
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select size="default" v-model="tableData.param.status" placeholder="请选择状态" clearable style="width: 120px">
|
||||
<el-option label="启用" value="1" />
|
||||
<el-option label="禁用" value="0" />
|
||||
<el-option label="启用" value="enabled" />
|
||||
<el-option label="禁用" value="disabled" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -41,17 +41,23 @@
|
||||
<el-table-column prop="zoneType" label="库区类型" width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="warehouseName" label="所属仓库" width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="capacity" label="容量" width="100" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="100" align="center">
|
||||
<el-table-column prop="status" label="状态" width="80" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.status == '1' || scope.row.status === 1 ? 'success' : 'danger'">
|
||||
{{ scope.row.status == '1' || scope.row.status === 1 ? '启用' : '禁用' }}
|
||||
</el-tag>
|
||||
<el-switch
|
||||
v-model="scope.row.statusEnabled"
|
||||
inline-prompt
|
||||
active-text="启"
|
||||
inactive-text="停"
|
||||
@change="onStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" fixed="right" align="center">
|
||||
<el-table-column prop="updatedAt" label="修改时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="180" fixed="right" align="center">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="onEdit(scope.row)">修改</el-button>
|
||||
<el-button size="small" text type="info" @click="onViewLog(scope.row)">日志</el-button>
|
||||
<el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -71,6 +77,7 @@
|
||||
</el-card>
|
||||
</div>
|
||||
<EditZone ref="editZoneRef" :warehouseOptions="warehouseOptions" @getZoneList="getZoneList" />
|
||||
<OperationLogDialog ref="operationLogRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -83,9 +90,10 @@ export default {
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { listZones, deleteZone } from '/@/api/assets/zone';
|
||||
import { listZones, deleteZone, updateZoneStatus } from '/@/api/assets/zone';
|
||||
import { listWarehouses } from '/@/api/assets/warehouse';
|
||||
import EditZone from './component/editZone.vue';
|
||||
import OperationLogDialog from '/@/views/assets/component/operationLogDialog.vue';
|
||||
|
||||
// 表格数据
|
||||
const tableData = reactive({
|
||||
@@ -106,6 +114,8 @@ const warehouseOptions = ref<any[]>([]);
|
||||
|
||||
// 编辑弹窗ref
|
||||
const editZoneRef = ref();
|
||||
// 日志弹窗ref
|
||||
const operationLogRef = ref();
|
||||
|
||||
// 获取仓库列表
|
||||
const getWarehouseOptions = async () => {
|
||||
@@ -122,7 +132,14 @@ const getZoneList = async () => {
|
||||
tableData.loading = true;
|
||||
try {
|
||||
const res: any = await listZones(tableData.param);
|
||||
tableData.data = res.data?.list || [];
|
||||
const list = res.data?.list || [];
|
||||
// 后端未返回 warehouseName 时,用仓库选项回填展示
|
||||
const warehouseMap = new Map(warehouseOptions.value.map((w: any) => [w.id, w.warehouseName]));
|
||||
tableData.data = list.map((item: any) => ({
|
||||
...item,
|
||||
warehouseName: item.warehouseName || warehouseMap.get(item.warehouseId) || '',
|
||||
statusEnabled: item.status === 'enabled',
|
||||
}));
|
||||
tableData.total = res.data?.total || 0;
|
||||
} catch (error) {
|
||||
console.error('获取库区列表失败:', error);
|
||||
@@ -150,6 +167,25 @@ const onEdit = (row: any) => {
|
||||
editZoneRef.value.openDialog(row);
|
||||
};
|
||||
|
||||
// 状态切换
|
||||
const onStatusChange = async (row: any) => {
|
||||
const newStatus = row.statusEnabled ? 'enabled' : 'disabled';
|
||||
const statusText = row.statusEnabled ? '启用' : '禁用';
|
||||
try {
|
||||
await updateZoneStatus({ id: [row.id], status: newStatus });
|
||||
ElMessage.success(`${statusText}成功`);
|
||||
} catch (error) {
|
||||
console.error('状态更新失败:', error);
|
||||
// 失败时恢复原状态
|
||||
row.statusEnabled = !row.statusEnabled;
|
||||
}
|
||||
};
|
||||
|
||||
// 查看日志
|
||||
const onViewLog = (row: any) => {
|
||||
operationLogRef.value?.openDialog(row.id);
|
||||
};
|
||||
|
||||
// 删除库区
|
||||
const onRowDel = (row: any) => {
|
||||
ElMessageBox.confirm(`确定要删除库区【${row.zoneName}】吗?`, '提示', {
|
||||
|
||||
Reference in New Issue
Block a user