ai-list-item.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="bg-white p-30 mx-card" @click="goDetail">
  3. <view class="fx-row fx-bet-cen gap-20">
  4. <text class="flex-1 text-main text-xl">{{ item.name }}</text>
  5. <text class="text-content">{{ createDate }}</text>
  6. <view class="fx-row fx-cen-cen gap-10">
  7. <uv-icon name="trash" size="24" color="primary" stop @click="handleDelete"/>
  8. <uv-icon name="arrow-right" size="20" color="primary"/>
  9. </view>
  10. </view>
  11. <view class="mt-10 text-sm text-content fx-row items-center gap-20">
  12. <text v-if="false">分数显示待定</text>
  13. <text>{{ examType }}</text>
  14. <text v-if="majorCategory">{{ majorCategory.name }}</text>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import MxConst from "@/common/MxConst";
  20. import _ from 'lodash';
  21. import {removeVoluntary} from "@/api/webApi/ie-voluntary";
  22. import {findTreeNode} from "@/utils/tree-helper";
  23. import {useInjectMajorTreeService} from "@/pages/ie/hooks/useMajorTreeInjection";
  24. import {useTransfer} from "@/hooks/useTransfer";
  25. import {confirmAsync} from "@/utils/uni-helper";
  26. import {toast} from "@/uni_modules/uv-ui-tools/libs/function";
  27. export default {
  28. name: "ai-list-item",
  29. emits: ['delete'],
  30. props: {
  31. item: {
  32. type: Object,
  33. default: () => ({})
  34. }
  35. },
  36. data() {
  37. return {
  38. type: MxConst.enum.ai.voluntaryType.ai
  39. }
  40. },
  41. setup() {
  42. const {majorTree} = useInjectMajorTreeService()
  43. const {transferTo} = useTransfer()
  44. return {
  45. majorTree,
  46. transferTo
  47. }
  48. },
  49. computed: {
  50. majorCategory() {
  51. if (!this.majorTree) return {}
  52. return findTreeNode(this.majorTree, n => n.code == this.item.request.majorCategory) || {}
  53. },
  54. examType() {
  55. return this.item.userSnapshot?.examType
  56. },
  57. createDate() {
  58. return _.first(this.item.createTime?.split(' '))
  59. }
  60. },
  61. methods: {
  62. async handleDelete() {
  63. const {id} = this.item
  64. if (!id) return
  65. await confirmAsync(`确认删除此条志愿记录么?\r\n删除后不可恢复!`)
  66. await removeVoluntary(id)
  67. toast('删除成功')
  68. this.$emit('delete', this.item)
  69. },
  70. goDetail() {
  71. const path = '/pages/ie/entry-ai-detail/entry-ai-detail'
  72. this.transferTo(path, this.item, null, true)
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped>
  78. </style>