|
@@ -0,0 +1,151 @@
|
|
|
+<template>
|
|
|
+ <div id="index">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <el-button type="primary" @click="toBack()">返回</el-button>
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <custom-button-bar :fields="buttonFields" @add="toAdd"></custom-button-bar>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <custom-search-bar :fields="fields.filter((f) => f.isSearch)" v-model="searchForm" @search="search" @reset="toReset"></custom-search-bar>
|
|
|
+ <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @edit="toEdit" @delete="toDelete"> </custom-table>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <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 #matchPath>
|
|
|
+ <el-option v-for="i in matchPathList" :key="i.id" :label="i.name" :value="i.id"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #sign>
|
|
|
+ <el-option v-for="i in signList" :key="i.id" :label="i.name" :value="i.id"></el-option>
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import moment from 'moment'
|
|
|
+import { cloneDeep, get } from 'lodash-es'
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+const { t } = useI18n()
|
|
|
+// 接口
|
|
|
+import { ScoreStore } from '@/store/api/platform/score'
|
|
|
+import { SignStore } from '@/store/api/platform/sign'
|
|
|
+import { ProcessStore } from '@/store/api/platform/process'
|
|
|
+const store = ScoreStore()
|
|
|
+const processStore = ProcessStore()
|
|
|
+const signStore = SignStore()
|
|
|
+// 路由
|
|
|
+const route = useRoute()
|
|
|
+const data = ref([])
|
|
|
+const searchForm = ref({})
|
|
|
+const fields = [
|
|
|
+ { label: t('pages.score.matchPath'), model: 'matchPath_name', isSearch: true },
|
|
|
+ { label: t('pages.score.sign'), model: 'sign_name', isSearch: true },
|
|
|
+ { label: t('pages.score.score'), model: 'score' },
|
|
|
+ { label: t('pages.score.time'), model: 'time' }
|
|
|
+]
|
|
|
+const opera = [
|
|
|
+ { label: t('common.update'), method: 'edit' },
|
|
|
+ {
|
|
|
+ label: t('common.delete'),
|
|
|
+ method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ type: 'danger'
|
|
|
+ }
|
|
|
+]
|
|
|
+let skip = 0
|
|
|
+let limit = inject('limit')
|
|
|
+const total = ref(0)
|
|
|
+const formFields = ref([
|
|
|
+ { label: t('pages.score.matchPath'), model: 'matchPath', type: 'select' },
|
|
|
+ { label: t('pages.score.sign'), model: 'sign', type: 'select' },
|
|
|
+ { label: t('pages.score.score'), model: 'score', type: 'number' }
|
|
|
+])
|
|
|
+const rules = reactive({
|
|
|
+ sign: [{ required: true, message: t('pages.score.signMessage'), trigger: 'blur' }],
|
|
|
+ score: [{ required: true, message: t('pages.score.scoreMessage'), trigger: 'blur' }]
|
|
|
+})
|
|
|
+const dialog = ref({ type: '1', show: false, title: t('pages.score.DialogTitle') })
|
|
|
+const buttonFields = [{ label: t('common.create'), method: 'add' }]
|
|
|
+const form = ref({})
|
|
|
+// 字典表
|
|
|
+const matchPathList = ref([])
|
|
|
+const signList = ref([])
|
|
|
+// 加载中
|
|
|
+const loading = ref(false)
|
|
|
+// 请求
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true
|
|
|
+ await searchOther()
|
|
|
+ await search({ skip, limit })
|
|
|
+ loading.value = false
|
|
|
+})
|
|
|
+const searchOther = async () => {
|
|
|
+ let result
|
|
|
+ // 流程
|
|
|
+ result = await processStore.query({ match: route.query.id, is_use: '0' })
|
|
|
+ if ($checkRes(result)) matchPathList.value = result.data
|
|
|
+ // 选手
|
|
|
+ result = await signStore.query({ match: route.query.id, status: '1' })
|
|
|
+ if ($checkRes(result)) signList.value = result.data
|
|
|
+}
|
|
|
+const search = async (query = { skip, limit }) => {
|
|
|
+ skip = query.skip
|
|
|
+ limit = query.limit
|
|
|
+ const info = { skip: query.skip, limit: query.limit, ...searchForm.value, match: route.query.id }
|
|
|
+ const res = await store.list(info)
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ data.value = res.data
|
|
|
+ total.value = res.total
|
|
|
+ }
|
|
|
+}
|
|
|
+// 添加
|
|
|
+const toAdd = () => {
|
|
|
+ dialog.value = { type: '1', show: true, title: t('pages.score.addDialogTitle') }
|
|
|
+}
|
|
|
+// 修改
|
|
|
+const toEdit = (data) => {
|
|
|
+ form.value = data
|
|
|
+ dialog.value = { type: '1', show: true, title: t('pages.score.upDialogTitle') }
|
|
|
+}
|
|
|
+// 删除
|
|
|
+const toDelete = async (data) => {
|
|
|
+ const res = await store.del(data.id)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ }
|
|
|
+}
|
|
|
+const toSave = async () => {
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ const other = { time: moment().format('YYYY-MM-DD'), match: route.query.id }
|
|
|
+ let res
|
|
|
+ if (get(data, 'id')) res = await store.update({ ...data, ...other })
|
|
|
+ else res = await store.create({ ...data, ...other })
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {}
|
|
|
+ dialog.value = { show: false }
|
|
|
+}
|
|
|
+// 返回上一页
|
|
|
+const toBack = () => {
|
|
|
+ window.history.go(-1)
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.main {
|
|
|
+ .one {
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|