add:历史库存分析
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.masterdata_manage.storage.service.dailyStructivt.dao.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@@ -20,5 +21,12 @@ public interface StIvtStructivtDailyMapper extends BaseMapper<StIvtStructivtDail
|
||||
|
||||
@Select("SELECT #{table} AS table_name,GROUP_CONCAT(a.struct_code) struct_code, 'A1' AS product_area, st_ivt_structattr.stor_id,st_ivt_structattr.stor_name , st_ivt_structattr.sect_id,st_ivt_structattr.sect_name , UUID_SHORT( ) id,a.material_id,md_me_materialbase.material_code,md_me_materialbase.material_spec, sum( canuse_qty ) canuse_qty, sum( frozen_qty ) frozen_qty, sum( ivt_qty ) ivt_qty, sum( warehousing_qty ) warehousing_qty, qty_unit_id, CURDATE( ) create_time FROM ${table} as a left join st_ivt_structattr on a.struct_code = st_ivt_structattr.struct_code left join md_me_materialbase on a.material_id = md_me_materialbase.material_id GROUP BY material_id")
|
||||
List<Map> selectStructivt(@Param("table") String table);
|
||||
|
||||
/**
|
||||
* 大屏数据 - 近一周工段产量
|
||||
* @param list /
|
||||
* @return /
|
||||
*/
|
||||
List<JSONObject> getHistoryivt(@Param("chanList") List<String> list, @Param("query") Map json);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.masterdata_manage.storage.service.dailyStructivt.dao.mapper.StIvtStructivtDailyMapper">
|
||||
<select id="getHistoryivt" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
da.*,
|
||||
mater.material_name
|
||||
FROM
|
||||
st_ivt_structivt_daily da
|
||||
LEFT JOIN md_me_materialbase mater ON da.material_id = mater.material_id
|
||||
<where>
|
||||
da.create_time IN
|
||||
<foreach collection="chanList" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
<if test="query.stor_id != null and query.stor_id != ''">
|
||||
and da.stor_id = #{query.stor_id}
|
||||
</if>
|
||||
|
||||
<if test="query.material_code != null and query.material_code != ''">
|
||||
and (mater.material_code LIKE '%${query.material_code}%' or
|
||||
mater.material_name LIKE '%${query.material_code}%' or
|
||||
mater.material_spec LIKE '%${query.material_code}%')
|
||||
</if>
|
||||
|
||||
order by da.create_time
|
||||
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
package org.nl.wms.stata_manage.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.stata_manage.service.HistoryivtService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2022-06-28
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "历史库存统计分析")
|
||||
@RequestMapping("/api/historyivt")
|
||||
@Slf4j
|
||||
public class HistoryivtController {
|
||||
|
||||
private final HistoryivtService historyivtService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("库存查询")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(historyivtService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getHeader")
|
||||
@ApiOperation("获取表头")
|
||||
public ResponseEntity<Object> getHeader() {
|
||||
return new ResponseEntity<>(historyivtService.getHeader(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/autoWeb")
|
||||
@ApiOperation("线性图")
|
||||
public ResponseEntity<Object> autoWeb(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(historyivtService.autoWeb(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
package org.nl.wms.stata_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务接口
|
||||
* @date 2022-06-28
|
||||
**/
|
||||
public interface HistoryivtService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 获取表头
|
||||
*/
|
||||
JSONArray getHeader();
|
||||
|
||||
/**
|
||||
* 线形图数据获取
|
||||
* @return /
|
||||
*/
|
||||
JSONObject autoWeb( JSONObject whereJson );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
|
||||
package org.nl.wms.stata_manage.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.wms.masterdata_manage.storage.service.dailyStructivt.dao.mapper.StIvtStructivtDailyMapper;
|
||||
import org.nl.wms.stata_manage.service.HistoryivtService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务实现
|
||||
* @date 2022-06-28
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class HistoryivtServiceImpl implements HistoryivtService {
|
||||
|
||||
@Autowired
|
||||
private StIvtStructivtDailyMapper stIvtStructivtDailyMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
|
||||
String endTime = DateUtil.today();
|
||||
DateTime toDay = DateUtil.parse(endTime);
|
||||
|
||||
String startTime = DateUtil.offsetDay(toDay, -6).toString().substring(0, 10);
|
||||
|
||||
// 7天时间集合
|
||||
List<String> timeList =
|
||||
DateUtil.rangeToList(DateUtil.parse(startTime), DateUtil.parse(endTime), DateField.DAY_OF_YEAR)
|
||||
.stream()
|
||||
.map(row -> row.toString().substring(0,10))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<JSONObject> ivtList = stIvtStructivtDailyMapper.getHistoryivt(timeList, whereJson);
|
||||
|
||||
// 处理数据
|
||||
JSONArray data = new JSONArray();
|
||||
|
||||
Map<String, List<JSONObject>> ivt = ivtList.stream().collect(Collectors.groupingBy(
|
||||
row -> row.getString("material_code")
|
||||
));
|
||||
|
||||
for (String material_coed: ivt.keySet()) {
|
||||
|
||||
// 找出相同数据
|
||||
List<JSONObject> findList = ivtList.stream()
|
||||
.filter(row -> row.getString("material_code").equals(material_coed))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("1", findList.get(0).getString("material_code"));
|
||||
jsonObject.put("2", findList.get(0).getString("material_name"));
|
||||
jsonObject.put("3", findList.get(0).getString("material_spec"));
|
||||
|
||||
for (JSONObject json : findList) {
|
||||
jsonObject.put(json.getString("create_time"), NumberUtil.round(json.getDoubleValue("canuse_qty"), 3));
|
||||
}
|
||||
|
||||
data.add(jsonObject);
|
||||
}
|
||||
|
||||
// 处理分页
|
||||
Map<String, Object> json = PageUtil.toPage(
|
||||
PageUtil.toPage(page.getPageNumber(), page.getPageSize(), data),
|
||||
data.size()
|
||||
);
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getHeader() {
|
||||
JSONArray jsonResultArr = new JSONArray();
|
||||
|
||||
// 获取日期: 当前日期前7天
|
||||
String todayStr = DateUtil.today();
|
||||
DateTime toDay = DateUtil.parse(todayStr);
|
||||
|
||||
for (int i = 6; i >=0; i--) {
|
||||
DateTime dateTime = DateUtil.offsetDay(toDay, -i);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("prop", dateTime.toString().substring(0, 10));
|
||||
json.put("label", dateTime.toString().substring(0, 10));
|
||||
jsonResultArr.add(json);
|
||||
}
|
||||
return jsonResultArr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject autoWeb(JSONObject whereJson) {
|
||||
/*
|
||||
* 处理数据
|
||||
* 1.legend:每条线的名称
|
||||
* 2.xAxis:所有日期
|
||||
* 3.series:具体数据
|
||||
*/
|
||||
|
||||
// 3.具体数据
|
||||
List<JSONObject> allList = publicMethodQuery(whereJson);
|
||||
|
||||
// 1.每条线的名称
|
||||
List<String> legendList = allList.stream()
|
||||
.map(row -> row.getString("name"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2.所有日期
|
||||
JSONArray headerArr = getHeader();
|
||||
|
||||
List<String> xAxisList = headerArr.stream()
|
||||
.map(row -> ((JSONObject) row).getString("prop"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 整理数据
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("legenda",legendList);
|
||||
result.put("xAxisa",xAxisList);
|
||||
result.put("seriesa",allList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询共用方法
|
||||
* @param whereJson 、
|
||||
* @return 、
|
||||
*/
|
||||
private List<JSONObject> publicMethodQuery(Map whereJson) {
|
||||
|
||||
String endTime = DateUtil.today();
|
||||
DateTime toDay = DateUtil.parse(endTime);
|
||||
|
||||
String startTime = DateUtil.offsetDay(toDay, -6).toString().substring(0, 10);
|
||||
|
||||
// 7天时间集合
|
||||
List<String> timeList =
|
||||
DateUtil.rangeToList(DateUtil.parse(startTime), DateUtil.parse(endTime), DateField.DAY_OF_YEAR)
|
||||
.stream()
|
||||
.map(row -> row.toString().substring(0,10))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<JSONObject> ivtList = stIvtStructivtDailyMapper.getHistoryivt(timeList, whereJson);
|
||||
|
||||
// 处理数据
|
||||
List<JSONObject> alldataList = new ArrayList<>();
|
||||
|
||||
Map<String, List<JSONObject>> ivt = ivtList.stream().collect(Collectors.groupingBy(
|
||||
row -> row.getString("material_code")
|
||||
));
|
||||
|
||||
for (String material_coed: ivt.keySet()) {
|
||||
|
||||
// 找出相同数据
|
||||
List<JSONObject> findList = ivtList.stream()
|
||||
.filter(row -> row.getString("material_code").equals(material_coed))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", findList.get(0).getString("material_code"));
|
||||
jsonObject.put("type", "line");
|
||||
jsonObject.put("stack", "Total");
|
||||
|
||||
JSONArray data = new JSONArray();
|
||||
|
||||
JSONArray headerArr = getHeader();
|
||||
List<String> xAxisList = headerArr.stream()
|
||||
.map(row -> ((JSONObject) row).getString("prop"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
xAxisList.forEach(row -> {
|
||||
for (JSONObject json : findList) {
|
||||
|
||||
if (json.getString("create_time").equals(row)) {
|
||||
data.add(NumberUtil.round(json.getDoubleValue("canuse_qty"), 3));
|
||||
} else {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jsonObject.put("data", data);
|
||||
|
||||
alldataList.add(jsonObject);
|
||||
}
|
||||
return alldataList;
|
||||
}
|
||||
|
||||
}
|
||||
102
mes/qd/src/views/wms/stata_manage/historyivt/LinChart.vue
Normal file
102
mes/qd/src/views/wms/stata_manage/historyivt/LinChart.vue
Normal file
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div id="myId" :class="className" :style="{height:height,width:width}" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import echarts from 'echarts'
|
||||
require('echarts/theme/macarons') // echarts theme
|
||||
import { debounce } from '@/utils'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
className: {
|
||||
type: String,
|
||||
default: 'chart'
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: '100%'
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: '300px'
|
||||
},
|
||||
chartData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chart: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
chartData: {
|
||||
deep: true,
|
||||
handler() {
|
||||
// 每次清除之后重新渲染
|
||||
const myChart = echarts.init(document.getElementById('myId'))
|
||||
myChart.clear()
|
||||
this.setOptions()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initChart()
|
||||
this.__resizeHandler = debounce(() => {
|
||||
if (this.chart) {
|
||||
this.chart.resize()
|
||||
}
|
||||
}, 100)
|
||||
window.addEventListener('resize', this.__resizeHandler)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (!this.chart) {
|
||||
return
|
||||
}
|
||||
window.removeEventListener('resize', this.__resizeHandler)
|
||||
this.chart.dispose()
|
||||
this.chart = null
|
||||
},
|
||||
methods: {
|
||||
initChart() {
|
||||
this.chart = echarts.init(this.$el, 'macarons')
|
||||
this.setOptions()
|
||||
},
|
||||
setOptions() {
|
||||
this.chart.setOption({
|
||||
title: {
|
||||
text: 'material_code'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: this.chartData.legenda
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: this.chartData.xAxisa
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: this.chartData.seriesa
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
42
mes/qd/src/views/wms/stata_manage/historyivt/historyivt.js
Normal file
42
mes/qd/src/views/wms/stata_manage/historyivt/historyivt.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/historyivt',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/historyivt/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/historyivt',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getHeader() {
|
||||
return request({
|
||||
url: 'api/historyivt/getHeader',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function autoWeb(data) {
|
||||
return request({
|
||||
url: 'api/historyivt/autoWeb',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getHeader, autoWeb }
|
||||
216
mes/qd/src/views/wms/stata_manage/historyivt/index.vue
Normal file
216
mes/qd/src/views/wms/stata_manage/historyivt/index.vue
Normal file
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
label-suffix=":"
|
||||
size="mini"
|
||||
>
|
||||
|
||||
<el-form-item label="仓库">
|
||||
<label slot="label">仓 库:</label>
|
||||
<el-select
|
||||
v-model="query.stor_id"
|
||||
size="mini"
|
||||
placeholder="单据状态"
|
||||
class="filter-item"
|
||||
@change="crud.toQuery"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in storlist"
|
||||
:key="item.stor_id"
|
||||
:label="item.stor_name"
|
||||
:value="item.stor_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="日期">
|
||||
<label slot="label">日 期:</label>
|
||||
<el-date-picker
|
||||
v-model="query.createTime"
|
||||
type="daterange"
|
||||
value-format="yyyy-MM-dd"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:clearable="false"
|
||||
:disabled="true"
|
||||
@input="onInput()"
|
||||
@change="mytoQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="物料编码">
|
||||
<el-input
|
||||
v-model="query.material_code"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="请输入物料编码、名称、规格"
|
||||
style="width: 230px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission"/>
|
||||
<!--表格渲染-->
|
||||
<el-row :gutter="20">
|
||||
<el-col :xs="24" :sm="24" :lg="24">
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
size="mini"
|
||||
:max-height="590"
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="45" />
|
||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
||||
<el-table-column prop="1" label="物料编码" min-width="150" />
|
||||
<el-table-column prop="2" label="物料名称" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="3" label="物料规格" min-width="150" />
|
||||
<template v-for="(col,index) in cols">
|
||||
<el-table-column v-if="col" :prop="col.prop" :label="col.label" align="center" min-width="140" />
|
||||
</template>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :xs="24" :sm="24" :lg="24">
|
||||
<div class="chart-wrapper">
|
||||
<Lin-chart :chart-data="dataList" />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudHistoryivt, { autoWeb } from '@/views/wms/stata_manage/historyivt/historyivt'
|
||||
import CRUD, { presenter, header, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import DateRangePicker from '@/components/DateRangePicker/index'
|
||||
import Date from '@/utils/datetime'
|
||||
import crudStorattr from '@/views/wms/storage_manage/basedata/basedata'
|
||||
import LinChart from '@/views/wms/stata_manage/historyivt/LinChart'
|
||||
|
||||
export default {
|
||||
name: 'Historyivt',
|
||||
components: { pagination, crudOperation, rrOperation, LinChart, udOperation, DateRangePicker },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '历史库存分析',
|
||||
url: 'api/historyivt',
|
||||
idField: 'id',
|
||||
sort: 'id,desc',
|
||||
crudMethod: { ...crudHistoryivt },
|
||||
props: {
|
||||
// 每页数据条数
|
||||
size: 10
|
||||
},
|
||||
optShow: {
|
||||
add: false,
|
||||
edit: false,
|
||||
del: false,
|
||||
download: false,
|
||||
reset: true
|
||||
}
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cols: [],
|
||||
storlist: [],
|
||||
dataList: '',
|
||||
query_flag: true,
|
||||
openParam: null,
|
||||
permission: {
|
||||
},
|
||||
rules: {
|
||||
}}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
},
|
||||
beforeDestroy() {
|
||||
// js提供的clearInterval方法用来清除定时器
|
||||
console.log('定时器销毁')
|
||||
clearInterval(this.timer)
|
||||
},
|
||||
created() {
|
||||
crudStorattr.getStor({ 'stor_type': '' }).then(res => {
|
||||
this.storlist = res.content
|
||||
})
|
||||
this.crud.query.createTime = [new Date().daysAgo(6), new Date()]
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
if (this.query_flag) {
|
||||
this.crud.query.begin_time = (new Date().daysAgo(6)).strftime('%F', 'zh')
|
||||
this.crud.query.end_time = (new Date()).strftime('%F', 'zh')
|
||||
this.crud.query.stor_id = '1528627995269533696'
|
||||
this.query_flag = false
|
||||
}
|
||||
this.getHeader()
|
||||
},
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
onInput() {
|
||||
this.$forceUpdate()
|
||||
},
|
||||
getHeader() {
|
||||
crudHistoryivt.getHeader().then(res => {
|
||||
this.cols = res
|
||||
})
|
||||
},
|
||||
mytoQuery(array1) {
|
||||
if (array1 === null) {
|
||||
this.crud.query.begin_time = ''
|
||||
this.crud.query.end_time = ''
|
||||
} else {
|
||||
this.crud.query.begin_time = array1[0]
|
||||
this.crud.query.end_time = array1[1]
|
||||
}
|
||||
this.crud.toQuery()
|
||||
},
|
||||
init: function() {
|
||||
this.initStageData()
|
||||
},
|
||||
initStageData() {
|
||||
this.timer = setInterval(() => { // 定时刷新
|
||||
console.log('定时器启动')
|
||||
this.initStatus()
|
||||
}, 4000)
|
||||
},
|
||||
initStatus() {
|
||||
autoWeb(this.crud.query).then(res => {
|
||||
this.dataList = res
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user