gongdanzhijianfeipintongji.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 handleExcel = () => {
  99. const el = document.getElementById('tab');
  100. // 文件名
  101. const filename = '核检废品日统计-'+input.value+ '.xlsx';
  102. const wb = XLSX.utils.table_to_book(el, { raw: true });
  103. const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
  104. try {
  105. FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
  106. } catch (e) {
  107. console.log(e);
  108. }
  109. return wbout;
  110. }
  111. nextTick(() => {
  112. handleSearch()
  113. })
  114. const gdwhformData = reactive({
  115. // 下拉框选项数据
  116. yinjian: [],
  117. // 设置默认值
  118. yjno: '',
  119. });
  120. const ongdwhfanclick = async() => {
  121. console.log(gdwhformData.yjno)
  122. const response = await PrintDetailList({ workOrder:input.value});
  123. // console.log(response)
  124. const matchingItem = response.data.find(item => item.no === gdwhformData.yjno);
  125. if (matchingItem) {
  126. console.log(matchingItem.name)
  127. inputCpmc.value = matchingItem.name;
  128. } else {
  129. console.log(`No matching item found for no: ${gdwhformData.yjno}`);
  130. }
  131. }
  132. const handleSearch = async() => {
  133. const response = await PrintDetailList({ workOrder:input.value});
  134. // console.log(response)
  135. if (response.code === 0) {
  136. const noFields = response.data.map(item => item.no);
  137. // console.log(noFields)
  138. gdwhformData.yinjian = noFields
  139. // 你可以在这里进一步处理 noFields,例如展示在页面上
  140. } else {
  141. console.error('查询失败:', response.msg);
  142. }
  143. if (!input.value) { return }
  144. const params = { order: input.value,yjno:gdwhformData.yjno }
  145. // console.log(params)
  146. isLoading.value = true
  147. const res = await getOrderWasteTotal(params)
  148. console.log(res)
  149. isLoading.value = false
  150. if (res.code === 0) {
  151. // inputCpmc.value = res.data?.[0]?.['product_name']
  152. const val = res.data.map(item => {
  153. return { ...item, gdbh: params.order }
  154. })
  155. // console.log(res.data)
  156. tableData.value = val
  157. }
  158. }
  159. </script>
  160. <style scoped>
  161. :deep(.el-table td .cell) {
  162. line-height: 20px !important;
  163. }
  164. </style>