fix: 库存统计更新
This commit is contained in:
parent
a97006c2d3
commit
00c57134d3
|
|
@ -1,40 +1,90 @@
|
||||||
<template>
|
<template>
|
||||||
<el-container>
|
<el-container>
|
||||||
<el-aside style="width: 50%;background: #ffffff;">
|
<el-aside style="width: 50%; background: #ffffff">
|
||||||
<el-container>
|
<el-container>
|
||||||
<el-header>
|
<el-header>
|
||||||
<div class="left-panel">
|
<div class="left-panel">
|
||||||
<span style="font-size: 14px">库存统计</span>
|
<span style="font-size: 14px">库存统计</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<el-select v-model="params.type" clearable @change="materialTypeChange">
|
<el-select
|
||||||
<el-option v-for="item in materialTypeOptions"
|
v-model="params.type"
|
||||||
:key="item.id"
|
clearable
|
||||||
:label="item.name"
|
@change="materialTypeChange"
|
||||||
:value="item.id"
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in materialTypeOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button type="primary" icon="el-icon-search" @click="materialTypeChange"></el-button>
|
<el-button
|
||||||
<el-button @click="handleExport('1')" type="primary">导出</el-button>
|
type="primary"
|
||||||
|
icon="el-icon-search"
|
||||||
|
@click="materialTypeChange"
|
||||||
|
></el-button>
|
||||||
|
<el-button @click="handleExport('1')" type="primary"
|
||||||
|
>导出</el-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-main>
|
<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 type="index" width="50" />
|
||||||
<el-table-column label="物料名" prop="name"></el-table-column>
|
<el-table-column
|
||||||
<el-table-column label="型号" prop="model"></el-table-column>
|
label="物料名"
|
||||||
<el-table-column label="规格" prop="specification"></el-table-column>
|
prop="name"
|
||||||
<el-table-column label="库存总数" prop="count"></el-table-column>
|
></el-table-column>
|
||||||
<el-table-column label="周预估值" v-if="params.type==30">
|
<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">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="可用天数" v-if="params.type==30">
|
<el-table-column
|
||||||
|
label="可用天数"
|
||||||
|
v-if="params.type == 30"
|
||||||
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span v-if="scope.row.week_esitimate_consume&&scope.row.week_esitimate_consume!==null">
|
<span
|
||||||
{{ Math.floor(scope.row.count/scope.row.week_esitimate_consume)}}
|
v-if="
|
||||||
|
scope.row.week_esitimate_consume &&
|
||||||
|
scope.row.week_esitimate_consume !==
|
||||||
|
null
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
Math.floor(
|
||||||
|
scope.row.count /
|
||||||
|
scope.row.week_esitimate_consume
|
||||||
|
)
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -49,57 +99,132 @@
|
||||||
<span style="font-size: 14px">库存出入库统计</span>
|
<span style="font-size: 14px">库存出入库统计</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<el-select v-model="query.mio_type" clearable @change="mioTypeChange" style="width: 100px;">
|
<el-select
|
||||||
<el-option v-for="e in mioTypeEnum.values" :key="e.key" :value="e.key"
|
v-model="query.mio_type"
|
||||||
:label="e.text"></el-option>
|
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>
|
||||||
<el-select v-model="queryType" @change="queryTypeChange" style="width: 100px;">
|
<el-select
|
||||||
<el-option v-for="item in typeOptions"
|
v-model="queryType"
|
||||||
:key="item" :label="item" :value="item"></el-option>
|
style="width: 100px"
|
||||||
|
@change="queryTypeChnge"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in typeOptions"
|
||||||
|
:key="item"
|
||||||
|
:label="item"
|
||||||
|
:value="item"
|
||||||
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-if="queryType=='月'"
|
v-if="queryType == '月'"
|
||||||
v-model="queryDate"
|
v-model="queryDate"
|
||||||
type="month"
|
type="month"
|
||||||
placeholder="查询月"
|
placeholder="查询月"
|
||||||
value-format="YYYY-MM"
|
value-format="YYYY-MM"
|
||||||
style="width: 100px;"
|
style="width: 100px"
|
||||||
>
|
>
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-if="queryType=='年'"
|
v-if="queryType == '年'"
|
||||||
v-model="queryDate"
|
v-model="queryDate"
|
||||||
type="year"
|
type="year"
|
||||||
placeholder="查询年"
|
placeholder="查询年"
|
||||||
value-format="YYYY"
|
value-format="YYYY"
|
||||||
style="width: 100px;"
|
style="width: 100px"
|
||||||
>
|
>
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
|
<el-button
|
||||||
<el-button @click="handleExport('2')" type="primary">导出</el-button>
|
type="primary"
|
||||||
|
icon="el-icon-search"
|
||||||
|
@click="handleQuery"
|
||||||
|
></el-button>
|
||||||
|
<el-button @click="handleExport('2')" type="primary"
|
||||||
|
>导出</el-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-main>
|
<el-main>
|
||||||
<scTable ref="tables2" :data="tableData" id="exportDiv2" stripe hideDo hidePagination>
|
<scTable
|
||||||
<el-table-column label="物料名" prop="material"></el-table-column>
|
ref="tables2"
|
||||||
<el-table-column label="型号" prop="model"></el-table-column>
|
:data="tableData"
|
||||||
<el-table-column label="规格" prop="specification"></el-table-column>
|
id="exportDiv2"
|
||||||
<el-table-column label="出入库类型" prop="model">
|
stripe
|
||||||
<template>
|
hideDo
|
||||||
<span></span>
|
hidePagination
|
||||||
</template>
|
>
|
||||||
|
<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>
|
</el-table-column>
|
||||||
<template v-if="queryType=='月'&&(query.mio_type=='pur_in'||query.mio_type=='do_in'||query.mio_type=='other_in')">
|
<template
|
||||||
<el-table-column label="月入库总数" prop="count"></el-table-column>
|
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>
|
||||||
<template v-if="queryType=='月'&&(query.mio_type=='do_out'||query.mio_type=='sale_out'||query.mio_type=='other_out')">
|
<template
|
||||||
<el-table-column label="月出库数量" prop="batch"> </el-table-column>
|
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>
|
||||||
<template v-if="queryType=='年'&&(query.mio_type=='pur_in'||query.mio_type=='do_in'||query.mio_type=='other_in')">
|
<template
|
||||||
<el-table-column label="年入库总数" prop="count"></el-table-column>
|
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>
|
||||||
<template v-if="queryType=='年'&&(query.mio_type=='do_out'||query.mio_type=='sale_out'||query.mio_type=='other_out')">
|
<template
|
||||||
<el-table-column label="年出库总数" prop="count"></el-table-column>
|
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>
|
||||||
</scTable>
|
</scTable>
|
||||||
</el-main>
|
</el-main>
|
||||||
|
|
@ -108,117 +233,147 @@
|
||||||
</el-container>
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mioTypeEnum } from "@/utils/enum.js";
|
import { mioTypeEnum } from "@/utils/enum.js";
|
||||||
function deepCopy(obj) {
|
function deepCopy(obj) {
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'chart',
|
name: "chart",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
mioTypeEnum,
|
mioTypeEnum,
|
||||||
apiObj: this.$API.mtm.material.list,
|
apiObj: this.$API.mtm.material.list,
|
||||||
materialType: '',
|
materialType: "",
|
||||||
params: { is_hidden: false, type: 10 ,count__gte:1},
|
params: { is_hidden: false, type: 10, count__gte: 1 },
|
||||||
query: {
|
query: {
|
||||||
mio_type:mioTypeEnum.values[0].key
|
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();
|
|
||||||
},
|
},
|
||||||
//更改周预估用量
|
mio_type_name: mioTypeEnum.values[0].text,
|
||||||
weekcountChange(row) {
|
queryType: "月",
|
||||||
let obj = { week_esitimate_consume: row.week_esitimate_consume };
|
queryDate: "",
|
||||||
this.$API.mtm.material.setWeekConsume.req(row.id, obj).then(res => {
|
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);
|
console.log(res);
|
||||||
this.$refs.tables1.refresh();
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.tables {
|
.tables {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
right: 6px;
|
right: 6px;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue