销售统计
This commit is contained in:
parent
6472e9adcb
commit
b9e1fe491c
|
|
@ -38,22 +38,23 @@
|
||||||
<el-header>
|
<el-header>
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<h2>棒管交付数</h2>
|
<h2>棒管交付数</h2>
|
||||||
<el-select v-model="product" clearable @change="productChange">
|
<!-- <el-select v-model="product" clearable @change="productChange">
|
||||||
<el-option v-for="item in inmData"
|
<el-option v-for="item in inmData"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.material_.name"
|
:label="item.material_.name"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select> -->
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<scEcharts height="300px" :option="option1"></scEcharts>
|
<div id="bachart1" style="width:100%;height:300px;"></div>
|
||||||
|
<!-- <scEcharts height="300px" :option="option1"></scEcharts> -->
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-table :data="tableData">
|
<el-table :data="tableData1">
|
||||||
<el-table-column type="index" width="50" />
|
<el-table-column type="index" width="50" />
|
||||||
<el-table-column label="日期" prop="date">
|
<el-table-column label="日期" prop="date">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -71,22 +72,23 @@
|
||||||
<el-header>
|
<el-header>
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<h2>棒交付数</h2>
|
<h2>棒交付数</h2>
|
||||||
<el-select v-model="product" clearable @change="productChange">
|
<!-- <el-select v-model="product" clearable @change="productChange">
|
||||||
<el-option v-for="item in outData"
|
<el-option v-for="item in outData"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.material_.name"
|
:label="item.material_.name"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select> -->
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<scEcharts height="300px" :option="option2"></scEcharts>
|
<div id="bachart2" style="width:100%;height:300px;"></div>
|
||||||
|
<!-- <scEcharts height="300px" :option="option2"></scEcharts> -->
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-table :data="tableData">
|
<el-table :data="tableData2">
|
||||||
<el-table-column type="index" width="50" />
|
<el-table-column type="index" width="50" />
|
||||||
<el-table-column label="日期" prop="date">
|
<el-table-column label="日期" prop="date">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -105,8 +107,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import * as echarts from "echarts";
|
||||||
|
import T from '@/components/scEcharts/echarts-theme-T.js';
|
||||||
|
echarts.registerTheme('T', T);
|
||||||
import scEcharts from '@/components/scEcharts';
|
import scEcharts from '@/components/scEcharts';
|
||||||
const xAxisData = ['第一周','第二周','第三周','第四周'];
|
function deepCopy(obj) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'chart',
|
name: 'chart',
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -120,9 +127,14 @@
|
||||||
end_date:'',
|
end_date:'',
|
||||||
currentYear:'',
|
currentYear:'',
|
||||||
currentMonth:'',
|
currentMonth:'',
|
||||||
xAxisData:['第一周','第二周','第三周','第四周'],
|
xAxisOrigin:[],
|
||||||
|
xAxisData:[],
|
||||||
typeOptions:['月','年'],
|
typeOptions:['月','年'],
|
||||||
option1: {
|
basicOption: {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
title: {
|
||||||
|
text: '',
|
||||||
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: '80px'
|
top: '80px'
|
||||||
},
|
},
|
||||||
|
|
@ -131,137 +143,209 @@
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data:xAxisData
|
data: []
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'value'
|
type: 'value'
|
||||||
},
|
},
|
||||||
|
lenged:[],
|
||||||
series: [{
|
series: [{
|
||||||
data: [120, 200, 150, 80, 70, 110, 130],
|
data: [0, 0, 0, 0, 0, 0, 0],
|
||||||
type: 'bar',
|
stack: 'Ad',
|
||||||
barWidth: '15px',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: [110, 180, 120, 120, 60, 90, 110],
|
|
||||||
type: 'bar',
|
|
||||||
barWidth: '15px',
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
option2: {
|
|
||||||
grid: {
|
|
||||||
top: '80px'
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis'
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
type: 'category',
|
|
||||||
data: xAxisData
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
type: 'value'
|
|
||||||
},
|
|
||||||
series: [{
|
|
||||||
data: [120, 200, 150, 80, 70, 110, 130],
|
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
barWidth: '15px',
|
barWidth: '15px',
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
// option1: {
|
||||||
|
// grid: {
|
||||||
|
// top: '80px'
|
||||||
|
// },
|
||||||
|
// tooltip: {
|
||||||
|
// trigger: 'axis'
|
||||||
|
// },
|
||||||
|
// xAxis: {
|
||||||
|
// type: 'category',
|
||||||
|
// data:xAxisData
|
||||||
|
// },
|
||||||
|
// yAxis: {
|
||||||
|
// type: 'value'
|
||||||
|
// },
|
||||||
|
// series: [{
|
||||||
|
// data: [120, 200, 150, 80, 70, 110, 130],
|
||||||
|
// type: 'bar',
|
||||||
|
// barWidth: '15px',
|
||||||
|
// }]
|
||||||
|
// },
|
||||||
|
// option2: {
|
||||||
|
// grid: {
|
||||||
|
// top: '80px'
|
||||||
|
// },
|
||||||
|
// tooltip: {
|
||||||
|
// trigger: 'axis'
|
||||||
|
// },
|
||||||
|
// xAxis: {
|
||||||
|
// type: 'category',
|
||||||
|
// data: xAxisData
|
||||||
|
// },
|
||||||
|
// yAxis: {
|
||||||
|
// type: 'value'
|
||||||
|
// },
|
||||||
|
// series: [{
|
||||||
|
// data: [120, 200, 150, 80, 70, 110, 130],
|
||||||
|
// type: 'bar',
|
||||||
|
// barWidth: '15px',
|
||||||
|
// }]
|
||||||
|
// },
|
||||||
tableData:[
|
tableData:[
|
||||||
{id:1,date:'2023-12-11',name:'ZJ2-1',count:200},
|
{id:1,date:'2023-12-11',name:'ZJ2-1',count:200},
|
||||||
{id:1,date:'2023-12-11',name:'ZJ2-2',count:200},
|
{id:1,date:'2023-12-11',name:'ZJ2-2',count:200},
|
||||||
{id:1,date:'2023-12-11',name:'ZJ2-3',count:200},
|
{id:1,date:'2023-12-11',name:'ZJ2-3',count:200},
|
||||||
{id:1,date:'2023-12-11',name:'ZJ2-4',count:200},
|
{id:1,date:'2023-12-11',name:'ZJ2-4',count:200},
|
||||||
],
|
],
|
||||||
inmData:[],
|
tableData1:[],
|
||||||
outData:[],
|
tableData2:[],
|
||||||
|
firstWeekNum:1,
|
||||||
|
endWeekNum:4,
|
||||||
|
monthList:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
|
let that =this;
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
let year = date.getFullYear();
|
let year = date.getFullYear();
|
||||||
let month = date.getMonth()+1;
|
let month = date.getMonth()+1;
|
||||||
let days = new Date(year, month, 0).getDate();
|
let days = new Date(year, month, 0).getDate();
|
||||||
this.currentYear = year;
|
that.currentYear = year;
|
||||||
this.currentMonth = month;
|
that.currentMonth = month;
|
||||||
this.start_date =year+'-'+month+'-01';
|
that.start_date =year+'-'+month+'-01';
|
||||||
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
|
that.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
|
||||||
this.queryDate = year+'-'+month;
|
let month1=month;
|
||||||
this.getInmData();
|
if(month1<10){month1='0'+month1}
|
||||||
this.getOutData();
|
that.queryDate = year+'-'+month1;
|
||||||
|
that.firstWeekNum = that.getWeekOfYear(new Date(that.start_date));
|
||||||
|
that.endWeekNum = that.getWeekOfYear(new Date(that.end_date));
|
||||||
|
let duration = that.endWeekNum - that.firstWeekNum + 1;
|
||||||
|
for(let i =1;i<=duration;i++ ){
|
||||||
|
that.xAxisOrigin.push('第'+i+'周');
|
||||||
|
}
|
||||||
|
that.xAxisData = that.xAxisOrigin;
|
||||||
|
this.getTableData();
|
||||||
|
// this.getTableData2();
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getInmData(){},
|
setChart(name, option = null) {
|
||||||
getOutData(){},
|
// 根据name 渲染数据, option需填写,否则option为模拟数据
|
||||||
|
var myChart = echarts.getInstanceByDom(document.getElementById(name));
|
||||||
|
if (myChart == undefined) {
|
||||||
|
myChart = echarts.init(document.getElementById(name), 'T');
|
||||||
|
}
|
||||||
|
if (option == null) {
|
||||||
|
option = Object.assign({}, this.basicOption)
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
myChart.setOption(option);
|
||||||
|
} catch (error) { }
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
queryTypeChange(value){
|
queryTypeChange(value){
|
||||||
console.log(value)
|
console.log(value)
|
||||||
this.queryDate = '';
|
this.queryDate = '';
|
||||||
if(value=='月'){
|
},
|
||||||
this.xAxisData = ['第一周','第二周','第三周','第四周'];
|
getWeekOfYear(date) {
|
||||||
|
var target = new Date(date.getFullYear(), date.getMonth(), date.getDate()); // 创建目标日期对象
|
||||||
|
var firstDayOfYear = new Date(target.getFullYear(), 0, 1); // 创建当前年份第一天的日期对象
|
||||||
|
if(target.getTime()==firstDayOfYear.getTime()){
|
||||||
|
return 1;
|
||||||
}else{
|
}else{
|
||||||
this.xAxisData = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
|
return Math.ceil((target - firstDayOfYear + 8 * (firstDayOfYear.getTimezoneOffset() / 480)) / 604800000);
|
||||||
}
|
}
|
||||||
this.option1.xAxis.data = this.xAxisData;
|
// 计算两者之间相隔的周数并返回结果
|
||||||
this.option2.xAxis.data = this.xAxisData;
|
|
||||||
},
|
},
|
||||||
getData6(){
|
getTableData(){
|
||||||
let that = this;
|
let that = this;
|
||||||
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
|
let option1 = deepCopy(that.basicOption);
|
||||||
|
let option2 = deepCopy(that.basicOption);
|
||||||
|
option1.xAxis.data = that.xAxisData;
|
||||||
|
option2.xAxis.data = that.xAxisData;
|
||||||
|
let exec = that.queryType=='月'?'saleOutWeek':'saleOutMonth';
|
||||||
let obj = {
|
let obj = {
|
||||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "6车间" },
|
query: { start_date: that.start_date, end_date: that.end_date },
|
||||||
};
|
};
|
||||||
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
|
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
|
||||||
console.log('6生产车间统计:',doInRes);
|
// console.log('交付数:',res);
|
||||||
debugger;
|
if(res.length>0){
|
||||||
});
|
let data1 = [],data2 = [],seriesData1=[],seriesData2=[];
|
||||||
},
|
for(let i=0;i<res.length;i++){
|
||||||
getData7(){
|
if(res[i].物料名.indexOf('棒')){
|
||||||
let that = this;
|
data1.push(res[i]);
|
||||||
let obj = {
|
}else if(res[i].物料名.indexOf('管')){
|
||||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "7车间" },
|
data2.push(res[i]);
|
||||||
};
|
}
|
||||||
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
|
}
|
||||||
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
|
that.tableData1 = data1;
|
||||||
console.log('7生产车间统计:',doInRes);
|
that.tableData2 = data2;
|
||||||
debugger;
|
data1.forEach(item1=>{
|
||||||
});
|
let index =0;
|
||||||
},
|
if(that.queryType=='月'){
|
||||||
getData10(){
|
index = item1.月-1;
|
||||||
let that = this;
|
}else{
|
||||||
let obj = {
|
index = item1.周-that.firstWeekNum;
|
||||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "10·车间" },
|
}
|
||||||
};
|
seriesData1[index]=item1.交付数;
|
||||||
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
|
})
|
||||||
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
|
data2.forEach(item2=>{
|
||||||
console.log('10生产车间统计:',doInRes);
|
let index2 =0;
|
||||||
debugger;
|
if(that.queryType=='月'){
|
||||||
});
|
index2 = item2.月-1;
|
||||||
|
}else{
|
||||||
|
index2 = item2.周-that.firstWeekNum;
|
||||||
|
}
|
||||||
|
seriesData2[index2]=item2.交付数;
|
||||||
|
})
|
||||||
|
option1.seriesData1 = seriesData1;
|
||||||
|
option2.seriesData2 = seriesData2;
|
||||||
|
that.setChart("bachart1", option1);
|
||||||
|
that.setChart("bachart2", option2);
|
||||||
|
}else{
|
||||||
|
that.setChart("bachart1", option1);
|
||||||
|
that.setChart("bachart2", option2);
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleQuery(){
|
handleQuery(){
|
||||||
if(this.queryDate!==''){
|
let that = this;
|
||||||
if(this.queryType=='月'){
|
if(this.queryType=='月'){
|
||||||
|
if(this.queryDate!==''&&this.queryDate!==null){
|
||||||
this.start_date =this.queryDate+'-01';
|
this.start_date =this.queryDate+'-01';
|
||||||
let arr = this.queryDate.split('-');
|
let arr = this.queryDate.split('-');
|
||||||
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
|
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
|
||||||
|
this.firstWeekNum = this.getWeekOfYear(new Date(this.start_date));
|
||||||
|
this.endWeekNum = this.getWeekOfYear(new Date(this.end_date));
|
||||||
|
let duration = this.endWeekNum - this.firstWeekNum + 1;
|
||||||
|
let xAxisData = [];
|
||||||
|
for(let i =1;i<=duration;i++ ){
|
||||||
|
xAxisData.push('第'+i+'周');
|
||||||
|
}
|
||||||
|
that.xAxisData = xAxisData;
|
||||||
}else{
|
}else{
|
||||||
this.start_date = this.queryDate+'-01-01';
|
|
||||||
this.end_date = this.queryDate+'-12-31';
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(this.queryType=='月'){
|
|
||||||
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
|
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
|
||||||
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
|
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
|
||||||
|
let date = new Date(this.start_date);
|
||||||
|
this.firstWeekNum = this.getWeekOfYear(date);
|
||||||
|
this.xAxisData = this.xAxisOrigin;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(this.queryDate!==''&&this.queryDate!==null){
|
||||||
|
this.start_date = this.queryDate+'-01-01';
|
||||||
|
this.end_date = this.queryDate+'-12-31';
|
||||||
}else{
|
}else{
|
||||||
this.start_date = this.currentYear+'-01-01';
|
this.start_date = this.currentYear+'-01-01';
|
||||||
this.end_date = this.currentYear+'-12-31';
|
this.end_date = this.currentYear+'-12-31';
|
||||||
}
|
}
|
||||||
|
that.xAxisData = that.monthList;
|
||||||
}
|
}
|
||||||
debugger;
|
this.getTableData();
|
||||||
console.log(this.query)
|
|
||||||
this.getData6();
|
|
||||||
this.getData7();
|
|
||||||
this.getData10();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<h2>采购统计</h2>
|
<h2>采购统计</h2>
|
||||||
<el-select v-model="product" clearable @change="productChange">
|
<el-select v-model="product" clearable @change="productChange">
|
||||||
<el-option v-for="item in inmData"
|
<el-option v-for="item in inmOption"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.material_.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
|
|
@ -50,7 +50,8 @@
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<scEcharts height="300px" :option="option2"></scEcharts>
|
<div id="bachart1" style="width:100%;height:300px;"></div>
|
||||||
|
<!-- <scEcharts height="300px" :option="option2"></scEcharts> -->
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-table :data="tableData">
|
<el-table :data="tableData">
|
||||||
|
|
@ -72,9 +73,9 @@
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<h2>消耗统计</h2>
|
<h2>消耗统计</h2>
|
||||||
<el-select v-model="product" clearable @change="productChange">
|
<el-select v-model="product" clearable @change="productChange">
|
||||||
<el-option v-for="item in outData"
|
<el-option v-for="item in inmOption"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.material_.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
|
|
@ -83,7 +84,8 @@
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<scEcharts height="300px" :option="option2"></scEcharts>
|
<div id="bachart2" style="width:100%;height:300px;"></div>
|
||||||
|
<!-- <scEcharts height="300px" :option="option2"></scEcharts> -->
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-table :data="tableData">
|
<el-table :data="tableData">
|
||||||
|
|
@ -105,8 +107,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import * as echarts from "echarts";
|
||||||
|
import T from '@/components/scEcharts/echarts-theme-T.js';
|
||||||
|
echarts.registerTheme('T', T);
|
||||||
import scEcharts from '@/components/scEcharts';
|
import scEcharts from '@/components/scEcharts';
|
||||||
const xAxisData = ['第一周','第二周','第三周','第四周'];
|
function deepCopy(obj) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'chart',
|
name: 'chart',
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -120,9 +127,14 @@
|
||||||
end_date:'',
|
end_date:'',
|
||||||
currentYear:'',
|
currentYear:'',
|
||||||
currentMonth:'',
|
currentMonth:'',
|
||||||
xAxisData:['第一周','第二周','第三周','第四周'],
|
xAxisOrigin:[],
|
||||||
|
xAxisData:[],
|
||||||
typeOptions:['月','年'],
|
typeOptions:['月','年'],
|
||||||
option1: {
|
basicOption: {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
title: {
|
||||||
|
text: '',
|
||||||
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: '80px'
|
top: '80px'
|
||||||
},
|
},
|
||||||
|
|
@ -131,43 +143,15 @@
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data:xAxisData
|
data: []
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'value'
|
type: 'value'
|
||||||
},
|
},
|
||||||
|
lenged:[],
|
||||||
series: [{
|
series: [{
|
||||||
data: [120, 200, 150, 80, 70, 110, 130],
|
data: [0, 0, 0, 0, 0, 0, 0],
|
||||||
type: 'bar',
|
stack: 'Ad',
|
||||||
barWidth: '15px',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: [110, 180, 120, 120, 60, 90, 110],
|
|
||||||
type: 'bar',
|
|
||||||
barWidth: '15px',
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
option2: {
|
|
||||||
grid: {
|
|
||||||
top: '80px'
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis'
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
type: 'category',
|
|
||||||
data: xAxisData
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
type: 'value'
|
|
||||||
},
|
|
||||||
series: [{
|
|
||||||
data: [120, 200, 150, 80, 70, 110, 130],
|
|
||||||
type: 'bar',
|
|
||||||
barWidth: '15px',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: [110, 180, 120, 120, 60, 90, 110],
|
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
barWidth: '15px',
|
barWidth: '15px',
|
||||||
}]
|
}]
|
||||||
|
|
@ -178,95 +162,153 @@
|
||||||
{id:1,date:'2023-12-11',name:'ZJ2-3',count:200},
|
{id:1,date:'2023-12-11',name:'ZJ2-3',count:200},
|
||||||
{id:1,date:'2023-12-11',name:'ZJ2-4',count:200},
|
{id:1,date:'2023-12-11',name:'ZJ2-4',count:200},
|
||||||
],
|
],
|
||||||
|
firstWeekNum:1,
|
||||||
|
endWeekNum:1,
|
||||||
|
product:'',
|
||||||
inmData:[],
|
inmData:[],
|
||||||
outData:[],
|
outData:[],
|
||||||
|
inmOption:[],
|
||||||
|
outOption:[],
|
||||||
|
monthList:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
|
let that =this;
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
let year = date.getFullYear();
|
let year = date.getFullYear();
|
||||||
let month = date.getMonth()+1;
|
let month = date.getMonth()+1;
|
||||||
let days = new Date(year, month, 0).getDate();
|
let days = new Date(year, month, 0).getDate();
|
||||||
this.currentYear = year;
|
that.currentYear = year;
|
||||||
this.currentMonth = month;
|
that.currentMonth = month;
|
||||||
this.start_date =year+'-'+month+'-01';
|
that.start_date =year+'-'+month+'-01';
|
||||||
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
|
that.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
|
||||||
this.queryDate = year+'-'+month;
|
let month1=month;
|
||||||
this.getInmData();
|
if(month1<10){month1='0'+month1}
|
||||||
this.getOutData();
|
that.queryDate = year+'-'+month1;
|
||||||
|
that.firstWeekNum = that.getWeekOfYear(new Date(that.firstWeekNum));
|
||||||
|
that.endWeekNum = that.getWeekOfYear(new Date(that.end_date));
|
||||||
|
let duration = that.endWeekNum - that.firstWeekNum + 1;
|
||||||
|
for(let i =1;i<=duration;i++ ){
|
||||||
|
that.xAxisOrigin.push('第'+i+'周');
|
||||||
|
}
|
||||||
|
that.xAxisData = that.xAxisOrigin;
|
||||||
|
this.getInmOption();
|
||||||
|
// this.getOutOption();
|
||||||
|
let option = deepCopy(that.basicOption);
|
||||||
|
option.xAxis.data = that.xAxisData;
|
||||||
|
that.setChart("bachart1", option);
|
||||||
|
let option2 = deepCopy(that.basicOption);
|
||||||
|
option2.xAxis.data = that.xAxisData;
|
||||||
|
that.setChart("bachart2", option2);
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getInmData(){},
|
setChart(name, option = null) {
|
||||||
getOutData(){},
|
var myChart = echarts.getInstanceByDom(document.getElementById(name));
|
||||||
|
if (myChart == undefined) {
|
||||||
|
myChart = echarts.init(document.getElementById(name), 'T');
|
||||||
|
}
|
||||||
|
if (option == null) {
|
||||||
|
option = Object.assign({}, this.basicOption)
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
myChart.setOption(option);
|
||||||
|
} catch (error) { }
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
getWeekOfYear(date) {
|
||||||
|
var target = new Date(date.getFullYear(), date.getMonth(), date.getDate()); //目标日期
|
||||||
|
var firstDayOfYear = new Date(target.getFullYear(), 0, 1); // 当前年份第一天
|
||||||
|
if(target.getTime()==firstDayOfYear.getTime()){
|
||||||
|
return 1;
|
||||||
|
}else{
|
||||||
|
return Math.ceil((target - firstDayOfYear + 8 * (firstDayOfYear.getTimezoneOffset() / 480)) / 604800000);
|
||||||
|
}
|
||||||
|
},
|
||||||
queryTypeChange(value){
|
queryTypeChange(value){
|
||||||
console.log(value)
|
console.log(value)
|
||||||
this.queryDate = '';
|
this.queryDate = '';
|
||||||
if(value=='月'){
|
|
||||||
this.xAxisData = ['第一周','第二周','第三周','第四周'];
|
|
||||||
}else{
|
|
||||||
this.xAxisData = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
|
|
||||||
}
|
|
||||||
this.option1.xAxis.data = this.xAxisData;
|
|
||||||
this.option2.xAxis.data = this.xAxisData;
|
|
||||||
},
|
},
|
||||||
getData6(){
|
//采购物料选项
|
||||||
|
getInmOption(){
|
||||||
let that = this;
|
let that = this;
|
||||||
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
|
let obj = {};
|
||||||
let obj = {
|
obj.page=0;
|
||||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "6车间" },
|
obj.type__in = '30,40,50,60,70';
|
||||||
};
|
that.$API.mtm.material.list.req( obj).then((res) => {
|
||||||
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
|
that.inmOption = res;
|
||||||
console.log('6生产车间统计:',doInRes);
|
console.log('inmOption',res)
|
||||||
debugger;
|
that.product = res[0].id;
|
||||||
});
|
that.getInmData();
|
||||||
|
})
|
||||||
},
|
},
|
||||||
getData7(){
|
//采购物料
|
||||||
|
getInmData(){
|
||||||
let that = this;
|
let that = this;
|
||||||
let obj = {
|
let obj = {};
|
||||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "7车间" },
|
obj.mio__state = 20;
|
||||||
};
|
obj.mio__type = 'pur_in';
|
||||||
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
|
obj.material = that.product;
|
||||||
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
|
obj.mio__inout_date__gte = this.start_date;
|
||||||
console.log('7生产车间统计:',doInRes);
|
obj.mio__inout_date__lte = this.end_date;
|
||||||
|
obj.page=0;
|
||||||
|
that.$API.inm.mioitem.list.req( obj).then((res) => {
|
||||||
debugger;
|
debugger;
|
||||||
});
|
console.log('getInmData',res);
|
||||||
},
|
res.forEach(item => {
|
||||||
getData10(){
|
|
||||||
let that = this;
|
|
||||||
let obj = {
|
|
||||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "10·车间" },
|
|
||||||
};
|
|
||||||
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
|
|
||||||
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
|
|
||||||
console.log('10生产车间统计:',doInRes);
|
|
||||||
debugger;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleQuery(){
|
|
||||||
if(this.queryDate!==''){
|
|
||||||
if(this.queryType=='月'){
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//消耗暂定
|
||||||
|
getOutOption(){
|
||||||
|
let that = this;
|
||||||
|
let obj = {};
|
||||||
|
obj.page=0;
|
||||||
|
that.$API.inm.mioitem.list.req( obj).then((res) => {
|
||||||
|
that.inmOption = res;
|
||||||
|
console.log('inmOption',res)
|
||||||
|
that.product = res[0].id;
|
||||||
|
that.getOutData();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//消耗暂定
|
||||||
|
getOutData(){},
|
||||||
|
handleQuery(){
|
||||||
|
let that = this;
|
||||||
|
if(this.queryType=='月'){
|
||||||
|
if(this.queryDate!==''&&this.queryDate!==null){
|
||||||
this.start_date =this.queryDate+'-01';
|
this.start_date =this.queryDate+'-01';
|
||||||
let arr = this.queryDate.split('-');
|
let arr = this.queryDate.split('-');
|
||||||
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
|
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
|
||||||
|
this.firstWeekNum = this.getWeekOfYear(new Date(this.start_date));
|
||||||
|
this.endWeekNum = this.getWeekOfYear(new Date(this.end_date));
|
||||||
|
let duration = this.endWeekNum - this.firstWeekNum + 1;
|
||||||
|
let xAxisData = [];
|
||||||
|
for(let i =1;i<=duration;i++ ){
|
||||||
|
xAxisData.push('第'+i+'周');
|
||||||
|
}
|
||||||
|
that.xAxisData = xAxisData;
|
||||||
}else{
|
}else{
|
||||||
this.start_date = this.queryDate+'-01-01';
|
|
||||||
this.end_date = this.queryDate+'-12-31';
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(this.queryType=='月'){
|
|
||||||
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
|
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
|
||||||
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
|
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
|
||||||
|
let date = new Date(this.start_date);
|
||||||
|
this.firstWeekNum = this.getWeekOfYear(date);
|
||||||
|
this.xAxisData = this.xAxisOrigin;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(this.queryDate!==''&&this.queryDate!==null){
|
||||||
|
this.start_date = this.queryDate+'-01-01';
|
||||||
|
this.end_date = this.queryDate+'-12-31';
|
||||||
}else{
|
}else{
|
||||||
this.start_date = this.currentYear+'-01-01';
|
this.start_date = this.currentYear+'-01-01';
|
||||||
this.end_date = this.currentYear+'-12-31';
|
this.end_date = this.currentYear+'-12-31';
|
||||||
}
|
}
|
||||||
|
that.xAxisData = that.monthList;
|
||||||
}
|
}
|
||||||
debugger;
|
this.getInmData();
|
||||||
console.log(this.query)
|
this.getOutData();
|
||||||
this.getData6();
|
|
||||||
this.getData7();
|
|
||||||
this.getData10();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,8 @@
|
||||||
let month1=month;
|
let month1=month;
|
||||||
if(month1<10){month1='0'+month1}
|
if(month1<10){month1='0'+month1}
|
||||||
that.queryDate = year+'-'+month1;
|
that.queryDate = year+'-'+month1;
|
||||||
that.firstWeekNum = that.getWeekOfYear(new Date('2024-1-01'));
|
that.firstWeekNum = that.getWeekOfYear(new Date(that.start_date));
|
||||||
that.endWeekNum = that.getWeekOfYear(new Date('2024-1-31'));
|
that.endWeekNum = that.getWeekOfYear(new Date(that.end_date));
|
||||||
let duration = that.endWeekNum - that.firstWeekNum + 1;
|
let duration = that.endWeekNum - that.firstWeekNum + 1;
|
||||||
for(let i =1;i<=duration;i++ ){
|
for(let i =1;i<=duration;i++ ){
|
||||||
that.xAxisOrigin.push('第'+i+'周');
|
that.xAxisOrigin.push('第'+i+'周');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue