<template>
|
<div class="app-container">
|
<el-dialog
|
:title="dialogTitle"
|
:visible.sync="dialogVisible"
|
:close-on-click-modal="false"
|
width="90%"
|
top="5vh"
|
@close="handleClose"
|
>
|
<!-- 表单内容 -->
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-tabs v-model="activeTab">
|
<!-- 基本信息标签页 -->
|
<el-tab-pane label="基本信息" name="basic">
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="单据号" prop="HBillNo">
|
<el-input v-model="form.HBillNo" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="日期" prop="HDate">
|
<el-date-picker
|
v-model="form.HDate"
|
type="date"
|
placeholder="选择日期"
|
style="width: 100%"
|
value-format="yyyy-MM-dd"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="源单类型" prop="HSourceBillType">
|
<el-select v-model="form.HSourceBillType" placeholder="请选择源单类型" style="width: 100%">
|
<el-option
|
v-for="item in sourceBillTypes"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<!-- <el-col :span="8">
|
<el-form-item label="选单号">
|
<el-input v-model="form.sourceBillNo" placeholder="选单号" style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="handleSelectSourceBill">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col> -->
|
<el-col :span="8">
|
<el-form-item label="供应商" prop="supplier">
|
<el-input v-model="form.HSupName" placeholder="供应商" style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="showSupplierDialog">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="仓管员">
|
<el-input v-model="form.HEmpName" placeholder="仓管员" style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="showEmployeeDialog('Employee')">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="负责人">
|
<el-input v-model="form.HManagerName" placeholder="负责人" style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="showEmployeeDialog('manager')">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="调入仓库" prop="HWHID">
|
<el-input v-model="form.HWHName" placeholder="调入仓库" readonly style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="handleSelectInWarehouse">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="调出仓库" prop="HSCWHID">
|
<el-input v-model="form.HSCWHName" placeholder="调出仓库" readonly style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="handleSelectOutWarehouse">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="验收">
|
<el-input v-model="form.HSecManagerName" placeholder="验收" style="width: calc(100% - 50px)" />
|
<el-button type="primary" icon="el-icon-search" @click="showEmployeeDialog('inspector')">
|
</el-button>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="保管员">
|
<el-input v-model="form.HKeeperName" placeholder="保管员" style="width: calc(100% - 50px)" />
|
<el-button type="primary" icon="el-icon-search" @click="showEmployeeDialog('keeper')">
|
</el-button>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="部门" prop="HDeptID">
|
<el-input v-model="form.HDeptName" placeholder="部门" readonly style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="handleSelectDept">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<!-- <el-col :span="8">
|
<el-form-item label="项目代码">
|
<el-input v-model="form.HProNumber" placeholder="项目代码" readonly style="width: calc(100% - 50px)" />
|
<el-button type="primary" style="width: 40px; margin-left: 10px" @click="handleSelectProject">
|
<i class="el-icon-search"></i>
|
</el-button>
|
</el-form-item>
|
</el-col> -->
|
<!-- <el-col :span="8">
|
<el-form-item label="项目名称">
|
<el-input v-model="form.HProName" placeholder="项目名称" readonly />
|
</el-form-item>
|
</el-col> -->
|
<el-col :span="8">
|
<el-form-item label="备注">
|
<el-input v-model="form.HRemark" placeholder="备注" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<!-- 表格部分 -->
|
<div class="table-section">
|
<div class="table-toolbar">
|
<el-button size="mini" @click="handleAddLine">增加一行</el-button>
|
<el-button size="mini" @click="handleCopyLine">复制一行</el-button>
|
<el-button size="mini" @click="handleInventoryQuery">库存查询</el-button>
|
<el-button size="mini" @click="handleInOutQuery">出入库记录查询</el-button>
|
</div>
|
|
<el-table
|
:data="tableData"
|
border
|
style="width: 100%"
|
height="400"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="55" />
|
<el-table-column type="index" label="序号" width="60" />
|
<el-table-column prop="物料代码" label="物料代码" width="150">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.物料代码"
|
placeholder="物料代码"
|
@focus="handleMaterialFocus(scope.$index, scope.row)"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="物料名称" label="物料名称" width="150" />
|
<el-table-column prop="规格型号" label="规格型号" width="100" />
|
<el-table-column prop="计量单位" label="计量单位" width="100">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.计量单位"
|
placeholder="计量单位"
|
@focus="handleUnitFocus(scope.$index, scope.row)"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HQtyMust" label="应收数量" width="100">
|
<template slot-scope="scope">
|
<el-input-number
|
v-model="scope.row.HQtyMust"
|
:min="0"
|
:precision="2"
|
controls-position="right"
|
style="width: 100%"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HQty" label="实收数量" width="100">
|
<template slot-scope="scope">
|
<el-input-number
|
v-model="scope.row.HQty"
|
:min="0"
|
:precision="2"
|
controls-position="right"
|
style="width: 100%"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HPrice" label="单价" width="100">
|
<template slot-scope="scope">
|
<el-input-number
|
v-model="scope.row.HPrice"
|
:min="0"
|
:precision="2"
|
controls-position="right"
|
style="width: 100%"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HMoney" label="金额" width="100">
|
<template slot-scope="scope">
|
<el-input-number
|
v-model="scope.row.HMoney"
|
:min="0"
|
:precision="2"
|
controls-position="right"
|
style="width: 100%"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="调入仓库" label="调入仓库" width="150">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.调入仓库"
|
placeholder="调入仓库"
|
readonly
|
@focus="handleInWarehouseFocus(scope.$index, scope.row)"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="调出仓库" label="调出仓库" width="100">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.调出仓库"
|
placeholder="调出仓库"
|
readonly
|
@focus="handleOutWarehouseFocus(scope.$index, scope.row)"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HBatchNo" label="批次" width="100">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HBatchNo" placeholder="批次" />
|
</template>
|
</el-table-column>
|
<el-table-column prop="HRemark" label="备注" width="100">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HRemark" placeholder="备注" />
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="70" fixed="right">
|
<template slot-scope="scope">
|
<el-button size="mini" type="danger" @click="handleDeleteLine(scope.$index)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</el-tab-pane>
|
|
<!-- 制单信息标签页 -->
|
<el-tab-pane label="制单信息" name="maker">
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="制单人">
|
<el-input v-model="form.HMaker" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="审核人">
|
<el-input v-model="form.HChecker" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="关闭人">
|
<el-input v-model="form.HCloseMan" readonly />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="修改人">
|
<el-input v-model="form.HUpDater" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="作废人">
|
<el-input v-model="form.HDeleteMan" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="制单日期">
|
<el-input v-model="form.HMakeDate" readonly />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="审核日期">
|
<el-input v-model="form.HCheckDate" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="关闭日期">
|
<el-input v-model="form.HCloseDate" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="修改日期">
|
<el-input v-model="form.HUpDateDate" readonly />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="作废日期">
|
<el-input v-model="form.HDeleteDate" readonly />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
</el-tabs>
|
</el-form>
|
|
<!-- 底部按钮 -->
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="handleSave">保存</el-button>
|
<el-button @click="handleClose">退出</el-button>
|
</div>
|
</el-dialog>
|
|
<!-- 部门选择对话框 -->
|
<el-dialog
|
title="选择部门"
|
:visible.sync="deptVisible"
|
width="80%"
|
top="5vh"
|
@close="deptVisible = false"
|
>
|
<dept
|
ref="deptDialog"
|
@deptEmit="handleDeptSelect"
|
@deptEmitDb="handleDeptSelectDb"
|
/>
|
</el-dialog>
|
|
<!-- 仓库选择对话框 -->
|
<el-dialog
|
:visible.sync="warehouseVisible"
|
width="80%"
|
top="5vh"
|
@close="warehouseVisible = false"
|
>
|
<warehouse
|
ref="warehouseDialog"
|
:warehouse-type="warehouseType"
|
@deptEmit="handleWarehouseSelect"
|
@deptEmitDb="handleWarehouseSelectDb"
|
/>
|
</el-dialog>
|
|
<!-- 供应商弹窗 -->
|
<SupplierDialog
|
:visible.sync="supplierDialogVisible"
|
:dialog-type="currentDialogType"
|
@select="handleSupplierSelect"
|
/>
|
|
<!-- 职员弹窗 -->
|
<EmployeeDialog
|
:visible.sync="employeeDialogVisible"
|
:dialog-type="currentDialogType"
|
:dialog-title="employeeDialogTitle"
|
@select="handleEmployeeSelect"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import Dept from '@/views/component/dept'
|
import Warehouse from '@/views/component/warehouse'
|
import axios from 'axios'
|
import SupplierDialog from '@/views/FbStepFoldinBillList/SupplierDialog'
|
import EmployeeDialog from '@/views/FbStepFoldinBillList/EmployeeDialog'
|
export default {
|
name: 'FbStepFoldOutBillEdit',
|
components: {
|
Dept,
|
Warehouse,
|
SupplierDialog,
|
EmployeeDialog
|
},
|
props: {
|
visible: {
|
type: Boolean,
|
default: false
|
},
|
operationType: {
|
type: String,
|
default: '1' // 1:新增, 3:编辑
|
},
|
linterid: {
|
type: [String, Number],
|
default: ''
|
}
|
},
|
data() {
|
return {
|
dialogVisible: false,
|
activeTab: 'basic',
|
deptVisible: false,
|
warehouseVisible: false,
|
warehouseType: '',
|
currentRowIndex: null,
|
currentField: '',
|
sourceBillTypes: [
|
{ value: '1250', label: '分步式调出单' }
|
],
|
supplierDialogVisible: false,
|
employeeDialogVisible: false,
|
currentDialogType: '',
|
employeeDialogTitle: '选择职员',
|
form: {
|
HInterID: 0,
|
HBillNo: '',
|
HDate: '',
|
HSourceBillType: '',
|
sourceBillNo: '',
|
HSupName: '',
|
HSupID: 0,
|
HEmpName: '',
|
HEmpID: 0,
|
HManagerName: '',
|
HManagerID: 0,
|
HWHName: '',
|
HWHID: 0,
|
HSCWHName: '',
|
HSCWHID: 0,
|
HSecManagerName: '',
|
HSecManagerID: 0,
|
HKeeperName: '',
|
HKeeperID: 0,
|
HDeptName: '',
|
HDeptID: 0,
|
HProNumber: '',
|
HProName: '',
|
HProjectID: 0,
|
HRemark: '',
|
HMaker: '',
|
HChecker: '',
|
HCloseMan: '',
|
HUpDater: '',
|
HDeleteMan: '',
|
HMakeDate: '',
|
HCheckDate: '',
|
HCloseDate: '',
|
HUpDateDate: '',
|
HDeleteDate: '',
|
supplierId: '',
|
keeperId: '',
|
keeperName: '',
|
inspectorId: '',
|
inspectorName: '',
|
managerId: '',
|
managerName: ''
|
},
|
rules: {
|
HWHID: [{ required: true, message: '请选择调入仓库', trigger: 'change' }],
|
HSCWHID: [{ required: true, message: '请选择调出仓库', trigger: 'change' }],
|
HDeptID: [{ required: true, message: '请选择部门', trigger: 'change' }]
|
},
|
tableData: [
|
{
|
HMaterID: 0,
|
物料代码: '',
|
物料名称: '',
|
规格型号: '',
|
HUnitID: 0,
|
计量单位: '',
|
HSecUnitRate: '0',
|
HSecUnitID: '0',
|
辅助计量单位: '',
|
HQtyMust: 0,
|
HQty: 0,
|
HPrice: 0,
|
HMoney: 0,
|
HOrderPrice: 0,
|
HWHID: 0,
|
调入仓库: '',
|
HSCWHID: 0,
|
调出仓库: '',
|
HBatchNo: '',
|
HRemark: ''
|
}
|
],
|
selectedRows: [],
|
baseURL: process.env.VUE_APP_BASE_URL || 'http://47.96.97.237/API/'
|
}
|
},
|
computed: {
|
dialogTitle() {
|
return this.operationType === '1' ? '新增分步式调入单' : '编辑分步式调入单'
|
}
|
},
|
watch: {
|
visible: {
|
immediate: true,
|
handler(val) {
|
this.dialogVisible = val
|
if (val) {
|
this.initForm()
|
}
|
}
|
}
|
},
|
methods: {
|
// 初始化表单
|
initForm() {
|
console.log('当前操作类型:', this.operationType)
|
if (this.operationType === '1') {
|
// 新增
|
this.resetForm()
|
this.getMaxBillNo()
|
this.form.HMaker = sessionStorage['HUserName'] || 'admin'
|
this.form.HMakeDate = this.formatDate(new Date())
|
this.form.HDate = this.formatDate(new Date())
|
} else if (this.operationType === '3' ) {
|
console.log('编辑模式,无主id',this.linterid)
|
// 编辑
|
this.loadBillData(this.linterid)
|
}
|
},
|
|
// 重置表单
|
resetForm() {
|
this.form = {
|
HInterID: 0,
|
HBillNo: '',
|
HDate: '',
|
HSourceBillType: '',
|
sourceBillNo: '',
|
HSupName: '',
|
HSupID: 0,
|
HEmpName: '',
|
HEmpID: 0,
|
HManagerName: '',
|
HManagerID: 0,
|
HWHName: '',
|
HWHID: 0,
|
HSCWHName: '',
|
HSCWHID: 0,
|
HSecManagerName: '',
|
HSecManagerID: 0,
|
HKeeperName: '',
|
HKeeperID: 0,
|
HDeptName: '',
|
HDeptID: 0,
|
HProNumber: '',
|
HProName: '',
|
HProjectID: 0,
|
HRemark: '',
|
HMaker: '',
|
HChecker: '',
|
HCloseMan: '',
|
HUpDater: '',
|
HDeleteMan: '',
|
HMakeDate: '',
|
HCheckDate: '',
|
HCloseDate: '',
|
HUpDateDate: '',
|
HDeleteDate: ''
|
}
|
this.tableData = [{
|
HMaterID: 0,
|
物料代码: '',
|
物料名称: '',
|
规格型号: '',
|
HUnitID: 0,
|
计量单位: '',
|
HSecUnitRate: '0',
|
HSecUnitID: '0',
|
辅助计量单位: '',
|
HQtyMust: 0,
|
HQty: 0,
|
HPrice: 0,
|
HMoney: 0,
|
HOrderPrice: 0,
|
HWHID: 0,
|
调入仓库: '',
|
HSCWHID: 0,
|
调出仓库: '',
|
HBatchNo: '',
|
HRemark: ''
|
}]
|
},
|
|
// 获取最大单据号
|
async getMaxBillNo() {
|
try {
|
const response = await axios.get(`${this.baseURL}/Web/GetMAXNum`, {
|
params: { HBillType: '1251' }
|
})
|
if (response.data && response.data.data && response.data.data.length > 0) {
|
this.form.HBillNo = response.data.data[0].HBillNo
|
this.form.HInterID = response.data.data[0].HInterID
|
}
|
} catch (error) {
|
console.error('获取单据号失败:', error)
|
this.$message.error('获取单据号失败')
|
}
|
},
|
|
// 加载单据数据
|
async loadBillData(linterid) {
|
try {
|
const response = await axios.get(`${this.baseURL}/Kf_StepFoldOutBill/cx`, {
|
params: { HInterID: linterid }
|
})
|
console.log('编辑传入的主id:', linterid)
|
console.log('加载的单据数据:', response.data)
|
if (response.data.code == 1) {
|
const data = response.data.data[0]
|
console.log('单据头数据:', data)
|
Object.keys(this.form).forEach(key => {
|
if (data[key] !== undefined) {
|
this.form[key] = data[key]
|
}
|
})
|
this.form.HInterID = linterid;
|
this.HInterID=data.HInterID;
|
this.form.HBillNo = data.单据号
|
this.form.HDate = data.日期
|
this.form.HSourceBillType = '分布式调出单'
|
this.form.sourceBillNo = data.源单号
|
this.form.HSupName = data.供应商
|
this.form.HSupID = data.HSupID
|
this.form.HEmpName = data.仓管员
|
this.form.HEmpID = data.HEmpID
|
this.form.HManagerName = data.负责人
|
this.form.HManagerID = data.HManagerID
|
this.form.HWHName = data.调入仓库
|
this.form.HWHID = data.HWHID
|
this.form.HSCWHName = data.调出仓库
|
this.form.HSCWHID = data.HSCWHID
|
this.form.HSecManagerName = data.验收
|
this.form.HSecManagerID = data.HSecManagerID
|
this.form.HKeeperName = data.保管员
|
this.form.HKeeperID = data.HKeeperID
|
this.form.HDeptName = data.部门
|
this.form.HDeptID = data.HDeptID
|
this.form.HProNumber = data.项目代码
|
this.form.HProName = data.项目名称
|
this.form.HProjectID = data.HProjectID
|
this.form.HRemark = data.备注
|
this.form.HMaker = data.制单人
|
this.form.HChecker = data.审核人
|
this.form.HCloseMan = data.关闭人
|
this.form.HUpDater = data.修改人
|
this.form.HDeleteMan = data.作废人
|
this.form.HMakeDate = data.制单日期
|
this.form.HCheckDate = data.审核日期
|
this.form.HCloseDate = data.关闭日期
|
this.form.HUpDateDate = data.修改日期
|
this.form.HDeleteDate = data.作废日期
|
|
|
if (response.data.data.length > 0) {
|
this.tableData = response.data.data.map(item => ({
|
HMaterID: item.HMaterID,
|
物料代码: item.物料代码,
|
物料名称: item.物料名称,
|
规格型号: item.规格型号,
|
HUnitID: item.HUnitID,
|
计量单位: item.计量单位,
|
HQtyMust: item.应收数量,
|
HQty: item.实收数量,
|
HPrice: item.单价,
|
HMoney: item.金额,
|
HOrderPrice: item.采购金额,
|
HWHID: item.HWHID,
|
调入仓库: item.调入仓库,
|
HSCWHID: item.HSCWHID,
|
调出仓库: item.调出仓库,
|
HBatchNo: item.批次,
|
HRemark: item.表体备注
|
}))
|
}
|
} else {
|
this.$message.error(response.data.msg || '加载数据失败')
|
}
|
} catch (error) {
|
console.error('加载单据数据失败:', error)
|
this.$message.error('加载单据数据失败')
|
}
|
},
|
|
// 部门选择
|
handleSelectDept() {
|
console.log('打开部门选择')
|
this.deptVisible = true
|
},
|
|
// 调入仓库选择
|
handleSelectInWarehouse() {
|
console.log('打开调入仓库选择')
|
this.warehouseType = 'HWH'
|
this.warehouseVisible = true
|
this.currentField = 'inWarehouse'
|
},
|
|
// 调出仓库选择
|
handleSelectOutWarehouse() {
|
console.log('打开调入仓库选择')
|
this.warehouseType = 'HSCWH'
|
this.warehouseVisible = true
|
this.currentField = 'outWarehouse'
|
},
|
|
// 部门选择回调 - 单击
|
handleDeptSelect(selectedData) {
|
if (selectedData) {
|
this.form.HDeptName = selectedData.部门名称
|
this.form.HDeptID = selectedData.HItemID
|
this.deptVisible = false
|
}
|
},
|
|
// 部门选择回调 - 双击
|
handleDeptSelectDb(selectedData) {
|
this.handleDeptSelect(selectedData)
|
},
|
|
// 仓库选择回调 - 单击
|
handleWarehouseSelect(selectedData) {
|
if (selectedData) {
|
const warehouse = selectedData
|
if (this.currentField === 'inWarehouse') {
|
this.form.HWHName = warehouse.仓库名称
|
this.form.HWHID = warehouse.HItemID
|
} else if (this.currentField === 'outWarehouse') {
|
this.form.HSCWHName = warehouse.仓库名称
|
this.form.HSCWHID = warehouse.HItemID
|
} else if (this.currentField === 'tableInWarehouse') {
|
this.tableData[this.currentRowIndex].调入仓库 = warehouse.仓库名称
|
this.tableData[this.currentRowIndex].HWHID = warehouse.HItemID
|
} else if (this.currentField === 'tableOutWarehouse') {
|
this.tableData[this.currentRowIndex].调出仓库 = warehouse.仓库名称
|
this.tableData[this.currentRowIndex].HSCWHID = warehouse.HItemID
|
}
|
this.warehouseVisible = false
|
// 重置当前选择
|
this.currentRowIndex = null
|
this.currentField = ''
|
}
|
},
|
|
// 仓库选择回调 - 双击
|
handleWarehouseSelectDb(selectedData) {
|
this.handleWarehouseSelect(selectedData)
|
},
|
|
// 表格行仓库选择
|
handleInWarehouseFocus(index, row) {
|
this.currentRowIndex = index
|
this.warehouseType = 'HWH'
|
this.warehouseVisible = true
|
this.currentField = 'tableInWarehouse'
|
},
|
|
handleOutWarehouseFocus(index, row) {
|
this.currentRowIndex = index
|
this.warehouseType = 'HSCWH'
|
this.warehouseVisible = true
|
this.currentField = 'tableOutWarehouse'
|
},
|
showSupplierDialog() {
|
this.currentDialogType = 'supplier'
|
this.supplierDialogVisible = true
|
},
|
// 显示职员弹窗
|
showEmployeeDialog(type) {
|
this.currentDialogType = type
|
const titleMap = {
|
keeper: '选择保管员',
|
inspector: '选择验收员',
|
manager: '选择负责人',
|
worker: '选择负责人',
|
Employee: '选择仓管员'
|
}
|
this.employeeDialogTitle = titleMap[type] || '选择职员'
|
this.employeeDialogVisible = true
|
},
|
handleEmployeeSelect(data, type) {
|
const fieldMap = {
|
keeper: { id: 'HkeeperId', name: 'HkeeperName' },
|
inspector: { id: 'HSecManagerID', name: 'HSecManagerName' },
|
manager: { id: 'HManagerID', name: 'HManagerName' },
|
Employee: { id: 'HEmpID', name: 'HEmpName' }
|
}
|
|
const field = fieldMap[type]
|
if (field) {
|
this.form[field.id] = data.HItemID
|
this.form[field.name] = data.职员名称 || data.职员代码
|
}
|
console.log(`选择的${type}:`, data)
|
},
|
|
|
handleSupplierSelect(data, type) {
|
this.form.HSupID = data.HItemID
|
this.form.HSupName = data.供应商名称 || data.供应商代码
|
console.log('选择的供应商:', data)
|
},
|
|
|
// 表格操作
|
handleAddLine() {
|
this.tableData.push({
|
HMaterID: 0,
|
物料代码: '',
|
物料名称: '',
|
规格型号: '',
|
HUnitID: 0,
|
计量单位: '',
|
HSecUnitRate: '0',
|
HSecUnitID: '0',
|
辅助计量单位: '',
|
HQtyMust: 0,
|
HQty: 0,
|
HPrice: 0,
|
HMoney: 0,
|
HOrderPrice: 0,
|
HWHID: 0,
|
调入仓库: '',
|
HSCWHID: 0,
|
调出仓库: '',
|
HBatchNo: '',
|
HRemark: ''
|
})
|
},
|
|
handleCopyLine() {
|
if (this.selectedRows.length === 1) {
|
const copyData = JSON.parse(JSON.stringify(this.selectedRows[0]))
|
this.tableData.push(copyData)
|
} else {
|
this.$message.warning('请选择一行数据进行复制')
|
}
|
},
|
|
handleDeleteLine(index) {
|
if (this.tableData.length > 1) {
|
this.tableData.splice(index, 1)
|
} else {
|
this.$message.warning('至少保留一行数据')
|
}
|
},
|
|
handleSelectionChange(selection) {
|
this.selectedRows = selection
|
},
|
|
handleInventoryQuery() {
|
this.$message.info('库存查询功能待实现')
|
},
|
|
handleInOutQuery() {
|
this.$message.info('出入库记录查询功能待实现')
|
},
|
|
// 保存
|
async handleSave() {
|
try {
|
await this.$refs.form.validate()
|
// 确保关键字段有值
|
if (!this.form.HWHID || this.form.HWHID === 0) {
|
this.$message.error('请选择调入仓库')
|
return
|
}
|
if (!this.form.HSCWHID || this.form.HSCWHID === 0) {
|
this.$message.error('请选择调出仓库')
|
return
|
}
|
if (!this.form.HDeptID || this.form.HDeptID === 0) {
|
this.$message.error('请选择部门')
|
return
|
}
|
|
// 确保表格数据中的仓库ID也有值
|
const hasValidTableData = this.tableData.every(row =>
|
row.HMaterID && row.HMaterID !== 0 &&
|
row.HUnitID && row.HUnitID !== 0
|
)
|
|
if (!hasValidTableData) {
|
// this.$message.error('请完善表格中的物料和单位信息')
|
// return
|
this.tableData=[];
|
}
|
// const formData = {
|
// mainData: JSON.stringify([this.form]), // 主表数据,包装成数组
|
// tableData: JSON.stringify(this.tableData), // 子表数据
|
// operationType: this.operationType,
|
// user: sessionStorage['HUserName'] || 'admin',
|
// allData: JSON.stringify({ // 主表+子表所有数据
|
// main: this.form,
|
// table: this.tableData
|
// })
|
// }
|
//const formData=JSON.stringify(this.form)+';'+JSON.stringify(this.tableData)+';'+this.operationType+';'+(sessionStorage['HUserName'] || 'admin');
|
const submitData =
|
JSON.stringify(this.form) + ';' +
|
JSON.stringify(this.tableData) + ';' +
|
this.operationType + ';' +
|
(sessionStorage['HUserName'] || 'admin') + ';' +
|
JSON.stringify({ main: this.form, table: this.tableData })
|
console.log('提交的完整数据:', submitData)
|
|
const response = await axios.post(`${this.baseURL}/Kf_StepFoldOutBill/Kf_StepFoldOutBillEdit`, {
|
sMainSub: submitData
|
})
|
|
if (response.data && response.data.count === 1) {
|
this.$message.success(response.data.Message || '保存成功')
|
this.handleClose()
|
this.$emit('saved')
|
} else {
|
this.$message.error(response.data.Message || '保存失败')
|
}
|
} catch (error) {
|
console.error('保存失败:', error)
|
if (error.response && error.response.data) {
|
this.$message.error(error.response.data.Message || '保存失败')
|
} else {
|
this.$message.error('保存失败')
|
}
|
}
|
},
|
|
// 关闭
|
handleClose() {
|
this.dialogVisible = false
|
this.$emit('update:visible', false)
|
this.$emit('closed')
|
},
|
|
// 工具方法
|
formatDate(date) {
|
if (!date) return ''
|
const d = new Date(date)
|
const year = d.getFullYear()
|
const month = String(d.getMonth() + 1).padStart(2, '0')
|
const day = String(d.getDate()).padStart(2, '0')
|
return `${year}-${month}-${day}`
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.app-container {
|
padding: 0;
|
}
|
|
.dialog-footer {
|
text-align: center;
|
padding: 20px 0 0;
|
}
|
|
.table-section {
|
margin-top: 20px;
|
border: 1px solid #e6ebf5;
|
border-radius: 4px;
|
padding: 10px;
|
}
|
|
.table-toolbar {
|
margin-bottom: 10px;
|
}
|
|
.el-form-item {
|
margin-bottom: 18px;
|
}
|
|
.el-tabs {
|
margin-top: -20px;
|
}
|
|
.el-table {
|
margin-top: 10px;
|
}
|
|
.el-input-number {
|
width: 100%;
|
}
|
</style>
|