|
@@ -1,36 +1,67 @@
|
|
|
<template>
|
|
|
<div id="certCard">
|
|
|
<el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <el-col :span="24" class="btn">
|
|
|
- <el-button type="primary" size="mini" @click="submit">生成打印文件</el-button>
|
|
|
- <el-button v-if="url" type="success" size="mini" @click="openPdf">
|
|
|
- 打开生成文件
|
|
|
- </el-button>
|
|
|
+ <span v-if="display == 'list'">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-col :span="24" style="margin:15px 0;">
|
|
|
+ <el-button type="primary" size="mini" @click="clickView()"> 打印预览</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <data-table :fields="fields" :data="list" :opera="opera" :usePage="false"></data-table>
|
|
|
+ </el-col>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="list">
|
|
|
- <data-table :fields="fields" :data="list" :opera="opera" :usePage="false"></data-table>
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-col :span="24" style="margin:15px 0;">
|
|
|
+ <el-button type="primary" size="mini" @click="display = 'list'">返回</el-button>
|
|
|
+ <el-button type="success" size="mini" @click="toPrint()">打印</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="certInfo" ref="print">
|
|
|
+ <el-col :span="24" class="list" v-for="(item, index) in certList" :key="index">
|
|
|
+ <el-col :span="24" class="bjImage no-print">
|
|
|
+ <el-image :src="beijingImage"></el-image>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="cardInfo">
|
|
|
+ <p class="one">
|
|
|
+ <span class="one1">学校(院):</span>
|
|
|
+ <span class="one2">{{ item.school_name }}</span>
|
|
|
+ <span class="one3">{{ item.entry_year }}</span>
|
|
|
+ <span class="one4">级</span>
|
|
|
+ <span class="one5">{{ item.major }}</span>
|
|
|
+ <span class="one6">专业</span>
|
|
|
+ </p>
|
|
|
+ <p class="two">
|
|
|
+ <span class="two1">学生:</span>
|
|
|
+ <span class="two2">{{ item.name }}</span>
|
|
|
+ <span class="two3">于</span>
|
|
|
+ <span class="two4">{{ item.year }}</span>
|
|
|
+ <span class="two5">年</span>
|
|
|
+ <span class="two6">{{ item.month }}</span>
|
|
|
+ <span class="two7">月参加吉林省大学生创新创业培训</span>
|
|
|
+ </p>
|
|
|
+ <p class="three">
|
|
|
+ <span class="thr1">第</span>
|
|
|
+ <span class="thr2"> {{ item.termname }}</span>
|
|
|
+ <span class="thr3">期培训班,培训合格,特发此证。</span>
|
|
|
+ </p>
|
|
|
+ <p class="four">
|
|
|
+ <span class="four1">证书编号:</span>
|
|
|
+ <span class="four2">{{ item.year }}{{ item.termname }}{{ item.classname }}</span>
|
|
|
+ <span class="four3">2020年03月16日</span>
|
|
|
+ </p>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
</el-col>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <!-- 不需要输入了, 作为参数传过来,班级最后一天为毕业日期 -->
|
|
|
- <!-- <el-dialog title="毕业日期" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
|
|
|
- <el-col :span="24">
|
|
|
- <el-date-picker v-model="endDate" type="date" format="yyyy 年 MM 月 dd 日" value-format="yyyy 年 MM 月 dd 日" placeholder="选择日期">
|
|
|
- </el-date-picker>
|
|
|
- </el-col>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="submit">确 定</el-button>
|
|
|
</span>
|
|
|
- </el-dialog> -->
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
const moment = require('moment');
|
|
|
import _ from 'lodash';
|
|
|
-import printTemplate from 'print-template';
|
|
|
import dataTable from '@frame/components/filter-page-table';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
export default {
|
|
@@ -40,14 +71,10 @@ export default {
|
|
|
startdate: { type: String },
|
|
|
enddate: { type: String },
|
|
|
},
|
|
|
- components: {
|
|
|
- dataTable,
|
|
|
- },
|
|
|
+ components: { dataTable },
|
|
|
data: function() {
|
|
|
return {
|
|
|
- url: '',
|
|
|
- template: null,
|
|
|
- zhengshu: require('@/assets/zhengshu.jpg'),
|
|
|
+ display: 'list',
|
|
|
opera: [],
|
|
|
fields: [
|
|
|
{ label: '姓名', prop: 'name' },
|
|
@@ -57,89 +84,29 @@ export default {
|
|
|
{ label: '职务', prop: 'job' },
|
|
|
{ label: '是否优秀', prop: 'is_fine', format: i => (i === '0' ? '否' : i === '1' ? '是' : '无资格') },
|
|
|
],
|
|
|
- dialogVisible: false,
|
|
|
+ beijingImage: require('@/assets/zhengshu.jpg'),
|
|
|
+ // 证书列表
|
|
|
+ certList: [],
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
- this.init();
|
|
|
- },
|
|
|
+ created() {},
|
|
|
methods: {
|
|
|
- init() {
|
|
|
- this.template = new printTemplate();
|
|
|
- this.template.push({
|
|
|
- name: 'expressDelivery1',
|
|
|
- unit: 'px',
|
|
|
- size: [1046.93, 714.02],
|
|
|
- fixed: [
|
|
|
- { type: 'image', x: 0, y: 0, default: this.zhengshu, width: 1046.93, height: 714.02 },
|
|
|
- { type: 'text', x: 138, y: 356, default: '学校(院):', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 607, y: 356, default: '级', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 857, y: 356, default: '专业', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 138, y: 426, default: '学生:', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 365, y: 426, default: '于', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 480, y: 426, default: '年', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 560, y: 426, default: '月参加吉林省大学生创新创业培训', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 138, y: 500, default: '第', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 238, y: 500, default: '期培训班。培训合格,特发此证。', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- { type: 'text', x: 155, y: 580, default: '证书编号:', fontSize: 18, fontFamily: '华文中宋' },
|
|
|
- ],
|
|
|
- data: {
|
|
|
- school_name: { type: 'text', x: 268, y: 356, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- entry_year: { type: 'text', x: 555, y: 356, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- major: { type: 'text', x: 635, y: 356, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- name: { type: 'text', x: 206, y: 426, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- year: { type: 'text', x: 417, y: 426, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- month: { type: 'text', x: 507, y: 426, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- termnames: { type: 'text', x: 190, y: 500, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- cernum: { type: 'text', x: 270, y: 580, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- end_date: { type: 'text', x: 655, y: 580, fontSize: 20, fontFamily: '华文中宋' },
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- openPdf() {
|
|
|
- let link = document.createElement('a');
|
|
|
- link.href = this.url;
|
|
|
- link.target = '_blank';
|
|
|
- link.click();
|
|
|
- },
|
|
|
- print() {
|
|
|
- this.dialogVisible = true;
|
|
|
- },
|
|
|
- submit() {
|
|
|
- let msg = this.$message({ message: '正在生成...', duration: 0 });
|
|
|
- this.dialogVisible = false;
|
|
|
+ // 打印预览
|
|
|
+ clickView() {
|
|
|
+ this.display = 'listView';
|
|
|
+ let certList = this.list;
|
|
|
let end_date = { end_date: moment(this.enddate).format('YYYY 年 MM 月 DD 日') };
|
|
|
- let year = { year: this.startdate.substring(0, 4) };
|
|
|
- let month = { month: this.startdate.substring(5, 7) };
|
|
|
- var enticeNew = this.list.map(item => ({ ...item, ...end_date, ...year, ...month }));
|
|
|
- let data = [];
|
|
|
- this.url = null;
|
|
|
- let duplicate = _.cloneDeep(enticeNew);
|
|
|
- duplicate = duplicate.map(i => {
|
|
|
- i.school_name = `${i.school_name}`;
|
|
|
- i.entry_year = `${i.entry_year}`;
|
|
|
- i.major = `${i.major}`;
|
|
|
- i.name = `${i.name}`;
|
|
|
- i.year = `${i.year}`;
|
|
|
- i.month = `${i.month}`;
|
|
|
- i.termnames = `${i.termname}`;
|
|
|
- i.cernum = `${i.year}${i.termname}${i.classname}01`;
|
|
|
- i.end_date = `${i.end_date}`;
|
|
|
- return i;
|
|
|
- });
|
|
|
- // this.template.print('expressDelivery1', [duplicate[0]]).then(pdf => {
|
|
|
- this.template.print('expressDelivery1', duplicate).then(pdf => {
|
|
|
- msg.close();
|
|
|
- if (pdf) {
|
|
|
- this.$message.success('生成成功');
|
|
|
- this.url = pdf.output('bloburi', { filename: '证书' });
|
|
|
- } else {
|
|
|
- this.$message.warring('生成失败');
|
|
|
- }
|
|
|
- });
|
|
|
+ let year = this.startdate.substring(0, 4);
|
|
|
+ let month = this.startdate.substring(5, 7);
|
|
|
+ for (const val of certList) {
|
|
|
+ val.year = year;
|
|
|
+ val.month = month;
|
|
|
+ }
|
|
|
+ console.log(certList);
|
|
|
+ this.$set(this, `certList`, certList);
|
|
|
},
|
|
|
- handleClose(done) {
|
|
|
- done();
|
|
|
+ toPrint() {
|
|
|
+ this.$print(this.$refs.print);
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
@@ -155,7 +122,133 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
-.btn {
|
|
|
- margin: 0 0 15px 0;
|
|
|
+.certInfo {
|
|
|
+ .list {
|
|
|
+ width: 1050px;
|
|
|
+ height: 719px;
|
|
|
+ overflow: hidden;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ .bjImage {
|
|
|
+ width: 100%;
|
|
|
+ height: 719px;
|
|
|
+ border: 1px solid #000;
|
|
|
+ .el-image {
|
|
|
+ width: 100%;
|
|
|
+ height: 717px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .cardInfo {
|
|
|
+ position: absolute;
|
|
|
+ font-family: '华文中宋';
|
|
|
+ .one {
|
|
|
+ position: absolute;
|
|
|
+ top: 356px;
|
|
|
+ left: 138px;
|
|
|
+ .one1 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 110px;
|
|
|
+ }
|
|
|
+ .one2 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 255px;
|
|
|
+ }
|
|
|
+ .one3 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 55px;
|
|
|
+ }
|
|
|
+ .one4 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 22px;
|
|
|
+ }
|
|
|
+ .one5 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 270px;
|
|
|
+ }
|
|
|
+ .one6 {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .two {
|
|
|
+ position: absolute;
|
|
|
+ top: 426px;
|
|
|
+ left: 138px;
|
|
|
+ .two1 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 60px;
|
|
|
+ }
|
|
|
+ .two2 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 150px;
|
|
|
+ }
|
|
|
+ .two3 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 40px;
|
|
|
+ }
|
|
|
+ .two4 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 55px;
|
|
|
+ }
|
|
|
+ .two5 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 25px;
|
|
|
+ }
|
|
|
+ .two6 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 35px;
|
|
|
+ }
|
|
|
+ .two7 {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .three {
|
|
|
+ position: absolute;
|
|
|
+ top: 500px;
|
|
|
+ left: 138px;
|
|
|
+ .thr1 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 35px;
|
|
|
+ }
|
|
|
+ .thr2 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 45px;
|
|
|
+ }
|
|
|
+ .thr3 {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .four {
|
|
|
+ position: absolute;
|
|
|
+ top: 580px;
|
|
|
+ left: 155px;
|
|
|
+ .four1 {
|
|
|
+ font-size: 18px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 100px;
|
|
|
+ }
|
|
|
+ .four2 {
|
|
|
+ font-size: 20px;
|
|
|
+ display: inline-block;
|
|
|
+ width: 385px;
|
|
|
+ }
|
|
|
+ .four3 {
|
|
|
+ font-size: 20px;
|
|
|
+ letter-spacing: 6px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|