certCard.vue 9.5 KB

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