| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <template>
- <div style="width: 30vw; height: 50vh">
- <el-input v-model="input" />
- <el-button
- @click="handlePrint1"
- >按工序打印
- </el-button>
- <el-button
- @click="handlePrint2"
- >按班组打印
- </el-button>
- </div>
- </template>
- <script>
- export default {
- name: 'Gdcjstj',
- }
- // 2工单超节损统计(按工序)
- import service from '@/utils/request'
- const getOrderSuperLossCount = (params) => {
- return service({
- url: '/mes_server/order_super_loss/getOrderSuperLossCount',
- method: 'get',
- params
- })
- }
- </script>
- <script setup>
- import { ref, defineProps } from 'vue'
- import { hiprint } from 'vue-plugin-hiprint'
- import { ElMessage } from 'element-plus'
- import template1 from './template-gx.json'
- import template2 from './template-bz.json'
- // const props = defineProps(['gdbh'])
- const props = defineProps({
- gdbh: {
- type: String,
- default: '',
- }
- })
- const input = ref(props['gdbh'])
- // 按工序打印
- const handlePrint1 = async() => {
- // 引入后初始化
- hiprint.init()
- const template = JSON.parse(JSON.stringify(template1))
- const hiprintTemplate = new hiprint.PrintTemplate({ template })
- const params = {
- order: input.value,
- type: '1',
- }
- const res = await getOrderSuperLossCount(params)
- if (res['code'] === 0) {
- console.log(res['data'])
- const { data } = res
- if (!data) {
- ElMessage({
- type: 'info',
- message: res['msg']
- })
- return
- }
- const tableData = {
- 'gdbh': data['Gd_gdbh'],
- 'cpdh': data['成品代号'],
- 'cpmc': data['成品名称'],
- 'xsddh': data['销售订单号'],
- 'ddsl': `${parseFloat(data['订单数量']).toFixed(4)} 万张`,
- 'sjtl': `${parseFloat(data['实际投料']).toFixed(4)} 万张`,
- 'rcrq': data['warehousing_date'],
- 'rchj': data['warehousing_num'],
- 'clf': data['材料废'],
- 'wff': data['外发废'],
- 'ltcl': data['零头处理'],
- 'zcf': data['zcfp'],
- 'zjf': data['工单质检废'],
- 'wxs': data['intangible_loss'],
- 'mbhgl': data['target_rate'],
- 'sjhgl': data['real_rate'],
- 'total1': data['total']['plan_loss'],
- 'total2': data['total']['total_fp'],
- 'total3': data['total']['waste_quality'],
- 'total4': data['total']['waste_intangible'],
- 'total5': data['total']['total_waste'],
- 'total6': data['total']['loss'],
- 'total7': data['total']['reward'],
- 'table': data['gy_data'].map(item => ({
- '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),
- 'jhcl': item['Gy0_计划接货数'],
- 'jhsh': item['Gy0_计划损耗'],
- 'zcf': item['total_fp'],
- 'zjf': item['waste_quality'],
- 'wxs': item['intangible_loss'],
- 'bfhj': item['total_waste'],
- 'jss': item['loss'],
- 'tlbfl': item['loss_rate'],
- 'mbbfl': item['target_loss_rate'],
- 'sjbfl': item['actual_loss_rate'],
- 'cdbl': item['超节损承担比例'],
- 'gxcjsje': item['工序超节损金额'].substring(0, item['工序超节损金额'].length - 2),
- 'zgqr': '',
- })),
- }
- console.log(tableData)
- hiprintTemplate.print(tableData)
- }
- }
- // 按班组打印
- const handlePrint2 = async() => {
- // 引入后初始化
- hiprint.init()
- const template = JSON.parse(JSON.stringify(template2))
- const hiprintTemplate = new hiprint.PrintTemplate({ template })
- const params = {
- order: input.value,
- type: '2',
- }
- const res = await getOrderSuperLossCount(params)
- if (res['code'] === 0) {
- console.log(res['data'])
- const { data } = res
- if (!data) {
- ElMessage({
- type: 'info',
- message: res['msg']
- })
- return
- }
- const tableData = {
- 'gdbh': data['Gd_gdbh'],
- 'cpmc': data['成品名称'],
- 'sjtl': parseFloat(data['实际投料']).toFixed(2) + '万张',
- 'rcs': data['warehousing_num'],
- 'wg': data['warehousing_date'],
- 'clf': data['材料废'],
- 'wff': data['外发废'],
- 'ltcl': data['零头处理'],
- 'zcf': data['zcfp'],
- 'zjf': data['工单质检废'],
- 'wxs': data[''],
- 'mbhgl': data['target_rate'],
- 'sjhgl': data['real_rate'],
- 'plan_loss': data['total']['plan_loss'],
- 'total_fp': data['total']['total_fp'],
- 'waste_quality': data['total']['waste_quality'],
- 'waste_intangible': data['total']['waste_intangible'],
- 'total_jsj': '',
- 'table': data['gy_data'].map(item => ({
- 'bzcy': item['member'],
- 'yjgx': item['sczl_gxmc'].substring(0, 20),
- 'cl': item['total_cl'],
- 'jhsh': item['计划损耗'],
- 'zcfp': item['sczl_zcfp'],
- 'zjf': item['质检废'],
- 'wxsft': item['无形损分摊'],
- 'jssl': item['节损数量'],
- 'cdbl': item['超节损承担比例'],
- 'jsj': `<span style="color: red;">${item['节损奖'] ? item['节损奖'] : ''}</span>`,
- })),
- }
- console.log(tableData)
- hiprintTemplate.print(tableData)
- }
- }
- </script>
- <style scoped>
- </style>
|