hjfpfb.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <el-dialog
  3. :model-value="modelValue"
  4. title="核检废品日统计"
  5. fullscreen
  6. destroy-on-close
  7. :before-close="() => emits('update:modelValue', false )"
  8. >
  9. <el-container>
  10. <!-- 按钮部分 -->
  11. <el-header height="90px">
  12. <div>
  13. <el-button
  14. type="primary"
  15. size="large"
  16. @click="handleExcel"
  17. >导出到Excel
  18. </el-button>
  19. <el-button
  20. type="primary"
  21. size="large"
  22. @click="() => emits('update:modelValue', false )"
  23. >退出
  24. </el-button>
  25. </div>
  26. <div style="margin-top: 10px;">
  27. <el-form
  28. :inline="true"
  29. :model="form"
  30. @submit.prevent
  31. >
  32. <el-form-item label="工单编号">
  33. <el-input
  34. v-model="form.gdbh"
  35. style="width: 100px;"
  36. />
  37. <el-button
  38. type="primary"
  39. :loading="isLoading"
  40. style="margin-left: 1px;"
  41. @click="handleSearch"
  42. >刷新
  43. </el-button>
  44. </el-form-item>
  45. <el-form-item label="印件名称">
  46. <el-input
  47. v-model="form.yjmc"
  48. readonly
  49. style="width: 200px;"
  50. />
  51. </el-form-item>
  52. <el-form-item label="投料量">
  53. <el-input
  54. v-model="form.tll"
  55. readonly
  56. style="width: 100px;"
  57. />
  58. </el-form-item>
  59. <el-form-item label="总废品">
  60. <el-input
  61. v-model="form.zfp"
  62. readonly
  63. style="width: 100px;"
  64. />
  65. </el-form-item>
  66. <el-form-item label="实际合格率">
  67. <el-input
  68. v-model="form.sjhgl"
  69. readonly
  70. style="width:100px;"
  71. />
  72. </el-form-item>
  73. </el-form>
  74. </div>
  75. </el-header>
  76. <el-container>
  77. <el-aside width="400px">
  78. <el-table
  79. ref="multipleTable"
  80. height="70vh"
  81. :data="tableData"
  82. row-key="ID"
  83. highlight-current-row
  84. border
  85. show-overflow-tooltip
  86. :row-style="{ height: '20px' }"
  87. :cell-style="{ padding: '0px' }"
  88. :header-row-style="{ height: '20px' }"
  89. :header-cell-style="{ padding: '0px' }"
  90. >
  91. <!-- 循环渲染表格列 -->
  92. <el-table-column
  93. v-for="column in tableColumns"
  94. :key="column.prop"
  95. :prop="column.prop"
  96. :label="column.label"
  97. :width="column.width"
  98. />
  99. </el-table>
  100. </el-aside>
  101. <el-main>
  102. <div
  103. ref="echart"
  104. style="height: 100%; width: 100%;"
  105. />
  106. </el-main>
  107. </el-container>
  108. </el-container>
  109. </el-dialog>
  110. </template>
  111. <script>
  112. export default {
  113. name: 'Hjfpfb',
  114. }
  115. // 3.1工单核检废品分布
  116. import service from '@/utils/request'
  117. export const getWasteDistribution = (params) => {
  118. return service({
  119. url: '/mes_server/work_order_verification/wasteDistribution',
  120. method: 'get',
  121. params
  122. })
  123. }
  124. </script>
  125. <script setup>
  126. import * as echarts from 'echarts'
  127. import { nextTick, onMounted, onUnmounted, ref, shallowRef, defineProps, defineEmits } from 'vue'
  128. const props = defineProps(['modelValue', 'val'])
  129. const emits = defineEmits(['update:modelValue'])
  130. const form = ref({
  131. gdbh: props['val'],
  132. })
  133. const tableColumns = ref([
  134. { label: '废品分类', prop: 'fpfl', width: '130' },
  135. { label: '数量', prop: 'sl', width: '70' },
  136. { label: '报损率', prop: 'bsl', width: '100' },
  137. { label: '废品占比', prop: 'fpzb', width: '100' },
  138. ])
  139. const tableData = ref([])
  140. const isLoading = ref(false)
  141. const handleExcel = () => {
  142. }
  143. const handleSearch = async() => {
  144. const order = form.value['gdbh']
  145. const res = await getWasteDistribution({ order })
  146. if (res['code'] === 0) {
  147. console.log(res['data'])
  148. form.value = {
  149. ...form.value,
  150. gdbh: res['data']['Gd_gdbh'],
  151. yjmc: res['data']['yj_yjmc'],
  152. tll: res['data']['实际投料'],
  153. zfp: res['data']['wasteTotal'],
  154. sjhgl: res['data']['passRate'],
  155. }
  156. tableData.value = res['data']['wasteData'].map(item => ({
  157. fpfl: item['type'],
  158. sl: item['num'],
  159. bsl: item['lossesRate'],
  160. fpzb: item['wasteRate'],
  161. }))
  162. const data = []
  163. res['data']['rightData'].forEach(element => {
  164. data.push({ name: element['type'], value: parseFloat(element['rate']) })
  165. })
  166. setOptions(data)
  167. }
  168. }
  169. const chart = shallowRef(null)
  170. const echart = ref(null)
  171. const initChart = () => {
  172. chart.value = echarts.init(echart.value /* 'macarons' */)
  173. }
  174. const setOptions = (data) => {
  175. chart.value.setOption({
  176. // title: {
  177. // text: 'Weather Statistics',
  178. // subtext: 'Fake Data',
  179. // left: 'center'
  180. // },
  181. // tooltip: {
  182. // trigger: 'item',
  183. // formatter: '{a} <br/>{b} : {c} ({d}%)'
  184. // },
  185. legend: {
  186. orient: 'vertical',
  187. right: 20,
  188. top: 'center',
  189. textStyle: {
  190. fontSize: 14,
  191. },
  192. selectedMode: false, // 设置图例禁止点击
  193. data: data.map(item => item['name'])
  194. },
  195. series: [
  196. {
  197. type: 'pie',
  198. radius: '65%',
  199. center: ['40%', '50%'],
  200. data: data,
  201. label: {
  202. show: true,
  203. formatter: '{b}: {d}%',
  204. fontSize: 14,
  205. },
  206. },
  207. ]
  208. })
  209. }
  210. onMounted(async() => {
  211. await nextTick()
  212. initChart()
  213. })
  214. onUnmounted(() => {
  215. if (!chart.value) {
  216. return
  217. }
  218. chart.value.dispose()
  219. chart.value = null
  220. })
  221. </script>
  222. <style scoped>
  223. :deep(.el-table td .cell) {
  224. line-height: 20px !important;
  225. }
  226. </style>