gongdanzhijianfeipintongji.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. :sortable= "column.sortable"
  48. />
  49. </el-table>
  50. </el-main>
  51. </el-container>
  52. </el-dialog>
  53. </template>
  54. <script>
  55. export default {
  56. name: 'Gongdanzhijianfeipintongji',
  57. }
  58. // 8工单质检废品统计
  59. import service from '@/utils/request'
  60. export const getOrderWasteTotal = (params) => {
  61. return service({
  62. url: '/mes_server/work_order_verification/getOrderWasteTotal',
  63. method: 'get',
  64. params
  65. })
  66. }
  67. </script>
  68. <script setup>
  69. import * as XLSX from 'xlsx'
  70. import FileSaver from 'file-saver'
  71. import { watch, ref, reactive, defineProps, defineEmits, nextTick } from 'vue'
  72. import {PrintDetailList} from "@/api/yunyin/yunying";
  73. const props = defineProps(['modelValue', 'val'])
  74. const emits = defineEmits(['update:modelValue'])
  75. const tableColumns = reactive([
  76. { label: '工单编号',sortable: 'sortable', prop: 'gdbh', width: '150' },
  77. { label: '产品代号',sortable: 'sortable', prop: 'product_code', width: '150' },
  78. { label: '产品名称',sortable: 'sortable', prop: 'product_name', width: '150' },
  79. { label: '订单数量',sortable: 'sortable', prop: '订单数量', width: '150' },
  80. { label: '实际投料',sortable: 'sortable', prop: 'aaa', width: '150' },
  81. { label: '计量单位',sortable: 'sortable', prop: '计量单位', width: '150' },
  82. { label: '交货日期',sortable: 'sortable', prop: '交货日期', width: '150' },
  83. { label: '入仓数量',sortable: 'sortable', prop: 'jjcp_sl', width: '150' },
  84. { label: '入仓日期',sortable: 'sortable', prop: 'jjcp_sj', width: '150' },
  85. { label: '印件号',sortable: 'sortable', prop: 'qczl_yjno', width: '150' },
  86. { label: '联数',sortable: 'sortable', prop: 'yj_ls', width: '150' },
  87. { label: '工序号',sortable: 'sortable', prop: 'fp_gxh', width: '150' },
  88. { label: '流程单号', sortable: 'sortable',prop: 'qczl_num', width: '150' },
  89. { label: '员工编号',sortable: 'sortable', prop: 'fp_bh', width: '150' },
  90. { label: '员工姓名',sortable: 'sortable', prop: 'fp_name', width: '150' },
  91. { label: '废品类别',sortable: 'sortable', prop: 'fp_lb', width: '150' },
  92. { label: '数量',sortable: 'sortable', prop: 'fp_sl', width: '150' },
  93. ])
  94. const tableData = ref([])
  95. const input = ref(props.val)
  96. const inputCpmc = ref('')
  97. const isLoading = ref(false)
  98. console.log(input.value)
  99. const handleExcel = () => {
  100. const el = document.getElementById('tab');
  101. // 文件名
  102. const filename = '核检废品日统计-'+input.value+ '.xlsx';
  103. const wb = XLSX.utils.table_to_book(el, { raw: true });
  104. const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
  105. try {
  106. FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
  107. } catch (e) {
  108. console.log(e);
  109. }
  110. return wbout;
  111. }
  112. nextTick(() => {
  113. handleSearch()
  114. })
  115. const gdwhformData = reactive({
  116. // 下拉框选项数据
  117. yinjian: [],
  118. // 设置默认值
  119. yjno: '',
  120. });
  121. const ongdwhfanclick = async() => {
  122. console.log(gdwhformData.yjno)
  123. const response = await PrintDetailList({ workOrder:input.value});
  124. // console.log(response)
  125. const matchingItem = response.data.find(item => item.no === gdwhformData.yjno);
  126. if (matchingItem) {
  127. console.log(matchingItem.name)
  128. inputCpmc.value = matchingItem.name;
  129. } else {
  130. console.log(`No matching item found for no: ${gdwhformData.yjno}`);
  131. }
  132. }
  133. const handleSearch = async() => {
  134. const response = await PrintDetailList({ workOrder:input.value});
  135. // console.log(response)
  136. if (response.code === 0) {
  137. const noFields = response.data.map(item => item.no);
  138. // console.log(noFields)
  139. gdwhformData.yinjian = noFields
  140. // 你可以在这里进一步处理 noFields,例如展示在页面上
  141. } else {
  142. console.error('查询失败:', response.msg);
  143. }
  144. if (!input.value) { return }
  145. const params = { order: input.value,yjno:gdwhformData.yjno }
  146. // console.log(params)
  147. isLoading.value = true
  148. const res = await getOrderWasteTotal(params)
  149. console.log(res)
  150. isLoading.value = false
  151. if (res.code === 0) {
  152. // inputCpmc.value = res.data?.[0]?.['product_name']
  153. const val = res.data.map(item => {
  154. return { ...item, gdbh: params.order }
  155. })
  156. // console.log(res.data)
  157. tableData.value = val
  158. }
  159. }
  160. </script>
  161. <style scoped>
  162. :deep(.el-table td .cell) {
  163. line-height: 20px !important;
  164. }
  165. </style>