diff --git a/src/views/modules/erf/components/expTriConfirm.vue b/src/views/modules/erf/components/expTriConfirm.vue index 2cdeef2..c2a73a5 100644 --- a/src/views/modules/erf/components/expTriConfirm.vue +++ b/src/views/modules/erf/components/expTriConfirm.vue @@ -3,6 +3,7 @@
新增 + 批量新增
可以拖拽调整工序顺序 @@ -347,6 +348,88 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 取消 + + 批量创建({{ validBatchCount }}个) + +
+
+ + item.prodApproverName && item.qaApproverName && item.techApproverName + ).length } }, @@ -502,6 +602,14 @@ export default { this.loadProcessList() } } + }, + + // 监听弹框关闭,重置批量模式 + processDialogVisible(val) { + if (!val) { + this.isBatchMode = false + this.currentBatchIndex = -1 + } } }, @@ -628,6 +736,153 @@ export default { 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 } + // 批量模式:只更新列表,不保存 + 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 saveTriConfirmProcess({ diff --git a/src/views/modules/erf/expApplyList.vue b/src/views/modules/erf/expApplyList.vue index c0a706f..467935a 100644 --- a/src/views/modules/erf/expApplyList.vue +++ b/src/views/modules/erf/expApplyList.vue @@ -1265,7 +1265,8 @@ export default { '撤回': 'warning', '提醒': 'info', '已排产': 'success', - '录入最终结果': 'success' + '录入最终结果': 'success', + '样品确认': 'success', } return types[action] || 'info' },