certCard.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div id="certCard">
  3. <el-row>
  4. <span v-if="display == 'list'">
  5. <el-col :span="24">
  6. <el-col :span="24" style="margin:15px 0;">
  7. <el-button type="primary" size="mini" @click="clickView()"> 打印预览</el-button>
  8. </el-col>
  9. <el-col :span="24">
  10. <data-table :fields="fields" :select="true" @handleSelect="handleSelect" :data="list" :opera="opera" :usePage="false"></data-table>
  11. </el-col>
  12. </el-col>
  13. </span>
  14. <span v-else>
  15. <el-col :span="24">
  16. <el-col :span="24" style="margin:15px 0;">
  17. <el-button type="primary" size="mini" @click="display = 'list'">返回</el-button>
  18. <el-button type="success" size="mini" @click="toPrint()">打印</el-button>
  19. </el-col>
  20. <el-col :span="24" class="certInfo" ref="print">
  21. <el-col :span="24" class="list" v-for="(item, index) in certList" :key="index">
  22. <el-col :span="24" class="bjImage no-print">
  23. <el-image :src="beijingImage"></el-image>
  24. </el-col>
  25. <el-col :span="24" class="cardInfo">
  26. <p class="one">
  27. <span class="one1">学校(院):</span>
  28. <span class="one2">{{ item.school_name }}</span>
  29. <span class="one3">{{ item.entry_year }}</span>
  30. <span class="one4">级</span>
  31. <span class="one5">{{ item.major }}</span>
  32. <span class="one6">专业</span>
  33. </p>
  34. <p class="two">
  35. <span class="two1">学生:</span>
  36. <span class="two2">{{ item.name }}</span>
  37. <span class="two3">于</span>
  38. <span class="two4">{{ item.year }}</span>
  39. <span class="two5">年</span>
  40. <span class="two6">{{ item.month }}</span>
  41. <span class="two7">月参加吉林省大学生就业能力扩展训练</span>
  42. </p>
  43. <p class="three">
  44. <span class="thr1">第</span>
  45. <span class="thr2"> {{ term }}</span>
  46. <span class="thr3">期培训班,培训合格,特发此证。</span>
  47. </p>
  48. <p class="four">
  49. <span class="four1">证书编号:</span>
  50. <span class="four2">{{ item.year }}{{ term }}{{ getclanum(classname) }}{{ item.number }}</span>
  51. <span class="four3">{{ getend(enddate) }}</span>
  52. </p>
  53. </el-col>
  54. </el-col>
  55. </el-col>
  56. </el-col>
  57. </span>
  58. </el-row>
  59. </div>
  60. </template>
  61. <script>
  62. const moment = require('moment');
  63. import _ from 'lodash';
  64. import dataTable from '@frame/components/filter-page-table';
  65. import { mapState, createNamespacedHelpers } from 'vuex';
  66. export default {
  67. name: 'certCard',
  68. props: {
  69. list: { type: Array, default: () => [] },
  70. startdate: { type: String },
  71. enddate: { type: String },
  72. classname: { type: String },
  73. term: { type: String },
  74. },
  75. components: { dataTable },
  76. data: function() {
  77. return {
  78. display: 'list',
  79. opera: [],
  80. fields: [
  81. { label: '姓名', prop: 'name' },
  82. { label: '学校名称', prop: 'school_name' },
  83. { label: '院系', prop: 'faculty' },
  84. { label: '专业', prop: 'major' },
  85. { label: '职务', prop: 'job' },
  86. { label: '是否优秀', prop: 'is_fine', format: i => (i === '0' ? '否' : i === '1' ? '是' : '无资格') },
  87. ],
  88. beijingImage: require('@/assets/zhengshu.jpg'),
  89. // 证书列表
  90. certList: [],
  91. // 选择学生的列表
  92. selectList: [],
  93. };
  94. },
  95. created() {},
  96. methods: {
  97. // 打印预览
  98. clickView() {
  99. let certList = this.selectList;
  100. if (certList.length == 0) {
  101. this.$message({
  102. message: '请选择需要打印证书的学生',
  103. type: 'warning',
  104. });
  105. } else {
  106. this.display = 'listView';
  107. let end_date = { end_date: moment(this.enddate).format('YYYY 年 MM 月 DD 日') };
  108. let year = this.startdate.substring(0, 4);
  109. let month = this.startdate.substring(5, 7);
  110. for (const val of certList) {
  111. val.year = year;
  112. val.month = month;
  113. }
  114. this.$set(this, `certList`, certList);
  115. }
  116. },
  117. handleSelect(data) {
  118. this.$set(this, `selectList`, data);
  119. },
  120. toPrint() {
  121. this.$print(this.$refs.print);
  122. },
  123. // 結束時間
  124. getend(date) {
  125. let end_date = moment(date).format('YYYY 年 MM 月 DD 日');
  126. if (end_date) return end_date;
  127. },
  128. // 过滤班级
  129. getclanum(index) {
  130. var num = index.replace(/[^\d]/g, '');
  131. if (num < 10) return '0' + num;
  132. else return num;
  133. },
  134. // 过滤几号学生
  135. // getnum(index) {
  136. // let num = index + 1;
  137. // if (num < 10) return '0' + num;
  138. // else return index;
  139. // },
  140. },
  141. computed: {
  142. ...mapState(['user']),
  143. pageTitle() {
  144. return `${this.$route.meta.title}`;
  145. },
  146. },
  147. metaInfo() {
  148. return { title: this.$route.meta.title };
  149. },
  150. };
  151. </script>
  152. <style lang="less" scoped>
  153. .certInfo {
  154. .list {
  155. width: 1050px;
  156. height: 719px;
  157. overflow: hidden;
  158. position: relative;
  159. }
  160. .bjImage {
  161. width: 100%;
  162. height: 719px;
  163. border: 1px solid #000;
  164. .el-image {
  165. width: 100%;
  166. height: 717px;
  167. }
  168. }
  169. .cardInfo {
  170. position: absolute;
  171. font-family: Arial;
  172. .one {
  173. position: absolute;
  174. top: 356px;
  175. left: 115px;
  176. .one1 {
  177. font-size: 18px;
  178. display: inline-block;
  179. width: 110px;
  180. font-weight: bold;
  181. font-family: Arial;
  182. }
  183. .one2 {
  184. font-size: 20px;
  185. display: inline-block;
  186. width: 270px;
  187. font-weight: bold;
  188. font-family: Arial;
  189. }
  190. .one3 {
  191. font-size: 20px;
  192. display: inline-block;
  193. width: 55px;
  194. font-weight: bold;
  195. font-family: Arial;
  196. }
  197. .one4 {
  198. font-size: 18px;
  199. display: inline-block;
  200. width: 22px;
  201. font-weight: bold;
  202. font-family: Arial;
  203. }
  204. .one5 {
  205. font-size: 20px;
  206. display: inline-block;
  207. width: 310px;
  208. font-weight: bold;
  209. font-family: Arial;
  210. }
  211. .one6 {
  212. font-size: 18px;
  213. font-weight: bold;
  214. font-family: Arial;
  215. }
  216. }
  217. .two {
  218. position: absolute;
  219. top: 426px;
  220. left: 115px;
  221. .two1 {
  222. font-size: 18px;
  223. display: inline-block;
  224. width: 60px;
  225. font-weight: bold;
  226. font-family: Arial;
  227. }
  228. .two2 {
  229. font-size: 20px;
  230. display: inline-block;
  231. width: 150px;
  232. font-weight: bold;
  233. font-family: Arial;
  234. }
  235. .two3 {
  236. font-size: 18px;
  237. display: inline-block;
  238. width: 70px;
  239. font-weight: bold;
  240. font-family: Arial;
  241. }
  242. font-weight: bold;
  243. font-family: Arial;
  244. .two4 {
  245. font-size: 20px;
  246. display: inline-block;
  247. width: 90px;
  248. font-weight: bold;
  249. font-family: Arial;
  250. }
  251. .two5 {
  252. font-size: 18px;
  253. display: inline-block;
  254. width: 25px;
  255. font-weight: bold;
  256. font-family: Arial;
  257. }
  258. .two6 {
  259. font-size: 20px;
  260. display: inline-block;
  261. width: 90px;
  262. font-weight: bold;
  263. font-family: Arial;
  264. }
  265. .two7 {
  266. font-size: 18px;
  267. font-weight: bold;
  268. font-family: Arial;
  269. }
  270. }
  271. .three {
  272. position: absolute;
  273. top: 500px;
  274. left: 115px;
  275. .thr1 {
  276. font-size: 18px;
  277. display: inline-block;
  278. width: 35px;
  279. font-weight: bold;
  280. font-family: Arial;
  281. }
  282. .thr2 {
  283. font-size: 20px;
  284. display: inline-block;
  285. width: 45px;
  286. font-weight: bold;
  287. font-family: Arial;
  288. }
  289. .thr3 {
  290. font-size: 18px;
  291. font-weight: bold;
  292. font-family: Arial;
  293. }
  294. }
  295. .four {
  296. position: absolute;
  297. top: 580px;
  298. left: 120px;
  299. .four1 {
  300. font-size: 18px;
  301. display: inline-block;
  302. width: 100px;
  303. font-weight: bold;
  304. font-family: Arial;
  305. }
  306. .four2 {
  307. font-size: 20px;
  308. display: inline-block;
  309. width: 430px;
  310. font-weight: bold;
  311. font-family: Arial;
  312. }
  313. .four3 {
  314. font-size: 20px;
  315. letter-spacing: 6px;
  316. font-weight: bold;
  317. font-family: Arial;
  318. }
  319. }
  320. }
  321. }
  322. </style>