gongdanzhijianfeipintongji.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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>
  12. <el-button type="primary" size="large" @click="handleExcel" >导出到Excel</el-button>
  13. <el-button type="primary" size="large" @click="() => emits('update:modelValue', false )" >退出
  14. </el-button>
  15. </el-header>
  16. <el-main>
  17. <div style="display: flex; align-items: center;">
  18. <el-input v-model="input" placeholder="输入工单编号" style="width: 180px; margin-right: 10px;" />
  19. 印件选择:
  20. <el-select v-model="gdwhformData.yjno" placeholder="请选择" allow-create filterable style="width: 100px; margin-right: 10px;">
  21. <el-option v-for="option in gdwhformData.yinjian" @click="ongdwhfanclick" :key="option" :label="option" :value="option" />
  22. </el-select>
  23. <el-button type="primary" :loading="isLoading" style="margin-right: 10px;" @click="handleSearch">刷新</el-button>
  24. <el-input v-model="inputCpmc" readonly style="width: 50vw; margin-right: 10px;" />
  25. </div>
  26. <br>
  27. <el-table id="tab"
  28. ref="multipleTable"
  29. height="70vh"
  30. :data="tableData"
  31. row-key="ID"
  32. highlight-current-row
  33. border
  34. show-overflow-tooltip
  35. :row-style="{ height: '20px' }"
  36. :cell-style="{ padding: '0px' }"
  37. :header-row-style="{ height: '20px' }"
  38. :header-cell-style="{ padding: '0px' }"
  39. >
  40. <!-- 循环渲染表格列 -->
  41. <el-table-column
  42. v-for="column in tableColumns"
  43. :key="column.prop"
  44. :prop="column.prop"
  45. :label="column.label"
  46. :width="column.width"
  47. />
  48. </el-table>
  49. </el-main>
  50. </el-container>
  51. </el-dialog>
  52. </template>
  53. <script>
  54. export default {
  55. name: 'Gongdanzhijianfeipintongji',
  56. }
  57. // 8工单质检废品统计
  58. import service from '@/utils/request'
  59. export const getOrderWasteTotal = (params) => {
  60. return service({
  61. url: '/mes_server/work_order_verification/getOrderWasteTotal',
  62. method: 'get',
  63. params
  64. })
  65. }
  66. </script>
  67. <script setup>
  68. import * as XLSX from 'xlsx'
  69. import FileSaver from 'file-saver'
  70. import { watch, ref, reactive, defineProps, defineEmits, nextTick } from 'vue'
  71. import {PrintDetailList} from "@/api/yunyin/yunying";
  72. const props = defineProps(['modelValue', 'val'])
  73. const emits = defineEmits(['update:modelValue'])
  74. const tableColumns = reactive([
  75. { label: '工单编号', prop: 'gdbh', width: '150' },
  76. { label: '产品代号', prop: 'product_code', width: '150' },
  77. { label: '产品名称', prop: 'product_name', width: '150' },
  78. { label: '订单数量', prop: '订单数量', width: '150' },
  79. { label: '实际投料', prop: 'aaa', width: '150' },
  80. { label: '计量单位', prop: '计量单位', width: '150' },
  81. { label: '交货日期', prop: '交货日期', width: '150' },
  82. { label: '入仓数量', prop: 'jjcp_sl', width: '150' },
  83. { label: '入仓日期', prop: 'jjcp_sj', width: '150' },
  84. { label: '印件号', prop: 'qczl_yjno', width: '150' },
  85. { label: '联数', prop: 'yj_ls', width: '150' },
  86. { label: '工序号', prop: 'fp_gxh', width: '150' },
  87. { label: '流程单号', prop: 'qczl_num', width: '150' },
  88. { label: '员工编号', prop: 'fp_bh', width: '150' },
  89. { label: '员工姓名', prop: 'fp_name', width: '150' },
  90. { label: '废品类别', prop: 'fp_lb', width: '150' },
  91. { label: '数量', prop: 'fp_sl', width: '150' },
  92. ])
  93. const tableData = ref([])
  94. const input = ref(props.val)
  95. const inputCpmc = ref('')
  96. const isLoading = ref(false)
  97. // console.log(input.value)
  98. // const ongdwhfanclick = () => {
  99. // const workOrder = gdwhformData.cpgyfan;
  100. // handleSearch();
  101. // }
  102. // PrintDetailList_list()
  103. // const PrintDetailList_list = async() => {
  104. // 获取印件数据
  105. // }
  106. const handleExcel = () => {
  107. const el = document.getElementById('tab');
  108. // 文件名
  109. const filename = '核检废品日统计-'+input.value+ '.xlsx';
  110. const wb = XLSX.utils.table_to_book(el, { raw: true });
  111. const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
  112. try {
  113. FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
  114. } catch (e) {
  115. console.log(e);
  116. }
  117. return wbout;
  118. }
  119. nextTick(() => {
  120. handleSearch()
  121. })
  122. const gdwhformData = reactive({
  123. // 下拉框选项数据
  124. yinjian: [],
  125. // 设置默认值
  126. yjno: '',
  127. });
  128. const handleSearch = async() => {
  129. const response = await PrintDetailList({ workOrder:input.value});
  130. // console.log(response)
  131. if (response.code === 0) {
  132. const noFields = response.data.map(item => item.no);
  133. // console.log(noFields)
  134. gdwhformData.yinjian = noFields
  135. // 你可以在这里进一步处理 noFields,例如展示在页面上
  136. } else {
  137. console.error('查询失败:', response.msg);
  138. }
  139. if (!input.value) { return }
  140. const params = { order: input.value,yjno:gdwhformData.yjno }
  141. // console.log(params)
  142. isLoading.value = true
  143. const res = await getOrderWasteTotal(params)
  144. // console.log(res)
  145. isLoading.value = false
  146. if (res.code === 0) {
  147. inputCpmc.value = res.data?.[0]?.['product_name']
  148. const val = res.data.map(item => {
  149. return { ...item, gdbh: params.order }
  150. })
  151. console.log(res.data)
  152. tableData.value = val
  153. }
  154. }
  155. </script>
  156. <style scoped>
  157. :deep(.el-table td .cell) {
  158. line-height: 20px !important;
  159. }
  160. </style>