AchievementCertificateIndex.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <!--
  2. * @Description: 我的技能培训 => 技能培训详情 => 成绩和证书
  3. * @Author: 空白格
  4. * @Date: 2022-08-26 16:50:09
  5. * @LastEditors: gcz
  6. * @LastEditTime: 2022-08-29 16:20:04
  7. * @FilePath: \veterans_client_web\src\views\PersonalCenter\SkillTraining\SkillsTrainingDetails\AchievementCertificate\AchievementCertificateIndex.vue
  8. * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
  9. -->
  10. <template>
  11. <div class='certificate'>
  12. <BannerBreadcrumb title="成绩与证书" :breadcrumb="true" :isRouter="true"/>
  13. <section class="wrap-r u-flex u-col-top certificate-wrap">
  14. <section class="certificate-list">
  15. <div class="title">成绩与证书</div>
  16. <div class="list u-flex u-flex-wrap u-row-between" v-if="total>=1">
  17. <div class="list-item" :class="{even:(index+1)%2 == 0}" v-for="(item,index) in dataList" :key="item.id">
  18. <div class="up">
  19. <div class="examName">{{item.examName}}</div>
  20. <div class="score">{{item.score}}</div>
  21. <div class="fullScore">(满分{{item.fullScore}})</div>
  22. <div class="certificateName" v-if="item.certificateName">
  23. 获得<br />
  24. {{item.certificateName}}
  25. ({{getCertificateGradeName(item.grade)}})</div>
  26. <el-image
  27. v-if="item.imgUrl.length>0"
  28. class="images" :src="item.imgUrl.split(',')[0]"
  29. :preview-src-list="item.imgUrl.split(',')">
  30. </el-image>
  31. </div>
  32. <div class="down u-flex">
  33. <div class="passDate u-flex-1">{{item.passDate}}</div>
  34. <div class="btns u-flex-1"><span class="del" @click="delCertificate(item.id)">删除</span></div>
  35. </div>
  36. </div>
  37. </div>
  38. <el-empty v-else description="暂无数据"></el-empty>
  39. <!-- <div class="pagination" v-if="total>queryParams.pageSize">
  40. <el-pagination
  41. background
  42. layout="prev, pager, next"
  43. :page-size="queryParams.pageSize"
  44. :total="total"
  45. @current-change="currentChange"
  46. />
  47. </div> -->
  48. </section>
  49. <section class="certificate-form">
  50. <div class="title">+ 录入</div>
  51. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  52. <el-form-item label="考试名称:" prop="examName">
  53. <el-input v-model="form.examName "></el-input>
  54. </el-form-item>
  55. <el-form-item label="证书名称:" prop="certificateName">
  56. <el-input v-model="form.certificateName "></el-input>
  57. </el-form-item>
  58. <el-form-item label="成绩" prop="score">
  59. <el-input v-model="form.score "></el-input>
  60. </el-form-item>
  61. <el-form-item label="满分" prop="fullScore">
  62. <el-input v-model="form.fullScore "></el-input>
  63. </el-form-item>
  64. <el-form-item label="证书等级" prop="grade">
  65. <el-select
  66. v-model="form.grade"
  67. placeholder="请选择证书等级"
  68. >
  69. <el-option
  70. v-for="item in gradeList"
  71. :key="item.index"
  72. :label="item.label"
  73. :value="item.value"
  74. ></el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="通过日期:" prop="passDate">
  78. <div style="display: inline-block">
  79. <el-date-picker
  80. v-model="form.passDate"
  81. type="date"
  82. value-format="yyyy-MM-dd"
  83. placeholder="请选择通过日期"
  84. >
  85. </el-date-picker>
  86. </div>
  87. </el-form-item>
  88. <el-form-item label="上传证书:" prop="imgUrl">
  89. <div class="inner-wrap">
  90. <el-upload
  91. class="uploader logo-uploader"
  92. :action="upAction"
  93. accept="image/*"
  94. multiple
  95. :show-file-list="true"
  96. :on-success="fileUploadSuccess"
  97. :on-remove="fileRemove"
  98. :limit="2"
  99. list-type="picture"
  100. :file-list="fileList"
  101. >
  102. <img
  103. v-if="logoTempImg"
  104. :src="logoTempImg"
  105. class="uploader-img"
  106. />
  107. <i v-else class="el-icon-plus uploader-icon"></i>
  108. <div class="text">上传证书</div>
  109. </el-upload>
  110. </div>
  111. </el-form-item>
  112. <div class="btn" @click="submitForm">提交</div>
  113. </el-form>
  114. </section>
  115. </section>
  116. </div>
  117. </template>
  118. <script>
  119. import BannerBreadcrumb from "@/components/BannerBreadcrumb";
  120. import { getCertificateList,deleteCertificate,addCertificate,getCertificate } from "@/api/Certificate";
  121. import { getDictData } from "@/api/Dict";
  122. export default {
  123. name: '',
  124. components: {BannerBreadcrumb},
  125. data () {
  126. return {
  127. upAction:process.env.VUE_APP_FILE_UPLOAD_URL,
  128. skillTrainId:'',
  129. fileList:[],
  130. logoTempImg:'',
  131. gradeList:[],
  132. queryParams: {
  133. pageNum: 1,
  134. pageSize: 10,
  135. },
  136. imgUrlArr:[],
  137. form:{
  138. skillTrainId:'',
  139. examName:'',
  140. score:'',
  141. fullScore:'',
  142. passDate:'',
  143. certificateName:'',
  144. imgUrl:'',
  145. },
  146. rules:{
  147. examName: [
  148. { required: true, message: "请输入考试名称", trigger: "blur" },
  149. ],
  150. certificateName: [
  151. { required: true, message: "请输入证书名称", trigger: "blur" },
  152. ],
  153. score: [
  154. { required: true, message: "请输入成绩", trigger: "blur" },
  155. ],
  156. fullScore: [
  157. { required: true, message: "请输入满分", trigger: "blur" },
  158. ],
  159. passDate: [
  160. { required: true, message: "请选择通过日期", trigger: "blur" },
  161. ],
  162. grade: [
  163. { required: true, message: "请选择证书等级", trigger: "blur" },
  164. ],
  165. imgUrl: [
  166. { required: true, message: "请上传证书图片", trigger: "blur" },
  167. ],
  168. },
  169. total:0,
  170. loading:false,
  171. dataList:[],
  172. };
  173. },
  174. created(){
  175. this.form.skillTrainId = this.$route.query.id;
  176. this.getDataList();
  177. this.getCertificateGrade();
  178. },
  179. methods: {
  180. /**
  181. * 获取证书等级
  182. */
  183. getCertificateGrade() {
  184. getDictData({ key:'certificate_grade' }).then(res=>{
  185. if(res.code == 200){
  186. this.gradeList = res.data.map(item => {
  187. return {
  188. ...item,
  189. value: item.text
  190. }
  191. });
  192. }
  193. });
  194. },
  195. /**
  196. * 获取证书等级名称
  197. * @param {Object} value
  198. */
  199. getCertificateGradeName(value) {
  200. let name;
  201. this.gradeList.forEach(item => {
  202. if (item.value == value) {
  203. name = item.label
  204. }
  205. })
  206. return name;
  207. },
  208. // fileUploadSuccess(res, file) {
  209. // // console.log("file", file);
  210. // this.form.imgUrl = '';
  211. // this.imgUrlArr = [];
  212. // this.imgUrlArr.push(res.data.url,);
  213. // this.form.imgUrl = this.imgUrlArr.toString();
  214. // },
  215. fileUploadSuccess(response, file, fileList) {
  216. let that = this;
  217. this.form.imgUrl = '';
  218. this.imgUrlArr = [];
  219. for (let index = 0; index < fileList.length; index++) {
  220. const element = fileList[index].response.data;
  221. that.imgUrlArr.push(element.url);
  222. }
  223. this.form.imgUrl = this.imgUrlArr.toString();
  224. },
  225. fileRemove(file, fileList) {
  226. let that = this;
  227. this.form.imgUrl = '';
  228. this.imgUrlArr = [];
  229. for (let index = 0; index < fileList.length; index++) {
  230. const element = fileList[index].response.data;
  231. that.imgUrlArr.push(element.url);
  232. }
  233. this.form.imgUrl = this.imgUrlArr.toString();
  234. },
  235. getDataList() {
  236. this.loading = true;
  237. getCertificateList(Object.assign(this.queryParams,{skillTrainId:this.form.skillTrainId})).then((res) => {
  238. this.dataList = res.data;
  239. this.total = res.data.length;
  240. this.loading = false;
  241. });
  242. },
  243. /**
  244. * 分页切换
  245. * @date 2022-08-12
  246. * @param {any} page
  247. * @returns {any}
  248. */
  249. // currentChange(page) {
  250. // this.queryParams.pageNum = page;
  251. // this.getDataList();
  252. // },
  253. resetFields(){
  254. this.$refs['form'].resetFields();
  255. this.fileList=[];
  256. this.form.imgUrl = '';
  257. this.imgUrlArr = [];
  258. },
  259. submitForm() {
  260. this.$refs['form'].validate((valid) => {
  261. if (valid) {
  262. addCertificate(this.form).then(res=>{
  263. this.$message.success(res.msg);
  264. this.resetFields();
  265. this.getDataList();
  266. }).catch(err=>{
  267. console.log('addCertificate err',err);
  268. this.$message.error(err.msg)
  269. })
  270. } else {
  271. console.log('error submit!!');
  272. return false;
  273. }
  274. });
  275. },
  276. delCertificate(id){
  277. this.$confirm("您确认删除该证书吗?", "提示", {
  278. confirmButtonText: "确定",
  279. cancelButtonText: "取消",
  280. type: "warning",
  281. }).then(()=>{
  282. deleteCertificate({skillTrainId:id}).then(res=>{
  283. console.log('res',res);
  284. this.$message.success(res.msg);
  285. this.getDataList();
  286. }).catch(err=>{
  287. console.log('deleteCertificate err',err);
  288. this.$message.error(err.msg)
  289. })
  290. })
  291. }
  292. },
  293. }
  294. </script>
  295. <style lang='scss' scoped>
  296. .certificate{
  297. overflow: hidden;
  298. }
  299. .wrap-r{
  300. box-sizing: border-box;
  301. background: #fff;
  302. padding: 20px;
  303. width:70%;
  304. margin: 23px auto;
  305. }
  306. .title{
  307. font-size: 20px;
  308. color: #1A1A1A;
  309. font-weight: 600;
  310. margin-bottom: 24px;
  311. }
  312. .certificate-wrap{
  313. padding: 0;
  314. width: 1200px;
  315. background-color: #f4f4f4;
  316. .certificate-list{
  317. background-color: #fff;
  318. flex: 1;
  319. padding: 20px;
  320. margin-right: 20px;
  321. box-sizing: border-box;
  322. .list{
  323. &-item{
  324. width: 240px;
  325. margin-bottom: 24px;
  326. box-sizing: border-box;
  327. text-align: center;
  328. color: #fff;
  329. background: #FE5862;
  330. &.even{
  331. background: #FE9C37;
  332. }
  333. .up{
  334. position: relative;
  335. padding: 30px 20px 0;
  336. box-sizing: border-box;
  337. height: 314px;
  338. background: url(@/assets/images/certificate-bg.png) no-repeat;
  339. background-size: 200px 246px;
  340. background-position: 52px 100px;
  341. .images{
  342. position: absolute;
  343. left: 0;
  344. right: 0;
  345. bottom: 0;
  346. top: 0;
  347. opacity: 0;
  348. }
  349. .examName{
  350. font-size: 20px;
  351. height: 80px;
  352. overflow: hidden;
  353. }
  354. .score{
  355. font-size: 60px;
  356. line-height: 1;
  357. margin-bottom: 5px;
  358. }
  359. .fullScore{
  360. font-size: 14px;
  361. color: rgba(255,255,255,.4);
  362. margin-bottom: 45px;
  363. }
  364. .certificateName{
  365. font-size: 14px;
  366. }
  367. }
  368. .down{
  369. height: 44px;
  370. background: rgba(255,255,255,.4);
  371. .btns{
  372. .del{
  373. display: inline-block;
  374. padding: 0 15px;
  375. border-radius: 24px;
  376. height: 24px;
  377. line-height: 24px;
  378. text-align: center;
  379. background: rgba(255,255,255,0.70);
  380. color: #FE5862;
  381. font-size: 14px;
  382. cursor: pointer;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. .certificate-form{
  390. background-color: #fff;
  391. width: 380px;
  392. padding: 20px;
  393. box-sizing: border-box;
  394. }
  395. }
  396. .el-form{
  397. // .el-form-item{
  398. // margin-bottom: 10px;
  399. // }
  400. .btn{
  401. background: #709078;
  402. color: #fff;
  403. text-align: center;
  404. padding: 10px 0;
  405. margin-bottom: 20px;
  406. cursor: pointer;
  407. letter-spacing: 1.2px;
  408. }
  409. }
  410. .logo-uploader :deep(.el-upload){
  411. border: 1px dashed #d9d9d9;
  412. border-radius: 6px;
  413. cursor: pointer;
  414. position: relative;
  415. overflow: hidden;
  416. // float: left;
  417. & + .uploader {
  418. margin-left: 20px;
  419. }
  420. .text {
  421. position: absolute;
  422. left: 0;
  423. bottom: 0;
  424. right: 0;
  425. }
  426. .el-upload:hover {
  427. border-color: #409eff;
  428. }
  429. .uploader-icon {
  430. font-size: 28px;
  431. color: #8c939d;
  432. width: 100px;
  433. height: 100px;
  434. line-height: 100px;
  435. text-align: center;
  436. }
  437. .uploader-img {
  438. width: 100px;
  439. height: 100px;
  440. display: block;
  441. }
  442. }
  443. // .pagination {
  444. // text-align: center;
  445. // margin-top: 20px;
  446. // :deep(.el-pager .active) {
  447. // background-color: #ff3939;
  448. // }
  449. // :deep(.el-pagination.is-background
  450. // .el-pager
  451. // li:not(.disabled).active) {
  452. // background-color: #ff3939;
  453. // }
  454. // }
  455. </style>