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

281 lines
7.8 KiB
Plaintext

<template>
<div style="height:670px;width:1000px" v-loading="loading">
<el-tabs v-model="activeName" type="card">
<el-tab-pane label="物料选择" name="first">
<!--<el-cascader-panel
style="margin-left:2%;width:96%"
:options="options"
:props="props"
ref="cascader"
show-all-levels
collapse-tags
clearable
v-model="selectedOptions"
@change="handleChange(1)"
></el-cascader-panel>-->
<el-cascader
style="margin-left:2%;width:96%"
:options="options"
:props="props"
ref="cascader"
show-all-levels
collapse-tags
clearable
v-model="selectedOptions"
@change="handleChange(1)"
filterable></el-cascader>
</el-tab-pane>
<!--<el-tab-pane label="物料选择" name="second">
<el-cascader-panel
style="margin-left:2%;width:96%"
:options="optionsC"
:props="props"
ref="cascaderC"
show-all-levels
collapse-tags
clearable
v-model="selectedOptionsC"
@change="handleChange(2)"
></el-cascader-panel>
</el-tab-pane>-->
</el-tabs>
<el-divider></el-divider>
<div style="width:96%;margin-left:2%">
<el-table :data="tableStock" border height="450">
<el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
<el-table-column
prop="warehouseCode"
label="库区代码"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="warehouseName"
label="库区名称"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="locationCode"
label="库位代码"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="locationName"
label="库位名称"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="materialCode"
label="物料编码"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="materialName"
label="物料名称"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="materialSpec"
label="物料规格"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
prop="materialUnit"
label="物料单位"
align="center"
:show-overflow-tooltip="true"
></el-table-column>
</el-table>
</div>
<el-col :span="14" :offset="10" style="margin-top:20px">
<el-button type="primary" @click="submitForm" :disabled="this.tableStock.length<=0">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</el-col>
</div>
</template>
<script>
export default {
name: "CountSheet",
props: {
layerid: {
type: String,
default: "",
},
id: {
type: Number,
default: null,
},
currentRow: {
type: Object,
default: null,
},
},
data() {
return {
loading: false,
tableStock: [],
selectedOptions: [],
selectedOptionsC: [],
activeName: "first",
tablearr: [],
options: [
{
value: "",
label: "",
},
],
optionsC: [
{
value: "",
label: "",
},
],
props: {
multiple: true,
},
};
},
mounted() {
this.init();
this.initTwo();
},
methods: {
init() {
this.loading = true
this.$checkstock.warehouseDis().then((resp) => {
this.loading = false
if (resp.data.code == 200) {
this.options = resp.data.data;
return this.$checkstock.getStockCheckBillDetail({ id: this.id });
}
})
.then((resp) => {
if (resp.data.code == 200) {
// console.log(resp.data.data,"数据")
// console.log("执行、、、、",this.options)
let res = [];
resp.data.data.forEach((value) => {
let obj = [];
obj.push(value.locationCode);
obj.push(value.materialCode);
obj.unshift(this.getTreeByChildren(value));
res.push(obj);
});
this.selectedOptions = res;
this.$nextTick(() => {
this.handleChange(1);
});
}
});
},
//物料选择
initTwo() {
// this.$checkstock.materialDis().then((resp) => {
// if (resp.data.code == 200) {
// console.log("物料选择", resp.data.data);
// this.optionsC=resp.data.data
// }})
},
getTreeByChildren(obj) {
//根据第二层找第一层
for (let i = 0; i < this.options.length; i++) {
if (this.options[i].children != null) {
for (let j = 0; j < this.options[i].children.length; j++) {
if (this.options[i].children[j].value == obj.locationCode) {
return this.options[i].value;
}
}
}
}
},
handleChange(val) {
if(val==1){
var demo = this.$refs["cascader"].getCheckedNodes();
}
let array1 = [];
demo.forEach((element) => {
if (element.hasChildren == false) {
array1.push(element);
}
});
let tableStock1 = [];
array1.forEach((ele) => {
let tableData = {};
tableData.warehouseCode = ele.pathNodes[0].data.value;
tableData.warehouseId = ele.pathNodes[0].data.id;
tableData.warehouseName = ele.pathNodes[0].data.label;
tableData.locationId = ele.pathNodes[1].data.id;
tableData.locationCode = ele.pathNodes[1].data.value;
tableData.locationName = ele.pathNodes[1].data.label;
tableData.materialId = ele.pathNodes[2].data.id;
tableData.materialCode = ele.pathNodes[2].data.value;
tableData.materialName = ele.pathNodes[2].data.label;
tableData.materialSpec = ele.pathNodes[2].data.spec;
tableData.materialUnit = ele.pathNodes[2].data.unit;
tableStock1.push(tableData);
});
this.tableStock = tableStock1;
},
deleteRow(index, rows) {
console.log(rows, "index");
rows.splice(index, 1);
this.tableStock.slice(index, 1);
},
submitForm() {
if (this.$parent.isAdd == true) {
let params = {
mmCheckBill: {},
mmCheckBillDetailList: this.tableStock,
};
this.$checkstock.addCheck(params).then((resp) => {
if (resp.data.code == 200) {
this.$layer.close(this.layerid);
this.$parent.getcheckStock();
}
});
} else {
let params = {
mmCheckBill: this.currentRow,
mmCheckBillDetailList: this.tableStock,
};
this.$checkstock.update(params).then((resp) => {
if (resp.data.code == 200) {
setTimeout(() => {
//去掉选中项
this.$parent.$refs.singleTable.setCurrentRow(this.currentRow);
}, 100);
this.$layer.close(this.layerid);
this.$parent.getcheckStock();
}
});
}
},
cancel() {
this.$layer.close(this.layerid);
},
},
};
</script>
<style lang="scss" scoped>
>>> .el-cascader-node__postfix {
position: absolute;
right: 14px;
}
>>> .el-scrollbar__bar.is-vertical {
width: 21px;
top: 2px;
}
</style>