物料BOM修改
This commit is contained in:
parent
45a0cb48e4
commit
5fe0a6eda7
@ -239,9 +239,10 @@ export function PauseWorkorder(workorder) {
|
||||
})
|
||||
}
|
||||
//结束工单
|
||||
export function EndWorkorder(workorder) {
|
||||
export function EndWorkorder(data) {
|
||||
return request({
|
||||
url: `mes/productManagement/ProWorkorder/finish_workorder?workorder=${workorder}`,
|
||||
url: `mes/productManagement/ProWorkorder/finish_workorder`,
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
@ -12,11 +12,11 @@
|
||||
<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-col :span="1.5">
|
||||
<el-button class="tool-box" type="primary" icon="Plus" @click="handleAdd"> 新增 </el-button>
|
||||
<el-button class="tool-box" color="#626aef" icon="Download" @click="handleImport"> 导入
|
||||
</el-button>
|
||||
<el-button class="tool-box" color="#00aa00" icon="Upload" @click="handleDownload"> 导出 </el-button>
|
||||
@ -46,8 +46,8 @@
|
||||
<vxe-column field="bomVersion" title="bom版本"></vxe-column>
|
||||
<vxe-column field="iusequantity" title="操作">
|
||||
<template #default="{ row }">
|
||||
<!-- <el-button type="success" size="small" icon="edit" title="编辑" @click="handleEdit(row)"></el-button>
|
||||
<el-button type="danger" @click="handleDelete(row)" size="small" icon="delete" title="删除" /> -->
|
||||
<el-button type="success" size="small" icon="edit" title="编辑" @click="handleSubEdit(row)"></el-button>
|
||||
<el-button type="danger" @click="handleSubDelete(row)" size="small" icon="delete" title="删除" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
@ -66,9 +66,54 @@
|
||||
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
</div>
|
||||
|
||||
<!-- 主件编辑弹窗 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="600px" append-to-body draggable
|
||||
:close-on-click-modal="false">
|
||||
<el-form ref="editFormRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="母件编码" prop="invCode">
|
||||
<el-input v-model="formData.invCode" placeholder="请输入母件编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="母件名称" prop="invName">
|
||||
<el-input v-model="formData.invName" placeholder="请输入母件名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="BOM版本" prop="bomVersion">
|
||||
<el-input v-model="formData.bomVersion" placeholder="请输入BOM版本" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="cancel">{{ $t('btn.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitForm">{{ $t('btn.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 子件编辑弹窗 -->
|
||||
<el-dialog :title="subDialog.title" v-model="subDialog.visible" width="600px" append-to-body draggable
|
||||
:close-on-click-modal="false">
|
||||
<el-form ref="subEditFormRef" :model="subFormData" :rules="subRules" label-width="120px">
|
||||
<el-form-item label="子件编码" prop="subInvCode">
|
||||
<el-input v-model="subFormData.subInvCode" placeholder="请输入子件编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="子件名称" prop="subInvName">
|
||||
<el-input v-model="subFormData.subInvName" placeholder="请输入子件名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="使用数量" prop="iusequantity">
|
||||
<el-input-number v-model="subFormData.iusequantity" :min="0" :precision="2" placeholder="请输入使用数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="BOM版本" prop="bomVersion">
|
||||
<el-input v-model="subFormData.bomVersion" placeholder="请输入BOM版本" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="cancelSub">{{ $t('btn.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitSubForm">{{ $t('btn.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导入对话框 -->
|
||||
<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body draggable
|
||||
:close-on-click-modal="false"> <span v-if="show">数据正在导入中请稍等……</span>
|
||||
:close-on-click-modal="false">
|
||||
<span v-if="show">数据正在导入中请稍等……</span>
|
||||
<el-upload name="file" ref="uploadRef" :limit="1" accept=".xlsx,.xls" :headers="upload.headers"
|
||||
:action="`${upload.url}`" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess" :on-error="handleFileError" :auto-upload="false" drag>
|
||||
@ -82,7 +127,6 @@
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
|
||||
@click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
@ -93,11 +137,35 @@
|
||||
</template>
|
||||
|
||||
<script setup name="BaseMaterialBOM">
|
||||
import { listBaseMaterialBom, GetMonterInvList, GetSonInvList } from '@/api/baseManagement/basematerialBOM.js'
|
||||
import { listBaseMaterialBom, GetMonterInvList, GetSonInvList, updateBaseMaterialBom } from '@/api/baseManagement/basematerialBOM.js'
|
||||
import { addBaseMaterialBom, updateBaseMaterialBom as updateMainBom } from '@/api/baseManagement/basematerialBOM.js'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
const userStore = useUserStore()
|
||||
const userName = userStore.userName
|
||||
const { proxy } = getCurrentInstance()
|
||||
const ids = ref([])
|
||||
const loading = ref(false)
|
||||
const showSearch = ref(true)
|
||||
|
||||
// 弹窗相关数据
|
||||
const dialog = reactive({
|
||||
title: '',
|
||||
visible: false,
|
||||
isEdit: false
|
||||
})
|
||||
|
||||
const subDialog = reactive({
|
||||
title: '',
|
||||
visible: false,
|
||||
isEdit: false
|
||||
})
|
||||
|
||||
const formData = ref({})
|
||||
const subFormData = ref({})
|
||||
|
||||
const editFormRef = ref()
|
||||
const subEditFormRef = ref()
|
||||
|
||||
const queryParams = reactive({
|
||||
invCode: '',
|
||||
subInvCode: '',
|
||||
@ -106,22 +174,67 @@ const queryParams = reactive({
|
||||
sort: 'createdTime',
|
||||
sortType: 'desc'
|
||||
})
|
||||
const columns = ref([
|
||||
{ visible: true, field: 'invCode', title: '母件编码' },
|
||||
{ visible: true, field: 'invName', title: '母件编码' },
|
||||
{ visible: true, field: 'subInvCode', title: '子件编码' },
|
||||
{ visible: true, field: 'subInvName', title: '子件名称' },
|
||||
{ visible: true, field: 'iusequantity', title: '使用数量' },
|
||||
{ visible: true, field: 'bomVersion', title: 'bom版本' }
|
||||
])
|
||||
|
||||
const total = ref(0)
|
||||
const dataList = ref([])
|
||||
const tableRef = 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 = []
|
||||
// 主件表单验证规则
|
||||
const rules = {
|
||||
invCode: [
|
||||
{ required: true, message: '母件编码不能为空', trigger: 'blur' }
|
||||
],
|
||||
invName: [
|
||||
{ required: true, message: '母件名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
bomVersion: [
|
||||
{ required: true, message: 'BOM版本不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
// 子件表单验证规则
|
||||
const subRules = {
|
||||
subInvCode: [
|
||||
{ required: true, message: '子件编码不能为空', trigger: 'blur' }
|
||||
],
|
||||
subInvName: [
|
||||
{ required: true, message: '子件名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
iusequantity: [
|
||||
{ required: true, message: '使用数量不能为空', trigger: 'blur' },
|
||||
{ type: 'number', message: '使用数量必须为数字值', trigger: 'blur' }
|
||||
],
|
||||
bomVersion: [
|
||||
{ required: true, message: 'BOM版本不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
// 初始化表单数据
|
||||
function resetForm() {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
invCode: '',
|
||||
invName: '',
|
||||
bomVersion: '',
|
||||
createdBy: userName,
|
||||
updatedBy: userName
|
||||
}
|
||||
editFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
function resetSubForm() {
|
||||
subFormData.value = {
|
||||
id: undefined,
|
||||
subInvCode: '',
|
||||
subInvName: '',
|
||||
iusequantity: 0,
|
||||
bomVersion: ''
|
||||
}
|
||||
subEditFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
// 获取数据列表
|
||||
function getList() {
|
||||
loading.value = true
|
||||
GetMonterInvList(queryParams).then((res) => {
|
||||
@ -157,31 +270,106 @@ function handleSelectAll({ records }) {
|
||||
console.log('全选/取消全选后ID:', ids.value)
|
||||
}
|
||||
|
||||
// 批量编辑
|
||||
function handleBatchEdit() {
|
||||
const selectedRows = getSelectedRows()
|
||||
if (selectedRows.length === 0) {
|
||||
proxy.$modal.msgWarning('请选择要编辑的数据')
|
||||
return
|
||||
}
|
||||
console.log('批量编辑数据:', selectedRows)
|
||||
// 这里实现批量编辑逻辑
|
||||
// 编辑主件
|
||||
function handleEdit(row) {
|
||||
resetForm()
|
||||
const { id, invCode, invName, bomVersion } = row
|
||||
formData.value = { id, invCode, invName, bomVersion }
|
||||
dialog.title = '修改主件信息'
|
||||
dialog.visible = true
|
||||
dialog.isEdit = true
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
function handleBatchDelete() {
|
||||
const selectedRows = getSelectedRows()
|
||||
if (selectedRows.length === 0) {
|
||||
proxy.$modal.msgWarning('请选择要删除的数据')
|
||||
return
|
||||
}
|
||||
// 编辑子件
|
||||
function handleSubEdit(row) {
|
||||
resetSubForm()
|
||||
const { id, subInvCode, subInvName, iusequantity, bomVersion } = row
|
||||
subFormData.value = { id, subInvCode, subInvName, iusequantity, bomVersion }
|
||||
subDialog.title = '修改子件信息'
|
||||
subDialog.visible = true
|
||||
subDialog.isEdit = true
|
||||
}
|
||||
|
||||
proxy.$modal.confirm(`确认删除已选中的 ${selectedRows.length} 条数据?`)
|
||||
// 提交主件表单
|
||||
function submitForm() {
|
||||
editFormRef.value.validate(valid => {
|
||||
if (valid) {
|
||||
if (dialog.isEdit) {
|
||||
// 更新现有记录
|
||||
updateBaseMaterialBom(formData.value).then(res => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
dialog.visible = false
|
||||
resetForm()
|
||||
getList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 添加新记录
|
||||
addBaseMaterialBom(formData.value).then(res => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('新增成功')
|
||||
dialog.visible = false
|
||||
resetForm()
|
||||
getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 提交子件表单
|
||||
function submitSubForm() {
|
||||
subEditFormRef.value.validate(valid => {
|
||||
if (valid) {
|
||||
if (subDialog.isEdit) {
|
||||
// 更新现有记录
|
||||
updateBaseMaterialBom(subFormData.value).then(res => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
subDialog.visible = false
|
||||
resetSubForm()
|
||||
// 刷新父级数据
|
||||
getList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 添加新记录
|
||||
// 注意:这里可能需要不同的API接口,根据实际业务调整
|
||||
addBaseMaterialBom(subFormData.value).then(res => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('新增成功')
|
||||
subDialog.visible = false
|
||||
resetSubForm()
|
||||
getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 取消主件编辑
|
||||
function cancel() {
|
||||
dialog.visible = false
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 取消子件编辑
|
||||
function cancelSub() {
|
||||
subDialog.visible = false
|
||||
resetSubForm()
|
||||
}
|
||||
|
||||
// 删除子件
|
||||
function handleSubDelete(row) {
|
||||
proxy.$modal.confirm('确认删除该子件数据?')
|
||||
.then(() => {
|
||||
// 这里实现批量删除逻辑
|
||||
console.log('批量删除数据:', selectedRows)
|
||||
// 实现删除逻辑
|
||||
console.log('删除子件数据:', row.id)
|
||||
// 示例API调用
|
||||
// return deleteBatch(ids.value)
|
||||
// return deleteById(row.id)
|
||||
})
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
@ -189,11 +377,7 @@ function handleBatchDelete() {
|
||||
})
|
||||
}
|
||||
|
||||
//修改
|
||||
function handleEdit(row) {
|
||||
console.log('编辑行数据:', row)
|
||||
// 实现编辑逻辑
|
||||
}
|
||||
|
||||
|
||||
// 删除单行
|
||||
function handleDelete(row) {
|
||||
@ -215,16 +399,17 @@ function loadContentMethod({ row }) {
|
||||
return new Promise((resolve) => {
|
||||
GetSonInvList({ invCode: row.invCode }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
row.columns = columns.value
|
||||
row.children = res.data
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getToken() {
|
||||
return localStorage.getItem('token') || '';
|
||||
}
|
||||
|
||||
// 导入参数
|
||||
const upload = reactive({
|
||||
open: false,
|
||||
@ -235,10 +420,12 @@ const upload = reactive({
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
url: import.meta.env.VITE_APP_BASE_API + '/MasterDataManagement/Material/MaterialBom/importData'
|
||||
})
|
||||
|
||||
function handleImport(type) {
|
||||
upload.title = '导入'
|
||||
upload.open = true
|
||||
}
|
||||
|
||||
//导出
|
||||
function handleDownload() {
|
||||
proxy
|
||||
@ -251,14 +438,16 @@ function handleDownload() {
|
||||
await proxy.downFile('/MasterDataManagement/Material/MaterialBom/exportData', { ...queryParams })
|
||||
})
|
||||
}
|
||||
|
||||
function submitFileForm() {
|
||||
proxy.$refs['uploadRef'].submit()
|
||||
}
|
||||
|
||||
//下砸模版
|
||||
function importTemplate() {
|
||||
proxy.download('/MasterDataManagement/Material/MaterialBom/importTemplate', '物料类别导入模板')
|
||||
|
||||
}
|
||||
|
||||
/** 文件上传异常处理 */
|
||||
const handleFileError = (error, file, fileList) => {
|
||||
// 修复:使用正确的响应对象
|
||||
@ -267,12 +456,15 @@ const handleFileError = (error, file, fileList) => {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const show = ref(false)
|
||||
const handleFileUploadProgress = (event, file, fileList) => {
|
||||
upload.isUploading = true,
|
||||
show.value = true
|
||||
}
|
||||
|
||||
const dialogVisibleActualAssembly = ref(false)
|
||||
|
||||
/** 文件上传成功处理 */
|
||||
const handleFileSuccess = (response, file, fileList) => {
|
||||
|
||||
@ -297,6 +489,7 @@ const handleFileSuccess = (response, file, fileList) => {
|
||||
proxy.$refs['uploadRef'].clearFiles()
|
||||
dialogVisibleActualAssembly.value = true
|
||||
}
|
||||
|
||||
// 查询
|
||||
function handleQuery() {
|
||||
queryParams.pageNum = 1
|
||||
@ -308,6 +501,7 @@ function resetQuery() {
|
||||
proxy.resetForm('queryRef')
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 自定义排序
|
||||
function sortChange(column) {
|
||||
var sort = undefined
|
||||
@ -322,25 +516,11 @@ function sortChange(column) {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 打开BOM表
|
||||
const rowObject = ref(null)
|
||||
const BomDialogShow = ref(false)
|
||||
const handleShowBom = (row) => {
|
||||
rowObject.value = row
|
||||
BomDialogShow.value = true
|
||||
}
|
||||
|
||||
const updateRowObject = ref(null)
|
||||
const updateBomDialogShow = ref(false)
|
||||
const handleUpdateBom = (row) => {
|
||||
updateRowObject.value = row
|
||||
updateBomDialogShow.value = true
|
||||
}
|
||||
|
||||
/// ======================= 数据同步 =============================
|
||||
import { SynchERPBOM } from '@/api/erp/baseInteractERP.js'
|
||||
const throttle = ref(false)
|
||||
const syncLoading = ref(false)
|
||||
|
||||
function handleSync() {
|
||||
syncLoading.value = true
|
||||
throttle.value = true
|
||||
|
||||
@ -94,6 +94,42 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :title="title1" :lock-scroll="false" v-model="open1" draggable :close-on-click-modal="false" @close="cancel2">
|
||||
<el-form ref="form" :model="form1" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="合格数" prop="okQty">
|
||||
<el-input v-model.trim="form1.okQty" clearable placeholder="请输入" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="不合格数" prop="ngQty">
|
||||
<el-input v-model.trim="form1.ngQty" clearable placeholder="请输入" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="不良原因" prop="defectReason">
|
||||
<!-- <el-input v-model.trim="form1.workorder" clearable placeholder="请输入" /> -->
|
||||
<el-select v-model="form1.defectReason" placeholder="请选择">
|
||||
<el-option v-for="item in options.defectReason" :key="item.value" :label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model.trim="form1.description" clearable placeholder="请输入" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="cancel2">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm2">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -110,7 +146,9 @@ const { proxy } = getCurrentInstance()
|
||||
const loading = ref(false)
|
||||
const showSearch = ref(true)
|
||||
const open = ref(false)
|
||||
const open1=ref(false)
|
||||
const title = ref('')
|
||||
const title1 = ref('')
|
||||
// 使用原生 JavaScript 替代 dayjs
|
||||
const getDefaultTime = () => {
|
||||
const now = new Date()
|
||||
@ -171,8 +209,8 @@ function handleUpdate(row) {
|
||||
open.value = true
|
||||
}
|
||||
function handleDelete(row) {
|
||||
title.value = '完成'
|
||||
open.value = true
|
||||
title1.value = '完成'
|
||||
open1.value = true
|
||||
}
|
||||
function cancel() {
|
||||
open.value = false
|
||||
@ -193,14 +231,16 @@ function submitForm() {
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else if (title.value == '完成') {
|
||||
EndWorkorder(form.value.workorder).then((res) => {
|
||||
proxy.$modal.msgSuccess('完成成功')
|
||||
form.value.workorder = null
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
function submitForm2(){
|
||||
console.log(form1.value,'完工参数');
|
||||
EndWorkorder(form1.value).then((res) => {
|
||||
proxy.$modal.msgSuccess('完成成功')
|
||||
form.value.workorder = null
|
||||
open1.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
// 查询
|
||||
function handleQuery() {
|
||||
@ -240,6 +280,7 @@ function tableCellClassName({ row, column, rowIndex, columnIndex }) {
|
||||
|
||||
const state = reactive({
|
||||
form: {},
|
||||
form1: {},
|
||||
options: {
|
||||
// 优先级
|
||||
priorityOptions: [
|
||||
@ -249,13 +290,19 @@ const state = reactive({
|
||||
],
|
||||
dictWorkTypeOptions: [],
|
||||
// 工单状态 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
|
||||
statusOptions: []
|
||||
statusOptions: [],
|
||||
defectReason:[]
|
||||
},
|
||||
processList: [],
|
||||
stationList: []
|
||||
stationList: [],
|
||||
rules: {
|
||||
workorder: [
|
||||
{ required: true, message: '请输入工单号', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
const { options, form } = toRefs(state)
|
||||
const { options, form,form1 } = toRefs(state)
|
||||
|
||||
async function initDict() {
|
||||
const dictSelectList = ['pro_workorder_type', 'base_work_type']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user