新增「车间班次」功能(前缫车间排班配置)
后端 - 新增实体 ChejianBanci(表 ChejianBancis:车间 / 班次 / 日工作小时数) - 新增 ChejianBanciService 与 ChejianBanciController(api/prod/chejianbanci) 分页列表、编辑回显、新增、修改、删除、前缫车间下拉;含必填校验与同车间同班次重复校验 - 菜单种子:基础数据 → 车间班次(Timer 图标,权限 base:chejianbanci:list) - 修正历史数据:名称以「前缫」开头的部门职责类型改为「前缫」(25)。 迁移时 duty_type 被统一写成「其他」,导致按职责类型筛选车间取不到数据 前端 - 新增 web/src/views/base/chejianbanci/index.vue(列表 / 搜索 / 分页 / 新增 / 编辑 / 删除) - 注册组件映射 base/chejianbanci/index
This commit is contained in:
@@ -54,6 +54,7 @@ export const componentMap = {
|
||||
'base/jizuchetai/index': () => import('../views/base/jizuchetai/index.vue'),
|
||||
'base/worktype/index': () => import('../views/base/worktype/index.vue'),
|
||||
'base/zhangqi/index': () => import('../views/base/zhangqi/index.vue'),
|
||||
'base/chejianbanci/index': () => import('../views/base/chejianbanci/index.vue'),
|
||||
'base/registry/index': () => import('../views/base/registry/index.vue'),
|
||||
'base/yuanliaozhuangkou/index': () => import('../views/base/yuanliaozhuangkou/index.vue'),
|
||||
'base/wuzimulu/index': () => import('../views/base/wuzimulu/index.vue'),
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import request from '../../../utils/request';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
|
||||
const list = ref([]);
|
||||
const total = ref(0);
|
||||
const loading = ref(false);
|
||||
const query = reactive({ pageIndex: 1, pageSize: 20, like: '' });
|
||||
|
||||
// 车间下拉:只取职责类型为「前缫」的部门(后端接口)
|
||||
const depOptions = ref([]);
|
||||
// 班次枚举(与后端 Prod_Banci_Enum 一致)
|
||||
const banciOptions = [
|
||||
{ value: 1, label: '甲' },
|
||||
{ value: 2, label: '乙' }
|
||||
];
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const dialogTitle = ref('新增车间班次');
|
||||
const isEdit = ref(false);
|
||||
const editId = ref(null);
|
||||
const form = reactive({ depId: 0, banci: 1, kaoqinDayhours: 0 });
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await request.get('/prod/chejianbanci', { params: query });
|
||||
list.value = res.data.items || [];
|
||||
total.value = res.data.total || 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDepOptions() {
|
||||
try {
|
||||
const res = await request.get('/prod/chejianbanci/qianxian-deps');
|
||||
depOptions.value = res.data || [];
|
||||
} catch (e) {
|
||||
depOptions.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 分页组件挂载时会触发一次 current-change:页码未变化时忽略,避免首次打开重复请求
|
||||
function handlePageChange(p) {
|
||||
if (p === query.pageIndex) return;
|
||||
query.pageIndex = p;
|
||||
loadList();
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
query.pageIndex = 1;
|
||||
loadList();
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
isEdit.value = false;
|
||||
dialogTitle.value = '新增车间班次';
|
||||
Object.assign(form, {
|
||||
depId: Number(depOptions.value[0]?.id) || 0,
|
||||
banci: 1,
|
||||
kaoqinDayhours: 0
|
||||
});
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
async function openEdit(row) {
|
||||
isEdit.value = true;
|
||||
dialogTitle.value = '修改车间班次';
|
||||
editId.value = row.id;
|
||||
try {
|
||||
const res = await request.get(`/prod/chejianbanci/${row.id}`);
|
||||
Object.assign(form, {
|
||||
depId: Number(res.data.depId),
|
||||
banci: Number(res.data.banci),
|
||||
kaoqinDayhours: Number(res.data.kaoqinDayhours)
|
||||
});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (!form.depId) {
|
||||
ElMessage.warning('请选择车间');
|
||||
return;
|
||||
}
|
||||
if (!form.kaoqinDayhours || form.kaoqinDayhours <= 0) {
|
||||
ElMessage.warning('日工作小时数必须大于 0');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (isEdit.value) {
|
||||
await request.put(`/prod/chejianbanci/${editId.value}`, form);
|
||||
ElMessage.success('修改成功');
|
||||
} else {
|
||||
await request.post('/prod/chejianbanci', form);
|
||||
ElMessage.success('新增成功');
|
||||
}
|
||||
dialogVisible.value = false;
|
||||
loadList();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除「${row.deptname} · ${row.banciName}班」的班次配置吗?`, '提示', { type: 'warning' });
|
||||
try {
|
||||
await request.delete(`/prod/chejianbanci/${row.id}`);
|
||||
ElMessage.success('删除成功');
|
||||
loadList();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadDepOptions();
|
||||
loadList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>车间班次</span>
|
||||
<el-button type="primary" @click="openCreate">新增车间班次</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="search-bar">
|
||||
<el-input
|
||||
v-model="query.like"
|
||||
placeholder="车间 / 班次"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="loading" :data="list" row-key="id" border stripe>
|
||||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||||
<el-table-column prop="deptname" label="车间" min-width="200" />
|
||||
<el-table-column prop="banciName" label="班次" width="120" />
|
||||
<el-table-column prop="kaoqinDayhours" label="日工作小时数" width="140" />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="openEdit(row)">编辑</el-button>
|
||||
<el-button size="small" type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
class="pagination"
|
||||
:current-page="query.pageIndex"
|
||||
:page-size="query.pageSize"
|
||||
:total="total"
|
||||
layout="total, prev, pager, next"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="520px">
|
||||
<el-form :model="form" label-width="120px">
|
||||
<el-form-item label="车间" required>
|
||||
<el-select v-model="form.depId" placeholder="请选择车间" style="width: 100%">
|
||||
<el-option v-for="d in depOptions" :key="d.id" :label="d.name" :value="Number(d.id)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="班次" required>
|
||||
<el-select v-model="form.banci" style="width: 100%">
|
||||
<el-option v-for="b in banciOptions" :key="b.value" :label="b.label" :value="b.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="日工作小时数" required>
|
||||
<el-input-number
|
||||
v-model="form.kaoqinDayhours"
|
||||
:min="0"
|
||||
:max="24"
|
||||
:precision="1"
|
||||
:step="0.5"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleSave">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.card-header { display: flex; justify-content: space-between; align-items: center; }
|
||||
.search-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
|
||||
.pagination { margin-top: 16px; justify-content: flex-end; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user