Browse Source

用户输入RFID前道+绑定+Converting可以批量新增工序

master
han\hanst 3 weeks ago
parent
commit
77d00bddca
  1. 278
      src/views/modules/erf/components/expTriConfirm.vue
  2. 3
      src/views/modules/erf/expApplyList.vue

278
src/views/modules/erf/components/expTriConfirm.vue

@ -3,6 +3,7 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div class="toolbar"> <div class="toolbar">
<el-button @click="openAddDialog" type="primary" class="add-btn" size="small">新增</el-button> <el-button @click="openAddDialog" type="primary" class="add-btn" size="small">新增</el-button>
<el-button @click="openBatchAddDialog" type="success" class="add-btn" size="small">批量新增</el-button>
<div style="margin-top: 4px;margin-left: 10px; color: #909399; font-size: 12px"> <div style="margin-top: 4px;margin-left: 10px; color: #909399; font-size: 12px">
<i class="el-icon-info" style="color: #409EFF"></i> <i class="el-icon-info" style="color: #409EFF"></i>
可以拖拽调整工序顺序 可以拖拽调整工序顺序
@ -347,6 +348,88 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 批量新增工序弹框 -->
<el-dialog
title="批量新增工序"
:visible.sync="batchAddDialogVisible"
width="660px"
:close-on-click-modal="false">
<el-form label-position="top">
<el-form-item>
<template slot="label">
<span style="color: #909399; font-size: 12px; ">
支持多种输入RFID前道+绑定+Converting RFID前道绑定Converting
</span>
</template>
<el-input
v-model="batchProcessInput"
@blur="handleBatchInput"
@keyup.enter.native="handleBatchInput"
placeholder="输入工序名称后按回车或失去焦点自动识别">
</el-input>
</el-form-item>
</el-form>
<!-- 匹配结果表格 -->
<el-table
v-if="batchProcessList.length > 0"
:data="batchProcessList"
border style="margin-top: 10px"
max-height="400px">
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
<el-table-column prop="processStep" label="工序名称" width="130" align="center"></el-table-column>
<el-table-column label="状态" width="60" align="center">
<template slot-scope="scope">
<a v-if="scope.row.matched" type="success" size="mini">已匹配</a>
<a v-else type="warning" size="mini">待设置</a>
</template>
</el-table-column>
<el-table-column prop="prodApproverName" label="生产负责人" width="100" align="center">
<template slot-scope="scope">
<span v-if="scope.row.prodApproverName">{{ scope.row.prodApproverName }}</span>
<span v-else style="color: #ccc;">-</span>
</template>
</el-table-column>
<el-table-column prop="qaApproverName" label="质量负责人" width="100" align="center">
<template slot-scope="scope">
<span v-if="scope.row.qaApproverName">{{ scope.row.qaApproverName }}</span>
<span v-else style="color: #ccc;">-</span>
</template>
</el-table-column>
<el-table-column prop="techApproverName" label="技术负责人" width="100" align="center">
<template slot-scope="scope">
<span v-if="scope.row.techApproverName">{{ scope.row.techApproverName }}</span>
<span v-else style="color: #ccc;">-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="80" align="center" fixed="right">
<template slot-scope="scope">
<a type="text" size="small" @click="setBatchProcessApprovers(scope.row, scope.$index)">
设置
</a>
<a type="text" size="small" style="color: #F56C6C;" @click="removeBatchProcess(scope.$index)">
删除
</a>
</template>
</el-table-column>
</el-table>
<div slot="footer">
<el-button @click="batchAddDialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmBatchCreate" :disabled="validBatchCount === 0" :loading="batchCreating">
批量创建{{ validBatchCount }}
</el-button>
</div>
</el-dialog>
<!-- 确认对话框 --> <!-- 确认对话框 -->
<el-dialog <el-dialog
:title="confirmDialogTitle" :title="confirmDialogTitle"
@ -484,7 +567,24 @@ export default {
// //
sortableInstance: null, // Sortable sortableInstance: null, // Sortable
isDragging: false //
isDragging: false, //
//
batchAddDialogVisible: false,
batchProcessInput: '',
batchProcessList: [],
batchCreating: false,
currentBatchIndex: -1,
isBatchMode: false
}
},
computed: {
//
validBatchCount() {
return this.batchProcessList.filter(item =>
item.prodApproverName && item.qaApproverName && item.techApproverName
).length
} }
}, },
@ -502,6 +602,14 @@ export default {
this.loadProcessList() this.loadProcessList()
} }
} }
},
//
processDialogVisible(val) {
if (!val) {
this.isBatchMode = false
this.currentBatchIndex = -1
}
} }
}, },
@ -628,6 +736,153 @@ export default {
this.processDialogVisible = true this.processDialogVisible = true
}, },
/**
* 打开批量新增弹框
*/
openBatchAddDialog() {
this.batchProcessInput = ''
this.batchProcessList = []
this.batchAddDialogVisible = true
this.loadTemplateList()
},
/**
* 处理批量输入失去焦点或回车时触发
*/
handleBatchInput() {
if (!this.batchProcessInput || !this.batchProcessInput.trim()) {
this.batchProcessList = []
return
}
//
let text = this.batchProcessInput
text = text.replace(/\+/g, '\n')
.replace(/、/g, '\n')
.replace(/,/g, '\n')
.replace(/,/g, '\n')
.replace(/;/g, '\n')
.replace(/;/g, '\n')
.replace(/\|/g, '\n')
const names = text.split('\n')
.map(n => n.trim())
.filter(n => n.length > 0)
if (names.length === 0) {
this.batchProcessList = []
return
}
//
const uniqueNames = [...new Set(names)]
//
this.batchProcessList = uniqueNames.map(name => {
const template = this.templateList.find(t =>
t.templateName === name || t.templateName.includes(name) || name.includes(t.templateName)
)
if (template) {
return {
processStep: name,
matched: true,
prodApproverName: template.prodApproverName,
prodApproverUserId: template.prodApproverUserId,
qaApproverName: template.qaApproverName,
qaApproverUserId: template.qaApproverUserId,
techApproverName: template.techApproverName,
techApproverUserId: template.techApproverUserId,
remark: template.remark || ''
}
}
return {
processStep: name,
matched: false,
prodApproverName: '',
prodApproverUserId: null,
qaApproverName: '',
qaApproverUserId: null,
techApproverName: '',
techApproverUserId: null,
remark: ''
}
})
},
/**
* 设置批量工序的负责人
*/
setBatchProcessApprovers(row, index) {
this.currentBatchIndex = index
this.isBatchMode = true
this.processDialogTitle = '设置负责人 - ' + row.processStep
this.isEditMode = false
this.processForm = {
processStep: row.processStep,
prodApproverName: row.prodApproverName || '',
prodApproverUserId: row.prodApproverUserId || null,
qaApproverName: row.qaApproverName || '',
qaApproverUserId: row.qaApproverUserId || null,
techApproverName: row.techApproverName || '',
techApproverUserId: row.techApproverUserId || null,
remark: row.remark || ''
}
this.processDialogVisible = true
},
/**
* 删除批量工序
*/
removeBatchProcess(index) {
this.batchProcessList.splice(index, 1)
},
/**
* 确认批量创建
*/
async confirmBatchCreate() {
const validList = this.batchProcessList.filter(item =>
item.prodApproverName && item.qaApproverName && item.techApproverName
)
if (validList.length === 0) {
this.$message.warning('请先设置所有工序的负责人')
return
}
this.batchCreating = true
let successCount = 0
for (const item of validList) {
try {
const {data} = await saveTriConfirmProcess({
site: this.$store.state.user.site,
applyNo: this.applyNo,
processStep: item.processStep,
prodApproverName: item.prodApproverName,
prodApproverUserId: item.prodApproverUserId,
qaApproverName: item.qaApproverName,
qaApproverUserId: item.qaApproverUserId,
techApproverName: item.techApproverName,
techApproverUserId: item.techApproverUserId,
remark: item.remark
})
if (data && data.code === 0) {
successCount++
}
} catch (error) {
console.error('创建工序失败:', error)
}
}
this.batchCreating = false
this.$message.success(`批量创建完成!成功 ${successCount}`)
this.batchAddDialogVisible = false
this.loadProcessList()
},
/** /**
* 打开修改弹框 * 打开修改弹框
*/ */
@ -843,6 +1098,27 @@ export default {
return return
} }
//
if (this.isBatchMode && this.currentBatchIndex >= 0) {
const item = this.batchProcessList[this.currentBatchIndex]
if (item) {
item.prodApproverName = this.processForm.prodApproverName
item.prodApproverUserId = this.processForm.prodApproverUserId
item.qaApproverName = this.processForm.qaApproverName
item.qaApproverUserId = this.processForm.qaApproverUserId
item.techApproverName = this.processForm.techApproverName
item.techApproverUserId = this.processForm.techApproverUserId
item.remark = this.processForm.remark || ''
item.matched = true
}
this.$message.success('设置成功')
this.processDialogVisible = false
this.isBatchMode = false
this.currentBatchIndex = -1
return
}
//
this.processSaving = true this.processSaving = true
saveTriConfirmProcess({ saveTriConfirmProcess({

3
src/views/modules/erf/expApplyList.vue

@ -1265,7 +1265,8 @@ export default {
'撤回': 'warning', '撤回': 'warning',
'提醒': 'info', '提醒': 'info',
'已排产': 'success', '已排产': 'success',
'录入最终结果': 'success'
'录入最终结果': 'success',
'样品确认': 'success',
} }
return types[action] || 'info' return types[action] || 'info'
}, },

Loading…
Cancel
Save