552 lines
20 KiB
Vue
552 lines
20 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<!-- 主表信息录入 -->
|
|
<el-form :model="formData" ref="formRef" size="small" :inline="true" label-width="68px" :rules="rules">
|
|
<!-- <el-form-item :label="'仓库'" prop="warehouseId" required><!–仓库–>
|
|
<el-select v-model="formData.warehouseId" :placeholder="'请选择仓库'" clearable>
|
|
<el-option
|
|
v-for="dict in warehouseOptions"
|
|
:key="dict.warehouseId"
|
|
:label="dict.warehouseName"
|
|
:value="dict.warehouseId"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>-->
|
|
<el-form-item label="项目号" prop="departmentNo">
|
|
<el-input v-model="formData.departmentNo" placeholder="请输入项目号"/>
|
|
</el-form-item>
|
|
<el-form-item :label="'单据类型'" prop="outType" required><!--单据类型-->
|
|
<el-select v-model="formData.outType" :placeholder="'请选择单据类型'" clearable>
|
|
<el-option
|
|
v-for="dict in dict.type.out_bill_type"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="'出库方式'" prop="carNumber" required><!--出库方式-->
|
|
<el-select v-model="formData.carNumber" :placeholder="'请选择出库方式'" clearable>
|
|
<el-option
|
|
v-for="dict in dict.type.out_method"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="'客商'" prop="customerNo" required><!--客商-->
|
|
<el-input
|
|
v-model="formData.classNowId"
|
|
:placeholder="'请输入客商编号'"
|
|
clearable
|
|
@click.native="openCustomerSelector"
|
|
readonly
|
|
/>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="备注" prop="spare5">
|
|
<el-input v-model="formData.spare5" placeholder="请输入备注"/>
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
<el-button type="warning" icon="el-icon-refresh" size="mini" @click="reset">{{'重置'}}<!--重置--></el-button>
|
|
<el-button type="success" icon="el-icon-check" size="mini" @click="handleSave" v-hasPermi="['out:outStockout:saveBill']">{{'保存单据'}}<!--保存单据--></el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<div class="mb8">
|
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleSelectMaterials" v-hasPermi="['out:productAndStock:list']">{{'选择存货'}}<!--选择物资--></el-button>
|
|
<el-button type="info" icon="el-icon-refresh-right" size="mini" @click="handleReload">{{'重新建单'}}<!--重新建单--></el-button>
|
|
</div>
|
|
|
|
<!-- 物资明细表格 -->
|
|
<el-table v-loading="loading" :data="materialList">
|
|
<el-table-column label="存货编码" align="center" prop="productId" /><!--物资编号-->
|
|
<el-table-column label="存货名称" align="center" prop="productName" /><!--品名-->
|
|
<el-table-column label="批次号" align="center" prop="lotNo" />
|
|
<el-table-column label="仓库编码" align="center" prop="warehouseId" />
|
|
<el-table-column label="层级关系" align="center" prop="spare1" />
|
|
<el-table-column label="上层物料" align="center" prop="spare2" />
|
|
<el-table-column label="顶层物料" align="center" prop="spare3" />
|
|
<el-table-column label="项目号" align="center" prop="spare4" />
|
|
<el-table-column label="合同号" align="center" prop="spare5" />
|
|
<el-table-column label="销售订单号" align="center" prop="spare6" />
|
|
<el-table-column label="供应商编码" align="center" prop="fid" />
|
|
<el-table-column label="规格型号" align="center" prop="spec" />
|
|
<el-table-column label="计量单位" align="center" prop="unit" />
|
|
<el-table-column :label="'数量'" align="center" prop="quantity" width="150"><!--数量-->
|
|
<template slot-scope="scope">
|
|
<el-input-number v-model="scope.row.quantity" :min="1" size="mini" @change="handleQuantityChange(scope.row)" />
|
|
</template>
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column :label="'操作'" align="center" class-name="small-padding fixed-width"><!--操作-->
|
|
<template slot-scope="scope">
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.$index)">{{'删除'}}<!--删除--></el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<!-- 选择存货弹窗 -->
|
|
<el-dialog :title="'选择存货'" :visible.sync="materialDialog" width="70%" append-to-body><!--选择存货-->
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
|
|
|
|
<el-form-item label="存货编码" prop="productId"><!--品号-->
|
|
<el-input
|
|
v-model="queryParams.productId"
|
|
:placeholder="'请输入存货编码'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="存货名称" prop="productName"><!--品名-->
|
|
<el-input
|
|
v-model="queryParams.productName"
|
|
:placeholder="'请输入存货名称'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="层级关系" prop="spare1"><!--品名-->
|
|
<el-input
|
|
v-model="queryParams.spare1"
|
|
:placeholder="'请输入层级关系'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="上层物料" prop="spare2"><!--品名-->
|
|
<el-input
|
|
v-model="queryParams.spare2"
|
|
:placeholder="'请输入上层物料'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="顶层物料" prop="spare3"><!--品名-->
|
|
<el-input
|
|
v-model="queryParams.spare3"
|
|
:placeholder="'请输入顶层物料'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="规格型号" prop="power"><!--品名-->
|
|
<el-input
|
|
v-model="queryParams.power"
|
|
:placeholder="'请输入规格型号'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="计量单位" prop="phase"><!--品名-->
|
|
<el-input
|
|
v-model="queryParams.phase"
|
|
:placeholder="'请输入计量单位'"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{'搜索'}}<!--搜索--></el-button>
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置<!--重置--></el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<el-table v-loading="materialLoading" :data="materialOptions" @selection-change="handleSelectionChange">
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
<el-table-column label="序号" align="center" prop="onlyIdentity" />
|
|
<el-table-column label="存货编码" align="center" prop="productId" />
|
|
<el-table-column label="批号" align="center" prop="lotNo" />
|
|
<el-table-column label="存货名称" align="center" prop="productName" />
|
|
<el-table-column label="库存数量" align="center" prop="quantity" />
|
|
<el-table-column label="仓库编码" align="center" prop="warehouseId" />
|
|
<el-table-column label="供应商名称" align="center" prop="stackingId" />
|
|
<el-table-column label="层级关系" align="center" prop="spare1" />
|
|
<el-table-column label="上层物料" align="center" prop="spare2" />
|
|
<el-table-column label="顶层物料" align="center" prop="spare3" />
|
|
<el-table-column label="项目号" align="center" prop="spare4" />
|
|
<el-table-column label="合同号" align="center" prop="spare5" />
|
|
<el-table-column label="销售订单号" align="center" prop="spare6" />
|
|
<el-table-column label="供应商编码" align="center" prop="voltage" />
|
|
<el-table-column label="规格型号" align="center" prop="power" />
|
|
<el-table-column label="计量单位" align="center" prop="phase" />
|
|
</el-table>
|
|
|
|
<pagination
|
|
v-show="total > 0"
|
|
:total="total"
|
|
:page.sync="queryParams.pageNum"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getMaterialList"
|
|
/>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="confirmSelectMaterials">{{'确定'}}<!--确 定--></el-button>
|
|
<el-button @click="cancelSelectMaterials">{{'取消'}}<!--取 消--></el-button>
|
|
</div>
|
|
</el-dialog>
|
|
|
|
<!-- 选择客商弹窗 -->
|
|
<el-dialog :title="'客商管理'" :visible.sync="customerDialog" width="70%" append-to-body>
|
|
<el-form :model="customerQueryParams" ref="customerQueryForm" size="small" :inline="true" label-width="100px">
|
|
<el-form-item :label="'客商编号'" prop="customerNo"><!--客商编号-->
|
|
<el-input
|
|
v-model="customerQueryParams.customerNo"
|
|
:placeholder="'请输入客商编号'"
|
|
clearable
|
|
@keyup.enter.native="handleCustomerQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item :label="'客商名称'" prop="customerName"><!--客商名称-->
|
|
<el-input
|
|
v-model="customerQueryParams.customerName"
|
|
:placeholder="'请输入客商名称'"
|
|
clearable
|
|
@keyup.enter.native="handleCustomerQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleCustomerQuery">搜索<!--搜索--></el-button>
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetCustomerQuery">重置<!--重置--></el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<el-table ref="customerTable" v-loading="customerLoading" :data="customerList" @row-click="handleCustomerRowClick" highlight-current-row>
|
|
<el-table-column :label="'客商编号'" align="left" prop="customerNo" /><!--客商编号-->
|
|
<el-table-column :label="'客商名称'" align="left" prop="customerName" /><!--客商名称-->
|
|
<!-- <el-table-column :label="$t('basCustomer.simpleName')" align="left" prop="simpleName" />客商简称 -->
|
|
<el-table-column :label="'是否可用'" align="left" prop="useable">
|
|
<template slot-scope="scope">
|
|
<dict-tag :options="dict.type.is_available" :value="scope.row.useable"/>
|
|
</template>
|
|
</el-table-column><!--是否可用-->
|
|
</el-table>
|
|
|
|
<pagination
|
|
v-show="customerTotal > 0"
|
|
:total="customerTotal"
|
|
:page.sync="customerQueryParams.pageNum"
|
|
:limit.sync="customerQueryParams.pageSize"
|
|
@pagination="getCustomerList"
|
|
/>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="confirmSelectCustomer">确定<!--确 定--></el-button>
|
|
<el-button @click="cancelSelectCustomer">取消<!--取 消--></el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { listProductAndStock,saveOutStock } from "@/api/out/outStockout";
|
|
import {listWarehouse} from "@/api/bas/warehouse";
|
|
import { listBasCustomer } from "@/api/bas/BasCustomer";
|
|
import Pagination from "@/components/Pagination";
|
|
|
|
export default {
|
|
name: "AddOutStock",
|
|
dicts: ['out_bill_type', 'bill_status', 'is_available','out_method'],
|
|
components: {
|
|
Pagination
|
|
},
|
|
data() {
|
|
return {
|
|
// 遮罩层
|
|
loading: false,
|
|
materialLoading: false,
|
|
customerLoading: false,
|
|
// 总条数
|
|
total: 0,
|
|
customerTotal: 0,
|
|
// 表单验证规则
|
|
rules: {
|
|
// warehouseId: [
|
|
// { required: true, message: '请选择仓库', trigger: "change" }
|
|
// ],
|
|
customerNo: [
|
|
{ required: true, message: '请输入客商编号', trigger: "blur" }
|
|
],
|
|
outType: [
|
|
{ required: true, message: '请选择单据类型', trigger: "change" }
|
|
],
|
|
outMethod: [
|
|
{ required: true, message: '请选择出库方式', trigger: "change" }
|
|
],
|
|
departmentNo: [
|
|
{ required: true, message: '请输入项目号', trigger: "change" }
|
|
]
|
|
},
|
|
// 主表数据
|
|
formData: {
|
|
warehouseId: null,
|
|
customerNo: null,
|
|
customerName: null, // 添加客商名称字段,用于显示
|
|
outType: null,
|
|
carNumber:null,
|
|
departmentNo:null,
|
|
classNowId:null,
|
|
spare5:null
|
|
},
|
|
// 仓库选项
|
|
warehouseOptions: [],
|
|
// 物资明细列表
|
|
materialList: [],
|
|
// 选择存货弹窗
|
|
materialDialog: false,
|
|
// 物资选项数据
|
|
materialOptions: [],
|
|
// 已选择的物资
|
|
selectedMaterials: [],
|
|
// 查询参数
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
onlyIdentity: null,
|
|
productId: null,
|
|
lotNo: null,
|
|
productName: null,
|
|
quantity: null,
|
|
warehouseId: null,
|
|
spare1: null,
|
|
spare3: null,
|
|
spare4: null,
|
|
spare5: null,
|
|
spare6: null,
|
|
voltage: null,
|
|
power: null,
|
|
phase: null,
|
|
netWeight: null,
|
|
grossWeight: null,
|
|
distribution: null,
|
|
model: null,
|
|
orderId: null
|
|
},
|
|
// 客商选择弹窗
|
|
customerDialog: false,
|
|
// 客商列表数据
|
|
customerList: [],
|
|
// 当前选中的客商
|
|
selectedCustomer: null,
|
|
// 客商查询参数
|
|
customerQueryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
customerNo: null,
|
|
customerName: null,
|
|
useable: '1' // 默认只查询可用的客商
|
|
}
|
|
};
|
|
},
|
|
created() {
|
|
this.getWarehouseOptions();
|
|
},
|
|
methods: {
|
|
/** 获取仓库选项 */
|
|
getWarehouseOptions() {
|
|
|
|
listWarehouse({
|
|
pageNum: 1,
|
|
pageSize: 100
|
|
}).then(response => {
|
|
this.warehouseOptions = response.rows;
|
|
});
|
|
},
|
|
/** 打开客商选择弹窗 */
|
|
openCustomerSelector() {
|
|
this.customerDialog = true;
|
|
this.getCustomerList();
|
|
},
|
|
/** 获取客商列表 */
|
|
getCustomerList() {
|
|
this.customerLoading = true;
|
|
listBasCustomer(this.customerQueryParams).then(response => {
|
|
this.customerList = response.rows;
|
|
this.customerTotal = response.total;
|
|
this.customerLoading = false;
|
|
});
|
|
},
|
|
/** 客商搜索按钮操作 */
|
|
handleCustomerQuery() {
|
|
this.customerQueryParams.pageNum = 1;
|
|
this.getCustomerList();
|
|
},
|
|
/** 客商重置按钮操作 */
|
|
resetCustomerQuery() {
|
|
this.resetForm("customerQueryForm");
|
|
this.customerQueryParams.useable = '1'; // 保持默认只查询可用的客商
|
|
this.handleCustomerQuery();
|
|
},
|
|
/** 客商行点击事件 */
|
|
handleCustomerRowClick(row) {
|
|
this.selectedCustomer = row;
|
|
this.$refs['customerTable']?.setCurrentRow(row);
|
|
},
|
|
/** 确认选择客商 */
|
|
confirmSelectCustomer() {
|
|
if (!this.selectedCustomer) {
|
|
this.$modal.msgError('请选择客商');
|
|
return;
|
|
}
|
|
this.formData.customerNo = this.selectedCustomer.customerNo;
|
|
this.formData.classNowId = this.selectedCustomer.customerName;
|
|
this.customerDialog = false;
|
|
},
|
|
/** 取消选择客商 */
|
|
cancelSelectCustomer() {
|
|
this.selectedCustomer = null;
|
|
this.customerDialog = false;
|
|
},
|
|
/** 打开选择存货弹窗 */
|
|
handleSelectMaterials() {
|
|
/*if (!this.formData.warehouseId) {
|
|
this.$modal.msgError('请选择仓库');
|
|
return;
|
|
}*/
|
|
if (!this.formData.departmentNo) {
|
|
this.$modal.msgError('请输入项目号');
|
|
return;
|
|
}
|
|
this.materialDialog = true;
|
|
this.queryParams.warehouseId = this.formData.warehouseId;
|
|
this.queryParams.spare4 = this.formData.departmentNo;
|
|
this.getMaterialList();
|
|
},
|
|
/** 获取物资列表 */
|
|
getMaterialList() {
|
|
this.materialLoading = true;
|
|
listProductAndStock(this.queryParams).then(response => {
|
|
this.materialOptions = response.rows;
|
|
this.total = response.total;
|
|
this.materialLoading = false;
|
|
});
|
|
},
|
|
/** 物资选择变更 */
|
|
handleSelectionChange(selection) {
|
|
this.selectedMaterials = selection;
|
|
},
|
|
/** 确认选择存货 */
|
|
confirmSelectMaterials() {
|
|
if (this.selectedMaterials.length === 0) {
|
|
this.$modal.msgError('请选择存货');
|
|
return;
|
|
}
|
|
// 过滤掉已经存在的物资
|
|
const newMaterials = this.selectedMaterials.filter(item => {
|
|
return !this.materialList.some(existing => existing.onlyIdentity === item.onlyIdentity);
|
|
});
|
|
|
|
if (newMaterials.length === 0) {
|
|
this.$modal.msgWarning('选择的物资已存在');
|
|
return;
|
|
}
|
|
|
|
this.materialList = this.materialList.concat(
|
|
newMaterials.map(item => ({
|
|
productId: item.productId,
|
|
productName: item.productName,
|
|
quantity: item.quantity,
|
|
quantityOrignal: item.quantity,
|
|
fid: item.voltage,
|
|
unit: item.phase,
|
|
spec: item.power,
|
|
lotNo: item.lotNo,
|
|
warehouseId: item.warehouseId,
|
|
spare1: item.spare1,
|
|
spare2: item.spare2,
|
|
spare3: item.spare3,
|
|
spare4: item.spare4,
|
|
spare5: item.spare5,
|
|
spare6: item.spare6,
|
|
}))
|
|
);
|
|
this.materialDialog = false;
|
|
this.selectedMaterials = [];
|
|
},
|
|
/** 取消选择存货 */
|
|
cancelSelectMaterials() {
|
|
this.selectedMaterials = [];
|
|
this.materialDialog = false;
|
|
},
|
|
/** 搜索按钮操作 */
|
|
handleQuery() {
|
|
this.queryParams.pageNum = 1;
|
|
this.getMaterialList();
|
|
},
|
|
/** 重置按钮操作 */
|
|
resetQuery() {
|
|
this.resetForm("queryForm");
|
|
this.handleQuery();
|
|
},
|
|
/** 删除物资 */
|
|
handleDelete(index) {
|
|
this.materialList.splice(index, 1);
|
|
},
|
|
/** 数量变更 */
|
|
handleQuantityChange(row) {
|
|
// 如果没有初始数量,则设置初始数量
|
|
console.log(row.quantityOrignal)
|
|
// 如果修改后的数量大于初始数量,给出提示并重置为当前值
|
|
if (row.quantity > row.quantityOrignal) {
|
|
this.$modal.msgError('修改后的数量不能大于初始数量');
|
|
// 使用 $nextTick 确保在下一个 DOM 更新周期中重置数量
|
|
this.$nextTick(() => {
|
|
this.$set(row, 'quantity', row.quantityOrignal);
|
|
});
|
|
}
|
|
},
|
|
/** 保存单据 */
|
|
handleSave() {
|
|
this.$refs.formRef.validate(valid => {
|
|
if (valid) {
|
|
if (this.materialList.length === 0) {
|
|
this.$modal.msgError('请选择存货选择存货');
|
|
return;
|
|
}
|
|
const data = {
|
|
outStockout: this.formData,
|
|
detailList: this.materialList
|
|
};
|
|
// 这里需要调用保存接口
|
|
saveOutStock(data).then(response => {
|
|
console.log(response)
|
|
this.$modal.msgSuccess('操作成功'+":"+response.msg);
|
|
this.$tab.refreshPage(this.$route);
|
|
// this.reset();
|
|
});
|
|
}
|
|
});
|
|
},
|
|
/** 重置数据 */
|
|
reset() {
|
|
this.formData = {
|
|
// warehouseId: null,
|
|
customerNo: null,
|
|
customerName: null,
|
|
outType: null
|
|
};
|
|
this.materialList = [];
|
|
this.selectedCustomer = null;
|
|
},
|
|
/** 重新建单 */
|
|
handleReload() {
|
|
this.$tab.refreshPage(this.$route);
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
<style scoped>
|
|
.el-table >>> .current-row {
|
|
background-color: #f0f9eb;
|
|
}
|
|
.el-form-item >>> .el-form-item__label {
|
|
white-space: nowrap;
|
|
width: auto;
|
|
min-width: fit-content;
|
|
}
|
|
</style>
|