fix:修整采购统计

This commit is contained in:
shijing 2025-04-28 14:27:35 +08:00
parent c3c63afc2d
commit 8aa9dfe98b
1 changed files with 75 additions and 64 deletions

View File

@ -41,28 +41,25 @@
<el-header> <el-header>
<div class="right-panel"> <div class="right-panel">
<h2>采购统计</h2> <h2>采购统计</h2>
<el-select <xtSelect
:apiObj="apiObjMaterial"
v-model="materialIn" v-model="materialIn"
clearable v-model:label="materialName"
filterable v-model:obj="materialItem"
@change="materialInChange" @change="materialInChange"
> >
<el-option <el-table-column type="index" width="50" />
v-for="item in inmOption" <!-- <el-table-column label="物料编号" prop="number"></el-table-column> -->
:key="item.id" <el-table-column label="名称" prop="name"></el-table-column>
:label="item.full_name" <el-table-column label="规格" prop="specification"></el-table-column>
:value="item.id" <el-table-column label="型号" prop="model"></el-table-column>
> <el-table-column label="库存" prop="count"></el-table-column>
</el-option> </xtSelect>
</el-select>
</div> </div>
</el-header> </el-header>
<el-row> <el-row>
<el-col> <el-col>
<div <div id="bachart1" style="width: 100%; height: 300px"></div>
id="bachart1"
style="width: 100%; height: 300px"
></div>
</el-col> </el-col>
<el-card <el-card
shadow="never" shadow="never"
@ -227,6 +224,7 @@ export default {
tableData1: [], tableData1: [],
tableData2: [], tableData2: [],
materialIn: "", materialIn: "",
materialName: "",
firstWeekNum: 1, firstWeekNum: 1,
endWeekNum: 1, endWeekNum: 1,
product: "", product: "",
@ -234,20 +232,10 @@ export default {
outData: [], outData: [],
inmOption: [], inmOption: [],
outOption: [], outOption: [],
monthList: [ monthList: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
"一月", materialItem:{},
"二月", apiObjMaterial:this.$API.mtm.material.list,
"三月", queryMaterial:{type__in : "30,40,50,60,70"}
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月",
],
}; };
}, },
mounted() { mounted() {
@ -279,12 +267,11 @@ export default {
}, },
methods: { methods: {
setChart(name, option = null) { setChart(name, option = null) {
var myChart = echarts.getInstanceByDom( var myChart = echarts.getInstanceByDom(document.getElementById(name));
document.getElementById(name) if (myChart != null) {
); myChart.dispose(); //
if (myChart == undefined) {
myChart = echarts.init(document.getElementById(name), "T");
} }
myChart = echarts.init(document.getElementById(name), "T");
if (option == null) { if (option == null) {
option = Object.assign({}, this.basicOption); option = Object.assign({}, this.basicOption);
} }
@ -306,7 +293,15 @@ export default {
console.log(value); console.log(value);
this.queryDate = ""; this.queryDate = "";
}, },
materialInChange() { materialInChange(data) {
let that = this;
console.log(that.materialItem);
console.log(that.materialItem.id);
that.materialIn = that.materialItem.id;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
console.log(option);
that.setChart("bachart1",option);
this.getInmData(); this.getInmData();
}, },
// //
@ -317,21 +312,12 @@ export default {
obj.type__in = "30,40,50,60,70"; obj.type__in = "30,40,50,60,70";
that.$API.mtm.material.list.req(obj).then((res) => { that.$API.mtm.material.list.req(obj).then((res) => {
that.inmOption = res; that.inmOption = res;
// that.materialIn = res[1].id;
// let arr = [];
// res.forEach(item=>{
// if(item.type==30){
// arr.push(item)
// }
// });
// that.getInmData();
}); });
}, },
// //
getInmData() { getInmData() {
let that = this; let that = this;
let option = deepCopy(that.basicOption); that.tableData1 = [];
option.xAxis.data = that.xAxisData;
let exec = that.queryType == "月" ? "saleOutWeek" : "saleOutMonth"; let exec = that.queryType == "月" ? "saleOutWeek" : "saleOutMonth";
let obj = { let obj = {
query: { query: {
@ -342,26 +328,16 @@ export default {
}, },
}; };
that.$API.bi.dataset.exec.req(exec, obj).then((res) => { that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
console.log("getInmData", res); if (res.data2.ds0&&res.data2.ds0.length>0) {
option.series.data = []; that.tableData1 = res.data2.ds0;
if (res.data2.ds0) { that.setChartData(res.data2.ds0);
let data = res.data2.ds0; }else{
that.tableData1 = data; console.log('无数据')
if (data.length > 0) { let option = deepCopy(that.basicOption);
let seriesData = []; option.xAxis.data = that.xAxisData;
data.forEach((item) => { console.log(option);
if (that.queryType == "月") { that.setChart("bachart1",option);
let index = item. - that.firstWeekNum;
seriesData[index] = item.数量;
} else {
let index = item. - 1;
seriesData[index] = item.数量;
}
});
option.series.data = seriesData;
}
} }
that.setChart("bachart1", option);
}); });
}, },
getTable() { getTable() {
@ -378,7 +354,9 @@ export default {
that.tableData2 = []; that.tableData2 = [];
if (res.data2.ds0) { if (res.data2.ds0) {
let data = res.data2.ds0; let data = res.data2.ds0;
that.tableData1 = data;
that.tableData2 = data; that.tableData2 = data;
that.setChartData(data);
} }
}); });
}, },
@ -421,6 +399,39 @@ export default {
that.getInmData(); that.getInmData();
} }
}, },
setChartData(data){
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.series=[];
let materials = [],seriesData = [];
data.forEach((item) => {
if(materials.indexOf(item.物料名) == -1){
materials.push(item.物料名);
}
})
materials.forEach((item) => {
let obj = {};
obj.name = item;
obj.type = "bar";
obj.stack = "Ad";
obj.barWidth = "15px";
obj.data = [0,0,0,0,0,0,0,0,0,0,0,0];
seriesData.push(obj);
})
data.forEach((item) => {
let index = 0;let indexY = 0;
if (that.queryType == "月") {
index = item. - that.firstWeekNum;
} else {
index = item. - 1;
}
indexY = materials.indexOf(item.物料名);
seriesData[indexY].data[index] = item.数量;
});
option.series = seriesData;
that.setChart("bachart1", option);
},
handleExport(val) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = "#exportDiv" + val; let id = "#exportDiv" + val;