提交 1aaa870d authored 作者: lihuihui's avatar lihuihui

修改

上级 2493c5a8
差异被折叠。
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
"jspdf": "^2.3.1", "jspdf": "^2.3.1",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"vue": "^2.6.12", "vue": "^2.6.12",
"vue-html2pdf": "^1.8.0",
"vue-i18n": "^8.22.0", "vue-i18n": "^8.22.0",
"vue-loader": "^15.9.3", "vue-loader": "^15.9.3",
"vue-meta-info": "^0.1.7", "vue-meta-info": "^0.1.7",
......
...@@ -10,8 +10,8 @@ export const shmsLang = { ...@@ -10,8 +10,8 @@ export const shmsLang = {
}, },
status: { status: {
selectName: 'Program', selectName: 'Program',
sexMan: 'Man', sexMan: 'Male',
sexWoMan: 'WoMan', sexWoMan: 'Female',
sexUnknown: 'Unknown', sexUnknown: 'Unknown',
proTitle: 'PROFILE', proTitle: 'PROFILE',
mobile: 'Mobile Phone', mobile: 'Mobile Phone',
...@@ -25,7 +25,12 @@ export const shmsLang = { ...@@ -25,7 +25,12 @@ export const shmsLang = {
Level: 'Degree Level', Level: 'Degree Level',
Type: 'Degree Type', Type: 'Degree Type',
selectName2: 'Semester', selectName2: 'Semester',
selectName3: 'Course Name' selectName3: 'Course Name',
enrolled: 'enrolled',
graduate: 'graduate',
gap: 'gap',
withdraw: 'withdraw',
Lose: 'Lose contact'
}, },
score: { score: {
name: 'Name', name: 'Name',
......
...@@ -8,7 +8,6 @@ import './style.scss' // 公共样式 ...@@ -8,7 +8,6 @@ import './style.scss' // 公共样式
import MetaInfo from 'vue-meta-info' import MetaInfo from 'vue-meta-info'
import Element from 'element-ui' import Element from 'element-ui'
import i18n from './i18n' import i18n from './i18n'
import htmlToPdf from '@/utils/htmlToPdf.js'
// import createBefore from './components/beforeEnter' // import createBefore from './components/beforeEnter'
import BeforeEnter from './utils/beforeEnter' import BeforeEnter from './utils/beforeEnter'
...@@ -21,8 +20,6 @@ Vue.use(MetaInfo) ...@@ -21,8 +20,6 @@ Vue.use(MetaInfo)
Vue.use(Element) Vue.use(Element)
Vue.use(htmlToPdf)
/* 设置全局变量 */ /* 设置全局变量 */
window.G = Vue.prototype.$GLOBAL = { window.G = Vue.prototype.$GLOBAL = {
VERSION: 'PC-1.0.0' VERSION: 'PC-1.0.0'
......
<template> <template>
<div class="app-card"> <div class="app-card">
<div class="form-box"> <div class="form-box">
<el-select @change="changes" v-model="value" :placeholder="$t('shmsLang.selectHolder')" size="small" clearable> <el-select @change="changes" v-model="value" size="small" clearable>
<el-option v-for="item in options" :key="item.id" :label="item.english_name" :value="item.id"> </el-option> <el-option v-for="item in options" :key="item.id" :label="item.english_name" :value="item.id"> </el-option>
</el-select> </el-select>
<div class="down-btn" @click="openPdf">{{ $t('shmsLang.downloadBtn') }}</div> <div class="down-btn" @click="openPdf">{{ $t('shmsLang.downloadBtn') }}</div>
...@@ -54,6 +54,7 @@ export default { ...@@ -54,6 +54,7 @@ export default {
.getCondition() .getCondition()
.then(response => { .then(response => {
this.options = response.data.get_school_info.project_map this.options = response.data.get_school_info.project_map
this.value = response.data.get_school_info.project_map[0].id
}) })
.finally(() => {}) .finally(() => {})
} }
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
<div class="td">{{ item.semester }}</div> <div class="td">{{ item.semester }}</div>
<div class="td">{{ item.project_english_name }}</div> <div class="td">{{ item.project_english_name }}</div>
<div class="td">{{ item.score }}</div> <div class="td">{{ item.score }}</div>
<div class="td">{{ item.pubdate }}</div> <div class="td">
<div v-if="item.pubdate">{{ item.pubdate.substring(0, item.pubdate.indexOf(' ')) }}</div>
</div>
</div> </div>
</div> </div>
</template> </template>
...@@ -74,6 +76,8 @@ export default { ...@@ -74,6 +76,8 @@ export default {
{ {
name: this.$t('shmsLang.score.date'), name: this.$t('shmsLang.score.date'),
value: this.data.student_info.pubdate value: this.data.student_info.pubdate
? this.data.student_info.pubdate.substring(0, this.data.student_info.pubdate.indexOf(' '))
: ''
} }
] ]
] ]
...@@ -89,10 +93,11 @@ export default { ...@@ -89,10 +93,11 @@ export default {
padding: 30px 0; padding: 30px 0;
border-bottom: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8;
display: flex; display: flex;
justify-content: space-around;
.temp { .temp {
display: flex; display: flex;
align-items: center; align-items: center;
width: 440px; // width: 440px;
margin-bottom: 12px; margin-bottom: 12px;
&:nth-child(3) { &:nth-child(3) {
margin-bottom: 0; margin-bottom: 0;
......
<template> <template>
<div class="app-card"> <div class="app-card">
<scach-form @downPdf="downPdf" @search="search" /> <scach-form @downPdf="downPdf" @search="search" />
<app-info id="pdfDom" :data="data" :program="program"/> <!-- <app-info id="pdfDom" :data="data" :program="program"/> -->
<vue-html2pdf
:show-layout="false"
:float-layout="false"
:enable-download="true"
:preview-modal="true"
:paginate-elements-by-height="1000"
filename="file"
pdf-content-width="100%"
ref="html2Pdf"
>
<section slot="pdf-content">
<app-info :data="data" :program="program" />
</section>
</vue-html2pdf>
</div> </div>
</template> </template>
<script> <script>
import VueHtml2pdf from 'vue-html2pdf'
import scachForm from './components/form.vue' import scachForm from './components/form.vue'
import appInfo from './components/info.vue' import appInfo from './components/info.vue'
import * as api from '@/api/account.js' import * as api from '@/api/account.js'
export default { export default {
components: { scachForm, appInfo }, components: { scachForm, appInfo, VueHtml2pdf },
data() { data() {
return { return {
pageData: null, pageData: null,
...@@ -27,7 +42,8 @@ export default { ...@@ -27,7 +42,8 @@ export default {
this.getScore(params.form) this.getScore(params.form)
}, },
downPdf() { downPdf() {
this.getPdf('#pdfDom') // this.getPdf('#pdfDom')
this.$refs.html2Pdf.generatePdf()
}, },
getScore(param) { getScore(param) {
api api
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="profile-title">{{ $t('shmsLang.status.proTitle') }}</div> <div class="profile-title">{{ $t('shmsLang.status.proTitle') }}</div>
<div class="profile-content"> <div class="profile-content">
<div class="photo"> <div class="photo">
<img :src="info.head_img" /> <img :src="info.head_img || 'https://webapp-pub.ezijing.com/project/marywood/mary_banner_nx4.jpg'" />
</div> </div>
<div class="info-box" style="margin-right: 20px"> <div class="info-box" style="margin-right: 20px">
<div class="name">{{ $i18n.locale == 'zh' ? info.chinese_name : info.english_name }}</div> <div class="name">{{ $i18n.locale == 'zh' ? info.chinese_name : info.english_name }}</div>
...@@ -24,15 +24,19 @@ ...@@ -24,15 +24,19 @@
</div> </div>
<div class="info-temp m-t17"> <div class="info-temp m-t17">
<div class="name w140">{{ $t('shmsLang.status.state') }}</div> <div class="name w140">{{ $t('shmsLang.status.state') }}</div>
<div class="value">{{ currentStatus[info.graduation_status] }}</div> <div class="value">{{ setStatus(info.graduation_status) }}</div>
</div> </div>
<div class="info-temp m-t17"> <div class="info-temp m-t17">
<div class="name w140">{{ $t('shmsLang.status.added') }}</div> <div class="name w140">{{ $t('shmsLang.status.added') }}</div>
<div class="value">{{ info.created_time }}</div> <div class="value" v-if="info.created_time">
{{ info.created_time.substring(0, info.created_time.indexOf(' ')) }}
</div>
</div> </div>
<div class="info-temp m-t17"> <div class="info-temp m-t17">
<div class="name w140">{{ $t('shmsLang.status.graduated') }}</div> <div class="name w140">{{ $t('shmsLang.status.graduated') }}</div>
<div class="value">{{ info.graduation_time }}</div> <div class="value" v-if="info.graduation_time">
{{ info.graduation_time.substring(0, info.graduation_time.indexOf(' ')) }}
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -46,15 +50,7 @@ export default { ...@@ -46,15 +50,7 @@ export default {
} }
}, },
data() { data() {
return { return {}
currentStatus: {
1: '在读',
2: '毕业',
3: '失联',
4: '休学',
5: '退学'
}
}
}, },
computed: { computed: {
setSex() { setSex() {
...@@ -70,11 +66,11 @@ export default { ...@@ -70,11 +66,11 @@ export default {
setStatus() { setStatus() {
return n => { return n => {
const status = { const status = {
1: '在读', 1: this.$t('shmsLang.status.enrolled'),
2: '毕业', 2: this.$t('shmsLang.status.graduate'),
3: '失联', 3: this.$t('shmsLang.status.Lose'),
4: '休学', 4: this.$t('shmsLang.status.gap'),
5: '退学' 5: this.$t('shmsLang.status.withdraw')
} }
return status[n] return status[n]
} }
...@@ -106,6 +102,7 @@ export default { ...@@ -106,6 +102,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: block; display: block;
object-fit: cover;
} }
} }
.info-box { .info-box {
......
...@@ -15,20 +15,37 @@ ...@@ -15,20 +15,37 @@
</el-select> </el-select>
</div> </div>
</div> </div>
<div class="btn" @click="getPdf('#pdfDom')">{{ $t('shmsLang.downloadBtn') }}</div> <!-- <div class="btn" @click="getPdf('#pdfDom')">{{ $t('shmsLang.downloadBtn') }}</div> -->
<div class="btn" @click="generateReport">{{ $t('shmsLang.downloadBtn') }}</div>
</div> </div>
<div id="pdfDom"> <!-- <div>
<profile :info="info" @changes="changes" /> <profile :info="info" @changes="changes" />
<degrees :degreesItem="degreesItem" /> <degrees :degreesItem="degreesItem" />
</div> </div> -->
<vue-html2pdf
:show-layout="false"
:float-layout="false"
:enable-download="true"
:preview-modal="true"
:paginate-elements-by-height="1000"
filename="file"
pdf-content-width="100%"
ref="html2Pdf"
>
<section slot="pdf-content">
<profile :info="info" @changes="changes" />
<degrees :degreesItem="degreesItem" />
</section>
</vue-html2pdf>
</div> </div>
</template> </template>
<script> <script>
import VueHtml2pdf from 'vue-html2pdf'
import profile from './components/profile.vue' import profile from './components/profile.vue'
import degrees from './components/degrees.vue' import degrees from './components/degrees.vue'
import * as api from '@/api/account.js' import * as api from '@/api/account.js'
export default { export default {
components: { profile, degrees }, components: { profile, degrees, VueHtml2pdf },
data() { data() {
return { return {
pageData: null, pageData: null,
...@@ -44,6 +61,9 @@ export default { ...@@ -44,6 +61,9 @@ export default {
this.getCondition() this.getCondition()
}, },
methods: { methods: {
generateReport() {
this.$refs.html2Pdf.generatePdf()
},
getCondition() { getCondition() {
api api
.getCondition() .getCondition()
......
// 导出页面为PDF格式
import html2Canvas from 'html2canvas'
import JsPDF from 'jspdf'
export default {
install (Vue, options) {
Vue.prototype.getPdf = function () {
var title = this.htmlTitle
html2Canvas(document.querySelector('#pdfDom'), {
allowTaint: true,
useCORS: true
}).then(function (canvas) {
const contentWidth = canvas.width
const contentHeight = canvas.height
const pageHeight = contentWidth / 592.28 * 841.89
let leftHeight = contentHeight
let position = 0
const imgWidth = 595.28
const imgHeight = 592.28 / contentWidth * contentHeight
const pageData = canvas.toDataURL('image/jpeg', 1.0)
const PDF = new JsPDF('', 'pt', 'a4')
if (leftHeight < pageHeight) {
PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
} else {
while (leftHeight > 0) {
PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
leftHeight -= pageHeight
position -= 841.89
if (leftHeight > 0) {
PDF.addPage()
}
}
}
PDF.save(title + '.pdf')
}
)
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论