123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626 |
- <template>
- <view>
- <!-- 产量趋势 -->
- <view class="content">
- <view class="title_box">
- <picker mode="selector" :range="array_active" :value="index_active" @change="bindPickerChange_active">
- <view class="box">
- <view>{{array_active[index_active]}}</view>
- <view class="icon">
- <uni-icons type="arrowdown"></uni-icons>
- </view>
- </view>
- </picker>
-
- <view v-if="index_active==1">
- <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange" fields="month">
- <view class="box">
- <view>{{date}}</view>
- </view>
- </picker>
- </view>
-
- <view v-if="index_active==2">
- <picker mode="date" :value="date_year" :start="startDate_year" :end="endDate_year" @change="bindDateChange_year" fields="year">
- <view class="box">
- <view>{{date_year}}</view>
- </view>
- </picker>
- </view>
-
- </view>
- <view class="inner">
- <view v-show="index_active == 0">
- <view class="inner_content">
- <canvas style="width: 700upx; height:600upx;" canvas-id="canvasColumnStack" id="canvasColumnStack" class="charts" @touchstart="touchColumn"></canvas>
- </view>
- </view>
- <view v-show="index_active == 1">
- <view class="inner_content">
- <canvas style="width: 700upx; height:2500upx;" canvas-id="canvasColumnStack_month" id="canvasColumnStack_month" class="charts" @touchstart="touchColumn_month"></canvas>
- </view>
- </view>
- <view v-show="index_active == 2">
- <view class="inner_content">
- <canvas style="width: 700upx; height:600upx;" canvas-id="canvasColumnStack_year" id="canvasColumnStack_year" class="charts" @touchstart="touchColumn_year"></canvas>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import uCharts from '@/components/u-charts/u-charts.js';
- var _self;
-
- // 周产量
- var canvaColumn=null;
-
- // 月产量
- var canvaColumn_month=null;
-
- // 年产量
- var canvaColumn_year=null;
-
-
-
- export default {
- name:"p-production-report-inner-2",
- props:[
- "mine",
- "org_num"
- ],
- data() {
- const currentDate = this.getDate({
- format: true
- })
- const currentDate_year = this.getDate_year({
- format: true
- })
- return {
- cWidth: '',
- cHeight: '',
- pixelRatio: 1,
- // serverData: '',
-
-
- // 月
- cWidth_month: '',
- cHeight_month: '',
- pixelRatio_month: 1,
- cHeight_month:'',
-
- // 周产量
-
- // 产量趋势
- array_active: ['周产量趋势', '月产量趋势','年产量趋势'],
- index_active: 0,
- // 年 月
- date: currentDate,
- //
- date_year:currentDate_year,
-
-
-
- // 当前月
- month:""
-
- }
- },
- computed: {
- // 月
- startDate() {
- return this.getDate('start');
- },
- endDate() {
- return this.getDate('end');
- },
- // 年
- startDate_year() {
- return this.getDate_year('start');
- },
- endDate_year() {
- return this.getDate_year('end');
- }
- },
- created() {
- this.month = (new Date().getFullYear()) + "-" + (new Date().getMonth()+1)
- // console.log(this.month)
- _self = this;
- this.cWidth = uni.upx2px(680);
- this.cHeight = uni.upx2px(500);
-
- this.cWidth_month = uni.upx2px(680);
- this.cHeight_month = uni.upx2px(2500);
-
- // 周产量
- this.getServerData_week();
-
- // 月产量
- this.getServerData_month(this.date);
-
- // 年产量
- this.getServerData_year(this.date_year);
-
- },
- methods: {
- // 产量趋势 选择列表
- bindPickerChange_active: function(e) {
- console.log('picker发送选择改变,携带值为', e.target.value)
- this.index_active = 0
-
- setTimeout(()=>{
- this.index_active = e.target.value
-
- if(this.index_active == 0){
- this.getServerData_week(this.date)
- }else if(this.index_active == 1){
- // uni.switchTab({
- // url:"../../tabbar/production/production",
- // animationType:"fade-in",
- // animationDuration:50
- // })
- // uni.navigateTo({
- // url:"../../production/p-i-metering/p-i-metering",
- // animationType:"fade-in",
- // animationDuration:150
- // })
- // console.log(this.date)
- this.date = this.month
- this.getServerData_month(this.month)
- }else if(this.index_active == 2){
- this.getServerData_year(this.date_year)
- }
-
- },100)
-
-
- },
- // 月
- bindDateChange: function(e) {
- this.date = e.target.value
- console.log(this.date)
- this.getServerData_month(this.date);
- },
- getDate(type) {
- const date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
- if (type === 'start') {
- year = year - 60;
- } else if (type === 'end') {
- year = year + 2;
- }else{
- year = year
- }
- month = month > 9 ? month : '0' + month;
- return `${year}-${month}`;
- },
-
- // 年
- bindDateChange_year: function(e) {
- this.date_year = e.target.value
- console.log(this.date_year)
-
- this.getServerData_year(this.date_year)
- },
- getDate_year(type) {
- const date = new Date();
- let year = date.getFullYear();
-
- if (type === 'start') {
- year = year - 60;
- } else if (type === 'end') {
- year = year + 2;
- }
- return `${year}`;
- },
-
-
-
- // 周产量
- getServerData_week(){
- this.$p_api.coalmine_one_trend({
- type:"week",
- mine:this.mine,
- org_num:this.org_num
- }).then((res)=>{
- // console.log(res.data.data)
-
- let ColumnStack={
- categories:[],
- series:[
- {
- "name": "早班",
- "data": []
- },
- {
- "name": "中班",
- "data": []
- },
- {
- "name": "晚班",
- "data": []
- }
- ],
- };
-
- const categories = res.data.data
- categories.map(function(item,index){
- // console.log(item.date,index)
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.date;
- //将项放进新的数组
- ColumnStack.categories[index] = sevm
- })
-
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n1;
- //将项放进新的数组
- ColumnStack.series[0].data[index] = sevm
- })
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n2;
- //将项放进新的数组
- ColumnStack.series[1].data[index] = sevm
- })
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n3;
- //将项放进新的数组
- ColumnStack.series[2].data[index] = sevm
- })
-
- _self.showColumnStack("canvasColumnStack",ColumnStack);
- })
-
-
- },
- showColumnStack(canvasId,chartData){
- canvaColumn=new uCharts({
- $this:_self,
- canvasId: canvasId,
- type: 'column',
- legend:{show:true},
- fontSize:11,
- background:'#FFFFFF',
- pixelRatio:_self.pixelRatio,
- animation: true,
- categories: chartData.categories,
- legend:{
- position:'top',
- margin:10,
-
- },
- series: chartData.series,
- xAxis: {
- disableGrid:true,
- },
- yAxis: {
- //disabled:true
- },
- dataLabel: false,
- width: _self.cWidth*_self.pixelRatio,
- height: _self.cHeight*_self.pixelRatio,
- extra: {
- column: {
- type:'stack',
- width: _self.cWidth*_self.pixelRatio*0.5/chartData.categories.length
- }
- }
- });
-
- },
- touchColumn(e){
- canvaColumn.showToolTip(e, {
- format: function (item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- // 月产量
- getServerData_month(date){
- this.$p_api.coalmine_one_trend({
- type:"month",
- date: date,
- mine:this.mine,
- org_num:this.org_num
- }).then((res)=>{
- // console.log(res.data.data)
- let ColumnStack_month={
- categories:[],
- series:[
- {
- "name": "晚班",
- "data": []
- }, {
- "name": "早班",
- "data": []
- }, {
- "name": "中班",
- "data": []
- }
- ],
- }
-
- res.data.data.map(function(item,index){
- // console.log(item.date,index)
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.date;
- //将项放进新的数组
- ColumnStack_month.categories[index] = sevm
- })
-
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n1;
- //将项放进新的数组
- ColumnStack_month.series[0].data[index] = sevm
- })
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n2;
- //将项放进新的数组
- ColumnStack_month.series[1].data[index] = sevm
- })
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n3;
- //将项放进新的数组
- ColumnStack_month.series[2].data[index] = sevm
- })
-
-
-
- _self.showColumnStack_month("canvasColumnStack_month",ColumnStack_month);
- })
-
- },
- showColumnStack_month(canvasId,chartData){
- canvaColumn_month=new uCharts({
- $this:_self,
- canvasId: canvasId,
- type: 'column',
- legend:{show:true},
- fontSize:11,
- background:'#FFFFFF',
- pixelRatio:_self.pixelRatio_month,
- animation: true,
- rotate:true,
- categories: chartData.categories,
- legend:{
- show:false,
- position:'top',
- margin:10,
-
- },
- series: chartData.series,
- xAxis: {
- disableGrid:true,
- },
- yAxis: {
- //disabled:true
- },
- dataLabel: false,
- width: _self.cWidth_month*_self.pixelRatio_month,
- height: _self.cHeight_month*_self.pixelRatio_month,
- extra: {
- column: {
- type:'stack',
- width: _self.cWidth_month*_self.pixelRatio_month*0.5/chartData.categories.length
- }
- }
- });
-
- },
- touchColumn_month(e){
- canvaColumn_month.showToolTip(e, {
- format: function (item, category) {
- return item.name + ':' + item.data
- }
- });
- },
-
-
- // 年产量
- getServerData_year(date){
- this.$p_api.coalmine_one_trend({
- type:"year",
- date: date,
- mine:this.mine,
- org_num:this.org_num
- }).then((res)=>{
-
- // console.log(res.data.data)
-
- let ColumnStack_year={
- categories:[],
- series:[
- {
- "name": "早班",
- "data": []
- }, {
- "name": "中班",
- "data": []
- }, {
- "name": "晚班",
- "data": []
- }
- ],
- }
-
- res.data.data.map(function(item,index){
- // console.log(item.date,index)
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.date;
- //将项放进新的数组
- ColumnStack_year.categories[index] = sevm
- })
-
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n1;
- //将项放进新的数组
- ColumnStack_year.series[0].data[index] = sevm
- })
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n2;
- //将项放进新的数组
- ColumnStack_year.series[1].data[index] = sevm
- })
- res.data.data.map(function(item,index){
- //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
- var sevm = {};
- //给每一项中的参数初始化并赋值
- sevm = item.n3;
- //将项放进新的数组
- ColumnStack_year.series[2].data[index] = sevm
- })
-
- _self.showColumnStack_year("canvasColumnStack_year",ColumnStack_year);
- })
-
- },
- showColumnStack_year(canvasId,chartData){
- canvaColumn_year=new uCharts({
- $this:_self,
- canvasId: canvasId,
- type: 'column',
- legend:{show:true},
- fontSize:11,
- background:'#FFFFFF',
- pixelRatio:_self.pixelRatio,
- animation: true,
- categories: chartData.categories,
- legend:{
- position:'top',
- margin:10,
-
- },
- series: chartData.series,
- xAxis: {
- disableGrid:true,
- },
- yAxis: {
- //disabled:true
- },
- dataLabel: false,
- width: _self.cWidth*_self.pixelRatio,
- height: _self.cHeight*_self.pixelRatio,
- extra: {
- column: {
- type:'stack',
- width: _self.cWidth*_self.pixelRatio*0.5/chartData.categories.length
- }
- }
- });
-
- },
- touchColumn_year(e){
- canvaColumn_year.showToolTip(e, {
- format: function (item, category) {
- return item.name + ':' + item.data
- }
- });
- },
-
-
-
- }
- }
- </script>
- <style lang="scss">
-
- .content{
- width: 700rpx;
- margin-top: 16rpx;
- background: #FFFFFF;
- box-shadow: 0rpx 3rpx 29rpx 0rpx rgba(59, 74, 116, 0.14);
- border-radius: 20rpx;
-
- .time{
- line-height: 94rpx;
- padding: 0 20rpx;
- box-sizing: border-box;
- }
-
- .title{
- line-height: 96rpx;
- text-align: center;
-
-
- font-size: 30rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #232627;
-
- border-bottom: 2rpx solid #f3f3f3;
- }
- .inner{
- min-height: 200rpx;
- .inner_content{
- margin-top: 20rpx;
- }
- }
- .title_box{
- height: 96rpx;
- border-bottom: 2rpx solid #f3f3f3;
-
- display: flex;
- align-items: center;
- .box{
- margin-left: 22rpx;
- height: 50rpx;
- border-radius: 14rpx;
- border: 1rpx solid #BDC3C7;
-
- box-sizing: border-box;
- padding: 0 20rpx;
- // 文本
- font-size: 28rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #232627;
- line-height: 50rpx;
-
- display: flex;
- .icon{
- margin-left: 10rpx;
- }
- }
- }
- }
- </style>
|