|
@@ -0,0 +1,348 @@
|
|
|
+<template>
|
|
|
+ <div class="main animate__animated animate__backInRight">
|
|
|
+ <custom-search-bar v-model="searchForm" :fields="fields.filter((f) => f.filter)" @search="search" @reset="toReset">
|
|
|
+ <template #industry>
|
|
|
+ <el-option v-for="i in sectorList" :key="i.id" :label="i.title" :value="i.title"></el-option>
|
|
|
+ </template>
|
|
|
+ </custom-search-bar>
|
|
|
+ <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @view="toView" @exam="toExam" @delete="toDelete">
|
|
|
+ <template #role="{ row }">
|
|
|
+ <div class="tags">
|
|
|
+ <el-tag v-for="(item, index) in row.role" :key="index" type="primary">{{ getRole(item) }}</el-tag>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template #is_audit="{ row }">
|
|
|
+ <div class="audit" v-if="row && row.is_audit.length > 0">
|
|
|
+ <div v-for="(item, index) in row.is_audit" :key="index">{{ item }}</div>
|
|
|
+ </div>
|
|
|
+ <div v-else>已通过</div>
|
|
|
+ </template>
|
|
|
+ </custom-table>
|
|
|
+ <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" v-if="dialog.type == '1'">
|
|
|
+ <el-tabs v-model="type" type="card" @tab-change="toChang">
|
|
|
+ <el-tab-pane v-for="(item, index) in role" :key="index" :label="getRole(item)" :name="item"></el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ <user v-if="type == 'User'"></user>
|
|
|
+ <expert v-if="type == 'Expert'"></expert>
|
|
|
+ <company v-if="type == 'Company'"></company>
|
|
|
+ <incubator v-if="type == 'Incubator'"></incubator>
|
|
|
+ <competition v-if="type == 'Competition'"></competition>
|
|
|
+ <investment v-if="type == 'Investment'"></investment>
|
|
|
+ <association v-if="type == 'Association'"></association>
|
|
|
+ <school v-if="type == 'School'"></school>
|
|
|
+ <state v-if="type == 'State'"></state>
|
|
|
+ <unit v-if="type == 'Unit'"></unit>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" v-if="dialog.type == '2'">
|
|
|
+ <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave">
|
|
|
+ <template #status>
|
|
|
+ <el-option v-for="i in statusList" :key="i.id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { cloneDeep, get } from 'lodash-es'
|
|
|
+// 组件
|
|
|
+import user from './user/user.vue'
|
|
|
+import association from './user/association.vue'
|
|
|
+import school from './user/school.vue'
|
|
|
+import company from './user/company.vue'
|
|
|
+import competition from './user/competition.vue'
|
|
|
+import expert from './user/expert.vue'
|
|
|
+import incubator from './user/incubator.vue'
|
|
|
+import state from './user/state.vue'
|
|
|
+import unit from './user/unit.vue'
|
|
|
+import investment from './user/investment.vue'
|
|
|
+import { UserStore } from '@/store/api/user/user'
|
|
|
+import { RoleStore } from '@/store/api/system/role'
|
|
|
+import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+import { RegionStore } from '@/store/api/system/region'
|
|
|
+const regionStore = RegionStore()
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+const store = UserStore()
|
|
|
+const dictDataStore = DictDataStore()
|
|
|
+const roleStore = RoleStore()
|
|
|
+// 接口
|
|
|
+import { UnitStore } from '@/store/api/user/unit'
|
|
|
+const unitStore = UnitStore()
|
|
|
+import { ExpertStore } from '@/store/api/user/expert'
|
|
|
+const expertStore = ExpertStore()
|
|
|
+import { AssociationStore } from '@/store/api/user/association'
|
|
|
+const associationStore = AssociationStore()
|
|
|
+import { SchoolStore } from '@/store/api/user/school'
|
|
|
+const schoolStore = SchoolStore()
|
|
|
+import { CompanyStore } from '@/store/api/user/company'
|
|
|
+const companyStore = CompanyStore()
|
|
|
+import { CompetitionStore } from '@/store/api/user/competition'
|
|
|
+const competitionStore = CompetitionStore()
|
|
|
+import { IncubatorStore } from '@/store/api/user/incubator'
|
|
|
+const incubatorStore = IncubatorStore()
|
|
|
+import { InvestmentStore } from '@/store/api/user/investment'
|
|
|
+const investmentStore = InvestmentStore()
|
|
|
+import { StateStore } from '@/store/api/user/state'
|
|
|
+const stateStore = StateStore()
|
|
|
+import { SectorStore } from '@/store/api/system/sector'
|
|
|
+const sectorStore = SectorStore()
|
|
|
+const { t } = useI18n()
|
|
|
+const loading = ref(false)
|
|
|
+let skip = 0
|
|
|
+let limit = inject('limit')
|
|
|
+const data = ref([])
|
|
|
+const total = ref(0)
|
|
|
+const type = ref('User')
|
|
|
+const user_id = ref('')
|
|
|
+const role = ref([])
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true
|
|
|
+ await searchOther()
|
|
|
+ await search({ skip, limit })
|
|
|
+ loading.value = false
|
|
|
+})
|
|
|
+const fields = [
|
|
|
+ { label: t('pages.user.openid'), model: 'openid' },
|
|
|
+ { label: t('pages.user.account'), model: 'account', filter: true },
|
|
|
+ { label: t('pages.user.industry'), model: 'industry', filter: true, type: 'select', format: (i) => getDict(i, 'industry') },
|
|
|
+ { label: t('pages.user.nick_name'), model: 'nick_name', filter: true },
|
|
|
+ { label: t('pages.user.phone'), model: 'phone', filter: true },
|
|
|
+ { label: t('pages.user.role'), model: 'role', custom: true },
|
|
|
+ { label: t('pages.user.is_audit'), model: 'is_audit', custom: true }
|
|
|
+ // { label: t('pages.user.status'), model: 'status', format: (i) => getDict(i, 'status') }
|
|
|
+]
|
|
|
+const opera = [
|
|
|
+ { label: t('common.view'), method: 'view' },
|
|
|
+ { label: t('common.exam'), method: 'exam', type: 'warning', display: (i) => i.status === '0' },
|
|
|
+ {
|
|
|
+ label: t('common.delete'),
|
|
|
+ method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ type: 'danger'
|
|
|
+ }
|
|
|
+]
|
|
|
+const searchForm = ref({})
|
|
|
+const dialog = ref({ type: '1', show: false, title: t('pages.user.dialogTitle') })
|
|
|
+// 查询
|
|
|
+const search = async (query = { skip, limit }) => {
|
|
|
+ skip = query.skip
|
|
|
+ limit = query.limit
|
|
|
+ const info = { skip: query.skip, limit: query.limit, ...searchForm.value }
|
|
|
+ const res = await store.list(info)
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ data.value = res.data
|
|
|
+ total.value = res.total
|
|
|
+ }
|
|
|
+}
|
|
|
+// 表单验证
|
|
|
+const ruleFormRef = ref()
|
|
|
+const form = ref({})
|
|
|
+// 审核
|
|
|
+const examFormFields = [{ label: t('pages.user.status'), model: 'status', type: 'select' }]
|
|
|
+const examRules = reactive({
|
|
|
+ status: [{ required: true, message: t('common.statusMessage'), trigger: 'blur' }]
|
|
|
+})
|
|
|
+const examForm = ref({})
|
|
|
+// 字典表
|
|
|
+const statusList = ref([])
|
|
|
+const roleList = ref([])
|
|
|
+const genderList = ref([])
|
|
|
+const fieldList = ref([])
|
|
|
+const educationList = ref([])
|
|
|
+const cityList = ref([])
|
|
|
+const isUseList = ref([])
|
|
|
+const patternList = ref([])
|
|
|
+const scaleList = ref([])
|
|
|
+const IndustryList = ref([])
|
|
|
+const cardTypeList = ref([])
|
|
|
+const contributionList = ref([])
|
|
|
+const sectorList = ref([])
|
|
|
+const modeList = ref([])
|
|
|
+
|
|
|
+const searchOther = async () => {
|
|
|
+ let result
|
|
|
+ // 状态
|
|
|
+ result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
|
|
|
+ if ($checkRes(result)) statusList.value = result.data
|
|
|
+ // 性别
|
|
|
+ result = await dictDataStore.query({ code: 'gender', is_use: '0' })
|
|
|
+ if ($checkRes(result)) genderList.value = result.data
|
|
|
+ // 角色
|
|
|
+ result = await roleStore.query({ is_use: '0' })
|
|
|
+ if ($checkRes(result)) roleList.value = result.data
|
|
|
+ // 专家领域
|
|
|
+ result = await dictDataStore.query({ code: 'field', is_use: '0' })
|
|
|
+ if ($checkRes(result)) fieldList.value = result.data
|
|
|
+ // 企业类型
|
|
|
+ result = await dictDataStore.query({ code: 'companyType', is_use: '0' })
|
|
|
+ if ($checkRes(result)) patternList.value = result.data
|
|
|
+ // 企业规模
|
|
|
+ result = await dictDataStore.query({ code: 'companyScale', is_use: '0' })
|
|
|
+ if ($checkRes(result)) scaleList.value = result.data
|
|
|
+ // 企业所属行业
|
|
|
+ result = await dictDataStore.query({ code: 'companyIndustry', is_use: '0' })
|
|
|
+ if ($checkRes(result)) IndustryList.value = result.data
|
|
|
+ // 学历
|
|
|
+ result = await dictDataStore.query({ code: 'education', is_use: '0' })
|
|
|
+ if ($checkRes(result)) educationList.value = result.data
|
|
|
+ // 证件类型
|
|
|
+ result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
|
|
|
+ if ($checkRes(result)) cardTypeList.value = result.data
|
|
|
+ // 出资方式
|
|
|
+ result = await dictDataStore.query({ code: 'contribution', is_use: '0' })
|
|
|
+ if ($checkRes(result)) contributionList.value = result.data
|
|
|
+ // 是否使用
|
|
|
+ result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
|
|
|
+ if ($checkRes(result)) isUseList.value = result.data
|
|
|
+ // 城市
|
|
|
+ result = await regionStore.area({ level: 'province', code: 22 })
|
|
|
+ if ($checkRes(result)) cityList.value = result.data
|
|
|
+ // 角色
|
|
|
+ result = await roleStore.query({ is_use: '0' })
|
|
|
+ if ($checkRes(result)) roleList.value = result.data
|
|
|
+ // 行业
|
|
|
+ result = await sectorStore.query({ is_use: '0' })
|
|
|
+ if ($checkRes(result)) sectorList.value = result.data
|
|
|
+ // 盈利模式
|
|
|
+ result = await dictDataStore.query({ code: 'modeType', is_use: '0' })
|
|
|
+ if ($checkRes(result)) modeList.value = result.data
|
|
|
+}
|
|
|
+
|
|
|
+const toDelete = async (data) => {
|
|
|
+ const res = await store.del(data.id)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ }
|
|
|
+}
|
|
|
+const getRole = (data) => {
|
|
|
+ const res = roleList.value.find((f) => f.code === data)
|
|
|
+ return get(res, 'name')
|
|
|
+}
|
|
|
+const getDict = (data, model) => {
|
|
|
+ if (data) {
|
|
|
+ let res
|
|
|
+ if (model == 'status') res = statusList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'industry') {
|
|
|
+ if (Array.isArray(data)) res = { label: data.join(',') }
|
|
|
+ else res = { label: data }
|
|
|
+ }
|
|
|
+ return get(res, 'label')
|
|
|
+ }
|
|
|
+}
|
|
|
+// 查看
|
|
|
+const toView = async (data) => {
|
|
|
+ form.value = data
|
|
|
+ user_id.value = data.id
|
|
|
+ role.value = get(data, 'role')
|
|
|
+ dialog.value = { type: '1', show: true, title: t('pages.user.dialogTitle') }
|
|
|
+}
|
|
|
+// 标签改变
|
|
|
+const toChang = async (name) => {
|
|
|
+ let result
|
|
|
+ if (name == 'User') {
|
|
|
+ result = await store.fetch(user_id.value)
|
|
|
+ if ($checkRes(result)) form.value = result.data
|
|
|
+ } else {
|
|
|
+ if (name == 'Expert') {
|
|
|
+ result = await expertStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'Company') {
|
|
|
+ result = await companyStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'Unit') {
|
|
|
+ result = await unitStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'Association') {
|
|
|
+ result = await associationStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'School') {
|
|
|
+ result = await schoolStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'Competition') {
|
|
|
+ result = await competitionStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'Incubator') {
|
|
|
+ result = await incubatorStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'Investment') {
|
|
|
+ result = await investmentStore.query({ user: user_id.value })
|
|
|
+ } else if (name == 'State') {
|
|
|
+ result = await stateStore.query({ user: user_id.value })
|
|
|
+ }
|
|
|
+ if ($checkRes(result)) form.value = result.data[0] || {}
|
|
|
+ }
|
|
|
+}
|
|
|
+const onSubmit = async () => {
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ let res
|
|
|
+ if (type.value == 'User') res = await store.update(data)
|
|
|
+ else if (type.value == 'Expert') res = await expertStore.update(data)
|
|
|
+ else if (type.value == 'Company') res = await companyStore.update(data)
|
|
|
+ else if (type.value == 'Unit') res = await unitStore.update(data)
|
|
|
+ else if (type.value == 'Association') res = await associationStore.update(data)
|
|
|
+ else if (type.value == 'School') res = await schoolStore.update(data)
|
|
|
+ else if (type.value == 'Competition') res = await competitionStore.update(data)
|
|
|
+ else if (type.value == 'Incubator') res = await incubatorStore.update(data)
|
|
|
+ else if (type.value == 'Investment') res = await investmentStore.update(data)
|
|
|
+ else if (type.value == 'State') res = await stateStore.update(data)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+// 审核
|
|
|
+const toExam = (data) => {
|
|
|
+ examForm.value = data
|
|
|
+ dialog.value = { type: '2', show: true, title: t('pages.user.examDialogTitle') }
|
|
|
+}
|
|
|
+// 审核保存
|
|
|
+const toExamSave = async () => {
|
|
|
+ const data = cloneDeep(examForm.value)
|
|
|
+ let res = await store.update({ id: data.id, status: data.status })
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {}
|
|
|
+ type.value = 'User'
|
|
|
+ role.value = []
|
|
|
+ dialog.value = { show: false }
|
|
|
+}
|
|
|
+// 重置
|
|
|
+const toReset = async () => {
|
|
|
+ searchForm.value = {}
|
|
|
+ await search({ skip, limit })
|
|
|
+}
|
|
|
+// provide
|
|
|
+provide('cloneDeep', cloneDeep)
|
|
|
+provide('ruleFormRef ', ruleFormRef)
|
|
|
+provide('form', form)
|
|
|
+provide('onSubmit', onSubmit)
|
|
|
+// 字典
|
|
|
+provide('sectorList', sectorList)
|
|
|
+provide('statusList', statusList)
|
|
|
+provide('genderList', genderList)
|
|
|
+provide('fieldList', fieldList)
|
|
|
+provide('educationList', educationList)
|
|
|
+provide('cityList', cityList)
|
|
|
+provide('isUseList', isUseList)
|
|
|
+provide('patternList', patternList)
|
|
|
+provide('scaleList', scaleList)
|
|
|
+provide('IndustryList', IndustryList)
|
|
|
+provide('cardTypeList', cardTypeList)
|
|
|
+provide('contributionList', contributionList)
|
|
|
+provide('modeList', modeList)
|
|
|
+// 方法
|
|
|
+provide('getRole', getRole)
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.tags {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ grid-gap: 0.5rem;
|
|
|
+ gap: 0.5rem;
|
|
|
+}
|
|
|
+.audit {
|
|
|
+ color: red;
|
|
|
+}
|
|
|
+</style>
|