gdcjstj.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div style="width: 30vw; height: 50vh">
  3. <el-input v-model="input" />
  4. <el-button
  5. @click="handlePrint1"
  6. >按工序打印
  7. </el-button>
  8. <el-button
  9. @click="handlePrint2"
  10. >按班组打印
  11. </el-button>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'Gdcjstj',
  17. }
  18. // 2工单超节损统计(按工序)
  19. import service from '@/utils/request'
  20. const getOrderSuperLossCount = (params) => {
  21. return service({
  22. url: '/mes_server/order_super_loss/getOrderSuperLossCount',
  23. method: 'get',
  24. params
  25. })
  26. }
  27. </script>
  28. <script setup>
  29. import { ref, defineProps } from 'vue'
  30. import { hiprint } from 'vue-plugin-hiprint'
  31. import { ElMessage } from 'element-plus'
  32. import template1 from './template-gx.json'
  33. import template2 from './template-bz.json'
  34. // const props = defineProps(['gdbh'])
  35. const props = defineProps({
  36. gdbh: {
  37. type: String,
  38. default: '',
  39. }
  40. })
  41. const input = ref(props['gdbh'])
  42. const handlePrint1 = async() => {
  43. // 引入后初始化
  44. hiprint.init()
  45. const template = JSON.parse(JSON.stringify(template1))
  46. const hiprintTemplate = new hiprint.PrintTemplate({ template })
  47. const params = {
  48. order: input.value,
  49. type: '1',
  50. }
  51. const res = await getOrderSuperLossCount(params)
  52. if (res['code'] === 0) {
  53. console.log(res['data'])
  54. const { data } = res
  55. if (!data) {
  56. ElMessage({
  57. type: 'info',
  58. message: res['msg']
  59. })
  60. return
  61. }
  62. const tableData = {
  63. 'gdbh': data['Gd_gdbh'],
  64. 'cpdh': data['成品代号'],
  65. 'cpmc': data['成品名称'],
  66. 'xsddh': data['销售订单号'],
  67. 'ddsl': `${parseFloat(data['订单数量']).toFixed(4)} 万张`,
  68. 'sjtl': `${parseFloat(data['实际投料']).toFixed(4)} 万张`,
  69. 'rcrq': data['warehousing_date'],
  70. 'rchj': data['warehousing_num'],
  71. 'clf': data['material_waste'],
  72. 'wff': data['waste_out'],
  73. 'ltcl': data['minor_processing'],
  74. 'zcf': data['zcfp'],
  75. 'zjf': data['waste_quality'],
  76. 'wxs': data['intangible_loss'],
  77. 'mbhgl': data['target_rate'],
  78. 'sjhgl': data['real_rate'],
  79. 'total1': data['total']['plan_loss'],
  80. 'total2': data['total']['total_fp'],
  81. 'total3': data['total']['waste_quality'],
  82. 'total4': data['total']['waste_intangible'],
  83. 'total5': data['total']['total_waste'],
  84. 'total6': data['total']['loss'],
  85. // 'total7': data['total'][''],
  86. 'table': data['gy_data'].map(item => ({
  87. 'gxmc': `${item.Gy0_yjno}${item.Gy0_gxh === '' ? '' : '-' + item.Gy0_gxh}${item.Gy0_gxmc === '' ? '' : '-' + item.Gy0_gxmc}${item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc}`.substring(0, 20),
  88. 'jhcl': item['Gy0_计划接货数'],
  89. 'jhsh': item['Gy0_计划损耗'],
  90. 'zcf': item['total_fp'],
  91. 'zjf': item['waste_quality'],
  92. 'wxs': item['intangible_loss'],
  93. 'bfhj': item['total_waste'],
  94. 'jss': item['loss'],
  95. 'tlbfl': item['loss_rate'],
  96. 'mbbfl': item['target_loss_rate'],
  97. 'sjbfl': item['actual_loss_rate'],
  98. 'cdbl': item['超节损承担比例'],
  99. 'cjsje': item[''],
  100. 'zgqr': item[''],
  101. })),
  102. }
  103. console.log(tableData)
  104. hiprintTemplate.print(tableData)
  105. }
  106. }
  107. const handlePrint2 = async() => {
  108. // 引入后初始化
  109. hiprint.init()
  110. const template = JSON.parse(JSON.stringify(template2))
  111. const hiprintTemplate = new hiprint.PrintTemplate({ template })
  112. const params = {
  113. order: input.value,
  114. type: '2',
  115. }
  116. const res = await getOrderSuperLossCount(params)
  117. if (res['code'] === 0) {
  118. console.log(res['data'])
  119. const { data } = res
  120. if (!data) {
  121. ElMessage({
  122. type: 'info',
  123. message: res['msg']
  124. })
  125. return
  126. }
  127. const tableData = {
  128. 'gdbh': data['Gd_gdbh'],
  129. 'cpmc': data['成品名称'],
  130. 'sjtl': parseFloat(data['实际投料']).toFixed(2) + '万张',
  131. 'rcs': data['warehousing_num'],
  132. 'wg': data['warehousing_date'],
  133. 'clf': data['材料废'],
  134. 'wff': data['外发废'],
  135. 'ltcl': data['零头处理'],
  136. 'zcf': data[''],
  137. 'zjf': data['工单质检废'],
  138. 'wxs': data[''],
  139. 'mbhgl': data['target_rate'],
  140. 'sjhgl': data['real_rate'],
  141. 'plan_loss': data['total']['plan_loss'],
  142. 'total_fp': data['total']['total_fp'],
  143. 'waste_quality': data['total']['waste_quality'],
  144. 'waste_intangible': data['total']['waste_intangible'],
  145. 'total_jsj': '',
  146. 'table': data['gy_data'].map(item => ({
  147. 'bzcy': item['member'],
  148. 'yjgx': item['sczl_gxmc'].substring(0, 20),
  149. 'cl': item['total_cl'],
  150. 'jhsh': item['计划损耗'],
  151. 'zcfp': item['sczl_zcfp'],
  152. 'zjf': item['waste_quality'],
  153. 'wxsft': item['intangible_loss'],
  154. 'jssl': item['loss'],
  155. 'cdbl': item['超节损承担比例'],
  156. 'jsj': `<span style="color: red;">${item['loss'] ? item['loss'] : ''}</span>`,
  157. })),
  158. }
  159. console.log(tableData)
  160. hiprintTemplate.print(tableData)
  161. }
  162. }
  163. </script>
  164. <style scoped>
  165. </style>