Index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="app-container">
  3. <el-row class="rowCls">
  4. <!-- 搜索模块 -->
  5. <div class="filter-container">
  6. <span style="margin-left: 15px;" v-show="this.productionresourceList.length>1">
  7. <span>{{$t("statisticalAnalysis.searchForm.rate.resourceName")}}:</span>
  8. <el-select v-model="resourceId" :placeholder='$t("common.pleaseSelect")' size="medium" style="width: 250px;">
  9. <el-option
  10. v-for="item in productionresourceList"
  11. :key="item.id"
  12. :label="item.name"
  13. :value="item.id">
  14. </el-option>
  15. </el-select>
  16. </span>
  17. <span style="margin-left: 15px;">
  18. <span>{{$t("statisticalAnalysis.searchForm.rate.date")}}:</span>
  19. <el-date-picker
  20. v-model="date"
  21. type="date"
  22. format="yyyy-MM-dd"
  23. value-format="yyyy-MM-dd"
  24. placeholder="选择日"
  25. />
  26. </span>
  27. <span style="margin-left: 15px;">
  28. <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
  29. {{ $t("table.search") }}
  30. </el-button>
  31. <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
  32. {{ $t("table.reset") }}
  33. </el-button>
  34. </span>
  35. </div>
  36. </el-row>
  37. <!-- OEE柱状图 -->
  38. <el-row class="rowCls">
  39. <div class="bottomDiv">
  40. <!-- 柱状图数据 -->
  41. <div class="chart-wrapper">
  42. <div id="myChart" class="chart" :style="{width: '100%', height: '500px'}"></div>
  43. </div>
  44. </div>
  45. </el-row>
  46. </div>
  47. </template>
  48. <script>
  49. import productionLineMgrApi from "@/api/runManageCenter/productionLineMgr"
  50. import productlineAvailabilityApi from "@/api/statisticalAnalysis/productlineAvailability"
  51. // 【产线管理】-API
  52. import areaMgrApi from "@/api/resourceProductMgr/areaMgr"
  53. import {message} from "@/utils/resetMessage";
  54. import * as echarts from 'echarts'
  55. export default {
  56. name: "rate",
  57. props: {
  58. },
  59. data () {
  60. return {
  61. heightStr: "380px",
  62. productionresourceList: [],
  63. tableKey: 0,
  64. loading: false,
  65. resourceId:"",
  66. date:"",
  67. barData: {
  68. name: 'rate',
  69. xData: [],
  70. yData: []
  71. },
  72. }
  73. },
  74. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  75. created() {
  76. // 加载产线下拉框数据
  77. this.getByIndition();
  78. // this.queryProductionLines()
  79. },
  80. computed: {
  81. },
  82. mounted () {
  83. this.chart();
  84. },
  85. methods: {
  86. search() {
  87. if(!this.resourceId){
  88. this.$message({
  89. message: '请选择设备',
  90. type: 'warning'
  91. })
  92. }
  93. this.fetch()
  94. },
  95. reset() {
  96. this.resourceId = '';
  97. this.date = '';
  98. //this.queryParams = initQueryParams({})
  99. //this.$refs.table.clearSort()
  100. //this.$refs.clearFilter()
  101. this.getByIndition()
  102. },
  103. fetch () {
  104. if(!this.resourceId){
  105. return
  106. }
  107. this.tableKey = !this.tableKey
  108. this.loading = true
  109. let params = {}
  110. params.resourceId = this.resourceId
  111. params.date = this.date
  112. productlineAvailabilityApi.resourceRate(params).then(response => {
  113. const res = response.data
  114. if (res.isSuccess) {
  115. this.barData.xData = res.data.hour
  116. this.barData.yData = res.data.rate
  117. console.log(this.barData)
  118. this.chart()
  119. }
  120. }).finally(() => this.loading = false)
  121. },
  122. // 设备下拉数据
  123. getByIndition(){
  124. let params = {}
  125. params.modeSpecification = "modeSpecification"
  126. areaMgrApi.getByIndition(params).then(res => {
  127. res = res.data;
  128. // console.log("产线下拉数据: ", res);
  129. if(res.code == 0) {
  130. this.productionresourceList = res.data;
  131. if(this.productionresourceList.length > 1){
  132. this.resourceId = this.productionresourceList[2].id
  133. }
  134. this.fetch()
  135. }
  136. })
  137. },
  138. // 产线查找
  139. queryProductionLines(){
  140. this.productionLines = []
  141. productionLineMgrApi.getList({}).then(response => {
  142. const res = response.data
  143. if (res.isSuccess) {
  144. this.productionLines = res.data
  145. if(this.productionLines.length > 0){
  146. this.productionLineId = this.productionLines[0].id
  147. }
  148. }
  149. })
  150. },
  151. chart(){
  152. this.myChartone = echarts.init(document.getElementById('myChart'))
  153. this.myChartone.setOption( {
  154. title : {
  155. text: '',
  156. subtext: '主轴利用率'
  157. },
  158. tooltip : {
  159. trigger: 'axis'
  160. },
  161. legend: {
  162. data:['利用率']
  163. },
  164. toolbox: {
  165. show : true,
  166. feature : {
  167. mark : {show: true},
  168. dataView : {show: true, readOnly: false},
  169. magicType : {show: true, type: ['line', 'bar']},
  170. restore : {show: true},
  171. saveAsImage : {show: true}
  172. }
  173. },
  174. calculable : true,
  175. xAxis : [
  176. {
  177. type : 'category',
  178. boundaryGap : false,
  179. data : this.barData.xData
  180. }
  181. ],
  182. yAxis : [
  183. {
  184. type : 'value',
  185. axisLabel : {
  186. formatter: '{value} %'
  187. }
  188. }
  189. ],
  190. series : [
  191. {
  192. name:'利用率',
  193. type:'line',
  194. data:this.barData.yData,
  195. markPoint : {
  196. data : [
  197. {type : 'max', name: '最大值'},
  198. {type : 'min', name: '最小值'}
  199. ]
  200. },
  201. markLine : {
  202. data : [
  203. {type : 'average', name: '平均值'}
  204. ]
  205. }
  206. }
  207. ]
  208. });
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped></style>