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