<template>
|
<div class="rightContent">
|
<el-dialog
|
title="配置初期时间"
|
:visible.sync="timeModal"
|
width="30%"
|
:before-close="handlerClose">
|
<el-form style="width: 80%;margin: 20px auto;" ref="sysFormRef">
|
<el-form-item label="日期配置:">
|
<el-select v-model="startDate.day" style="margin-left: 20px">
|
<el-option v-for="day in 28" :value="day.toString().padStart(2,'0')":label="day.toString().padStart(2,'0')"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="时间配置:">
|
<el-time-select
|
:picker-options="startPickerOptions"
|
v-model="startDate.time"
|
type="time"
|
format="HH:mm"
|
value-format="HH:mm"
|
:clearable='true'
|
class='margin_left_20px'
|
>
|
</el-time-select>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="timeModal = false" size="mini">取 消</el-button>
|
<el-button type="primary" @click="saveStartDate" size="mini">保存</el-button>
|
</span>
|
</el-dialog>
|
<div class="top">
|
<SearchCommonView :add-title="'新建'" :showAdd="false" :placeholder="'请输入产品编码/产品名称搜索'" :amount-view="false" :showDownload="true" @downloadClick="downHttpClick"
|
@searchClick="getList" >
|
<template slot="leftButton">
|
<div>
|
<el-date-picker
|
v-model="monthBoundObject.date"
|
value-format="yyyy-MM"
|
type="month"
|
:clearable='false'
|
class='margin_left_20px'
|
@change='getData'
|
placeholder="选择日期"
|
:picker-options="pickerOptions"
|
>
|
</el-date-picker>
|
<el-select v-model="warehouseId" @change="getData" style="margin-left: 10px">
|
<el-option v-for="warehouse in warehouseList" :key="warehouse.id" :label="warehouse.name" :value="warehouse.id"></el-option>
|
</el-select>
|
<el-button size="mini" @click="timeModal=true" class="el-icon-setting" type="text" style="margin-left: 10px">配置</el-button>
|
</div>
|
</template>
|
</SearchCommonView>
|
</div>
|
<div class="list-view">
|
<div class="table">
|
<TableCommonView ref="tableListRef"
|
:loading="isTableOneLoading"
|
:table-list="tableList"
|
:showCheckcol='false'
|
@selTableCol="selTableCol">
|
<template slot="tableButton">
|
<!-- <el-table-column label="规格" ></el-table-column>
|
<el-table-column label="颜色"></el-table-column>-->
|
<el-table-column label="期初库存" prop='beginAmount'></el-table-column>
|
<el-table-column label="期末库存" prop='amount'></el-table-column>
|
<el-table-column label="单位" prop='unit'></el-table-column>
|
<!--<el-table-column label="状态" prop='status'></el-table-column>-->
|
<el-table-column label="本月入库" prop='inInventoryCurrentMonth'>
|
<el-table-column v-for="input in inputList" :key="input.id" :label="input.name" min="90">
|
<template slot-scope="scope">
|
{{doUnit(scope.row.inputItems,input)}}
|
</template>
|
</el-table-column>
|
<el-table-column label="入库合计" min="90">
|
<template slot-scope="scope">
|
{{doUnitCount(scope.row.inputItems,inputList)}}
|
</template>
|
</el-table-column>
|
</el-table-column>
|
<el-table-column label="本月出库">
|
<el-table-column v-for="out in outList" :key="out.id" :label="out.name" min="90">
|
<template slot-scope="scope" >
|
{{doUnit(scope.row.outputItems,out)}}
|
</template>
|
</el-table-column>
|
<el-table-column label="出库合计" min="90">
|
<template slot-scope="scope">
|
{{doUnitCount(scope.row.outputItems,outList)}}
|
</template>
|
</el-table-column>
|
</el-table-column>
|
|
</template>
|
</TableCommonView>
|
</div>
|
<div class="btn-pager">
|
<PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
|
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
|
import { getmonthStats ,getSystemConfigApi,saveSystemConfigApi,getWarehouseMothStatsApi} from "@/api/reportForm/inventoryRwport"
|
import newDate from "@/api/date";
|
import { downloadMonthStats ,downloadWareMothStatsApi} from "@/api/downFile"
|
import FileSaver from 'file-saver'
|
import _ from 'lodash'
|
import {getWarehouseList} from '@/api/warehouseManage/warehouse.js'
|
import {
|
getDictListApi
|
} from "@/api/operate/inventoryAdjustment";
|
|
const { getPreviousMonth,formatTime,getCurrentMonth} = newDate;
|
export default {
|
name: "outboundDetail",
|
props: {},
|
components: {},
|
mixins: [pageMixin],
|
computed: {},
|
data() {
|
return {
|
inputList:[],
|
outList:[],
|
warehouseList:[],
|
warehouseId:0,
|
systemParams:{
|
ID:0,
|
configType:1,
|
name:'',
|
},
|
startDate:{
|
day:'01',
|
time:'00:00'
|
},
|
timeModal:false,
|
monthBoundObject:{
|
keyWord:'',
|
date:getCurrentMonth(),
|
},
|
startPickerOptions:{
|
start:'00:00',
|
step:'00:30',
|
end:'23:59'
|
},
|
tableList: {},
|
showcol: [],
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() > formatTime(getCurrentMonth());
|
},
|
},
|
isTableOneLoading: false,
|
}
|
},
|
created() {
|
this.setTable();
|
this.queryWareHouse();
|
this.querySystemConfig();
|
this.queryDictList();
|
},
|
methods: {
|
doUnit(items,typeObj){
|
let res= '--';
|
if(Array.isArray(items)&&items.length>0){
|
items.forEach(item=>{
|
if(item.name===typeObj.name){
|
res=item.amount;
|
}
|
})
|
}
|
return res;
|
},
|
doUnitCount(items,typeList){
|
let result=0;
|
if(Array.isArray(items)&&items.length>0){
|
items.forEach(item=>{
|
const flag=typeList.some(tItem=>tItem.name===item.name);
|
if(flag){
|
result+=parseInt(item.amount);
|
}
|
})
|
}
|
return result;
|
},
|
async queryDictList(){
|
const {code,data} =await getDictListApi({type:0});
|
if(code===200){
|
this.inputList=data.filter(item=>item.type===1);
|
this.outList=data.filter(item=>item.type===2);
|
const otherObj={
|
"id": 0,
|
"createdAt": "0001-01-01 00:00:00",
|
"updatedAt": "0001-01-01 00:00:00",
|
"name": "其他",
|
"code": "",
|
"value": "",
|
"isDefault": false
|
};
|
let flag=this.inputList.some(item=>item.name==='其他');
|
if(!flag){
|
otherObj.type=1;
|
this.inputList.push(otherObj);
|
}
|
flag=this.outList.some(item=>item.name==='其他');
|
if(!flag){
|
otherObj.type=2;
|
this.outList.push(otherObj);
|
}
|
}
|
},
|
//1.查询仓库列表
|
async queryWareHouse(){
|
const {code,data}=await getWarehouseList({page:0,pageSize:0,keyword: ""});
|
if(code===200){
|
this.warehouseList=data;
|
if(Array.isArray(data)&&data.length>0){
|
this.warehouseId=data[0].id;
|
this.getData();
|
}
|
}
|
},
|
async querySystemConfig(){
|
const params={configType:1};
|
const {code,data}=await getSystemConfigApi(params);
|
if(code===200){
|
if(data.val){
|
this.systemParams.ID=data.id;
|
this.systemParams.name=data.name;
|
this.startDate.day=data.val.split("-")[0];
|
this.startDate.time=data.val.split("-")[1];
|
}
|
}
|
},
|
handlerClose(){
|
this.timeModal=false;
|
this.$refs.sysFormRef.resetFields();
|
},
|
async saveStartDate(){
|
const params={...this.systemParams,val:this.startDate.day+'-'+this.startDate.time};
|
const {code} =await saveSystemConfigApi(params);
|
if(code===200){
|
this.$message.success('配置成功');
|
this.querySystemConfig();
|
this.timeModal=false;
|
}else{
|
this.$message.error('配置失败');
|
}
|
},
|
|
// 下载
|
downHttpClick: _.debounce(function(){
|
downloadWareMothStatsApi({
|
date:this.monthBoundObject.date,
|
keyword: this.monthBoundObject.keyWord,
|
page: this.pagerOptions.currPage,
|
pageSize: this.pagerOptions.pageSize,
|
warehouseId:this.warehouseId
|
}).then(res => {
|
if (res) {
|
FileSaver.saveAs(res, '仓库月度明细报表.xlsx');
|
this.$message.success("下载成功!");
|
}
|
})
|
}, 1000),
|
getUnitValue(list,val,num,unit){
|
let string='--'
|
if(list){
|
if(list.length>0){
|
for(let i in list){
|
if(list[i].unit==val){
|
string=list[i].amount
|
break;
|
}
|
}
|
}
|
}
|
if(unit==val){
|
string=num
|
}
|
return string
|
},
|
setTable() {
|
this.tableList = {
|
tableInfomation: [],
|
selectBox: false,
|
selectIndex:true,
|
showcol: this.showcol,
|
allcol: [],
|
tableColumn: this.setTableColumn(this.showcol)
|
}
|
let allcol = []
|
for (let i = 0; i < this.tableList.tableColumn.length; i++) {
|
if (!this.tableList.tableColumn[i].default) {
|
const label = this.tableList.tableColumn[i].label
|
allcol.push(label)
|
}
|
}
|
this.tableList.allcol = allcol
|
},
|
setTableColumn() {
|
let tableColumn = [
|
{
|
label: "产品编码",
|
prop: "productId",
|
min:110,
|
isShowColumn: true,
|
default: true
|
},
|
{
|
label: "产品名称",
|
prop: "productName",
|
min:110,
|
isShowColumn: true,
|
default: true
|
},
|
]
|
return tableColumn
|
},
|
selTableCol(val) {
|
this.showcol = val
|
this.tableList.tableColumn = this.setTableColumn(val)
|
},
|
// 库存报表跳转请求数据
|
async getData() {
|
this.isTableOneLoading = true;
|
await getWarehouseMothStatsApi({
|
date:this.monthBoundObject.date,
|
keyword: this.monthBoundObject.keyWord,
|
page: this.pagerOptions.currPage,
|
pageSize: this.pagerOptions.pageSize,
|
warehouseId: this.warehouseId
|
}).then((res) => {
|
if (res.code == 200&&res.data) {
|
this.tableList.tableInfomation = res.data||[]
|
}else{
|
this.tableList.tableInfomation = res.data||[]
|
}
|
this.pagerOptions.totalCount = res.total
|
this.isTableOneLoading = false;
|
})
|
|
},
|
// 搜索
|
getList(val) {
|
this.monthBoundObject.keyWord = val;
|
this.getData()
|
},
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped></style>
|