123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <template>
- <div class="index">
- <el-row>
- <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
- <el-col :span="24" class="one">
- <div class="one_left">
- <span>收藏分类</span>
- <el-select v-model="searchForm.type" placeholder="请选择" style="width: 240px">
- <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </div>
- <div class="one_right">
- <el-input v-model="searchForm.name" style="width: 250px" size="large" placeholder="搜索" @change="search" :suffix-icon="Search" />
- </div>
- </el-col>
- <el-col :span="24" class="two">
- <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
- <template #empty>
- <el-empty description="暂无数据" />
- </template>
- <el-table-column prop="name" align="center" label="需求名称" />
- <el-table-column prop="created_time" align="center" label="发布时间" width="180" />
- <el-table-column prop="status" align="center" label="状态" width="180">
- <template #default="scope">
- <div>{{ getDict(scope.row.status, 'status') }}</div>
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作" width="180">
- <template #default="{ row }">
- <el-link :underline="false" type="primary" size="mini" @click="toEdit(row)" style="margin-right: 10px">修改</el-link>
- <el-link :underline="false" type="danger" size="mini" @click="toDelete(row)"> 删除 </el-link>
- </template>
- </el-table-column>
- </el-table>
- </el-col>
- <el-col :span="24" class="thr">
- <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script setup>
- import { Search } from '@element-plus/icons-vue'
- import { get } from 'lodash-es'
- const $checkRes = inject('$checkRes')
- import { UserStore } from '@/store/user'
- const userStore = UserStore()
- const user = computed(() => userStore.user)
- // 接口
- import { DemandStore } from '@/store/api/platform/demand'
- const store = DemandStore()
- import { DictDataStore } from '@/store/api/system/dictData'
- const dictDataStore = DictDataStore()
- // 加载中
- const loading = ref(false)
- // 列表
- const list = ref([])
- let skip = 0
- let limit = inject('limit')
- const total = ref(0)
- const currentPage = ref(1)
- const searchForm = ref({})
- // 字典表
- const statusList = ref([])
- const typeList = ref([
- { value: '1', label: '全部' },
- { value: '2', label: '需求' },
- { value: '3', label: '成果' },
- { value: '4', label: '项目' },
- { value: '5', label: '专家' },
- { value: '5', label: '企业' }
- ])
- // 请求
- onMounted(async () => {
- loading.value = true
- await searchOther()
- await search()
- loading.value = false
- })
- const search = async (query = { skip, limit }) => {
- // skip = query.skip
- // limit = query.limit
- // const info = {
- // skip: query.skip,
- // limit: query.limit,
- // user: user.value.id,
- // ...searchForm.value
- // }
- // const res = await store.list(info)
- // if (res.errcode == '0') {
- // list.value = res.data
- // total.value = res.total
- // }
- }
- const searchOther = async () => {
- let result
- // 状态
- result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
- if ($checkRes(result)) statusList.value = result.data
- }
- // 字典数据转换
- const getDict = (data, model) => {
- if (data) {
- let res
- if (model == 'status') res = statusList.value.find((f) => f.value == data)
- return get(res, 'label')
- }
- }
- // 分页
- const changePage = (page = currentPage.value) => {
- search({ skip: (page - 1) * limit, limit: limit })
- }
- const sizeChange = (limits) => {
- limit = limits
- currentPage.value = 1
- search({ skip: 0, limit: limit })
- }
- </script>
- <style scoped lang="scss">
- .main {
- .one {
- height: 50px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin: 0 0 10px 0;
- .one_left {
- display: flex;
- align-items: center;
- span {
- font-size: $global-font-size-16;
- margin: 0 5px 0 0;
- color: #606266;
- }
- }
- }
- .thr {
- display: flex;
- justify-content: center;
- margin: 20px 0 0 0;
- }
- }
- </style>
|