455 lines
19 KiB
Vue
455 lines
19 KiB
Vue
<!--
|
||
* @Descripttion: (物料表/mm_material)
|
||
* @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="materialCode">
|
||
<el-input v-model="queryParams.materialCode" placeholder="请输入物料编码" />
|
||
</el-form-item>
|
||
<el-form-item label="物料名称" prop="materialName">
|
||
<el-input v-model="queryParams.materialName" placeholder="请输入物料名称" />
|
||
</el-form-item>
|
||
<el-form-item label="物料分类名称" prop="categoryCode">
|
||
<el-select v-model="queryParams.categoryCode" placeholder="请选择">
|
||
<el-option label="全部" value="" />
|
||
<el-option v-for="item in materialCategoryOptions" :key="item.value" :label="item.label" :value="item.value"></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="['mmmaterial: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">
|
||
<el-table-column prop="id" label="主键ID" align="center" v-if="columns.showColumn('id')" />
|
||
<el-table-column prop="materialCode" label="物料编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('materialCode')" />
|
||
<el-table-column prop="materialName" label="物料名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('materialName')" />
|
||
<el-table-column prop="specification" label="规格型号" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('specification')" />
|
||
<el-table-column prop="categoryCode" label="物料分类编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('categoryCode')" />
|
||
<el-table-column prop="categoryName" label="物料分类名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('categoryName')" />
|
||
<el-table-column prop="unit" label="计量单位" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('unit')" />
|
||
<el-table-column prop="type" label="物料类型" align="center" v-if="columns.showColumn('type')">
|
||
<template #default="scope">
|
||
<dict-tag :options="options.typeOptions" :value="scope.row.type" />
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="supplierCode" label="供应商编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('supplierCode')" />
|
||
<el-table-column prop="supplierName" label="供应商名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('supplierName')" />
|
||
<el-table-column prop="safetyStock" label="安全库存" align="center" v-if="columns.showColumn('safetyStock')" />
|
||
<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="createdTime" label="创建时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdTime')" />
|
||
<el-table-column prop="updatedTime" label="更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedTime')" />
|
||
<el-table-column prop="description" label="描述" align="center" :show-overflow-tooltip="true" 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="['mmmaterial:edit']"
|
||
@click="handleUpdate(scope.row)"></el-button>
|
||
<el-button
|
||
type="danger"
|
||
size="small"
|
||
icon="delete"
|
||
title="删除"
|
||
v-hasPermi="['mmmaterial: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" v-if="opertype != 1">
|
||
<el-form-item label="主键ID" prop="id">
|
||
<el-input-number v-model.number="form.id" controls-position="right" placeholder="请输入主键ID" :disabled="true" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="物料编码" prop="materialCode">
|
||
<el-input v-model="form.materialCode" placeholder="请输入物料编码" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="物料名称" prop="materialName">
|
||
<el-input v-model="form.materialName" placeholder="请输入物料名称" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="规格型号" prop="specification">
|
||
<el-input v-model="form.specification" placeholder="请输入规格型号" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="物料分类编码" prop="categoryCode">
|
||
<el-input v-model="form.categoryCode" placeholder="请输入物料分类编码" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="物料分类名称" prop="categoryName">
|
||
<el-input v-model="form.categoryName" 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="type">
|
||
<el-select v-model="form.type" placeholder="请选择物料类型(原材料/半成品/产成品/打包材料/辅料)">
|
||
<el-option
|
||
v-for="item in options.typeOptions"
|
||
: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="supplierCode">
|
||
<el-input v-model="form.supplierCode" placeholder="请输入供应商编码" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="供应商名称" prop="supplierName">
|
||
<el-input v-model="form.supplierName" placeholder="请输入供应商名称" />
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
<el-col :lg="12">
|
||
<el-form-item label="安全库存" prop="safetyStock">
|
||
<el-input v-model="form.safetyStock" placeholder="请输入安全库存" />
|
||
</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="mmmaterial">
|
||
import {
|
||
listMmMaterial,
|
||
addMmMaterial,
|
||
delMmMaterial,
|
||
updateMmMaterial,
|
||
getMmMaterial,
|
||
getMmMaterialCategoryOptions
|
||
} from '@/api/materialManagement/productionMaterial/mmmaterial.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',
|
||
materialCode: '',
|
||
materialName: '',
|
||
categoryCode: ''
|
||
})
|
||
const columns = ref([
|
||
{ visible: true, align: 'center', type: '', prop: 'id', label: '主键ID' },
|
||
{ visible: true, align: 'center', type: '', prop: 'materialCode', label: '物料编码', showOverflowTooltip: true },
|
||
{ visible: true, align: 'center', type: '', prop: 'materialName', label: '物料名称', showOverflowTooltip: true },
|
||
{ visible: true, align: 'center', type: '', prop: 'specification', label: '规格型号', showOverflowTooltip: true },
|
||
{ visible: true, align: 'center', type: '', prop: 'categoryCode', label: '物料分类编码', showOverflowTooltip: true },
|
||
{ visible: true, align: 'center', type: '', prop: 'categoryName', label: '物料分类名称', showOverflowTooltip: true },
|
||
{ visible: true, align: 'center', type: '', prop: 'unit', label: '计量单位', showOverflowTooltip: true },
|
||
{ visible: true, align: 'center', type: 'dict', prop: 'type', label: '物料类型(原材料/半成品/产成品/打包材料/辅料)', showOverflowTooltip: true },
|
||
{ visible: false, align: 'center', type: '', prop: 'supplierCode', label: '供应商编码', showOverflowTooltip: true },
|
||
{ visible: false, align: 'center', type: '', prop: 'supplierName', label: '供应商名称', showOverflowTooltip: true },
|
||
{ visible: false, align: 'center', type: '', prop: 'safetyStock', label: '安全库存' },
|
||
{ visible: false, align: 'center', type: 'dict', prop: 'status', label: '状态(停用/启用)', showOverflowTooltip: true },
|
||
{ visible: false, 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
|
||
listMmMaterial(queryParams).then((res) => {
|
||
console.log(queryParams)
|
||
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: {
|
||
materialCode: [{ required: true, message: '物料编码不能为空', trigger: 'blur' }],
|
||
materialName: [{ required: true, message: '物料名称不能为空', trigger: 'blur' }]
|
||
},
|
||
options: {
|
||
// 物料类型(原材料/半成品/产成品/打包材料/辅料) 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
|
||
typeOptions: [
|
||
{
|
||
dictValue: '0',
|
||
dictLabel: '原材料'
|
||
},
|
||
{
|
||
dictValue: '1',
|
||
dictLabel: '半成品'
|
||
},
|
||
{
|
||
dictValue: '2',
|
||
dictLabel: '产成品'
|
||
},
|
||
{
|
||
dictValue: '3',
|
||
dictLabel: '打包材料'
|
||
},
|
||
{
|
||
dictValue: '4',
|
||
dictLabel: '辅料'
|
||
}
|
||
],
|
||
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,
|
||
materialCode: null,
|
||
materialName: null,
|
||
specification: null,
|
||
categoryCode: null,
|
||
categoryName: null,
|
||
unit: null,
|
||
type: null,
|
||
supplierCode: null,
|
||
supplierName: null,
|
||
safetyStock: 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
|
||
getMmMaterial(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) {
|
||
updateMmMaterial(form.value).then((res) => {
|
||
proxy.$modal.msgSuccess('修改成功')
|
||
open.value = false
|
||
getList()
|
||
})
|
||
} else {
|
||
addMmMaterial(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 delMmMaterial(Ids)
|
||
})
|
||
.then(() => {
|
||
getList()
|
||
proxy.$modal.msgSuccess('删除成功')
|
||
})
|
||
}
|
||
// 物料分类名称下拉列表
|
||
const materialCategoryOptions = ref([])
|
||
|
||
// 物料分类名称下拉列表 可见性变化时触发
|
||
function handleGetMmMaterialCategoryOptions() {
|
||
try {
|
||
getMmMaterialCategoryOptions().then((res) => {
|
||
const { code, data } = res
|
||
if (code == 200) {
|
||
console.log(data)
|
||
materialCategoryOptions.value = data
|
||
}
|
||
})
|
||
} catch (err) {
|
||
console.log(err)
|
||
}
|
||
}
|
||
handleGetMmMaterialCategoryOptions()
|
||
handleQuery()
|
||
</script>
|