add:历史库存分析
This commit is contained in:
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