certCard.vue 11 KB

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