collect.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <div class="one_left">
  7. <span>收藏分类</span>
  8. <el-select v-model="searchForm.type" placeholder="请选择" style="width: 240px">
  9. <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value" />
  10. </el-select>
  11. </div>
  12. <div class="one_right">
  13. <el-input v-model="searchForm.name" style="width: 250px" size="large" placeholder="搜索" @change="search" :suffix-icon="Search" />
  14. </div>
  15. </el-col>
  16. <el-col :span="24" class="two">
  17. <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
  18. <template #empty>
  19. <el-empty description="暂无数据" />
  20. </template>
  21. <el-table-column prop="name" align="center" label="需求名称" />
  22. <el-table-column prop="created_time" align="center" label="发布时间" width="180" />
  23. <el-table-column prop="status" align="center" label="状态" width="180">
  24. <template #default="scope">
  25. <div>{{ getDict(scope.row.status, 'status') }}</div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column align="center" label="操作" width="180">
  29. <template #default="{ row }">
  30. <el-link :underline="false" type="primary" size="mini" @click="toEdit(row)" style="margin-right: 10px">修改</el-link>
  31. <el-link :underline="false" type="danger" size="mini" @click="toDelete(row)"> 删除 </el-link>
  32. </template>
  33. </el-table-column>
  34. </el-table>
  35. </el-col>
  36. <el-col :span="24" class="thr">
  37. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  38. </el-col>
  39. </el-col>
  40. </el-row>
  41. </div>
  42. </template>
  43. <script setup>
  44. import { Search } from '@element-plus/icons-vue'
  45. import { get } from 'lodash-es'
  46. const $checkRes = inject('$checkRes')
  47. import { UserStore } from '@/store/user'
  48. const userStore = UserStore()
  49. const user = computed(() => userStore.user)
  50. // 接口
  51. import { DemandStore } from '@/store/api/platform/demand'
  52. const store = DemandStore()
  53. import { DictDataStore } from '@/store/api/system/dictData'
  54. const dictDataStore = DictDataStore()
  55. // 加载中
  56. const loading = ref(false)
  57. // 列表
  58. const list = ref([])
  59. let skip = 0
  60. let limit = inject('limit')
  61. const total = ref(0)
  62. const currentPage = ref(1)
  63. const searchForm = ref({})
  64. // 字典表
  65. const statusList = ref([])
  66. const typeList = ref([
  67. { value: '1', label: '全部' },
  68. { value: '2', label: '需求' },
  69. { value: '3', label: '成果' },
  70. { value: '4', label: '项目' },
  71. { value: '5', label: '专家' },
  72. { value: '5', label: '企业' }
  73. ])
  74. // 请求
  75. onMounted(async () => {
  76. loading.value = true
  77. await searchOther()
  78. await search()
  79. loading.value = false
  80. })
  81. const search = async (query = { skip, limit }) => {
  82. // skip = query.skip
  83. // limit = query.limit
  84. // const info = {
  85. // skip: query.skip,
  86. // limit: query.limit,
  87. // user: user.value.id,
  88. // ...searchForm.value
  89. // }
  90. // const res = await store.list(info)
  91. // if (res.errcode == '0') {
  92. // list.value = res.data
  93. // total.value = res.total
  94. // }
  95. }
  96. const searchOther = async () => {
  97. let result
  98. // 状态
  99. result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  100. if ($checkRes(result)) statusList.value = result.data
  101. }
  102. // 字典数据转换
  103. const getDict = (data, model) => {
  104. if (data) {
  105. let res
  106. if (model == 'status') res = statusList.value.find((f) => f.value == data)
  107. return get(res, 'label')
  108. }
  109. }
  110. // 分页
  111. const changePage = (page = currentPage.value) => {
  112. search({ skip: (page - 1) * limit, limit: limit })
  113. }
  114. const sizeChange = (limits) => {
  115. limit = limits
  116. currentPage.value = 1
  117. search({ skip: 0, limit: limit })
  118. }
  119. </script>
  120. <style scoped lang="scss">
  121. .main {
  122. .one {
  123. height: 50px;
  124. display: flex;
  125. justify-content: space-between;
  126. align-items: center;
  127. margin: 0 0 10px 0;
  128. .one_left {
  129. display: flex;
  130. align-items: center;
  131. span {
  132. font-size: $global-font-size-16;
  133. margin: 0 5px 0 0;
  134. color: #606266;
  135. }
  136. }
  137. }
  138. .thr {
  139. display: flex;
  140. justify-content: center;
  141. margin: 20px 0 0 0;
  142. }
  143. }
  144. </style>