Files
scrq-hd/.svn/pristine/a9/a9a70eb6e9920d1eae6bba94cca3e8af8ce15ed3.svn-base
2025-07-03 10:34:04 +08:00

825 lines
25 KiB
Plaintext

<template>
<el-container style="margin-top: 10px;" v-loading="loading" element-loading-text="正在加载中,加载时间可能较长,请耐心等待">
<!-- 添加或修改参数配置对话框 -->
<el-form
ref="form"
:model="form"
label-width="100px"
:rules="rules"
align="left"
style="width: 100%;"
>
<!-- 第一行 -->
<el-row>
<el-col :span="6">
<el-form-item label="到货单号" prop="arriveBillNumber">
<el-input
v-model="form.arriveBillNumber"
style="width: 95%"
placeholder=""
:maxlength="50"
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="到货人" prop="createdBy">
<el-input
v-model="form.createdBy"
style="width: 95%"
placeholder=""
:maxlength="50"
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="到货时间" prop="createdDt">
<el-input
v-model="form.createdDt"
style="width: 95%"
placeholder=""
:maxlength="50"
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="到货方式" prop="shippingType">
<el-input
v-model="form.shippingType"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
</el-row>
<!-- 第二行 -->
<el-row>
<el-col :span="6">
<el-form-item label="业务类型" prop="dictServiceType">
<el-select
v-model="form.dictServiceType"
style="width: 95%"
placeholder=""
size="small"
disabled
>
<el-option
v-for="dict in dictServiceTypeList"
:key="dict.groupKey"
:label="dict.groupText"
:value="dict.groupKey"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="币种" prop="currency">
<el-input
v-model="form.currency"
style="width: 95%"
placeholder=""
:maxlength="50"
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="汇率" prop="exchangeRate">
<el-input
v-model="form.exchangeRate"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="税率" prop="taxRate">
<el-input
v-model="form.taxRate"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
</el-row>
<!-- 第三行 -->
<el-row>
<el-col :span="6">
<el-form-item label="采购类型" prop="dictPurchaseType">
<el-select
v-model="form.dictPurchaseType"
style="width: 95%"
placeholder=""
size="small"
disabled
>
<el-option
v-for="dict in dictPurchaseTypeList"
:key="dict.groupKey"
:label="dict.groupText"
:value="dict.groupKey"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="供应商" prop="supplierName">
<el-input
v-model="form.supplierName"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="业务员" prop="salesmanName">
<el-input
v-model="form.salesmanName"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="部门名称" prop="departmentName">
<el-input
v-model="form.departmentName"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
</el-row>
<!-- 第四行 -->
<!--
<el-row>
<el-col :span="6">
<el-form-item label="采购类型代码" prop="dictPurchaseType">
<el-input v-model="form.dictPurchaseType" style="width: 95%" placeholder="" size="small" disabled/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="供应商代码" prop="supplierCode">
<el-input v-model="form.supplierCode" style="width: 95%" placeholder="" size="small" disabled/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="业务员代码" prop="salesmanCode">
<el-input v-model="form.salesmanCode" style="width: 95%" placeholder="" size="small" disabled/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="部门名称代码" prop="departmentCode">
<el-input v-model="form.departmentCode" style="width: 95%" placeholder="" size="small" disabled/>
</el-form-item>
</el-col>
</el-row>
-->
<!-- 第四行 -->
<el-row>
<el-col :span="6">
<el-form-item label="仓库名称" prop="warehouseName">
<el-input
v-model="form.warehouseName"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="仓库代码" prop="warehouseCode">
<el-input
v-model="form.warehouseCode"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="客户名称" prop="customerName">
<el-input
v-model="form.customerName"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="客户代码" prop="customerCode">
<el-input
v-model="form.customerCode"
style="width: 95%"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
</el-row>
<!-- 第五行 -->
<el-row style="margin-bottom:-24px">
<el-col :span="12">
<el-form-item label="到货备注" prop="remark">
<el-input
v-model="form.remark"
style="width: 428px;"
placeholder=""
size="small"
disabled
/>
</el-form-item>
</el-col>
<!-- <el-col :span="6">
<el-form-item label="多批次" prop="">
<el-input v-model="form." style="width: 95%" placeholder="" size="small" disabled/>
</el-form-item>
</el-col>
-->
</el-row>
<!-- 分割线 -->
<el-divider></el-divider>
<!-- 列表头部按钮 -->
<!--
// <el-row :gutter="10" style="width:99%;margin-left:0px;margin-bottom:10px">
// <el-col :span="1.5">
// <el-button type="primary" icon="el-icon-plus" size="mini">新增检验单</el-button>
// </el-col>
// </el-row>
-->
<!-- 列表 -->
<el-table
style="width: 99%;margin: 0px 0px 0px 5px;"
height="310"
border
:row-class-name="rowClass"
v-loading="tableLoading"
:data="detailList"
ref="list"
@selection-change="handleSelectionChange"
>
<el-table-column
align="center"
type="index"
label="序号"
width="50"
fixed="left"
/>
<el-table-column type="selection" width="50" fixed="left" />
<el-table-column
label="物料编码"
align="center"
prop="materialCode"
width="100px"
:show-overflow-tooltip="true"
/>
<el-table-column
label="物料名称"
align="center"
prop="materialName"
width="150px"
:show-overflow-tooltip="true"
/>
<el-table-column
label="物料规格"
align="center"
prop="materialSpec"
width="150px"
:show-overflow-tooltip="true"
/>
<!-- <el-table-column
label="存货代码"
align="center"
prop=""
width="auto"
:show-overflow-tooltip="true"
/> -->
<el-table-column
label="单位"
align="center"
prop="unitOfMeasure"
width="auto"
:show-overflow-tooltip="true"
/>
<el-table-column
label="应到数量"
align="center"
prop="planQty"
width="auto"
:show-overflow-tooltip="true"
/>
<el-table-column
label="实到数量"
align="center"
prop="realQty"
width="120px"
:show-overflow-tooltip="true"
>
<!-- <template slot-scope="scope"> -->
<!--<el-input v-model="scope.row.realQty"
size="mini" :maxlength="11"
oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+4)}"
@click="changeRealQty(scope.row)">
</el-input>-->
<!-- {{ scope.row.realQty }}
</template> -->
</el-table-column>
<el-table-column
label="检验总数"
align="center"
prop="inspectTotalQty"
width="120px"
:show-overflow-tooltip="true"
>
<!-- <template slot-scope="scope">
<el-input
v-model="scope.row.inspectTotalQty"
size="mini"
:maxlength="11"
oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+4)}"
@click="changeInspectTotalQty(scope.row)"
>
</el-input>
</template> -->
</el-table-column>
<el-table-column
label="抽检标准数量"
align="center"
width="120px"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.spotCheckQty"
size="mini"
:maxlength="11"
oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+4)}"
@click="changeSpotCheckQty(scope.row)"
>
</el-input>
</template>
</el-table-column>
<el-table-column
label="已检验数量"
align="center"
prop="spotCheckedQty"
width="100px"
:show-overflow-tooltip="true"
/>
<el-table-column
label="批次"
align="center"
prop="batchNo"
width="150px"
:show-overflow-tooltip="true"
>
<!-- <template slot-scope="scope">
<el-input v-model="scope.row.batchNo"
size="mini" :maxlength="11">
</el-input>
</template> -->
</el-table-column>
<el-table-column
label="条码数量"
align="center"
prop="barNo"
width="100px"
:show-overflow-tooltip="true"
/>
<!--<el-table-column label="实到数量" align="center" prop="" width="auto" :show-overflow-tooltip="true"/>-->
<!--<el-table-column label="合格数" align="center" prop="spotCheckQualifiedQty" width="100px" :show-overflow-tooltip="true"/>
<el-table-column label="不合格数" align="center" prop="spotCheckUnqualifiedQty" width="100px" :show-overflow-tooltip="true"/>
<el-table-column label="检验结果" align="center" width="100px" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-button type="primary" size="mini">查看</el-button>
</template>
</el-table-column>-->
<!-- <el-table-column
label=""
align="center"
width="50px"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<i
class="el-icon-plus"
@click="copyScope(scope.row)"
v-if="scope.row.isCopy == false"
/>
<i
class="el-icon-minus"
@click="deleteScope(scope.row)"
v-if="scope.row.isCopy == true"
/>
</template>
</el-table-column> -->
</el-table>
<!-- 表单按钮 -->
<el-row style="margin-top:20px">
<el-col :span="24">
<el-form-item style="float: right;margin-right: 20px">
<el-button
type="primary"
@click="submitForm"
v-loading="saveLoading"
>确 定</el-button
>
<el-button @click="cancel">取 消</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-container>
</template>
<script>
import TreeSelect from "@riophae/vue-treeselect"; //引用下拉树组件
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "arrive-bill-create-check",
components: {
TreeSelect
},
props: {
layerid: {
type: String,
default: ""
},
row: {
type: Object,
default: undefined
},
formType: {
type: Number,
default: 0
}
},
data() {
return {
loading: false,
//业务类型
dictServiceTypeList: [],
//采购类型
dictPurchaseTypeList: [],
//表单
form: {
id: "",
arriveBillNumber: "", //到货单号
createdBy: "", //到货人
dictServiceType: "", //业务类型
currency: "", //币种
exchangeRate: "", //汇率
taxRate: "", //税率
dictPurchaseType: "", //采购类型
supplierName: "", //供应商名称
salesmanName: "", //业务员名称
departmentName: "", //部门名称
supplierCode: "", //供应商代码
salesmanCode: "", //业务员代码
departmentCode: "", //部门代码
warehouseName: "", //仓库名称
warehouseCode: "", //仓库代码
customerName: "", //客户名称
customerCode: "", //客户代码
remark: "", //到货备注
shippingType: "" //运输方式
},
rules: {},
tableLoading: false,
detailList: [],
multipleSelection: [],
saveLoading: false,
copiedList: []
};
},
async mounted() {},
created() {
this.dictServiceTypeList = this.$dictType.getDictListByCode(
"mm_arrive_bill_server_type"
);
this.dictPurchaseTypeList = this.$dictType.getDictListByCode(
"mm_arrive_bill_purchase_type"
);
this.form.id = this.row.id;
this.initData();
},
methods: {
//改变实到数量
// changeRealQty(data){
// var sumRealQty = 0
// var sumCheckedQty = 0
// this.detailList.forEach(item=>{
// if(item.id == data.id){
// sumRealQty = sumRealQty + parseFloat(item.realQty)
// sumCheckedQty = sumCheckedQty + parseFloat(item.spotCheckedQty)
// }
// })
// if( parseFloat(sumRealQty) > this.floatSub(parseInt(data.planQty), parseInt(sumCheckedQty))){
// data.realQty = this.floatSub(
// this.floatSub(parseInt(data.planQty), parseInt(sumCheckedQty)),
// (this.floatSub(parseInt(sumRealQty), parseInt(data.realQty)))
// )
// }
// data.inspectTotalQty = 0
// data.spotCheckQty = 0
// },
//改变检验数量
changeInspectTotalQty(data) {
if (
parseFloat(data.inspectTotalQty) >
this.floatSub(parseFloat(data.realQty), parseFloat(data.spotCheckedQty))
) {
data.inspectTotalQty = this.floatSub(
parseFloat(data.realQty),
parseFloat(data.spotCheckedQty)
);
}
this.$arriveBill
.getSpotCheckQty({
materialCode: data.materialCode,
inspectTotalQty: data.inspectTotalQty
})
.then(res => (data.spotCheckQty = res.data.data))
.catch(() => (data.spotCheckQty = 0));
},
//改变抽检数量
changeSpotCheckQty(data) {
if (parseFloat(data.spotCheckQty) > parseFloat(data.inspectTotalQty)) {
data.spotCheckQty = data.inspectTotalQty;
}
},
//复制列表选中行
copyScope(data) {
var index = this.detailList.indexOf(data);
var copyData = JSON.parse(JSON.stringify(data));
copyData.batchNo = "";
copyData.isCopy = true;
copyData.realQty = 0;
copyData.inspectTotalQty = 0;
copyData.spotCheckQty = 0;
copyData.spotCheckedQty = 0;
this.detailList.splice(index + 1, 0, copyData);
this.copiedList.push(copyData);
},
//删除复制行
deleteScope(data) {
var index = this.detailList.indexOf(data);
this.detailList.splice(index, 1);
},
//根据id查询到货单
initData() {
this.loading = true;
this.$arriveBill
.getArriveBillByIdToCreInspect({
id: this.form.id
})
.then(res => {
this.form = res.data.data;
this.detailList = res.data.data.items;
this.detailList.forEach(item => {
item.isCopy = false;
if (item.realQty == "" || item.realQty == null) {
item.realQty = 0;
}
if (item.inspectTotalQty == "" || item.inspectTotalQty == null) {
item.inspectTotalQty = 0;
}
if (item.spotCheckQty == "" || item.spotCheckQty == null) {
item.spotCheckQty = 0;
}
if (item.spotCheckedQty == "" || item.spotCheckedQty == null) {
item.spotCheckedQty = 0;
}
});
this.detailList = JSON.parse(JSON.stringify(this.detailList));
this.loading = false;
});
},
//table多选
handleSelectionChange(val) {
this.multipleSelection = val;
this.multipleSelection.forEach(item => {
this.$refs.list.setCurrentRow(item);
});
},
//保存
submitForm() {
if (this.multipleSelection.length == 0) {
this.$message.error("请选择物料");
return;
}
var isStop = false;
// var batchNoList = [];
var batchNoMap = new Map();
this.multipleSelection.forEach(item => {
if (
parseInt(item.realQty) == 0 ||
parseInt(item.inspectTotalQty) == 0 ||
parseInt(item.spotCheckQty) == 0
) {
isStop = true;
this.$message.error(
"第" +
(parseInt(this.detailList.indexOf(item)) + 1) +
"行物料实到数量、检验总数、抽检标准数量均不能为0"
);
return;
}
if (item.batchNo == "" || item.batchNo == null) {
isStop = true;
this.$message.error(
"第" +
(parseInt(this.detailList.indexOf(item)) + 1) +
"行物料批次号不能为空"
);
return;
}
if (batchNoMap[item.materialId] == undefined) {
batchNoMap[item.materialId] = [];
}
batchNoMap[item.materialId].push(item.batchNo);
});
if (isStop) {
return;
}
var dto = this.form;
dto.items = this.multipleSelection;
dto.items.forEach(item => {
item.arriveBillDetailId = item.id;
});
if (this.saveLoading) return;
this.saveLoading = true;
this.$arriveBill.arriveCreInsepct(dto).then(res => {
if (res.data.code == 200) {
this.saveLoading = false;
this.$message.success("生成成功");
this.cancel();
} else {
this.saveLoading = false;
this.$message.error(res.data.msg || res.data.message);
}
});
},
//取消
cancel() {
this.reset();
this.$layer.close(this.layerid);
this.$parent.initData();
},
//表单重置
reset() {
this.form = {
id: "",
arriveBillNumber: "", //到货单号
createdBy: "", //到货人
dictServiceType: "", //业务类型
currency: "", //币种
exchangeRate: "", //汇率
taxRate: "", //税率
dictPurchaseType: "", //采购类型
supplierName: "", //供应商名称
salesmanName: "", //业务员名称
departmentName: "", //部门名称
supplierCode: "", //供应商代码
salesmanCode: "", //业务员代码
departmentCode: "", //部门代码
warehouseName: "", //仓库名称
warehouseCode: "", //仓库代码
customerName: "", //客户名称
customerCode: "", //客户代码
remark: "", //到货备注
shippingType: "" //运输方式
};
},
//勾选数据行的 Checkbox 时触发的事件
rowClass({ row }) {
if (this.multipleSelection.includes(row)) {
return "slecleRowColor ";
}
if (this.copiedList.includes(row)) {
return "lastCopiedRowColor";
}
},
//float乘法
floatMul(arg1, arg2) {
var m = 0;
var s1 = arg1.toString();
var s2 = arg2.toString();
try {
m += s1.split(".")[1].length;
} catch (e) {}
try {
m += s2.split(".")[1].length;
} catch (e) {}
return (
(Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
Math.pow(10, m)
);
},
//float除法
floatDiv(arg1, arg2) {
var r1 = 0;
var r2 = 0;
var m;
var s1 = arg1.toString();
var s2 = arg2.toString();
try {
if (s1.split(".")[1] != undefined) r1 = s1.split(".")[1].length;
} catch (e) {}
try {
if (s2.split(".")[1] != undefined) r2 = s2.split(".")[1].length;
} catch (e) {}
m = Math.pow(10, Math.max(r1, r2));
return this.floatMul(arg1, m) / this.floatMul(arg2, m);
},
//float减法
floatSub(arg1, arg2) {
var r1 = 0,
r2 = 0,
m,
n,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
if (s1.split(".")[1] != undefined) r1 = s1.split(".")[1].length;
} catch (e) {}
try {
if (s2.split(".")[1] != undefined) r2 = s2.split(".")[1].length;
} catch (e) {}
m = Math.pow(10, Math.max(r1, r2));
//last modify by deeka
//动态控制精度长度
n = r1 >= r2 ? r1 : r2;
return (this.floatMul(arg1, m) - this.floatMul(arg2, m)) / m;
},
//float加法
floatAdd(arg1, arg2) {
var r1 = 0;
var r2 = 0;
var m;
var s1 = arg1.toString();
var s2 = arg2.toString();
try {
if (s1.split(".")[1] != undefined) r1 = s1.split(".")[1].length;
} catch (e) {}
try {
if (s2.split(".")[1] != undefined) r2 = s2.split(".")[1].length;
} catch (e) {}
m = Math.pow(10, Math.max(r1, r2));
return (this.floatMul(arg1, m) + this.floatMul(arg2, m)) / m;
}
}
};
</script>
<style lang="scss" scoped>
.el-form-item {
margin-bottom: 10px;
}
>>> .el-table__body tr.current-row > td {
background-color: #8ac1ff !important;
cursor: pointer;
}
.el-table >>> tbody tr:hover > td {
background-color: #8ac1ff !important;
}
>>> .el-table .lastCopiedRowColor {
background-color: #67c23a !important;
}
>>> .el-table .slecleRowColor {
background-color: #8ac1ff !important;
}
</style>