fix: 库存统计更新

This commit is contained in:
shijing 2024-03-26 16:22:39 +08:00
parent a97006c2d3
commit 00c57134d3
1 changed files with 305 additions and 150 deletions

View File

@ -1,40 +1,90 @@
<template>
<el-container>
<el-aside style="width: 50%;background: #ffffff;">
<el-aside style="width: 50%; background: #ffffff">
<el-container>
<el-header>
<div class="left-panel">
<span style="font-size: 14px">库存统计</span>
</div>
<div class="right-panel">
<el-select v-model="params.type" clearable @change="materialTypeChange">
<el-option v-for="item in materialTypeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
<el-select
v-model="params.type"
clearable
@change="materialTypeChange"
>
<el-option
v-for="item in materialTypeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
<el-button type="primary" icon="el-icon-search" @click="materialTypeChange"></el-button>
<el-button @click="handleExport('1')" type="primary">导出</el-button>
<el-button
type="primary"
icon="el-icon-search"
@click="materialTypeChange"
></el-button>
<el-button @click="handleExport('1')" type="primary"
>导出</el-button
>
</div>
</el-header>
<el-main>
<scTable ref="tables1" :apiObj="apiObj" :params="params" id="exportDiv1" stripe hideDo>
<scTable
ref="tables1"
:apiObj="apiObj"
:params="params"
id="exportDiv1"
stripe
hideDo
>
<el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="name"></el-table-column>
<el-table-column label="型号" prop="model"></el-table-column>
<el-table-column label="规格" prop="specification"></el-table-column>
<el-table-column label="库存总数" prop="count"></el-table-column>
<el-table-column label="周预估值" v-if="params.type==30">
<el-table-column
label="物料名"
prop="name"
></el-table-column>
<el-table-column
label="型号"
prop="model"
></el-table-column>
<el-table-column
label="规格"
prop="specification"
></el-table-column>
<el-table-column
label="库存总数"
prop="count"
></el-table-column>
<el-table-column
label="周预估值"
v-if="params.type == 30"
>
<template #default="scope">
<el-input v-model="scope.row.week_esitimate_consume" @blur="weekcountChange(scope.row)"></el-input>
<el-input
v-model="scope.row.week_esitimate_consume"
@blur="weekcountChange(scope.row)"
></el-input>
</template>
</el-table-column>
<el-table-column label="可用天数" v-if="params.type==30">
<el-table-column
label="可用天数"
v-if="params.type == 30"
>
<template #default="scope">
<span v-if="scope.row.week_esitimate_consume&&scope.row.week_esitimate_consume!==null">
{{ Math.floor(scope.row.count/scope.row.week_esitimate_consume)}}
<span
v-if="
scope.row.week_esitimate_consume &&
scope.row.week_esitimate_consume !==
null
"
>
{{
Math.floor(
scope.row.count /
scope.row.week_esitimate_consume
)
}}
</span>
</template>
</el-table-column>
@ -49,57 +99,132 @@
<span style="font-size: 14px">库存出入库统计</span>
</div>
<div class="right-panel">
<el-select v-model="query.mio_type" clearable @change="mioTypeChange" style="width: 100px;">
<el-option v-for="e in mioTypeEnum.values" :key="e.key" :value="e.key"
:label="e.text"></el-option>
<el-select
v-model="query.mio_type"
clearable
@change="mioTypeChange"
style="width: 100px"
>
<el-option
v-for="e in mioTypeEnum.values"
:key="e.key"
:value="e.key"
:label="e.text"
></el-option>
</el-select>
<el-select v-model="queryType" @change="queryTypeChange" style="width: 100px;">
<el-option v-for="item in typeOptions"
:key="item" :label="item" :value="item"></el-option>
<el-select
v-model="queryType"
style="width: 100px"
@change="queryTypeChnge"
>
<el-option
v-for="item in typeOptions"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
<el-date-picker
v-if="queryType=='月'"
v-if="queryType == '月'"
v-model="queryDate"
type="month"
placeholder="查询月"
value-format="YYYY-MM"
style="width: 100px;"
style="width: 100px"
>
</el-date-picker>
<el-date-picker
v-if="queryType=='年'"
v-if="queryType == '年'"
v-model="queryDate"
type="year"
placeholder="查询年"
value-format="YYYY"
style="width: 100px;"
style="width: 100px"
>
</el-date-picker>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
<el-button @click="handleExport('2')" type="primary">导出</el-button>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
></el-button>
<el-button @click="handleExport('2')" type="primary"
>导出</el-button
>
</div>
</el-header>
<el-main>
<scTable ref="tables2" :data="tableData" id="exportDiv2" stripe hideDo hidePagination>
<el-table-column label="物料名" prop="material"></el-table-column>
<el-table-column label="型号" prop="model"></el-table-column>
<el-table-column label="规格" prop="specification"></el-table-column>
<el-table-column label="出入库类型" prop="model">
<template>
<span></span>
</template>
<scTable
ref="tables2"
:data="tableData"
id="exportDiv2"
stripe
hideDo
hidePagination
>
<el-table-column
label="物料名"
prop="物料名"
></el-table-column>
<el-table-column
label="型号"
prop="型号"
></el-table-column>
<el-table-column
label="规格"
prop="规格"
></el-table-column>
<el-table-column label="出入库类型">
<span>{{ mio_type_name }}</span>
</el-table-column>
<template v-if="queryType=='月'&&(query.mio_type=='pur_in'||query.mio_type=='do_in'||query.mio_type=='other_in')">
<el-table-column label="月入库总数" prop="count"></el-table-column>
<template
v-if="
queryType == '月' &&
(query.mio_type == 'pur_in' ||
query.mio_type == 'do_in' ||
query.mio_type == 'other_in')
"
>
<el-table-column
label="月入库总数"
prop="数量"
></el-table-column>
</template>
<template v-if="queryType=='月'&&(query.mio_type=='do_out'||query.mio_type=='sale_out'||query.mio_type=='other_out')">
<el-table-column label="月出库数量" prop="batch"> </el-table-column>
<template
v-if="
queryType == '月' &&
(query.mio_type == 'do_out' ||
query.mio_type == 'sale_out' ||
query.mio_type == 'other_out')
"
>
<el-table-column label="月出库数量" prop="数量">
</el-table-column>
</template>
<template v-if="queryType=='年'&&(query.mio_type=='pur_in'||query.mio_type=='do_in'||query.mio_type=='other_in')">
<el-table-column label="年入库总数" prop="count"></el-table-column>
<template
v-if="
queryType == '年' &&
(query.mio_type == 'pur_in' ||
query.mio_type == 'do_in' ||
query.mio_type == 'other_in')
"
>
<el-table-column
label="年入库总数"
prop="数量"
></el-table-column>
</template>
<template v-if="queryType=='年'&&(query.mio_type=='do_out'||query.mio_type=='sale_out'||query.mio_type=='other_out')">
<el-table-column label="年出库总数" prop="count"></el-table-column>
<template
v-if="
queryType == '年' &&
(query.mio_type == 'do_out' ||
query.mio_type == 'sale_out' ||
query.mio_type == 'other_out')
"
>
<el-table-column
label="年出库总数"
prop="数量"
></el-table-column>
</template>
</scTable>
</el-main>
@ -108,117 +233,147 @@
</el-container>
</template>
<script>
import { mioTypeEnum } from "@/utils/enum.js";
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
}
export default {
name: 'chart',
data() {
return {
mioTypeEnum,
apiObj: this.$API.mtm.material.list,
materialType: '',
params: { is_hidden: false, type: 10 ,count__gte:1},
query: {
mio_type:mioTypeEnum.values[0].key
},
queryType:'月',
queryDate: '',
start_date:'',
end_date: '',
currentYear:'',
currentMonth: '',
currentLastDay:'',
tableData: [],
typeOptions: ['月', '年'],
materialTypeOptions: [
{id:10,name:'成品'},
{id:20,name:'半成品'},
{id:30,name:'主要原料'},
{id:40,name:'辅助材料'},
{id:70,name:'办公用品'},
],
}
},
mounted(){
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let lastDay = new Date(year, month, 0).getDate();
that.currentYear = year;
that.currentMonth = month > 9 ? month : '0' + month;
that.currentLastDay = lastDay;
that.queryDate = that.currentYear + '-' + that.currentMonth;
that.start_date = that.currentYear + '-'+ that.currentMonth + '-01';
that.end_date = that.currentYear + '-'+ that.currentMonth + '-'+lastDay;
that.getInmData();
},
methods: {
materialTypeChange() {
this.$refs.tables1.refresh();
import { mioTypeEnum } from "@/utils/enum.js";
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
}
export default {
name: "chart",
data() {
return {
mioTypeEnum,
apiObj: this.$API.mtm.material.list,
materialType: "",
params: { is_hidden: false, type: 10, count__gte: 1 },
query: {
mio_type: mioTypeEnum.values[0].key,
},
//
weekcountChange(row) {
let obj = { week_esitimate_consume: row.week_esitimate_consume };
this.$API.mtm.material.setWeekConsume.req(row.id, obj).then(res => {
mio_type_name: mioTypeEnum.values[0].text,
queryType: "月",
queryDate: "",
start_date: "",
end_date: "",
currentYear: "",
currentMonth: "",
currentLastDay: "",
tableData: [],
typeOptions: ["月", "年"],
materialTypeOptions: [
{ id: 10, name: "成品" },
{ id: 20, name: "半成品" },
{ id: 30, name: "主要原料" },
{ id: 40, name: "辅助材料" },
{ id: 70, name: "办公用品" },
],
};
},
mounted() {
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let lastDay = new Date(year, month, 0).getDate();
that.currentYear = year;
that.currentMonth = month > 9 ? month : "0" + month;
that.currentLastDay = lastDay;
that.queryDate = that.currentYear + "-" + that.currentMonth;
that.start_date = that.currentYear + "-" + that.currentMonth + "-01";
that.end_date =
that.currentYear + "-" + that.currentMonth + "-" + lastDay;
that.getTableData();
console.log(that.mio_type_name);
},
methods: {
queryTypeChnge() {
this.query.queryDate = "";
},
materialTypeChange() {
this.$refs.tables1.refresh();
},
//
weekcountChange(row) {
let obj = { week_esitimate_consume: row.week_esitimate_consume };
this.$API.mtm.material.setWeekConsume
.req(row.id, obj)
.then((res) => {
console.log(res);
this.$refs.tables1.refresh();
})
},
//
getInmData(){
let that = this;
let exec = that.queryType=='月'?'saleOutMonth':'saleOutYear';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, mio_type: that.query.mio_type},
};
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
if (res.data2.ds0) {
let data = res.data2.ds0;
that.tableData = data;
}
})
},
handleQuery(){
let that = this;
if(that.queryType=='月'){
if(that.queryDate!==''&&that.queryDate!==null){
that.start_date =that.queryDate+'-01';
let arr = that.queryDate.split('-');
that.end_date = that.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
}else{
that.start_date =that.currentYear+'-'+this.currentMonth+'-01';
that.end_date = that.currentYear+'-'+this.currentMonth+'-'+that.currentLastDay;
}
}else{
if(this.queryDate!==''&&this.queryDate!==null){
this.start_date = this.queryDate+'-01-01';
this.end_date = this.queryDate+'-12-31';
}else{
this.start_date = this.currentYear+'-01-01';
this.end_date = this.currentYear+'-12-31';
}
}
this.getInmData();
},
handleExport(val) {
this.exportLoading = true;
let id = '#exportDiv' + val;
let name = val == '1' ? '库存统计' : '库存出入库统计';
this.$XLSX(id, name);
this.exportLoading = false;
},
});
},
}
//
getTableData() {
let that = this;
let exec = that.queryType == "月" ? "saleOutMonth" : "saleOutYear";
let obj = {
query: {
start_date: that.start_date,
end_date: that.end_date,
mio_type: that.query.mio_type,
},
};
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
if (res.data2.ds0) {
let data = res.data2.ds0;
that.tableData = data;
}
});
},
mioTypeChange() {
for (let key in this.mioTypeEnum.values) {
if (this.mioTypeEnum.values[key].key == this.query.mio_type) {
this.mio_type_name = this.mioTypeEnum.values[key].text;
}
}
console.log(this.mio_type_name);
this.getTableData();
},
handleQuery() {
let that = this;
if (that.queryType == "月") {
if (that.queryDate !== "" && that.queryDate !== null) {
that.start_date = that.queryDate + "-01";
let arr = that.queryDate.split("-");
that.end_date =
that.queryDate +
"-" +
new Date(arr[0], arr[1], 0).getDate();
} else {
that.start_date =
that.currentYear + "-" + this.currentMonth + "-01";
that.end_date =
that.currentYear +
"-" +
this.currentMonth +
"-" +
that.currentLastDay;
}
} else {
if (this.queryDate !== "" && this.queryDate !== null) {
this.start_date = this.queryDate + "-01-01";
this.end_date = this.queryDate + "-12-31";
} else {
this.start_date = this.currentYear + "-01-01";
this.end_date = this.currentYear + "-12-31";
}
}
this.getTableData();
},
handleExport(val) {
this.exportLoading = true;
let id = "#exportDiv" + val;
let name = val == "1" ? "库存统计" : "库存出入库统计";
this.$XLSX(id, name);
this.exportLoading = false;
},
},
};
</script>
<style scoped>
.tables {
position: absolute;
top: 4px;
right: 6px;
z-index: 10;
position: absolute;
top: 4px;
right: 6px;
z-index: 10;
}
</style>