Files
kunshan-bzfm-mes-vue/src/views/materialManagement/productionMaterial/MmLocation.vue
git_rabbit 4b9b76cfe5 feat(物料管理): 添加库位类型选项列表
为生产物料库位管理页面添加完整的库位类型选项,包括原材料、半成品、产成品等类型
2026-01-09 09:11:43 +08:00

446 lines
19 KiB
Vue

<!--
* @Descripttion: (库位表/mm_location)
* @Author: (mes)
* @Date: (2025-12-25)
-->
<template>
<div>
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
<el-form-item label="库位名称" prop="locationCode">
<el-select v-model="queryParams.locationCode" filterable placeholder="请选择">
<el-option label="全部" value=""> </el-option>
<el-option v-for="item in dataList" :key="item.locationCode" :label="item.locationName" :value="item.locationCode">
<span style="float: left">{{ item.locationCode }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.locationName }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="仓库名称" prop="warehouseCode">
<el-select v-model="queryParams.warehouseCode" filterable placeholder="请选择">
<el-option label="全部" value=""> </el-option>
<el-option v-for="item in warehouseOptions" :key="item.warehouseCode" :label="item.warehouseName" :value="item.warehouseCode">
<span style="float: left">{{ item.warehouseCode }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.warehouseName }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
</el-form-item>
</el-form>
<!-- 工具区域 -->
<el-row :gutter="15" class="mb10">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['mmlocation:add']" plain icon="plus" @click="handleAdd">
{{ $t('btn.add') }}
</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table
:data="dataList"
v-loading="loading"
ref="table"
border
header-cell-class-name="el-table-header-cell"
highlight-current-row
@sort-change="sortChange"
:default-sort="{ prop: 'createdTime', order: 'descending' }">
<!-- <el-table-column prop="id" label="主键ID" align="center" v-if="columns.showColumn('id')" /> -->
<!-- <el-table-column prop="createdTime" sortable align="center" label="创建时间" v-if="columns.showColumn('createdTime')" /> -->
<el-table-column prop="locationCode" label="库位编码" align="center" v-if="columns.showColumn('locationCode')" />
<el-table-column prop="locationName" label="库位名称" align="center" v-if="columns.showColumn('locationName')" />
<el-table-column prop="warehouseCode" label="仓库编码" align="center" v-if="columns.showColumn('warehouseCode')" />
<el-table-column prop="warehouseName" label="仓库名称" align="center" v-if="columns.showColumn('warehouseName')" />
<el-table-column prop="areaCode" label="区域编码" align="center" v-if="columns.showColumn('areaCode')" />
<el-table-column prop="areaName" label="区域名称" align="center" v-if="columns.showColumn('areaName')" />
<el-table-column prop="capacity" label="容量" align="center" v-if="columns.showColumn('capacity')" />
<el-table-column prop="unit" label="容量单位" align="center" v-if="columns.showColumn('unit')" />
<el-table-column prop="locationType" label="库位类型" align="center" v-if="columns.showColumn('locationType')">
<template #default="scope">
<dict-tag :options="options.locationTypeOptions" :value="scope.row.locationType" />
</template>
</el-table-column>
<el-table-column prop="status" label="状态(停用/启用)" align="center" v-if="columns.showColumn('status')">
<template #default="scope">
<dict-tag :options="options.statusOptions" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column prop="updatedTime" label="更新时间" v-if="columns.showColumn('updatedTime')" />
<el-table-column prop="description" label="描述" align="center" v-if="columns.showColumn('description')" />
<el-table-column label="操作" width="160">
<template #default="scope">
<el-button
type="success"
size="small"
icon="edit"
title="编辑"
v-hasPermi="['mmlocation:edit']"
@click="handleUpdate(scope.row)"></el-button>
<el-button
type="danger"
size="small"
icon="delete"
title="删除"
v-hasPermi="['mmlocation:delete']"
@click="handleDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
<el-dialog :title="title" :lock-scroll="false" v-model="open">
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item label="库位编码" prop="locationCode">
<el-input v-model="form.locationCode" placeholder="请输入库位编码" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="库位名称" prop="locationName">
<el-input v-model="form.locationName" placeholder="请输入库位名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="仓库编码" prop="warehouseCode">
<el-select @change="handleWarehouseChange" v-model="form.warehouseCode" filterable placeholder="请选择仓库编码">
<el-option v-for="item in warehouseOptions" :key="item.warehouseCode" :label="item.warehouseCode" :value="item">
<span style="float: left">{{ item.warehouseCode }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.warehouseName }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="仓库名称" prop="warehouseName">
<el-input :disabled="true" v-model="form.warehouseName" placeholder="请输入仓库名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="区域编码" prop="areaCode">
<el-input v-model="form.areaCode" placeholder="请输入区域编码" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="区域名称" prop="areaName">
<el-input v-model="form.areaName" placeholder="请输入区域名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="容量" prop="capacity">
<el-input v-model="form.capacity" placeholder="请输入容量" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="容量单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入容量单位" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="库位类型" prop="locationType">
<el-select v-model="form.locationType" placeholder="请选择库位类型(半成品/成品/临时/返工/报废)">
<el-option
v-for="item in options.locationTypeOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictValue"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="item in options.statusOptions" :key="item.dictValue" :value="item.dictValue">
{{ item.dictLabel }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<!-- <el-col :lg="12">
<el-form-item label="创建时间" prop="createdTime">
<el-date-picker v-model="form.createdTime" type="datetime" placeholder="选择日期时间" value-format="YYYY-MM-DD HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="更新时间" prop="updatedTime">
<el-date-picker v-model="form.updatedTime" type="datetime" placeholder="选择日期时间" value-format="YYYY-MM-DD HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-col> -->
<el-col :lg="12">
<el-form-item label="描述" prop="description">
<el-input v-model="form.description" placeholder="请输入描述" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer v-if="opertype != 3">
<el-button text @click="cancel">{{ $t('btn.cancel') }}</el-button>
<el-button type="primary" @click="submitForm">{{ $t('btn.submit') }}</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup name="mmlocation">
import { listMmLocation, addMmLocation, delMmLocation, updateMmLocation, getMmLocation } from '@/api/materialManagement/productionMaterial/mmlocation.js'
import { warehouseOptions } from '@/utils/warehouse.js'
const { proxy } = getCurrentInstance()
const ids = ref([])
const loading = ref(false)
const showSearch = ref(true)
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
sort: '',
sortType: 'asc',
locationCode: '',
warehouseCode: ''
})
const columns = ref([
// { visible: true, align: 'center', type: '', prop: 'id', label: '主键ID' },
{ visible: true, align: 'center', type: '', prop: 'locationCode', label: '库位编码', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'locationName', label: '库位名称', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'warehouseCode', label: '仓库编码', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'warehouseName', label: '仓库名称', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'areaCode', label: '区域编码', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'areaName', label: '区域名称', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'capacity', label: '容量' },
{ visible: false, align: 'center', type: '', prop: 'unit', label: '容量单位', showOverflowTooltip: true },
{ visible: false, align: 'center', type: 'dict', prop: 'locationType', label: '库位类型(半成品/成品/临时/返工/报废)', showOverflowTooltip: true },
{ visible: false, align: 'center', type: 'dict', prop: 'status', label: '状态(停用/启用)', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'createdTime', label: '创建时间', showOverflowTooltip: true },
{ visible: false, align: 'center', type: '', prop: 'updatedTime', label: '更新时间', showOverflowTooltip: true },
{ visible: false, align: 'center', type: '', prop: 'description', label: '描述', showOverflowTooltip: true }
//{ visible: false, prop: 'actions', label: '操作', type: 'slot', width: '160' }
])
const total = ref(0)
const dataList = ref([])
const queryRef = ref()
const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)])
var dictParams = []
function getList() {
loading.value = true
listMmLocation(queryParams).then((res) => {
const { code, data } = res
if (code == 200) {
dataList.value = data.result
total.value = data.totalNum
loading.value = false
}
})
}
// 查询
function handleQuery() {
queryParams.pageNum = 1
getList()
}
// 重置查询操作
function resetQuery() {
proxy.resetForm('queryRef')
handleQuery()
}
// 自定义排序
function sortChange(column) {
var sort = undefined
var sortType = undefined
if (column.prop != null && column.order != null) {
sort = column.prop
sortType = column.order
}
queryParams.sort = sort
queryParams.sortType = sortType
handleQuery()
}
/*************** form操作 ***************/
const formRef = ref()
const title = ref('')
// 操作类型 1、add 2、edit 3、view
const opertype = ref(0)
const open = ref(false)
const state = reactive({
single: true,
multiple: true,
form: {
status: '启用'
},
rules: {
locationCode: [{ required: true, message: '库位编码不能为空', trigger: 'blur' }],
locationName: [{ required: true, message: '库位名称不能为空', trigger: 'blur' }],
warehouseCode: [{ required: true, message: '仓库编码不能为空', trigger: 'blur' }]
},
options: {
// 库位类型(半成品/成品/临时/返工/报废) 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
locationTypeOptions: [
{
dictValue: '原材料',
dictLabel: '原材料'
},
{
dictValue: '半成品',
dictLabel: '半成品'
},
{
dictValue: '产成品',
dictLabel: '产成品'
},
{
dictValue: '临时',
dictLabel: '临时'
},
{
dictValue: '返工',
dictLabel: '返工'
},
{
dictValue: '退货',
dictLabel: '退货'
},
{
dictValue: '转用',
dictLabel: '转用'
},
{
dictValue: '报废',
dictLabel: '报废'
}
],
// 状态 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
statusOptions: [
{
dictValue: '停用',
dictLabel: '停用'
},
{
dictValue: '启用',
dictLabel: '启用'
}
]
}
})
const { form, rules, options, single, multiple } = toRefs(state)
// 关闭dialog
function cancel() {
open.value = false
reset()
}
// 重置表单
function reset() {
form.value = {
id: null,
locationCode: null,
locationName: null,
warehouseCode: null,
warehouseName: null,
areaCode: null,
areaName: null,
capacity: null,
unit: null,
locationType: null,
status: '启用',
createdTime: null,
updatedTime: null,
description: null
}
proxy.resetForm('formRef')
}
// 添加按钮操作
function handleAdd() {
reset()
open.value = true
title.value = '添加库位表'
opertype.value = 1
}
// 修改按钮操作
function handleUpdate(row) {
reset()
const id = row.id || ids.value
getMmLocation(id).then((res) => {
const { code, data } = res
if (code == 200) {
open.value = true
title.value = '修改库位表'
opertype.value = 2
form.value = {
...data
}
}
})
}
// 添加&修改 表单提交
function submitForm() {
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
if (form.value.id != undefined && opertype.value === 2) {
updateMmLocation(form.value).then((res) => {
proxy.$modal.msgSuccess('修改成功')
open.value = false
getList()
})
} else {
addMmLocation(form.value).then((res) => {
proxy.$modal.msgSuccess('新增成功')
open.value = false
getList()
})
}
}
})
}
// 删除按钮操作
function handleDelete(row) {
const Ids = row.id || ids.value
proxy
.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?', '警告', {
confirmButtonText: proxy.$t('common.ok'),
cancelButtonText: proxy.$t('common.cancel'),
type: 'warning'
})
.then(function () {
return delMmLocation(Ids)
})
.then(() => {
getList()
proxy.$modal.msgSuccess('删除成功')
})
}
// 仓库编码选择改变时触发
function handleWarehouseChange(val) {
form.value.warehouseCode = val.warehouseCode
form.value.warehouseName = val.warehouseName
}
handleQuery()
</script>