123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119 |
- <template>
- <div class="container">
- <el-row :gutter="20">
- <el-col :span="12">
- <div class="accuracy">
- <div class="accuracy_t">
- <div class="accuracy_t_l">
- <h4><span class="title"></span>准确性分析</h4>
- <el-select v-model="accuracy.value1" style="width:100px;margin-right: 5px;" class="filter-item" @change="changecattle('1')">
- <el-option v-for="item in accuracy.cattleTpyeList" :key="item.value" :label="item.label"
- :value="item.value"> </el-option>
- </el-select>
- <el-select v-model="accuracy.value2" style="width:100px;margin-right: 5px;" class="filter-item" @change="changeformula('1')">
- <el-option v-for="item in accuracy.formulaList" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- <el-date-picker v-model="accuracy.inputDatetime" :clearable="false" class="inputDatetime filter-item"
- type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
- style="width: 250px;" :picker-options="pickerOptions" @change="changeDate('1')" />
- </div>
- <div class="accuracy_t_r">
- <div class="exportTable button" @click="handleChart('accuracy')">切换图表</div>
- <div class="exportTable button" @click="handleExport('accuracy')">导出</div>
- </div>
- </div>
- <div class="accuracy_b">
- <el-tabs v-model="accuracy.activeName" @tab-click="handleTabClick">
- <el-tab-pane label="混料准确率" name="first" />
- <el-tab-pane label="混料正确率" name="second" />
- <el-tab-pane label="撒料准确率" name="third" />
- <el-tab-pane label="撒料正确率" name="fourth" />
- </el-tabs>
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="maxdiv">
- <div class="title-t">最高</div>
- <div class="title-c">{{accuracy.chart1.lineData1.max_value}}%</div>
- <div class="title-b">NO.1 {{accuracy.chart1.lineData1.top_one_name}}</div>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="mediandiv">
- <div class="title-t">中位值</div>
- <div class="title-c">{{accuracy.chart1.lineData1.middle_value}}%</div>
- <a class="title-b" @click="handleSeeRanking">查看排名</a>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="mindiv">
- <div class="title-t">最低</div>
- <div class="title-c">{{accuracy.chart1.lineData1.min_value}}%</div>
- </div>
- </el-col>
- </el-row>
- <div v-if="accuracy.chart1.isChart">
- <div id="chartLine1" v-loading="accuracy.chart1.listLoading" style="height:310px;" />
- <a class="more" @click="handleMore">更多></a>
- </div>
- <div v-else>
- <el-table style="width: 100%" :max-height="320" :row-style="rowStyle" :cell-style="cellStyle" border
- :data="accuracy.chart1.tableDataList1">
- <template v-for="item in accuracy.chart1.tableTitleList1">
- <template>
- <el-table-column min-width="30" :key="item.value" :label="item.value" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row[item.name] }}</span>
- </template>
- </el-table-column>
- </template>
- </template>
- </el-table>
- </div>
- </div>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="time">
- <div class="time_t">
- <div class="time_t_l">
- <h4><span class="title"></span>执行时间</h4>
- <el-select v-model="time.value1" style="width:100px;margin-right: 5px;" class="filter-item" @change="changecattle('2')">
- <el-option v-for="item in time.cattleTpyeList" :key="item.value" :label="item.label"
- :value="item.value"> </el-option>
- </el-select>
- <el-select v-model="time.value2" style="width:100px;margin-right: 5px;" class="filter-item" @change="changeformula('2')">
- <el-option v-for="item in time.formulaList" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- <el-date-picker v-model="time.inputDatetime" :clearable="false" class="inputDatetime filter-item"
- type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
- style="width: 250px;" :picker-options="pickerOptions" @change="changeDate('2')"/>
- </div>
- <div class="time_t_r">
- <div class="exportTable button" @click="handleChart('time')">切换图表</div>
- <div class="exportTable button" @click="handleExport('time')">导出</div>
- </div>
- </div>
- <div v-if="time.chart1.isChart">
- <div id="chartLine2" v-loading="time.chart1.listLoading" style="height:420px;" />
- </div>
- <div v-else style="margin: 10px 10px;">
- <el-table :data="time.chart1.tableDataList1" border style="width: 100%;" :max-height="410"
- :row-style="rowStyle" :cell-style="cellStyle" class="elTable">
- <el-table-column label="类型" min-width="80px" align="center">
- <el-table-column label="牧场" min-width="80px" align="center" prop="title" />
- </el-table-column>
- <el-table-column label="加料时间" min-width="80px" align="center">
- <el-table-column label="最大值" min-width="80px" align="center" prop="add_feed_time_max_value" />
- <el-table-column label="上四分位数" min-width="80px" align="center" prop="add_feed_time_up_middle_value" />
- <el-table-column label="中位数" min-width="80px" align="center" prop="add_feed_time_middle_value" />
- <el-table-column label="下四分位数" min-width="80px" align="center" prop="add_feed_time_down_middle_value" />
- <el-table-column label="最小值" min-width="80px" align="center" prop="add_feed_time_min_value" />
- </el-table-column>
- <el-table-column label="搅拌延时" min-width="80px" align="center">
- <el-table-column label="最大值" min-width="80px" align="center" prop="stir_time_max_value" />
- <el-table-column label="上四分位数" min-width="80px" align="center" prop="stir_time_up_middle_value" />
- <el-table-column label="中位数" min-width="80px" align="center" prop="stir_time_middle_value" />
- <el-table-column label="下四分位数" min-width="80px" align="center" prop="stir_time_down_middle_value" />
- <el-table-column label="最小值" min-width="80px" align="center" prop="stir_time_min_value" />
- </el-table-column>
- <el-table-column label="撒料时间" min-width="80px" align="center">
- <el-table-column label="最大值" min-width="80px" align="center" prop="sprinkle_time_max_value" />
- <el-table-column label="上四分位数" min-width="80px" align="center" prop="sprinkle_time_up_middle_value" />
- <el-table-column label="中位数" min-width="80px" align="center" prop="sprinkle_time_middle_value" />
- <el-table-column label="下四分位数" min-width="80px" align="center" prop="sprinkle_time_down_middle_value" />
- <el-table-column label="最小值" min-width="80px" align="center" prop="sprinkle_time_min_value" />
- </el-table-column>
- </el-table>
- </div>
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="24">
- <div class="abnormal">
- <div class="abnormal_t">
- <div class="abnormal_t_l">
- <h4>
- <span class="title"></span>
- 撒料时间统计分析
- <el-tooltip class="item" effect="dark" placement="top-start">
- <div slot="content">
- 按时间段统计各牧场配方的每个班次之间<br />
- 的撒料间隔时间波动,切换图表可查看各<br />
- 班次撒料时间,在波动时间外的异常撒料<br />
- 时间数据标红显示
- </div>
- <span class="el-icon-question"></span>
- </el-tooltip>
- </h4>
- <el-select v-model="abnormal.value2" style="width:100px;margin-right: 5px;" class="filter-item" @change="changeformula('3')">
- <el-option v-for="item in abnormal.formulaList" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- <el-date-picker v-model="abnormal.inputDatetime" :clearable="false" class="inputDatetime filter-item"
- type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
- style="width: 250px;" @change="changeDate('3')" />
- </div>
- <div class="abnormal_t_r">
- <div class="exportTable button" @click="handleChart('abnormal')">切换图表</div>
- <div class="exportTable button" @click="handleExport('abnormal')">导出</div>
- </div>
- </div>
- <div v-if="abnormal.chart1.isChart">
- <div id="chartLine3" v-loading="abnormal.chart1.listLoading" style="height:420px;" />
- </div>
- <div v-else style="margin: 10px 10px;">
- <el-select v-model="abnormal.value3" style="width:100px;margin-right: 5px;margin-bottom:10px;" class="filter-item" @change="changepasture('3')">
- <el-option v-for="item in abnormal.pastureList" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- <el-select v-model="abnormal.value4" style="width:100px;margin-right: 5px;margin-bottom:10px;" class="filter-item" @change="changestate('3')">
- <el-option v-for="item in abnormal.stateList" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- <span style="float: right;">共{{abnormal.chart1.tableDataList1.length}}次</span>
- <el-table :data="abnormal.chart1.tableDataList1" border style="width: 100%;" :max-height="410"
- :row-style="rowStyle" :cell-style="cellStyle" class="elTable">
- <el-table-column label="牧场" min-width="130px" align="center" prop="pasture_name" />
- <el-table-column label="栏舍" min-width="130px" align="center" prop="barn_name" />
- <el-table-column label="班次" min-width="130px" align="center" prop="class_number" />
- <el-table-column label="实际撒料时间" min-width="130px" align="center" prop="reality_sprinkle_feed_time" />
- </el-table>
- </div>
- </div>
- </el-col>
- </el-row>
- <el-dialog :title="textMap[accuracy.dialogStatus]" :visible.sync="accuracy.dialogFormVisible"
- :close-on-click-modal="false" width="50%">
- <div class="accuracy-content">
- <div v-if="accuracy.dialogStatus == 'more'" class="dialogmore" style="min-height: 100px;">
- <el-checkbox-group v-model="accuracy.more.checkedPasture">
- <el-checkbox border v-for="(item,index) in accuracy.more.pastureList" :label="item.id"
- :key="index">{{item.name}}</el-checkbox>
- </el-checkbox-group>
- </div>
- <div v-else class="seeRanking" style="min-height: 300px;">
- <el-tabs v-model="accuracy.seeRanking.activeName" @tab-click="handleSeeTabClick">
- <el-tab-pane label="混料准确率" name="first" />
- <el-tab-pane label="混料正确率" name="second" />
- <el-tab-pane label="撒料准确率" name="third" />
- <el-tab-pane label="撒料正确率" name="fourth" />
- </el-tabs>
- <div class="search">
- <el-input v-model="accuracy.seeRanking.top_rand_start" placeholder="准确率" style="width: 180px;" class="filter-item"
- type="number" clearable />
- <span style="margin-right: 5px;">-</span>
- <el-input v-model="accuracy.seeRanking.top_rand_end" placeholder="准确率" style="width: 180px;" class="filter-item"
- type="number" clearable />
- <el-button class="successBorder" @click="handleSearch">查询</el-button>
- </div>
- <el-table :key="accuracy.seeRanking.tableKey" v-loading="accuracy.seeRanking.listLoading"
- element-loading-text="给我一点时间" :data="accuracy.seeRanking.list" border fit highlight-current-row
- style="width: 100%;" :row-style="rowStyle" :cell-style="cellStyle" class="elTable">
- <el-table-column type="selection" align="center" width="50" />
- <el-table-column label="排名" min-width="130px" align="center" prop="rank" />
- <el-table-column label="牧场名称" min-width="130px" align="center" prop="pasture_name" />
- <el-table-column label="准确率" min-width="130px" align="center" prop="ratio" />
- </el-table>
- </div>
- <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom: 40px;">
- <el-button v-if="accuracy.dialogStatus == 'more'" class="cancelClose cancelClose"
- @click="accuracy.dialogFormVisible = false; ">关闭</el-button>
- <el-button v-else class="cancelClose1"
- @click="accuracy.dialogFormVisible = false;getFormulaList(); ">关闭</el-button>
- <el-button class="save" :disabled="isokDisable" v-if="accuracy.dialogStatus == 'more'"
- @click="createData()">确认</el-button>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- postJson,
- getJson
- } from '@/api/common'
- import {
- mapGetters
- } from 'vuex'
- import {
- parseTime
- } from '@/utils/index.js'
- // import echarts from 'echarts'
- import * as echarts from 'echarts';
- require('echarts/theme/macarons')
- import Cookies from 'js-cookie'
- export default {
- name: 'Dashboard',
- data() {
- return {
- pickerMinDate: '',
- pickerOptions: {
- onPick: ({
- maxDate,
- minDate
- }) => {
- this.pickerMinDate = minDate.getTime()
- if (maxDate) {
- this.pickerMinDate = ''
- }
- },
- // 限制不能选择明天之后的日期
- disabledDate: (time) => {
- if (this.pickerMinDate !== '') {
- const one = 31 * 24 * 3600 * 1000
- const minTime = this.pickerMinDate - one
- let maxTime = this.pickerMinDate + one
- if (maxTime > new Date()) {
- // maxTime = Date.now() + 8.64e7
- maxTime = Date.now()
- }
- return time.getTime() < minTime || time.getTime() > maxTime
- }
- return time.getTime() > Date.now()
- // return time.getTime() > Date.now() + 8.64e7
- }
- },
- pastureList: JSON.parse(sessionStorage.pastureList),
- accuracy: {
- value1: '',
- value2: '',
- inputDatetime: [new Date(), new Date()],
- cattleTpyeList: JSON.parse(sessionStorage.downlist).cattle_parent_category,
- formulaList: JSON.parse(sessionStorage.downlist).formula_list,
- activeName: 'first',
- chart1: {
- isChart: true,
- listLoading: false,
- chartLine: null,
- allChart1Data: {},
- allTable1Data: [],
- tableTitleList1: [],
- tableDataList1: [],
- lineData1: {},
- },
- dialogStatus: '',
- dialogFormVisible: false,
- more: {
- checkedPasture: [],
- pastureList: JSON.parse(sessionStorage.pastureList),
- },
- seeRanking: {
- activeName: 'first',
- tableKey: 0,
- listLoading: false,
- list: [],
- allData: {}
- },
- },
- time: {
- value1: '',
- value2: '',
- inputDatetime: [new Date(), new Date()],
- cattleTpyeList: JSON.parse(sessionStorage.downlist).cattle_parent_category,
- formulaList: JSON.parse(sessionStorage.downlist).formula_list,
- chart1: {
- isChart: true,
- listLoading: false,
- chartLine: null,
- lineData1: {},
- tableDataList1: [],
- },
- },
- abnormal: {
- value1: '',
- value2: '',
- value3:0,
- value4:0,
- inputDatetime: [new Date(), new Date()],
- cattleTpyeList: JSON.parse(sessionStorage.downlist).cattle_parent_category,
- formulaList: JSON.parse(sessionStorage.downlist).formula_list,
- pastureList:JSON.parse(sessionStorage.pastureList), //牧场
- stateList:[{name:'数据状态',id:0},{name:'正常撒料',id:1},{name:'异常撒料',id:2}],
- chart1: {
- isChart: true,
- listLoading: false,
- chartLine: null,
- lineData1: {},
- tableDataList1: [],
- },
- },
- textMap: {
- seeRanking: '查看排名',
- more: '更多'
- },
- isokDisable: false,
- rowStyle: {
- maxHeight: 30 + 'px',
- height: 30 + 'px'
- },
- cellStyle: {
- padding: 0 + 'px'
- },
- initData:[],seriesData:[]
- }
- },
- created() {
- // accuracy.inputDatetime
- this.abnormal.pastureList.unshift({id:0,name:'所有牧场'})
- this.getTimeFn()
- },
- mounted() {
- this.accuracy.value1 = this.accuracy.cattleTpyeList[0].value
- this.time.value1 = this.time.cattleTpyeList[0].value
- this.abnormal.value1 = this.abnormal.cattleTpyeList[0].value
- this.accuracy.value2 = this.accuracy.formulaList[0].value
- this.time.value2 = this.time.formulaList[0].value
- this.abnormal.value2 = this.abnormal.formulaList[0].value
- },
- methods: {
- getTimeFn() {
- const that = this
- const start1 = new Date()
- const end1 = new Date()
- start1.setTime(start1.getTime() - 3600 * 1000 * 24 * 7)
- end1.setTime(end1.getTime() - 3600 * 1000 * 24 * 0)
- that.accuracy.inputDatetime = [start1, end1]
-
- const start3 = new Date()
- const end3 = new Date()
- start3.setTime(start3.getTime() - 3600 * 1000 * 24 * 7)
- end3.setTime(end3.getTime() - 3600 * 1000 * 24 * 0)
- that.time.inputDatetime = [start3, end3]
- const start2 = new Date()
- const end2 = new Date()
- start2.setTime(start2.getTime() - 3600 * 1000 * 24 * 31)
- end2.setTime(end2.getTime() - 3600 * 1000 * 24 * 1)
- that.abnormal.inputDatetime = [start2, end2]
- that.getFormulaList()
- },
- getFormulaList() {
- let page = 1
- let page_size = 0
- let url = '/api/v1/ops/feed_formula/list' + '?page=' + page + '&page_size=' + page_size
- let data = {}
- postJson(url, data).then(response => {
- if (response.code == 200) {
- this.accuracy.formulaList = response.data.list
- this.time.formulaList = response.data.list
- this.abnormal.formulaList = response.data.list
- } else {
- this.accuracy.formulaList = []
- this.time.formulaList = []
- this.abnormal.formulaList = []
- }
- this.getChart1List()
- this.getChart2List()
- this.getChart3List()
- })
- },
- getChart1List() {
- let url = '/api/v1/ops/dashboard/accuracy'
- let pasture_ids = []
- this.pastureList.forEach((item) => {
- pasture_ids.push(item.id)
- })
- let data = {
- 'cattle_parent_category_id': this.accuracy.value1,
- 'start_date': parseTime(this.accuracy.inputDatetime[0], '{y}-{m}-{d}'),
- 'end_date': parseTime(this.accuracy.inputDatetime[1], '{y}-{m}-{d}'),
- 'pasture_ids': pasture_ids,
- 'feed_formula_id':this.accuracy.value2,
- }
- if (this.accuracy.value2 == '') {
- data.feed_formula_id = 0
- }
- postJson(url, data).then(response => {
- if (response.code == 200) {
- this.accuracy.chart1.allChart1Data = response.data.chart
- this.accuracy.chart1.allTable1Data = response.data.table.data_list
- if (this.accuracy.activeName == 'first') {
- this.accuracy.chart1.lineData1 = response.data.chart.mixed_fodder_accurate_ratio
- this.accuracy.chart1.tableDataList1 = response.data.table.data_list.mixed_fodder_accurate_ratio
- } else if (this.accuracy.activeName == 'second') {
- this.accuracy.chart1.lineData1 = response.data.chart.mixed_fodder_correct_ratio
- this.accuracy.chart1.tableDataList1 = response.data.table.data_list.mixed_fodder_correct_ratio
- } else if (this.accuracy.activeName == 'third') {
- this.accuracy.chart1.lineData1 = response.data.chart.sprinkle_fodder_accurate_ratio
- this.accuracy.chart1.tableDataList1 = response.data.table.data_list.sprinkle_fodder_accurate_ratio
- } else if (this.accuracy.activeName == 'fourth') {
- this.accuracy.chart1.lineData1 = response.data.chart.sprinkle_fodder_correct_ratio
- this.accuracy.chart1.tableDataList1 = response.data.table.data_list.sprinkle_fodder_correct_ratio
- }
- this.accuracy.chart1.tableTitleList1 = response.data.table.title_list
- console.log(this.accuracy.chart1.allChart1Data, 'allChart1Data')
- if (this.accuracy.chart1.isChart) {
- this.roadChartLine1(this.accuracy.chart1.lineData1)
- }
- console.log(this.accuracy.chart1.lineData1, '===')
- }
- })
- },
- handleTabClick(tab, event) {
- console.log(tab);
- if (tab.name == 'first') {
- this.accuracy.chart1.lineData1 = this.accuracy.chart1.allChart1Data.mixed_fodder_accurate_ratio
- this.accuracy.chart1.tableDataList1 = this.accuracy.chart1.allTable1Data.mixed_fodder_accurate_ratio
- } else if (tab.name == 'second') {
- this.accuracy.chart1.lineData1 = this.accuracy.chart1.allChart1Data.mixed_fodder_correct_ratio
- this.accuracy.chart1.tableDataList1 = this.accuracy.chart1.allTable1Data.mixed_fodder_correct_ratio
- } else if (tab.name == 'third') {
- this.accuracy.chart1.lineData1 = this.accuracy.chart1.allChart1Data.sprinkle_fodder_accurate_ratio
- this.accuracy.chart1.tableDataList1 = this.accuracy.chart1.allTable1Data.sprinkle_fodder_accurate_ratio
- } else if (tab.name == 'fourth') {
- this.accuracy.chart1.lineData1 = this.accuracy.chart1.allChart1Data.sprinkle_fodder_correct_ratio
- this.accuracy.chart1.tableDataList1 = this.accuracy.chart1.allTable1Data.sprinkle_fodder_correct_ratio
- }
- this.accuracy.chart1.isChart = true
- this.roadChartLine1(this.accuracy.chart1.lineData1)
- },
- handleChart(item) {
- if (item == 'accuracy') {
- this.accuracy.chart1.isChart = !this.accuracy.chart1.isChart
- this.$nextTick(() => {
- if (this.accuracy.chart1.isChart) {
- this.roadChartLine1(this.accuracy.chart1.lineData1)
- }
- });
- } else if (item == 'time') {
- this.time.chart1.isChart = !this.time.chart1.isChart
- this.$nextTick(() => {
- if (this.time.chart1.isChart) {
- this.roadChartLine2(this.time.chart1.lineData1)
- }
- });
- } else {
- this.abnormal.chart1.isChart = !this.abnormal.chart1.isChart
- this.abnormal.value3 = 0
- this.abnormal.value4 = 0
- this.getChart3List()
- this.$nextTick(() => {
- if (this.abnormal.chart1.isChart) {
- this.roadChartLine3(this.abnormal.chart1.lineData1)
- }
- });
- }
- },
- handleExport() {},
- handleSeeRanking() {
- this.accuracy.dialogStatus = 'seeRanking'
- this.accuracy.dialogFormVisible = true
- this.getSeeRankingList()
- },
- getSeeRankingList(item) {
- let url = '/api/v1/ops/dashboard/top_pasture'
- let pasture_ids = []
- this.pastureList.forEach((item) => {
- pasture_ids.push(item.id)
- })
- let dashboard_top_type = 0
- if(item){
- dashboard_top_type = item
- }else{
- dashboard_top_type = 0
- }
- let data = {
- 'cattle_parent_category_id': this.accuracy.value1,
- 'start_date':parseTime(this.accuracy.inputDatetime[0], '{y}-{m}-{d}'),
- 'end_date':parseTime(this.accuracy.inputDatetime[1], '{y}-{m}-{d}'),
- 'pasture_ids':pasture_ids,
- 'feed_formula_id':this.accuracy.value2,
- 'dashboard_top_type':dashboard_top_type
- }
- if (this.accuracy.value2 == '') {
- data.feed_formula_id = 0
- }
- if (this.accuracy.seeRanking.top_rand_start !== '') {
- data.top_rand_start = this.accuracy.seeRanking.top_rand_start
- }
- if (this.accuracy.seeRanking.top_rand_end !== '') {
- data.top_rand_end = this.accuracy.seeRanking.top_rand_end
- }
- postJson(url, data).then(response => {
- if (response.code == 200) {
- this.accuracy.seeRanking.allData = response.data
- if (this.accuracy.seeRanking.activeName == 'first') {
- this.accuracy.seeRanking.list = response.data.mixed_fodder_accurate_ratio
- } else if (this.accuracy.seeRanking.activeName == 'second') {
- this.accuracy.seeRanking.list = response.data.mixed_fodder_correct_ratio
- } else if (this.accuracy.seeRanking.activeName == 'third') {
- this.accuracy.seeRanking.list = response.data.sprinkle_fodder_accurate_ratio
- } else if (this.accuracy.seeRanking.activeName == 'fourth') {
- this.accuracy.seeRanking.list = response.data.sprinkle_fodder_correct_ratio
- }
- } else {
- this.accuracy.seeRanking.list = []
- }
- })
- },
- handleSeeTabClick(tab, ) {
- console.log(tab);
- if (tab.name == 'first') {
- this.accuracy.seeRanking.list = this.accuracy.seeRanking.allData.mixed_fodder_accurate_ratio
- } else if (tab.name == 'second') {
- this.accuracy.seeRanking.list = this.accuracy.seeRanking.allData.mixed_fodder_correct_ratio
- } else if (tab.name == 'third') {
- this.accuracy.seeRanking.list = this.accuracy.seeRanking.allData.sprinkle_fodder_accurate_ratio
- } else if (tab.name == 'fourth') {
- this.accuracy.seeRanking.list = this.accuracy.seeRanking.allData.sprinkle_fodder_correct_ratio
- }
- },
- handleSearch() {
- let dashboard_top_type = 0
- if(this.accuracy.seeRanking.activeName == 'first'){
- dashboard_top_type = 1
- }else if(this.accuracy.seeRanking.activeName == 'second'){
- dashboard_top_type = 2
- }else if(this.accuracy.seeRanking.activeName == 'third'){
- dashboard_top_type = 3
- }else{
- dashboard_top_type = 4
- }
- this.getSeeRankingList(dashboard_top_type)
- },
- handleMore() {
- this.accuracy.dialogStatus = 'more'
- this.getPastureList()
- },
- getPastureList() {
- let page = 1
- let page_size = 100
- let url = 'api/v1/ops/pasture/list' + '?page=' + page + '&page_size=' + page_size
- let data = {}
- postJson(url, data).then(response => {
- if (response.code == 200) {
- // this.accuracy.more.pastureList = response.data.list
- } else {
- // this.accuracy.more.pastureList = []
- }
- this.accuracy.dialogFormVisible = true
- })
- },
- getChart2List() {
- let url = '/api/v1/ops/dashboard/exec_time'
- let pasture_ids = []
- this.pastureList.forEach((item) => {
- pasture_ids.push(item.id)
- })
- let data = {
- 'cattle_parent_category_id': this.time.value1,
- 'feed_formula_id':this.time.value2,
- 'start_date': parseTime(this.time.inputDatetime[0], '{y}-{m}-{d}'),
- 'end_date': parseTime(this.time.inputDatetime[1], '{y}-{m}-{d}'),
- 'pasture_ids': pasture_ids,
- }
- if (this.time.value2 == '') {
- data.feed_formula_id = 0
- }
- postJson(url, data).then(response => {
- if (response.code == 200) {
- this.time.chart1.lineData1 = response.data.chart
- this.time.chart1.tableDataList1 = response.data.table_list
- if (this.time.chart1.isChart) {
- this.roadChartLine2(this.time.chart1.lineData1)
- }
- console.log(response.data, '===')
- }
- })
- },
- changecattle(item){
- if(item == '1'){
- this.getChart1List()
- }else if(item == '2'){
- this.getChart2List()
- }else if(item == '3'){
- this.getChart3List()
- }
- },
- changeformula(item){
- if(item == '1'){
- this.getChart1List()
- }else if(item == '2'){
- this.getChart2List()
- }else if(item == '3'){
- this.getChart3List()
- }
- },
- changeDate (item){
- if(item == '1'){
- this.getChart1List()
- }else if(item == '2'){
- this.getChart2List()
- }else if(item == '3'){
- if (this.abnormal.inputDatetime) {
- const startDate = this.abnormal.inputDatetime[0];
- const endDate = this.abnormal.inputDatetime[1];
- const days = Math.floor((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
- console.log('所选天数:', days);
- if(days < 7){
- this.$message({type: 'error',message: '最少选择7天时间', duration: 2000})
- }else if(days > 365){
- this.$message({type: 'error',message: '最多选择365天时间', duration: 2000})
- }else{
- this.getChart3List()
- }
- }
- }
- },
- changepasture(){
- this.getChart3List()
- },
- changestate(){
- this.getChart3List()
- },
- getChart3List() {
- let pasture_ids = []
- if(this.abnormal.chart1.isChart){
- this.abnormal.value3 == 0
- this.abnormal.value4 == 0
- }
- if(this.abnormal.value3 == 0){
- this.pastureList.forEach((item) => {
- pasture_ids.push(item.id)
- })
- }else{
- pasture_ids.push(this.abnormal.value3)
- }
- let url = '/api/v1/ops/dashboard/sprinkle_time'
- let data = {
- 'start_date': parseTime(this.abnormal.inputDatetime[0], '{y}-{m}-{d}'),
- 'end_date': parseTime(this.abnormal.inputDatetime[1], '{y}-{m}-{d}'),
- 'pasture_ids': pasture_ids,
- 'feed_formula_id':this.abnormal.value2
- }
- console.log(this.abnormal.value2,'====000')
- if (this.abnormal.value2 == '') {
- data.feed_formula_id = 0
- }
- postJson(url, data).then(response => {
- if (response.code == 200) {
- this.abnormal.chart1.lineData1 = response.data.chart
- this.abnormal.chart1.tableDataList1 = response.data.table_list
- if (this.abnormal.chart1.isChart) {
- this.roadChartLine3(this.abnormal.chart1.lineData1)
- }
- console.log(response.data, '===')
- }
- })
- },
- roadChartLine1(chartLine_data) {
- if (this.accuracy.chart1.chartLine != null) {
- this.accuracy.chart1.chartLine.dispose()
- }
- this.accuracy.chart1.chartLine = echarts.init(document.getElementById('chartLine1'))
- var option = {
- animation: false,
- tooltip: {
- trigger: 'axis'
- },
- legend: {
- data: chartLine_data.pasture_name,
- left: 14,
- bottom: 0,
- },
- grid: {
- left: '3%',
- right: '14%',
- // top: '3%',
- containLabel: true
- },
- xAxis: [{
- type: 'category',
- boundaryGap: false,
- data: chartLine_data.date_day,
- axisLabel: {
- showMinLabel: true,
- showMaxLabel: true,
- },
- axisLine: {
- lineStyle: {
- color: '#666'
- }
- },
- }],
- yAxis: [{
- type: 'value',
- name: '(%)',
- axisLine: {
- lineStyle: {
- color: '#666'
- }
- },
- }],
- color: ['#4b07fa', '#0f96fc', '#ff42a9', '#ff724c', '#05fbf0', '#ffae00', '#b705fa', '#9a60b4', '#3cff00'],
- series: function(e) {
- var serie = [];
- for (var i = 0; i < chartLine_data.pasture_name.length; i++) {
- var item = {
- name: chartLine_data.pasture_name[i],
- data: chartLine_data.data_list[i],
- type: 'line',
- smooth: true,
- itemStyle: {
- borderColor: '#fff',
- borderWidth: 2
- },
- label: {
- // normal: { show: true },
- },
- }
- serie.push(item);
- }
- console.log(serie)
- return serie;
- }()
- };
- this.accuracy.chart1.chartLine.setOption(option)
- if (this.accuracy.chart1.chartLine !== null) {
- window.onresize = function() {
- this.accuracy.chart1.chartLine.resize()
- }
- }
- },
- roadChartLine2(chartLine_data) {
- if (this.time.chart1.chartLine != null) {
- this.time.chart1.chartLine.dispose()
- }
- this.time.chart1.chartLine = echarts.init(document.getElementById('chartLine2'))
- var option = {
- tooltip: {
- trigger: `item`,
- formatter: this.formatter
- }, // formatter可不设置
- color: `#8d8d8d`, // 箱线图线框的颜色
- grid: {
- left: '3%',
- right: 10,
- bottom: 10,
- // top: 20,
- containLabel: true,
- },
- legend: {
- data: ['加料时间', '搅拌时间','撒料时间'],
- right: 14,
- top: 0,
- bottom: 10
- },
- color: ['#42C7FF', '#20DB7C','#FCC858'],
- xAxis: { // 此处设置与其他图表类似
- type: `category`,
- data:chartLine_data.title,
- axisLine: {
- //坐标轴轴线相关设置
- show: false,
- },
- axisLabel: {
- // 坐标轴刻度标签的相关设置
- show: true,
- showMaxLabel: true,
- },
- axisTick: {
- //刻度相关设置
- show: false, //让刻度隐藏
- },
- },
- yAxis: { // 此处设置与其他图表类似
- type: `value`,
- name:'(分钟)',
- splitArea: { show: false },
- axisLine: { lineStyle: { color: `#8d8d8d` } },
- },
- series: [
- {
- name:'加料时间',
- type: `boxplot`,
- itemStyle: { color: `#42C7FF` },
- data:chartLine_data.add_feed_time
- },{
- name:'搅拌时间',
- type: `boxplot`,
- itemStyle: { color: `#20DB7C` },
- data:chartLine_data.stir_time
- },{
- name:'撒料时间',
- type: `boxplot`,
- itemStyle: { color: `#FCC858` },
- data:chartLine_data.sprinkle_time
- }
- ],
- }
- this.time.chart1.chartLine.setOption(option)
- if (this.time.chart1.chartLine !== null) {
- window.onresize = function() {
- this.time.chart1.chartLine.resize()
- }
- }
- },
- formatter(param) {
- return [
- // '类别名称: ' + param.name,
- '最大值: ' + param.data[1],
- '上四分位数: ' + param.data[2],
- '中位数: ' + param.data[3],
- '下四分位数: ' + param.data[4],
- '最小值: ' + param.data[5]
- ].join('<br/>')
- },
- roadChartLine3(chartLine_data) {
- console.log(chartLine_data,'===999')
- if (this.abnormal.chart1.chartLine != null) {
- this.abnormal.chart1.chartLine.dispose()
- }
- this.abnormal.chart1.chartLine = echarts.init(document.getElementById('chartLine3'))
- var option = {
- animation: false,
- tooltip: {
- trigger: 'axis',
- formatter: function (data) {
- console.log(data,'====')
- let a = parseFloat(data[0].data)
- let b = parseFloat(data[0].data) + parseFloat(data[1].data)
- let rate1 = 0
- let rate2 = 0
- if(data[0].data !== 0 && data[1].data !== 0){
- rate1 = (a/b * 100).toFixed(2)
- rate2 = 100 - (parseFloat(rate1))
- }else{
- rate1 = 0
- rate2 = 0
- }
- var res = data[0].marker + data[0].seriesName + '<br/>'+ a + '次'+ "<span style='margin-left:10px;color:#ccc;'>总占比"+rate1+"%</span>"+'<br/>' + data[1].marker + data[1].seriesName+':'+'<br/>' + data[1].data + '次'+ "<span style='margin-left:10px;color:#ccc;'>总占比"+rate2+"%</span>"
- return res
- }
- },
- legend: {
- data: ['正常撒料次数', '异常撒料次数'],
- right: 14,
- top: 0,
- },
- grid: {
- // top: '20%',
- left: '3%',
- right: '14%',
- bottom: '13%',
- containLabel: true
- },
- xAxis: [{
- type: 'category',
- data: chartLine_data.title,
- }],
- yAxis: [{
- type: 'value',
- name:'(次)',
- axisLine: {
- lineStyle: {
- color: '#666'
- }
- },
- }],
- series: [{
- name: '正常撒料次数',
- type: 'bar',
- barWidth:50,
- data: chartLine_data.sprinkle_number_list[0]
- },
- {
- name: '异常撒料次数',
- type: 'bar',
- barWidth:50,
- data: chartLine_data.sprinkle_number_list[1]
- },
- ]
- };
- this.abnormal.chart1.chartLine.setOption(option)
- if (this.abnormal.chart1.chartLine !== null) {
- window.onresize = function() {
- this.abnormal.chart1.chartLine.resize()
- }
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- margin: 10px 10px;
- }
- .accuracy,
- .time,
- .abnormal {
- background: #fff;
- height: 550px;
- border-radius: 5px;
- border: 2px solid #ededed;
- }
- .accuracy_t {
- margin-left: 10px;
- position: relative;
- .accuracy_t_l {
- h3 {
- line-height: 15px;
- }
- .title {
- width: 3px;
- height: 15px;
- background: red;
- display: inline-block;
- margin-right: 10px;
- }
- }
- .accuracy_t_r {
- position: absolute;
- top: 0;
- right: 0;
- .button {
- display: inline-block;
- margin-right: 10px;
- }
- }
- }
- .accuracy_b {
- margin: 0 10px;
- /deep/ .el-tabs__item {
- font-size: 12px
- }
- position: relative;
- }
- .more {
- position: absolute;
- bottom: -14px;
- right: -8px;
- color: blue;
- font-size: 12px;
- }
- .maxdiv,
- .mediandiv,
- .mindiv {
- text-align: center;
- .title-t {
- font-size: 12px;
- }
- .title-c {
- font-size: 14px;
- font-weight: bold;
- }
- .title-b {
- font-size: 14px;
- color: red;
- font-weight: bold;
- }
- }
- .maxdiv,
- .mediandiv {
- border-right: 2px solid #eee;
- }
- .mediandiv {
- .title-b {
- color: blue;
- }
- }
- .accuracy-content {
- /deep/ .el-checkbox {
- margin: 5px 5px;
- }
- /deep/ .is-bordered {
- margin-left: 5px;
- }
- }
- .time {
- .time_t {
- margin-left: 10px;
- position: relative;
- .time_t_l {
- h3 {
- line-height: 15px;
- }
- .title {
- width: 3px;
- height: 15px;
- background: red;
- display: inline-block;
- margin-right: 10px;
- }
- }
- .time_t_r {
- position: absolute;
- top: 0;
- right: 0;
- .button {
- display: inline-block;
- margin-right: 10px;
- }
- }
- }
- }
- .abnormal {
- background: #fff;
- margin-top: 10px;
- .abnormal_t {
- margin-left: 10px;
- position: relative;
- .abnormal_t_l {
- h3 {
- line-height: 15px;
- }
- .title {
- width: 3px;
- height: 15px;
- background: red;
- display: inline-block;
- margin-right: 10px;
- }
- }
- .abnormal_t_r {
- position: absolute;
- top: 0;
- right: 0;
- .button {
- display: inline-block;
- margin-right: 10px;
- }
- }
- }
- }
- .container {
- background: #fff;
- }
- </style>
|