|
@@ -2,58 +2,141 @@
|
|
|
<div id="certCard">
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
- <el-col :span="24">
|
|
|
- <el-button type="primary" size="mini" @click="toTest()">打印证书</el-button>
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" size="mini" @click="print">生成打印文件</el-button>
|
|
|
+ <el-button v-if="url" type="success" size="mini" @click="openPdf">
|
|
|
+ 打开生成文件
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="list">
|
|
|
+ <data-table :fields="fields" :data="list" :opera="opera" :usePage="false"></data-table>
|
|
|
</el-col>
|
|
|
- <test :list="list"></test>
|
|
|
- <!-- <el-col :span="24" ref="print">
|
|
|
- <el-col :span="24" class="list" v-for="(item, index) in list" :key="index">
|
|
|
- <p>
|
|
|
- <span>学校(院):</span>
|
|
|
- <span>{{ item.school_name }}</span>
|
|
|
- <span>,</span>
|
|
|
- <span>{{ item.entry_year }}</span>
|
|
|
- <span>级</span>
|
|
|
- <span>{{ item.major }}</span>
|
|
|
- <span>专业</span>
|
|
|
- <span>学生:</span>
|
|
|
- <span>{{ item.name }}</span>
|
|
|
- <span>于</span>
|
|
|
- <span>2020年11月参加吉林省大学生就业能力扩展训练</span>
|
|
|
- <span>第</span>
|
|
|
- <span>{{ item.termname }}</span>
|
|
|
- <span>期培训班。培训合格,特发此证</span>
|
|
|
- </p>
|
|
|
- <p>
|
|
|
- <span>证书编号:2020{{ item.termname }}{{ item.classname }}</span>
|
|
|
- <span>2020年11月22日</span>
|
|
|
- </p>
|
|
|
- </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>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import _ from 'lodash';
|
|
|
import printTemplate from 'print-template';
|
|
|
-import test from './test';
|
|
|
+import dataTable from '@frame/components/filter-page-table';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
export default {
|
|
|
name: 'certCard',
|
|
|
props: {
|
|
|
- list: null,
|
|
|
+ list: { type: Array, default: () => [] },
|
|
|
+ startdate: null,
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ dataTable,
|
|
|
},
|
|
|
- components: { test },
|
|
|
data: function() {
|
|
|
return {
|
|
|
+ url: '',
|
|
|
+ template: null,
|
|
|
zhengshu: require('@/assets/zhengshu.jpg'),
|
|
|
+ opera: [],
|
|
|
+ fields: [
|
|
|
+ { label: '姓名', prop: 'name' },
|
|
|
+ { label: '学校名称', prop: 'school_name' },
|
|
|
+ { label: '院系', prop: 'faculty' },
|
|
|
+ { label: '专业', prop: 'major' },
|
|
|
+ { label: '职务', prop: 'job' },
|
|
|
+ { label: '是否优秀', prop: 'is_fine', format: i => (i === '0' ? '否' : i === '1' ? '是' : '无资格') },
|
|
|
+ ],
|
|
|
+ dialogVisible: false,
|
|
|
+ endDate: '',
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
methods: {
|
|
|
- toPrint() {
|
|
|
- this.$print(this.$refs.print);
|
|
|
+ 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() {
|
|
|
+ console.log(this.endDate);
|
|
|
+ this.dialogVisible = false;
|
|
|
+ let end_date = { end_date: this.endDate };
|
|
|
+ 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 => {
|
|
|
+ if (pdf) {
|
|
|
+ this.$message.success('生成成功');
|
|
|
+ this.url = pdf.output('bloburi', { filename: '证书' });
|
|
|
+ } else {
|
|
|
+ this.$message.warring('生成失败');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleClose(done) {
|
|
|
+ done();
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
@@ -69,11 +152,7 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
-.list {
|
|
|
- height: 710px;
|
|
|
- background-image: url(/img/zhengshu.bc829b8f.jpg);
|
|
|
- background-size: 100% 100%;
|
|
|
- background-repeat: no-repeat;
|
|
|
- width: 100%;
|
|
|
+.btn {
|
|
|
+ margin: 0 0 15px 0;
|
|
|
}
|
|
|
</style>
|