|
@@ -1,10 +1,194 @@
|
|
|
<template>
|
|
|
- <div id="competition">
|
|
|
- <p>competition</p>
|
|
|
+ <div id="competition" v-loading="loading">
|
|
|
+ <custom-search-bar :fields="fields.filter((f) => f.isSearch)" v-model="searchForm" @search="search" @reset="toReset">
|
|
|
+ <template #status="{ item }">
|
|
|
+ <el-select v-model="searchForm[item.model]" clearable filterable :placeholder="$t('pages.competition.statusSelectPlaceholder')" style="width: 100%; min-width: 200px">
|
|
|
+ <el-option v-for="i in examStatusList" :key="i.id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </custom-search-bar>
|
|
|
+ <custom-button-bar :fields="buttonFields"></custom-button-bar>
|
|
|
+ <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @edit="toEdit" @exam="toExam">
|
|
|
+ <template #status="{ row }">
|
|
|
+ <el-tag v-if="row.status == '1'" type="success">{{ getDict(row.status, 'status') }}</el-tag>
|
|
|
+ <el-tag v-else-if="row.status == '0'" type="warning">{{ getDict(row.status, 'status') }}</el-tag>
|
|
|
+ <el-tag v-else-if="row.status == '-1'" type="danger">{{ getDict(row.status, 'status') }}</el-tag>
|
|
|
+ </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'">
|
|
|
+ <custom-form v-model="form" :fields="formFields" :rules="rules" @save="toSave">
|
|
|
+ <template #is_show>
|
|
|
+ <el-radio v-for="i in isUseList" :key="i.id" :label="i.value">{{ i.label }}</el-radio>
|
|
|
+ </template>
|
|
|
+ <template #mode>
|
|
|
+ <el-radio v-for="i in modeList" :key="i.id" :label="i.value">{{ i.label }}</el-radio>
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <template v-if="dialog.type == '2'">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <custom-desc v-model="form" :fields="statusFields"></custom-desc>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row style="text-align: center; padding-top: 20px" justify="center">
|
|
|
+ <el-col :span="6" style="">
|
|
|
+ <el-button type="success" @click="exam('1')">{{ $t('common.agree') }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6" style="text-align: center">
|
|
|
+ <el-button type="danger" @click="exam('-1')">{{ $t('common.refuse') }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-// 赛事管理人
|
|
|
+//投资人
|
|
|
+import { CompetitionStore } from '@/store/api/user/competition'
|
|
|
+import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+import { get, cloneDeep } from 'lodash-es'
|
|
|
+const store = CompetitionStore()
|
|
|
+const dictDataStore = DictDataStore()
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+let skip = 0
|
|
|
+const limit = inject('limit')
|
|
|
+const { t } = useI18n()
|
|
|
+// #region 列表页面设置
|
|
|
+const fields = [
|
|
|
+ { label: t('pages.competition.name'), model: 'name', isSearch: true },
|
|
|
+ { label: t('pages.competition.person'), model: 'person', isSearch: true },
|
|
|
+ { label: t('pages.competition.person_phone'), model: 'person_phone', isSearch: true },
|
|
|
+ { label: t('pages.competition.status'), model: 'status', isSearch: true, custom: true }
|
|
|
+]
|
|
|
+const buttonFields = []
|
|
|
+const opera = [
|
|
|
+ { label: t('common.update'), method: 'edit', type: 'primary' },
|
|
|
+ { label: t('common.exam'), method: 'exam', type: 'warning', display: (i) => i.status !== '1' }
|
|
|
+]
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 列表操作
|
|
|
+const toReset = async () => {
|
|
|
+ searchForm.value = {}
|
|
|
+ await search()
|
|
|
+}
|
|
|
+const toEdit = (data) => {
|
|
|
+ form.value = cloneDeep(data)
|
|
|
+ dialog.value = { type: '1', show: true, title: t('pages.competition.updateTitle') }
|
|
|
+}
|
|
|
+const toExam = (data) => {
|
|
|
+ form.value = cloneDeep(data)
|
|
|
+ dialog.value = { type: '2', show: true, title: t('pages.competition.examTitle') }
|
|
|
+}
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {}
|
|
|
+ dialog.value = { show: false }
|
|
|
+}
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 表单
|
|
|
+const formFields = ref([
|
|
|
+ { label: t('pages.competition.name'), model: 'name' },
|
|
|
+ { label: t('pages.competition.person'), model: 'person' },
|
|
|
+ { label: t('pages.competition.person_phone'), model: 'person_phone' },
|
|
|
+ { label: t('pages.competition.address'), model: 'address' },
|
|
|
+ { label: t('pages.competition.mode'), model: 'mode', type: 'radio' },
|
|
|
+ { label: t('pages.competition.is_show'), model: 'is_show', type: 'radio' },
|
|
|
+ { label: t('pages.competition.brief'), model: 'brief', type: 'textarea' }
|
|
|
+])
|
|
|
+const rules = reactive({ name: [{ required: true, message: t('pages.competition.titleMessage'), trigger: 'blur' }] })
|
|
|
+const form = ref({})
|
|
|
+const dialog = ref({ type: '1', show: false, title: t('pages.competition.addDialogTitle') })
|
|
|
+const toSave = async () => {
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ let res
|
|
|
+ if (get(data, 'id')) res = await store.update(data)
|
|
|
+ else res = await store.create(data)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+const statusFields = ref([
|
|
|
+ { label: t('pages.competition.name'), model: 'name' },
|
|
|
+ { label: t('pages.competition.person'), model: 'person' },
|
|
|
+ { label: t('pages.competition.person_phone'), model: 'person_phone' },
|
|
|
+ { label: t('pages.competition.mode'), model: 'mode', format: (i) => getDict(i, 'mode') },
|
|
|
+ { label: t('pages.competition.is_show'), model: 'is_show', format: (i) => getDict(i, 'is_show') },
|
|
|
+ { label: t('pages.competition.address'), model: 'address', span: 2 },
|
|
|
+ { label: t('pages.competition.brief'), model: 'brief', span: 3 }
|
|
|
+])
|
|
|
+const exam = async (status) => {
|
|
|
+ // 单独审核接口
|
|
|
+ const data = { id: get(form, 'value.id'), status }
|
|
|
+ const res = await store.examine(data)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+// #endregion
|
|
|
+
|
|
|
+const loading = ref(false)
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true
|
|
|
+ await searchOther()
|
|
|
+ await search({ skip, limit })
|
|
|
+ loading.value = false
|
|
|
+})
|
|
|
+// #region 字典表
|
|
|
+const examStatusList = ref([])
|
|
|
+const isUseList = ref([])
|
|
|
+const modeList = ref([])
|
|
|
+const searchOther = async () => {
|
|
|
+ let result
|
|
|
+ result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
|
|
|
+ if ($checkRes(result)) examStatusList.value = result.data
|
|
|
+ result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
|
|
|
+ if ($checkRes(result)) isUseList.value = result.data
|
|
|
+ // 盈利模式
|
|
|
+ result = await dictDataStore.query({ code: 'modeType', is_use: '0' })
|
|
|
+ if ($checkRes(result)) modeList.value = result.data
|
|
|
+}
|
|
|
+const getDict = (data, type) => {
|
|
|
+ let list
|
|
|
+ let result
|
|
|
+ switch (type) {
|
|
|
+ case 'status':
|
|
|
+ list = examStatusList.value
|
|
|
+ break
|
|
|
+ case 'is_show':
|
|
|
+ list = isUseList.value
|
|
|
+ break
|
|
|
+ case 'mode':
|
|
|
+ list = modeList.value
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if (!list) return result
|
|
|
+ const i = list.find((f) => f.value === data)
|
|
|
+ if (!i) return result
|
|
|
+ return get(i, 'label')
|
|
|
+}
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 查询数据
|
|
|
+const searchForm = ref({})
|
|
|
+const data = ref([])
|
|
|
+const total = ref(0)
|
|
|
+const search = async (query = { skip, limit }) => {
|
|
|
+ const nq = { skip: get(query, 'skip'), limit: get(query, 'limit'), ...searchForm.value }
|
|
|
+ const res = await store.query(nq)
|
|
|
+ if ($checkRes(res)) {
|
|
|
+ data.value = get(res, 'data', [])
|
|
|
+ total.value = get(res, 'total', 0)
|
|
|
+ }
|
|
|
+}
|
|
|
+// #endregion
|
|
|
</script>
|
|
|
<style scoped></style>
|