工单管理打印功能 ( npm install print-js --save )

master
wws 1 year ago
parent 0bb0b55f0b
commit f2ca16bb18

@ -47,6 +47,7 @@
"jsencrypt": "3.0.0-rc.1", "jsencrypt": "3.0.0-rc.1",
"moment": "^2.29.4", "moment": "^2.29.4",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"print-js": "^1.6.0",
"quill": "1.3.7", "quill": "1.3.7",
"screenfull": "5.0.2", "screenfull": "5.0.2",
"sortablejs": "1.10.2", "sortablejs": "1.10.2",

@ -1,5 +1,12 @@
import request from '@/utils/request' import request from '@/utils/request'
export function getWorkOrders(workorderCode) {
return request({
url:'/plan/pro/workorder/getWorkOrders/'+workorderCode,
method:'get'
})
}
// 校验工单是否可以修改 // 校验工单是否可以修改
export function checkWorkOrder(workorderId){ export function checkWorkOrder(workorderId){
return request({ return request({

@ -37,6 +37,8 @@ import DictTag from '@/components/DictTag'
import VueMeta from 'vue-meta' import VueMeta from 'vue-meta'
// 字典数据组件 // 字典数据组件
import DictData from '@/components/DictData' import DictData from '@/components/DictData'
// 打印插件
import Print from 'print-js'
// 全局方法挂载 // 全局方法挂载
Vue.prototype.getDicts = getDicts Vue.prototype.getDicts = getDicts

@ -138,7 +138,18 @@
v-hasPermi="['mes:pro:workorder:export']" v-hasPermi="['mes:pro:workorder:export']"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <el-col :span="1.5">
<el-button
type="success"
plain
:disabled="single"
icon="el-icon-download"
size="mini"
@click="showPrint"
v-hasPermi="['mes:pro:workorder:export']"
>打印预览</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="workorderList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="workorderList" @selection-change="handleSelectionChange">
@ -182,6 +193,101 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 打印预览弹出层 -->
<el-dialog
title="工单信息"
:visible.sync="printDialogVisible"
width="1450px"
>
<div id="printFrom" class="my-print-box">
<el-form :ref="formRef" :model="form" :rules="validateRules">
<!-- 表头-工单信息 -->
<el-row class="my-print-head">
<el-col :offset="10" :span="4">生产工单</el-col>
</el-row>
<!-- 导航栏 -->
<el-row class="my-print-nav">
<el-col :span="4">工厂:{{printData.factory}}</el-col>
<el-col :span="4">工作中心:{{printData.workCenter}}</el-col>
<el-col :span="4">生产日期:{{printData.productDate}}</el-col>
<el-col :span="4">打印日期:{{printData.printDate}}</el-col>
<el-col :span="4">页次: 1/ 1</el-col>
</el-row>
<!-- 主数据 -->
<el-table
v-if="refreshNewWorkerTable"
v-loading="newWorkerLoading"
class="my-print-table"
:data="printData.workTable"
border
style="width: 100%">
<el-table-column
type="index"
label="序号"
width="50">
</el-table-column>
<el-table-column
prop="workorderCode"
label="工单号"
width="180">
</el-table-column>
<el-table-column
prop="productName"
label="物料名称"
width="180">
</el-table-column>
<el-table-column
prop="unit"
label="单位">
</el-table-column>
<el-table-column
prop="orderCode"
label="生产订单">
</el-table-column>
<el-table-column
prop="quantityProduced"
label="已生产数量">
</el-table-column>
<el-table-column
prop="quantitySplit"
label="拆分数量">
</el-table-column>
<el-table-column
prop="routeCode"
label="工艺编码">
</el-table-column>
<el-table-column
prop="prodLineCode"
label="产线设备">
</el-table-column>
<el-table-column label="班次" align="center" prop="shiftId">
<template slot-scope="scope">
<dict-tag :options="dict.type.shift_type" :value="scope.row.shiftId"/>
</template>
</el-table-column>
<el-table-column label="工单状态" align="center" prop="status" >
<template slot-scope="scope">
<dict-tag :options="dict.type.workorder_type" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="产品类型" align="center" prop="prodType" >
<template slot-scope="scope">
<dict-tag :options="dict.type.product_type" :value="scope.row.prodType"/>
</template>
</el-table-column>
</el-table>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handlePrint(printData)"> </el-button>
</span>
</el-dialog>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
@ -324,6 +430,7 @@
<script> <script>
import { import {
getWorkOrders,
listWorkorder, listWorkorder,
getWorkorder, getWorkorder,
delWorkorder, delWorkorder,
@ -342,14 +449,28 @@ export default {
dicts: ['product_type','workorder_type','shift_type'], dicts: ['product_type','workorder_type','shift_type'],
data() { data() {
return { return {
formRef: 'form',
validateRules: [],
printData: {
printable: 'printFrom',
ignore: ['no-print'],
workCenter: "暂无数据",
printDate: null,
factory: null,
productDate: null,
workTable: [],
},
printDialogVisible: false,
// form // form
workForm: {}, workForm: {},
// -- // --
selectWork: null, selectWork: null,
// //
workerLoading: false, workerLoading: false,
newWorkerLoading: false,
// //
refreshWorkerTable: true, refreshWorkerTable: true,
refreshNewWorkerTable: true,
// list // list
splitData: [], splitData: [],
// //
@ -458,6 +579,40 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
handlePrint(params) {
printJS({
printable: params.printable, // 'printFrom', // id
type: params.type || 'html',
maxWidth: 1500, //
font_size: "",//
header: params.header, // '',
targetStyles: ['*'],
style: '@page {margin:0 10mm};', // -
ignoreElements: params.ignore || [], // ['no-print']
properties: params.properties || null
})
},
//
showPrint() {
//
this.printData.workCenter = "暂无数据";
this.printData.printDate = null;
this.printData.workTable = [];
this.printData.factory = null;
this.printData.productDate = null;
//
this.printDialogVisible = true;
this.printData.printDate = moment(new Date()).format('YYYY.MM.DD');
this.newWorkerLoading = true // true
this.refreshNewWorkerTable = false // refreshProTablefalse
getWorkOrders(this.selectWork.workorderCode).then(response => {
this.printData.workTable = response.data;
this.printData.factory = response.data[0].factoryCode;
this.printData.productDate = response.data[0].productDate;
this.refreshNewWorkerTable = true // refreshProTabletrue
this.newWorkerLoading = false // false
})
},
/** 动态添加表单 */ /** 动态添加表单 */
addField() { addField() {
// //
@ -927,5 +1082,16 @@ export default {
.my-margin { .my-margin {
margin-top: 40px; margin-top: 40px;
margin-bottom: 10px; margin-bottom: 10px;
}
.my-print-head {
margin-top: 20px;
font-weight: bold;
}
.my-print-nav {
margin-top: 15px;
margin-bottom: 15px;
}
.my-print-table {
} }
</style> </style>

Loading…
Cancel
Save