538 lines
18 KiB
Vue
538 lines
18 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="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="remark">
|
|
<el-input
|
|
v-model="formData.remark"
|
|
:placeholder="'请输入备注'"
|
|
clearable
|
|
/>
|
|
</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="distribution" width="160"/>
|
|
<el-table-column label="物料名称" align="center" prop="productName" show-overflow-tooltip/>
|
|
<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" prop="orderId" width="120"/>
|
|
<el-table-column label="产品号" align="center" prop="power" width="100"/>
|
|
<el-table-column label="台次" align="center" prop="spec" width="80"/>
|
|
<el-table-column label="单重" align="center" prop="netWeight" />
|
|
<el-table-column label="路线" align="center" prop="grossWeight" show-overflow-tooltip/>
|
|
<el-table-column label="供应商" align="center" prop="phase" show-overflow-tooltip/>
|
|
<el-table-column label="部门" align="center" prop="model" />
|
|
|
|
|
|
<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="80%" custom-class="material-dialog" append-to-body><!--选择物资-->
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
|
|
|
|
<el-form-item label="合同号" prop="orderId">
|
|
<el-input
|
|
v-model="queryParams.orderId"
|
|
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="distribution">
|
|
<el-input
|
|
v-model="queryParams.distribution"
|
|
placeholder="请输入代号"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="台次" prop="spare5">
|
|
<el-input
|
|
v-model="queryParams.spare5"
|
|
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>
|
|
<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="distribution" width="160"/>
|
|
<el-table-column label="物料名称" align="center" prop="productName" show-overflow-tooltip/>
|
|
<el-table-column label="数量" align="center" prop="quantity" />
|
|
<el-table-column label="合同号" align="center" prop="orderId" width="160"/>
|
|
<el-table-column label="产品号" align="center" prop="power" width="160"/>
|
|
<el-table-column label="台次" align="center" prop="spare5" width="160"/>
|
|
<el-table-column label="单重" align="center" prop="netWeight" />
|
|
<el-table-column label="路线" align="center" prop="grossWeight" show-overflow-tooltip />
|
|
<el-table-column label="供应商" align="center" prop="phase" />
|
|
<el-table-column label="部门" align="center" prop="model" />
|
|
</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>
|
|
|
|
</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";
|
|
import { listBasSupplier } from "@/api/bas/BasSupplier";
|
|
|
|
export default {
|
|
name: "AddOutStock",
|
|
dicts: ['out_bill_type', 'bill_status', 'is_available', 'product_type', 'quality_type', 'turnover_type', 'sys_yes_no','account_type','origin_type','purpose_type','warehouse'],
|
|
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" }
|
|
]
|
|
},
|
|
// 主表数据
|
|
formData: {
|
|
// warehouseId: null,
|
|
customerNo: null,
|
|
customerName: null, // 添加客户名称字段,用于显示
|
|
outType: null,
|
|
remark:null,
|
|
stockoutSource:"1",
|
|
},
|
|
// 仓库选项
|
|
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,
|
|
// 当前正在编辑客户的物资行
|
|
selectedRowForCustomer: null,
|
|
// 客户查询参数
|
|
customerQueryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
customerNo: null,
|
|
customerName: null,
|
|
useable: '1' // 默认只查询可用的客户
|
|
},
|
|
// 供应商选择弹窗
|
|
supplierDialog: false,
|
|
// 供应商列表数据
|
|
supplierList: [],
|
|
// 当前选中的供应商
|
|
selectedSupplier: null,
|
|
// 供应商加载状态与总数
|
|
supplierLoading: false,
|
|
supplierTotal: 0,
|
|
// 供应商查询参数
|
|
supplierQueryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
supplierNo: null,
|
|
supplierName: null,
|
|
useable: '1' // 默认只查询可用的供应商
|
|
}
|
|
};
|
|
},
|
|
created() {
|
|
this.getWarehouseOptions();
|
|
},
|
|
methods: {
|
|
/** 获取仓库选项 */
|
|
getWarehouseOptions() {
|
|
|
|
listWarehouse({
|
|
pageNum: 1,
|
|
pageSize: 100
|
|
}).then(response => {
|
|
this.warehouseOptions = response.rows;
|
|
});
|
|
},
|
|
/** 打开客户选择弹窗(全局) */
|
|
openCustomerSelector() {
|
|
this.selectedRowForCustomer = null;
|
|
this.customerDialog = true;
|
|
this.getCustomerList();
|
|
},
|
|
/** 打开客户选择弹窗(行级) */
|
|
openRowCustomerSelector(row) {
|
|
this.selectedRowForCustomer = row;
|
|
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;
|
|
}
|
|
// 如果是行级编辑,赋值到该行;否则赋值到主表
|
|
if (this.selectedRowForCustomer) {
|
|
this.$set(this.selectedRowForCustomer, 'outId', this.selectedCustomer.customerNo);
|
|
this.$set(this.selectedRowForCustomer, 'customerName', this.selectedCustomer.customerName);
|
|
} else {
|
|
this.formData.customerNo = this.selectedCustomer.customerNo;
|
|
this.formData.customerName = this.selectedCustomer.customerName;
|
|
}
|
|
this.customerDialog = false;
|
|
this.selectedCustomer = null;
|
|
this.selectedRowForCustomer = null;
|
|
},
|
|
/** 取消选择客户 */
|
|
cancelSelectCustomer() {
|
|
this.selectedCustomer = null;
|
|
this.selectedRowForCustomer = null;
|
|
this.customerDialog = false;
|
|
},
|
|
/** 打开供应商选择弹窗 */
|
|
openSupplierSelector() {
|
|
this.getSupplierListForDialog();
|
|
this.supplierDialog = true;
|
|
},
|
|
/** 获取供应商列表(对话框数据) */
|
|
getSupplierListForDialog() {
|
|
this.supplierLoading = true;
|
|
listBasSupplier(this.supplierQueryParams).then(response => {
|
|
this.supplierList = response.rows;
|
|
this.supplierTotal = response.total;
|
|
this.supplierLoading = false;
|
|
});
|
|
},
|
|
/** 供应商查询 */
|
|
handleSupplierQuery() {
|
|
this.supplierQueryParams.pageNum = 1;
|
|
this.getSupplierListForDialog();
|
|
},
|
|
/** 重置供应商查询 */
|
|
resetSupplierQuery() {
|
|
this.resetForm("supplierQueryForm");
|
|
this.supplierQueryParams.useable = '1';
|
|
this.handleSupplierQuery();
|
|
},
|
|
/** 供应商行点击事件 */
|
|
handleSupplierRowClick(row) {
|
|
this.selectedSupplier = row;
|
|
this.$refs['supplierTable']?.setCurrentRow(row);
|
|
},
|
|
/** 确认选择供应商 */
|
|
confirmSelectSupplier() {
|
|
if (!this.selectedSupplier) {
|
|
this.$modal.msgError('请选择供应商');
|
|
return;
|
|
}
|
|
this.queryParams.supplierName = this.selectedSupplier.supplierName;
|
|
this.queryParams.phase = this.selectedSupplier.supplierNo;
|
|
this.supplierDialog = false;
|
|
},
|
|
/** 取消选择供应商 */
|
|
cancelSelectSupplier() {
|
|
this.selectedSupplier = null;
|
|
this.supplierDialog = false;
|
|
},
|
|
/** 打开选择物资弹窗 */
|
|
handleSelectMaterials() {
|
|
// if (!this.formData.warehouseId) {
|
|
// this.$modal.msgError('请选择仓库');
|
|
// return;
|
|
// }
|
|
this.materialDialog = true;
|
|
// this.queryParams.warehouseId = this.formData.warehouseId;
|
|
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 => ({
|
|
onlyIdentity: item.onlyIdentity,
|
|
productId: item.productId,
|
|
productName: item.productName,
|
|
quantity: item.quantity,
|
|
quantityOrignal: item.quantity,
|
|
warehouseId: item.warehouseId,
|
|
warehouseName: item.warehouseName,
|
|
orderId: item.orderId,
|
|
power: item.power,
|
|
distribution: item.distribution,
|
|
spec: item.spare5,
|
|
netWeight: item.netWeight,
|
|
grossWeight: item.grossWeight,
|
|
phase: item.phase,
|
|
model: item.model,
|
|
voltage: item.voltage,
|
|
|
|
}))
|
|
);
|
|
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;
|
|
}
|
|
.material-dialog {
|
|
height: 50vh;
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.material-dialog >>> .el-dialog__body {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
}
|
|
</style>
|