fix:成品检验修改
This commit is contained in:
parent
e804acde60
commit
646ec37336
@ -63,3 +63,11 @@ export function getLineName() {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
//不良原因下拉
|
||||
export function getReason() {
|
||||
return request({
|
||||
url: 'mes/QualityDefectReason/getQualityDefectReason',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
@ -29,6 +29,8 @@
|
||||
</el-button>
|
||||
<el-button class="tool-box" color="#00aa00" icon="Upload" @click="handleDownload"> 导出
|
||||
</el-button>
|
||||
<el-button class="tool-box" color="#00aa00" icon="" @click="handlerootCause"> 批量新增/修改不良原因
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"
|
||||
:columns="columns"></right-toolbar>
|
||||
@ -45,8 +47,8 @@
|
||||
<el-table-column prop="lineName" label="产线名称" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="lineCode" label="产线编号" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="orderDate" label="工单日期" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="productCode" label="产品编码" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="productName" label="产品信息" align="center" :show-overflow-tooltip="true" />
|
||||
<!-- <el-table-column prop="productCode" label="产品编码" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="productName" label="产品信息" align="center" :show-overflow-tooltip="true" /> -->
|
||||
<el-table-column prop="materialName" label="零件信息" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="materialCode" label="零件编码" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="totalQty" label="工单总数" align="center" :show-overflow-tooltip="true" />
|
||||
@ -54,13 +56,15 @@
|
||||
<el-table-column prop="ngQty" label="不合格数" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="defectReason" label="不良原因描述" align="center" :show-overflow-tooltip="true">
|
||||
<template #default="scope">
|
||||
<div>
|
||||
<div v-if="!scope.row.editing">
|
||||
{{ scope.row.defectReason }}
|
||||
<el-icon @click="handleEdit(scope.row)"
|
||||
style="cursor: pointer; margin-left: 5px;">
|
||||
<el-icon @click="handleEdit(scope.row)" style="cursor: pointer; margin-left: 5px;">
|
||||
<Edit />
|
||||
</el-icon>
|
||||
</div>
|
||||
<el-input v-else v-model="scope.row.defectReason" @blur="handleSave(scope.row)"
|
||||
@keyup.enter="handleSave(scope.row)" style="width: 100px;" ref="defectReasonInput"
|
||||
:data-row-id="scope.row.id || scope.row.planCode" data-field="defectReason" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="orderStatus" label="工单状态" align="center" :show-overflow-tooltip="true">
|
||||
@ -170,30 +174,6 @@
|
||||
<el-button type="primary" @click="submitForm">{{ $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>
|
||||
<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>
|
||||
<el-icon class="el-icon--upload">
|
||||
<upload-filled />
|
||||
</el-icon>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip text-center">
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
|
||||
@click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<el-button @click="upload.open = false">{{ $t('btn.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitFileForm">{{ $t('btn.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 导出 -->
|
||||
<el-dialog v-model="exportDialog.open" title="导出" @close="handleCloseWorkOrder" width="500" draggable
|
||||
:close-on-click-modal="false">
|
||||
@ -208,27 +188,43 @@
|
||||
<el-button type="primary" @click="submitExport">{{ $t('btn.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 不良原因弹窗 -->
|
||||
<el-dialog v-model="rootCauseCloseWork" title="不良原因" @close="handleCloseRootCause" width="500" draggable
|
||||
:close-on-click-modal="false">
|
||||
<el-form>
|
||||
<el-form-item label="不良原因选择" prop="defectReason">
|
||||
<el-select filterable clearable v-model="rootCause" placeholder="请选择">
|
||||
<el-option v-for="item in defectReasonData" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button text @click="handleCloseRootCause">{{ $t('btn.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitRootCause">{{ $t('btn.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="processInformationManagement">
|
||||
import { ElMessageBox, ElMessage } from 'element-plus'
|
||||
import { Edit } from '@element-plus/icons-vue';
|
||||
import { getProcessInfoList, getProcessInfoById, addProcessInfo, updateProcessInfo, delProcessInfo, getLineName } from "@/api/ticketInquiry/index"
|
||||
import { getProcessInfoList, addProcessInfo, updateProcessInfo, delProcessInfo, getLineName, getReason } from "@/api/ticketInquiry/index"
|
||||
import useUserStore from '@/store/modules/user'
|
||||
const dialogTableVisible = ref(false)
|
||||
const userStore = useUserStore()
|
||||
const userId = userStore.userId
|
||||
const userName = userStore.userName
|
||||
console.log(userStore.userId, 'userStore.userId')
|
||||
import { ref, reactive, getCurrentInstance, watch, toRefs, onMounted } from 'vue';
|
||||
import { start } from 'nprogress';
|
||||
const rootCause = ref('')
|
||||
const defectReasonData = ref([])
|
||||
const rootCauseCloseWork = ref(false)
|
||||
import { ref, reactive, getCurrentInstance, watch, toRefs, onMounted, nextTick } from 'vue';
|
||||
// 使用ref和reactive初始化响应式数据
|
||||
const { proxy } = getCurrentInstance()
|
||||
const ids = ref([])
|
||||
const loading = ref(false)
|
||||
const showSearch = ref(true)
|
||||
const show = ref(false)
|
||||
const editingRows = ref(new Set())
|
||||
const dataList = ref([])
|
||||
import { getToken } from '@/utils/auth'
|
||||
// 查询参数
|
||||
@ -236,36 +232,43 @@ const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
//详情请求参数
|
||||
const queryParamsDetail = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
id: null
|
||||
})
|
||||
const productionLine = ref([])
|
||||
const gridData = ref([])
|
||||
//导入参数
|
||||
const upload = reactive({
|
||||
open: false,
|
||||
title: '导入数据',
|
||||
isUploading: false,
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
url: import.meta.env.VITE_APP_BASE_API + `/mes/MaterialInfo/ImportMaterialInfo?userId=${userStore.userId}&userName=${userStore.userName}`
|
||||
})
|
||||
//文件上传中
|
||||
const handleFileUploadProgress = (event, file, fileList) => {
|
||||
upload.isUploading = true,
|
||||
show.value = true
|
||||
console.log(upload.url, '上传地址');
|
||||
function handleEdit(row) {
|
||||
// 设置当前行为编辑状态
|
||||
editingRows.value.add(row.id || row.planCode)
|
||||
row.editing = true
|
||||
|
||||
// 等待DOM更新后聚焦到输入框
|
||||
nextTick(() => {
|
||||
const input = document.querySelector(`[data-row-id="${row.id || row.planCode}"][data-field="defectReason"]`)
|
||||
if (input) {
|
||||
input.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
//表格不良原因输入框的值
|
||||
function handleEdit(row){
|
||||
console.log(row,'row');
|
||||
function handleSave(row) {
|
||||
// 移除编辑状态
|
||||
editingRows.value.delete(row.id || row.planCode)
|
||||
row.editing = false
|
||||
|
||||
// 这里添加保存逻辑,例如调用API更新数据
|
||||
console.log('保存数据:', row.defectReason)
|
||||
|
||||
// 示例:调用更新接口
|
||||
updateProcessInfo({
|
||||
...row,
|
||||
userId: userId,
|
||||
userName: userName
|
||||
}).then(res => {
|
||||
if (res.code == 200) {
|
||||
ElMessage.success('更新成功')
|
||||
getList() // 重新获取列表数据
|
||||
}
|
||||
})
|
||||
}
|
||||
// 多选下拉
|
||||
function handleSelectionChange(val) {
|
||||
// const selectedIds = val.map(item => item.materialCode);
|
||||
// ids.value = selectedIds;
|
||||
selectedRows.value = val;
|
||||
console.log(val.map(item => item.defectReason), '不良原因的值');
|
||||
}
|
||||
function getList() {
|
||||
@ -277,48 +280,24 @@ function getList() {
|
||||
})
|
||||
}
|
||||
|
||||
// 存储选中的行
|
||||
const selectedRows = ref([]);
|
||||
|
||||
/** 文件上传成功处理 */
|
||||
const handleFileSuccess = (response, file, fileList) => {
|
||||
|
||||
const { code, msg, data } = response
|
||||
if (code === 500) {
|
||||
proxy.$message.error('模板存在异常!')
|
||||
upload.isUploading = false
|
||||
proxy.$refs['uploadRef'].clearFiles()
|
||||
return
|
||||
//新增修改修改不良原因
|
||||
function handlerootCause() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
if (data === -1) {
|
||||
proxy.$message.error('模板不匹配!')
|
||||
upload.isUploading = false
|
||||
proxy.$refs['uploadRef'].clearFiles()
|
||||
return
|
||||
}
|
||||
if (code == 404) {
|
||||
proxy.$message.error(response.msg)
|
||||
upload.isUploading = false
|
||||
proxy.$refs['uploadRef'].clearFiles()
|
||||
return
|
||||
}
|
||||
upload.open = false
|
||||
show.value = false
|
||||
upload.isUploading = false
|
||||
proxy.$refs['uploadRef'].clearFiles()
|
||||
if (code == 200) {
|
||||
ElMessage({
|
||||
message: '导入成功',
|
||||
type: 'success',
|
||||
})
|
||||
getList()
|
||||
}
|
||||
}
|
||||
/** 文件上传异常处理 */
|
||||
const handleFileError = (error, file, fileList) => {
|
||||
const { code, msg, data } = error.response || {}
|
||||
if (error) {
|
||||
proxy.$message.error('模板导入异常!')
|
||||
return
|
||||
if (selectedRows.value.length > 0) {
|
||||
rootCause.value = '';
|
||||
}
|
||||
getReason().then(res => {
|
||||
if (res.code == 200) {
|
||||
defectReasonData.value = res.data.result
|
||||
}
|
||||
})
|
||||
rootCauseCloseWork.value = true
|
||||
}
|
||||
|
||||
//导出参数
|
||||
@ -358,14 +337,6 @@ const total = ref(0)
|
||||
const detailTotail = ref(0)
|
||||
const queryRef = ref()
|
||||
|
||||
//导入
|
||||
function handleImport() {
|
||||
upload.open = true
|
||||
}
|
||||
/** 下载模板操作 */
|
||||
function importTemplate() {
|
||||
proxy.download('/mes/MaterialInfo/importTemplate', '导入模板')
|
||||
}
|
||||
|
||||
//导出
|
||||
function handleDownload() {
|
||||
@ -544,27 +515,6 @@ function submitForm() {
|
||||
})
|
||||
}
|
||||
|
||||
function handleDeletes() {
|
||||
if (ids.value.length === 0) {
|
||||
ElMessage({
|
||||
message: '请至少选择一条记录进行删除',
|
||||
type: 'warning',
|
||||
});
|
||||
return;
|
||||
}
|
||||
proxy.$confirm(
|
||||
`确认删除${ids.value.length}条数据吗?`,
|
||||
'提示',
|
||||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
|
||||
).then(() => {
|
||||
delProcessInfo(ids.value).then(res => {
|
||||
if (res.code === 200) {
|
||||
ElMessage({ message: '删除成功', type: 'success' });
|
||||
getList();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// 删除工艺
|
||||
function handleDelete(row) {
|
||||
proxy.$confirm(
|
||||
@ -581,10 +531,42 @@ function handleDelete(row) {
|
||||
});
|
||||
}
|
||||
|
||||
// 树节点选择
|
||||
function handlerTreeSelected(id) {
|
||||
queryParams.RoutingCode = id
|
||||
handleQuery()
|
||||
// 提交批量不良原因修改
|
||||
function submitRootCause() {
|
||||
if (!rootCause.value) {
|
||||
ElMessage.warning('请输入不良原因描述');
|
||||
return;
|
||||
}
|
||||
const updatePromises = selectedRows.value.map(row => {
|
||||
const updatedRow = {
|
||||
...row,
|
||||
defectReason: rootCause.value,
|
||||
userId: userId,
|
||||
userName: userName
|
||||
};
|
||||
row.defectReason = rootCause.value;
|
||||
return updateProcessInfo(updatedRow);
|
||||
});
|
||||
Promise.all(updatePromises).then(results => {
|
||||
const allSuccessful = results.every(res => res.code === 200);
|
||||
if (allSuccessful) {
|
||||
ElMessage.success('批量更新成功');
|
||||
handleCloseRootCause();
|
||||
getList();
|
||||
} else {
|
||||
ElMessage.error('部分数据更新失败');
|
||||
}
|
||||
}).catch(error => {
|
||||
ElMessage.error('更新过程中发生错误');
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
// 关闭不良原因弹窗
|
||||
function handleCloseRootCause() {
|
||||
rootCauseCloseWork.value = false;
|
||||
rootCause.value = '';
|
||||
selectedRows.value = [];
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
parity: 'none',
|
||||
portName: 'COM1'
|
||||
})
|
||||
|
||||
console.log(port.value);
|
||||
readFromSerial()
|
||||
|
||||
} catch (error) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div>
|
||||
<demo></demo>
|
||||
<!-- <demo></demo> -->
|
||||
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch"
|
||||
@submit.prevent>
|
||||
<el-form-item label="产线名称" prop="lineName">
|
||||
|
||||
@ -40,8 +40,8 @@
|
||||
<el-table-column prop="lineName" label="产线名称" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="lineCode" label="产线编号" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="orderDate" label="工单日期" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="productCode" label="产品编码" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="productName" label="产品信息" align="center" :show-overflow-tooltip="true" />
|
||||
<!-- <el-table-column prop="productCode" label="产品编码" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="productName" label="产品信息" align="center" :show-overflow-tooltip="true" /> -->
|
||||
<el-table-column prop="totalQty" label="工单总数" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="okQty" label="合格数" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="ngQty" label="不合格数" align="center" :show-overflow-tooltip="true" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user