添加 出库单据出口选择 盘点单据粗口选择功能
This commit is contained in:
@@ -195,6 +195,26 @@
|
||||
:limit.sync="detailQueryParams.pageSize"
|
||||
@pagination="getDetailList"
|
||||
/>
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<el-dialog :title="$t('outStockoutManage.auditTitle')" :visible.sync="auditDialogVisible" width="400px" append-to-body>
|
||||
<el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="80px">
|
||||
<el-form-item :label="$t('outStockoutManage.selectExit')" prop="exitId">
|
||||
<el-select v-model="auditForm.exitId" :placeholder="$t('outStockoutManage.pleaseSelectExit')" clearable>
|
||||
<el-option
|
||||
v-for="item in exitOptions"
|
||||
:key="item.exitId"
|
||||
:label="item.exitName"
|
||||
:value="item.exitId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitAudit">{{$t('outStockoutManage.confirmExit')}}</el-button>
|
||||
<el-button @click="cancelAudit">{{$t('outStockoutManage.cancelExit')}}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -222,6 +242,40 @@ export default {
|
||||
outStockDetailList: [],
|
||||
// 选中数据
|
||||
selectedRows: [],
|
||||
// 审核弹窗显示状态
|
||||
auditDialogVisible: false,
|
||||
// 审核表单数据
|
||||
auditForm: {
|
||||
exitId: null
|
||||
},
|
||||
// 审核表单验证规则
|
||||
auditRules: {
|
||||
exitId: [
|
||||
{ required: true, message: '请选择出口', trigger: 'change' }
|
||||
]
|
||||
},
|
||||
// 出口选项
|
||||
exitOptions: [],
|
||||
// 所有出口数据(按仓库ID分组)
|
||||
allExitOptions: {
|
||||
'02': [
|
||||
{ exitId: "G1004", exitName: 'G1004' },
|
||||
{ exitId: 'G1010', exitName: 'G1010' },
|
||||
{ exitId: 'fluent1', exitName: 'fluent1' },
|
||||
{ exitId: 'fluent2', exitName: 'fluent2' },
|
||||
],
|
||||
'13': [
|
||||
{ exitId: 'G2001', exitName: 'G2001' },
|
||||
{ exitId: 'G3001', exitName: 'G3001' },
|
||||
{ exitId: 'G3010', exitName: 'G3010' },
|
||||
{ exitId: 'G4001', exitName: 'G4001' },
|
||||
{ exitId: 'G4010', exitName: 'G4010' },
|
||||
{ exitId: 'G5001', exitName: 'G5001' },
|
||||
{ exitId: 'G5010', exitName: 'G5010' },
|
||||
]
|
||||
},
|
||||
// 当前审核状态
|
||||
currentAuditStatus: null,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@@ -320,6 +374,17 @@ export default {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是审核操作(status=2),显示弹窗选择出口
|
||||
if (status === 2) {
|
||||
this.currentAuditStatus = status
|
||||
// 根据选中单据的仓库ID设置出口选项
|
||||
this.setExitOptionsByWarehouse()
|
||||
this.auditDialogVisible = true
|
||||
this.auditForm.exitId = null
|
||||
return
|
||||
}
|
||||
|
||||
const params = {
|
||||
stockoutIds: this.selectedRows.map(row => row.stockoutId),
|
||||
status: this.selectedRows[0].status,
|
||||
@@ -367,6 +432,79 @@ export default {
|
||||
const stockoutIds = this.selectedRows.map(row => row.stockoutId)
|
||||
// TODO: 调用手动分配接口
|
||||
console.log("手动分配:", stockoutIds)
|
||||
},
|
||||
|
||||
/** 提交审核 */
|
||||
submitAudit() {
|
||||
this.$refs["auditForm"].validate(valid => {
|
||||
if (valid) {
|
||||
const params = {
|
||||
stockoutIds: this.selectedRows.map(row => row.stockoutId),
|
||||
status: this.selectedRows[0].status,
|
||||
newStatus: this.currentAuditStatus,
|
||||
exitId: this.auditForm.exitId
|
||||
}
|
||||
console.log("单据状态修改(含出口信息):", params)
|
||||
|
||||
//调用单据状态改变接口
|
||||
updateOutStockStatus(params).then(response => {
|
||||
this.$modal.msgSuccess(response)
|
||||
this.auditDialogVisible = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/** 取消审核 */
|
||||
cancelAudit() {
|
||||
this.auditDialogVisible = false
|
||||
this.auditForm.exitId = null
|
||||
this.currentAuditStatus = null
|
||||
},
|
||||
|
||||
/** 根据仓库ID设置出口选项 */
|
||||
setExitOptionsByWarehouse() {
|
||||
try {
|
||||
// 获取选中单据的仓库ID集合,过滤掉空值和无效值
|
||||
const warehouseIds = [...new Set(
|
||||
this.selectedRows
|
||||
.map(row => row.warehouseId)
|
||||
.filter(id => id !== null && id !== undefined && id !== '')
|
||||
)]
|
||||
|
||||
console.log("仓库ID集合:", warehouseIds)
|
||||
|
||||
// 如果没有有效的仓库ID,清空出口选项
|
||||
if (warehouseIds.length === 0) {
|
||||
this.exitOptions = []
|
||||
console.warn('没有找到有效的仓库ID,已清空出口选项')
|
||||
return
|
||||
}
|
||||
|
||||
if (warehouseIds.length === 1) {
|
||||
// 如果所有选中单据都是同一个仓库,显示该仓库的出口
|
||||
const warehouseId = warehouseIds[0]
|
||||
this.exitOptions = this.allExitOptions[warehouseId] || []
|
||||
|
||||
// 如果没有对应key的默认为空数组,并给出提示
|
||||
if (!this.allExitOptions[warehouseId]) {
|
||||
console.warn(`仓库ID ${warehouseId} 没有配置出口选项,已设置为空数组`)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('选中仓库ID:', warehouseIds, '可用出口:', this.exitOptions)
|
||||
|
||||
// 如果最终没有可用的出口选项,给出提示
|
||||
if (this.exitOptions.length === 0) {
|
||||
this.exitOptions=[{exitId: '0', exitName: '人工出口'}]
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('设置出口选项时发生错误:', error)
|
||||
// 发生错误时,设置为空数组,确保不会影响用户操作
|
||||
this.exitOptions = []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user