hjfpfb.vue 6.5 KB

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