achievementCertificate.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!-- 成绩和证书 -->
  2. <template>
  3. <view class="achievement">
  4. <!-- 导航栏 -->
  5. <u-navbar back-icon-color="#fff" title="" title-color="#fff" :background="{ backgroundColor: '#3D5D4C' }">
  6. <view class="navbar-right" slot="right"
  7. @click="jumpPage('/pages/skillsTraining/addAchievementCertificate/addAchievementCertificate', { id })">
  8. <u-icon name="plus" color="#fff"></u-icon>
  9. <text>录入</text>
  10. </view>
  11. </u-navbar>
  12. <!-- 证书列表 -->
  13. <view class="achievement-content">
  14. <view class="achievement-content-list" v-if="certificateList.length">
  15. <view class="achievement-content-list-item" v-for="(item, index) in certificateList" :key="index"
  16. :class="index % 2 === 0 ? 'bg1' : 'bg2'"
  17. @click="viewItem(item)">
  18. <view class="title">
  19. <view>{{ item.examName }}</view>
  20. <view class="delete-btn" @click.stop="deleteItem(item)">删除</view>
  21. </view>
  22. <view class="result">
  23. 成绩 <text>{{ item.score }}分</text>(满分{{ item.fullScore }}分)
  24. </view>
  25. <view class="time">
  26. 通过时间:{{ item.passDate }}
  27. </view>
  28. <view class="time">
  29. 证书等级:{{ getCertificateGradeName(item.grade) || '无' }}
  30. </view>
  31. <view class="con">
  32. 证书名称:{{ item.certificateName }}
  33. </view>
  34. </view>
  35. </view>
  36. <view v-else>
  37. <u-empty text="暂无证书" mode="list" margin-top="300"></u-empty>
  38. </view>
  39. </view>
  40. <!-- 删除提示弹框 -->
  41. <u-modal v-model="deleteTips" content="您确认要删除该证书吗?" :show-cancel-button="true" @confirm="deleteConfirm">
  42. </u-modal>
  43. <u-toast ref="uToast" />
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. id: '',
  51. certificateList: [],
  52. deleteTips: false,
  53. curItem: '',
  54. gradeList: []
  55. }
  56. },
  57. onLoad(page) {
  58. if (page.id) {
  59. this.id = page.id;
  60. }
  61. },
  62. onShow() {
  63. this.getCertificateGrade();
  64. if (this.id) {
  65. this.getCertificateList(this.id);
  66. }
  67. },
  68. methods: {
  69. /**
  70. * 获取证书等级
  71. */
  72. getCertificateGrade() {
  73. this.$u.api.getDictdataUrl({ key:'certificate_grade' }).then(res=>{
  74. if(res.code == 200){
  75. this.gradeList = res.data.map(item => {
  76. return {
  77. ...item,
  78. value: item.text
  79. }
  80. });
  81. }
  82. });
  83. },
  84. /**
  85. * 获取证书等级名称
  86. * @param {Object} value
  87. */
  88. getCertificateGradeName(value) {
  89. let name;
  90. this.gradeList.forEach(item => {
  91. if (item.value == value) {
  92. name = item.label
  93. }
  94. })
  95. return name;
  96. },
  97. /**
  98. * 获取证书列表
  99. */
  100. getCertificateList(id) {
  101. this.$u.api.skillTraining.getCertificateListApi({
  102. id
  103. }).then(res => {
  104. if (res.code === 200) {
  105. this.certificateList = res.data;
  106. } else {
  107. this.$refs.uToast.show({
  108. title: res.msg,
  109. type: 'error'
  110. })
  111. }
  112. })
  113. },
  114. /**
  115. * 删除证书
  116. * @param {Object} item
  117. */
  118. deleteItem(item) {
  119. this.deleteTips = true;
  120. this.curItem = item;
  121. },
  122. viewItem(item) {
  123. if (item.imgUrl) {
  124. uni.previewImage({
  125. current: 0,
  126. urls: item.imgUrl.split(','),
  127. indicator: 'number'
  128. })
  129. } else {
  130. this.$refs.uToast.show({
  131. title: '该证书无相片!',
  132. type: 'info'
  133. })
  134. }
  135. },
  136. /**
  137. * 删除确认
  138. */
  139. deleteConfirm() {
  140. this.deleteTips = false
  141. this.$u.api.skillTraining.deleteCertificateApi({
  142. id: this.curItem.id
  143. }).then(res => {
  144. if (res.code === 200) {
  145. this.$refs.uToast.show({
  146. title: '删除成功!',
  147. type: 'success'
  148. })
  149. this.getCertificateList(this.id);
  150. } else {
  151. this.$refs.uToast.show({
  152. title: res.msg,
  153. type: 'error'
  154. })
  155. }
  156. })
  157. },
  158. /**
  159. * 跳转到指定页面
  160. * @param {Object} url
  161. * @param {Object} params
  162. */
  163. jumpPage(url, params) {
  164. this.$u.route({
  165. url,
  166. params
  167. });
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. @import './achievementCertificate.scss';
  174. </style>