match.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <div class="one_1">
  7. <el-radio-group size="large" v-model="searchForm.form" @change="search">
  8. <el-radio-button v-for="(item, index) in formList" :key="index" :label="item.label" :value="item.value" />
  9. </el-radio-group>
  10. </div>
  11. <div class="one_2">
  12. <div class="one_left" @click="toAdd">发布赛事</div>
  13. <div class="one_right">
  14. <el-input v-model="searchForm.name" style="width: 250px" size="large" placeholder="搜索" @change="search" :suffix-icon="Search" />
  15. </div>
  16. </div>
  17. </el-col>
  18. <el-col :span="24" class="two">
  19. <el-table :data="list" style="width: 100%" size="large" :header-cell-style="{ backgroundColor: '#edf3ff' }">
  20. <template #empty>
  21. <el-empty description="暂无数据" />
  22. </template>
  23. <el-table-column prop="name" align="center" label="赛事名称" />
  24. <el-table-column prop="start_time" align="center" label="开始时间" width="180" />
  25. <el-table-column prop="end_time" align="center" label="结束时间" width="180" />
  26. <el-table-column prop="status" align="center" label="状态" width="180">
  27. <template #default="scope">
  28. <div>{{ getDict(scope.row.status, 'status') }}</div>
  29. </template>
  30. </el-table-column>
  31. <el-table-column align="center" label="操作" width="250">
  32. <template #default="{ row }">
  33. <!-- <el-link v-if="row.form == '4'" :underline="false" type="primary" @click="toPreliminary(row)" style="margin-right: 10px">报名名单</el-link> -->
  34. <el-link v-if="row.status == '-2'" :underline="false" type="warning" @click="toExam(row)" style="margin-right: 10px">提交审核</el-link>
  35. <el-link v-if="row.match_status == '2' && row.form != '4' && row.form != '3'" :underline="false" type="primary" @click="toScore(row)" style="margin-right: 10px"> 分数 </el-link>
  36. <el-link v-if="row.form != '4'" :underline="false" type="warning" @click="toSign(row)" style="margin-right: 10px">报名</el-link>
  37. <el-link :underline="false" type="primary" @click="toEdit(row)" style="margin-right: 10px">修改</el-link>
  38. <el-link v-if="row.status != '1'" :underline="false" type="danger" style="margin-right: 10px" @click="toDelete(row)"> 删除 </el-link>
  39. <el-link :underline="false" type="primary" @click="toMatch(row)" style="margin-right: 10px">赛事状态修改</el-link>
  40. <el-link v-if="row.form == '4'" :underline="false" type="primary" @click="toExtOne(row)">赛事设置</el-link>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. </el-col>
  45. <el-col :span="24" class="thr">
  46. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  47. </el-col>
  48. </el-col>
  49. </el-row>
  50. <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
  51. <el-row>
  52. <el-col :span="24" v-if="dialog.type == '1'">
  53. <el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
  54. <el-tabs v-model="activeName" type="card">
  55. <el-tab-pane label="基本信息" name="first">
  56. <el-form-item label="封面" prop="file">
  57. <custom-upload model="file" :list="form.file" :limit="1" listType="picture-card" url="/files/web/cxyy_match/upload" @change="onUpload"></custom-upload>
  58. </el-form-item>
  59. <el-form-item label="赛事名称" prop="name">
  60. <el-input size="large" v-model="form.name" placeholder="请输入赛事名称" />
  61. </el-form-item>
  62. <el-form-item label="类别" prop="form">
  63. <el-select v-model="form.form" placeholder="请选择类别" size="large" style="width: 100%">
  64. <el-option v-for="item in formList" :key="item.value" :label="item.label" :value="item.value" />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="标签" prop="tags">
  68. <el-select size="large" v-model="form.tags" multiple filterable allow-create default-first-option :reserve-keyword="false" placeholder="请选择标签" style="width: 100%">
  69. <el-option v-for="item in tagsList" :key="item.id" :label="item.title" :value="item.title" />
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item label="类型" prop="type">
  73. <el-select v-model="form.type" placeholder="请选择类型" size="large" style="width: 100%">
  74. <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value" />
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="赛事规模" prop="scale">
  78. <el-radio-group v-model="form.scale">
  79. <el-radio v-for="item in scaleList" :key="item.value" :value="item.value" size="large">{{ item.label }}</el-radio>
  80. </el-radio-group>
  81. </el-form-item>
  82. <el-form-item label="赛事类型" prop="match_type">
  83. <el-radio-group v-model="form.match_type">
  84. <el-radio v-for="item in matchTypeList" :key="item.value" :value="item.value" size="large">{{ item.label }}</el-radio>
  85. </el-radio-group>
  86. </el-form-item>
  87. <el-form-item label="路由" prop="href" v-if="form.match_type == '1'">
  88. <el-input size="large" v-model="form.href" placeholder="请输入路由" />
  89. </el-form-item>
  90. <el-form-item label="组织单位" prop="work">
  91. <el-input size="large" v-model="form.work" placeholder="请输入组织单位" />
  92. </el-form-item>
  93. <el-form-item label="行业" prop="industry">
  94. <el-select v-model="form.industry" placeholder="请选择行业" size="large" style="width: 100%">
  95. <el-option v-for="item in industryList" :key="item.value" :label="item.label" :value="item.value" />
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item label="奖金(万元)" prop="money">
  99. <el-input size="large" v-model="form.money" placeholder="请输入奖金(万元)" />
  100. </el-form-item>
  101. <el-form-item label="有效期" prop="time">
  102. <el-date-picker v-model="form.time" type="datetimerange" start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"> </el-date-picker>
  103. </el-form-item>
  104. <el-form-item label="是否启用" prop="is_use">
  105. <el-radio-group v-model="form.is_use">
  106. <el-radio v-for="item in isUseList" :key="item.value" :value="item.value" size="large">{{ item.label }}</el-radio>
  107. </el-radio-group>
  108. </el-form-item>
  109. <el-form-item label="是否公开路演人信息" prop="is_show" v-if="form.form == '3'">
  110. <el-radio-group v-model="form.is_show">
  111. <el-radio v-for="item in isUseList" :key="item.value" :value="item.value" size="large">{{ item.label }}</el-radio>
  112. </el-radio-group>
  113. </el-form-item>
  114. <el-form-item label="视频" prop="vide">
  115. <custom-upload model="video" :list="form.video" :limit="1" url="/files/web/cxyy_match/upload" @change="onUpload"></custom-upload>
  116. </el-form-item>
  117. <el-form-item label="地址" prop="address">
  118. <el-input size="large" v-model="form.address" type="textarea" placeholder="请输入地址" />
  119. </el-form-item>
  120. <el-form-item label="备注" prop="remark">
  121. <el-input size="large" v-model="form.remark" type="textarea" placeholder="请输入备注" />
  122. </el-form-item>
  123. </el-tab-pane>
  124. <el-tab-pane label="拓展信息" name="second">
  125. <el-form-item label="" prop="file">
  126. <div class="rules">
  127. <custom-form v-model="form.rules" :fields="rulesFields" :useSave="false">
  128. <template #rules1>
  129. <WangEditor v-model="form.rules.rules1" />
  130. </template>
  131. <template #rules2>
  132. <WangEditor v-model="form.rules.rules2" />
  133. </template>
  134. <template #rules3>
  135. <WangEditor v-model="form.rules.rules3" />
  136. </template>
  137. <template #rules4>
  138. <WangEditor v-model="form.rules.rules4" />
  139. </template>
  140. <template #rules5>
  141. <WangEditor v-model="form.rules.rules5" />
  142. </template>
  143. <template #rules6>
  144. <WangEditor v-model="form.rules.rules6" />
  145. </template>
  146. <template #rules7>
  147. <WangEditor v-model="form.rules.rules7" />
  148. </template>
  149. <template #rules8>
  150. <WangEditor v-model="form.rules.rules8" />
  151. </template>
  152. <template #rules9>
  153. <WangEditor v-model="form.rules.rules9" />
  154. </template>
  155. <template #rules10>
  156. <WangEditor v-model="form.rules.rules10" />
  157. </template>
  158. <template #rules11>
  159. <WangEditor v-model="form.rules.rules11" />
  160. </template>
  161. <template #rules12>
  162. <WangEditor v-model="form.rules.rules12" />
  163. </template>
  164. </custom-form>
  165. </div>
  166. </el-form-item>
  167. <el-form-item label="简介" prop="brief">
  168. <WangEditor v-model="form.brief" />
  169. </el-form-item>
  170. </el-tab-pane>
  171. <el-tab-pane label="流程信息" name="third">
  172. <el-form-item label="" prop="process">
  173. <el-col :span="24" class="tables">
  174. <el-col :span="24" class="tables_1">
  175. <el-button type="primary" @click="addProcess()">添加</el-button>
  176. </el-col>
  177. <el-col :span="24">
  178. <el-table :data="processList" border>
  179. <el-table-column type="index" label="序号" width="80" align="center"> </el-table-column>
  180. <el-table-column prop="name" label="流程名称" align="center">
  181. <template #default="scope">
  182. <el-input v-model="scope.row.name" placeholder="请输入流程名称" />
  183. </template>
  184. </el-table-column>
  185. <el-table-column prop="order_num" label="排序" align="center">
  186. <template #default="scope">
  187. <el-input v-model="scope.row.order_num" type="number" placeholder="请输入排序" />
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="is_use" label="是否启用" align="center">
  191. <template #default="scope">
  192. <el-select v-model="scope.row.is_use" placeholder="请选择是否启用">
  193. <el-option v-for="item in isUseList" :key="item.value" :label="item.label" :value="item.value" />
  194. </el-select>
  195. </template>
  196. </el-table-column>
  197. <el-table-column label="操作" align="center" width="100">
  198. <template #default="scope">
  199. <el-button type="danger" @click="delProcess(scope.row)">删除</el-button>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. </el-col>
  204. </el-col>
  205. </el-form-item>
  206. </el-tab-pane>
  207. <el-tab-pane label="报名信息设置" name="fourth" v-if="form.form == '4'">
  208. <el-form-item label="" prop="ext_info">
  209. <el-col :span="24" class="add">
  210. <el-button type="primary" @click="addInvest()">添加</el-button>
  211. </el-col>
  212. <el-table :data="investigateList" border>
  213. <el-table-column type="index" label="序号" width="80" align="center"> </el-table-column>
  214. <el-table-column prop="problem" label="字段名称" align="center"> </el-table-column>
  215. <el-table-column label="操作" align="center" width="200">
  216. <template #default="scope">
  217. <el-button type="primary" @click="updateInvest(scope.row)">修改</el-button>
  218. <el-button size="mini" type="danger" @click="delInvest(scope.row)">删除</el-button>
  219. </template>
  220. </el-table-column>
  221. </el-table>
  222. </el-form-item>
  223. </el-tab-pane>
  224. <el-tab-pane label="分数纬度设置" name="fifth" v-if="form.form == '4'">
  225. <el-form-item label="" prop="ext_finals">
  226. <el-col :span="24" class="tables">
  227. <el-col :span="24" class="tables_1">
  228. <el-button type="primary" @click="addFinals()">添加</el-button>
  229. </el-col>
  230. <el-col :span="24">
  231. <el-table :data="finalsList" border>
  232. <el-table-column type="index" label="序号" width="80" align="center"> </el-table-column>
  233. <el-table-column prop="name" label="纬度名称" align="center">
  234. <template #default="scope">
  235. <el-input v-model="scope.row.name" placeholder="请输入纬度名称" />
  236. </template>
  237. </el-table-column>
  238. <el-table-column label="操作" align="center" width="100">
  239. <template #default="scope">
  240. <el-button type="danger" @click="delFinals(scope.row)">删除</el-button>
  241. </template>
  242. </el-table-column>
  243. </el-table>
  244. </el-col>
  245. </el-col>
  246. </el-form-item>
  247. </el-tab-pane>
  248. </el-tabs>
  249. <el-col :span="24" class="button">
  250. <el-button type="warning" size="large" @click="toDraftSave(formRef)">保存草稿</el-button>
  251. <el-button type="primary" size="large" @click="toSave(formRef)">保存并提交审核</el-button>
  252. </el-col>
  253. </el-form>
  254. </el-col>
  255. <el-col :span="24" v-if="dialog.type == '2'">
  256. <sign :matchForm="form"></sign>
  257. </el-col>
  258. <el-col :span="24" v-if="dialog.type == '3'">
  259. <custom-form v-model="form" :fields="matchFields" :rules="matchRules" @save="toMatchSave" submitText="保存" :DraftSave="false">
  260. <template #match_status>
  261. <el-option v-for="i in matchList" :key="i.id" :label="i.label" :value="i.value"></el-option>
  262. </template>
  263. </custom-form>
  264. </el-col>
  265. <el-col :span="24" v-if="dialog.type == '4'">
  266. <score :matchForm="form"></score>
  267. </el-col>
  268. <el-col :span="24" v-if="dialog.type == '5'">
  269. <preliminary :matchForm="form"></preliminary>
  270. </el-col>
  271. <el-col :span="24" v-if="dialog.type == '6'">
  272. <extOne :matchForm="form" :type="1" @toClose="toClose"></extOne>
  273. </el-col>
  274. <el-col :span="24" v-if="dialog.type == '7'">
  275. <extOne :matchForm="form" :type="2" @toClose="toClose"></extOne>
  276. </el-col>
  277. <el-col :span="24" v-if="dialog.type == '8'">
  278. <extOne :matchForm="form" :type="3" @toClose="toClose"></extOne>
  279. </el-col>
  280. <el-col :span="24" v-if="dialog.type == '9'">
  281. <extOne :matchForm="form" :type="4" @toClose="toClose"></extOne>
  282. </el-col>
  283. </el-row>
  284. </el-dialog>
  285. <el-dialog v-model="dialogVisible" title="报名信息填写" width="800" :destroy-on-close="false" @close="toInvestClose">
  286. <custom-form v-model="investigateForm" :fields="fourformFields" :rules="fourRules" @save="toInvestigateSave" submitText="保存" :DraftSave="false">
  287. <template #type>
  288. <el-option v-for="i in proTypeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
  289. </template>
  290. <template #answer>
  291. <div class="answer" v-if="investigateForm.type == '0' || investigateForm.type == '1' || investigateForm.type == '2' || investigateForm.type == '7'">
  292. <el-col :span="24" class="add">
  293. <el-button type="primary" @click="addAnswer()">添加</el-button>
  294. </el-col>
  295. <el-table :data="answerList" border>
  296. <el-table-column type="index" label="序号" width="80" align="center"> </el-table-column>
  297. <el-table-column prop="text" label="答案" align="center" width="500">
  298. <template #default="scope">
  299. <el-input v-model="scope.row.text" placeholder="请输入答案" />
  300. </template>
  301. </el-table-column>
  302. <el-table-column label="操作" align="center" width="100">
  303. <template #default="scope">
  304. <el-button type="danger" @click="delAnswer(scope.row)">删除</el-button>
  305. </template>
  306. </el-table-column>
  307. </el-table>
  308. </div>
  309. <div class="answer" v-if="investigateForm.type == '8'">
  310. <custom-upload model="file" :list="answerFile" accept="*" :limit="10" url="/files/web/cxyy_match/upload" @change="onaUpload"></custom-upload>
  311. </div>
  312. </template>
  313. <template #is_must>
  314. <el-radio v-for="i in isUseList" :key="i.id" :label="i.value">{{ i.label }}</el-radio>
  315. </template>
  316. </custom-form>
  317. </el-dialog>
  318. </div>
  319. </template>
  320. <script setup>
  321. // 组件
  322. import moment from 'moment'
  323. import sign from './parts/sign.vue'
  324. import score from './parts/score.vue'
  325. import preliminary from './parts/preliminaryMatch.vue'
  326. import extOne from './parts/extOne.vue'
  327. import { Search } from '@element-plus/icons-vue'
  328. import { cloneDeep, get } from 'lodash-es'
  329. const $checkRes = inject('$checkRes')
  330. import { UserStore } from '@/store/user'
  331. const userStore = UserStore()
  332. const user = computed(() => userStore.user)
  333. // 接口
  334. import { MatchStore } from '@/store/api/platform/match'
  335. import { ProcessStore } from '@/store/api/platform/process'
  336. import { DictDataStore } from '@/store/api/system/dictData'
  337. import { TagsStore } from '@/store/api/system/tags'
  338. const store = MatchStore()
  339. const dictDataStore = DictDataStore()
  340. const tagsStore = TagsStore()
  341. const processStore = ProcessStore()
  342. // 加载中
  343. const loading = ref(false)
  344. const match_id = ref('')
  345. const searchForm = ref({})
  346. // 列表
  347. const list = ref([])
  348. let skip = 0
  349. let limit = inject('limit')
  350. const total = ref(0)
  351. const currentPage = ref(1)
  352. // 字典表
  353. const isUseList = ref([])
  354. const statusList = ref([])
  355. const typeList = ref([])
  356. const matchList = ref([])
  357. const formList = ref([])
  358. const tagsList = ref([])
  359. const industryList = ref([])
  360. const matchTypeList = ref([])
  361. const scaleList = ref([])
  362. // 流程列表
  363. const processList = ref([])
  364. // 表单
  365. const formRef = ref()
  366. const form = ref({ video: [], time: [], rules: {} })
  367. const dialog = ref({ type: '1', show: false, title: '发布赛事' })
  368. const activeName = ref('first')
  369. // 分数纬度列表
  370. const finalsList = ref([])
  371. const matchFields = ref([{ label: '赛事状态', model: 'match_status', type: 'select' }])
  372. const matchRules = reactive({ match_status: [{ required: true, message: '请选择赛事状态', trigger: 'blur' }] })
  373. const rules = reactive({
  374. name: [{ required: true, message: '请输入赛事名称', trigger: 'blur' }],
  375. form: [{ required: true, message: '请选择类别', trigger: 'blur' }],
  376. scale: [{ required: true, message: '请选择赛事规模', trigger: 'blur' }],
  377. match_type: [{ required: true, message: '请选择赛事类型', trigger: 'blur' }],
  378. work: [{ required: true, message: '请输入组织单位', trigger: 'blur' }]
  379. })
  380. // 赛事规则
  381. const rulesFields = ref([
  382. { label: '大赛背景', model: 'rules1', custom: true },
  383. { label: '大赛主题和目标', model: 'rules2', custom: true },
  384. { label: '大赛基本情况介绍', model: 'rules3', custom: true },
  385. { label: '赛题任务', model: 'rules4', custom: true },
  386. { label: '赛程安排', model: 'rules5', custom: true },
  387. { label: '赛制阶段', model: 'rules6', custom: true },
  388. { label: '参赛资格', model: 'rules7', custom: true },
  389. { label: '参赛报名', model: 'rules8', custom: true },
  390. { label: '奖项设置与奖励办法', model: 'rules9', custom: true },
  391. { label: '组织单位', model: 'rules10', custom: true },
  392. { label: '赛事联络', model: 'rules11', custom: true },
  393. { label: '赛事交流', model: 'rules12', custom: true }
  394. ])
  395. // 调查问卷
  396. const investigateList = ref([])
  397. const investigateForm = ref({})
  398. const fourformFields = ref([
  399. { label: '字段名称', model: 'problem' },
  400. { label: '类型', model: 'type', type: 'select' },
  401. {
  402. label: '答案',
  403. model: 'answer',
  404. custom: true,
  405. display: () => investigateForm.value.type == '0' || investigateForm.value.type == '1' || investigateForm.value.type == '2' || investigateForm.value.type == '7' || investigateForm.value.type == '8'
  406. },
  407. { label: '是否必填', model: 'is_must', type: 'radio', display: () => investigateForm.value.type != '7' },
  408. { label: '备注', model: 'remark', type: 'textarea' }
  409. ])
  410. const fourRules = reactive({
  411. problem: [{ required: true, message: '请输入字段名称', trigger: 'blur' }]
  412. })
  413. const dialogVisible = ref(false)
  414. const proTypeList = ref([
  415. { value: '0', label: '单选' },
  416. { value: '1', label: '多选' },
  417. { value: '2', label: '下拉' },
  418. { value: '3', label: '数值类型' },
  419. { value: '4', label: '单行文本' },
  420. { value: '5', label: '多行文本' },
  421. { value: '6', label: '图片/文件' },
  422. { value: '7', label: '数组' },
  423. { value: '8', label: '附件模板' }
  424. ])
  425. // 答案
  426. const answerList = ref([])
  427. const answerFile = ref([])
  428. // 请求
  429. onMounted(async () => {
  430. loading.value = true
  431. await searchOther()
  432. await search()
  433. loading.value = false
  434. })
  435. const search = async (query = { skip, limit }) => {
  436. skip = query.skip
  437. limit = query.limit
  438. const info = {
  439. skip: query.skip,
  440. limit: query.limit,
  441. user: user.value.id,
  442. ...searchForm.value
  443. }
  444. const res = await store.query(info)
  445. if (res.errcode == '0') {
  446. list.value = res.data
  447. total.value = res.total
  448. }
  449. }
  450. const searchOther = async () => {
  451. let result
  452. // 是否使用
  453. result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
  454. if ($checkRes(result)) isUseList.value = result.data
  455. // 类型
  456. result = await dictDataStore.query({ code: 'matchType', is_use: '0' })
  457. if ($checkRes(result)) typeList.value = result.data
  458. // 赛事类型
  459. result = await dictDataStore.query({ code: 'activeType', is_use: '0' })
  460. if ($checkRes(result)) matchTypeList.value = result.data
  461. // 类别
  462. result = await dictDataStore.query({ code: 'matchForm', is_use: '0' })
  463. if ($checkRes(result)) formList.value = result.data
  464. // 状态
  465. result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
  466. if ($checkRes(result)) statusList.value = result.data
  467. // 赛事状态
  468. result = await dictDataStore.query({ code: 'matchStatus', is_use: '0' })
  469. if ($checkRes(result)) matchList.value = result.data
  470. // 赛事规模
  471. result = await dictDataStore.query({ code: 'matchScale', is_use: '0' })
  472. if ($checkRes(result)) scaleList.value = result.data
  473. // 标签
  474. result = await tagsStore.query({ is_use: '0' })
  475. if ($checkRes(result)) tagsList.value = result.data
  476. // 行业
  477. result = await dictDataStore.query({ code: 'matchIndustry', is_use: '0' })
  478. if ($checkRes(result)) industryList.value = result.data
  479. }
  480. const searchProcess = async () => {
  481. const info = { match: form.value.id }
  482. const res = await processStore.query(info)
  483. if (res.errcode == '0') processList.value = res.data
  484. }
  485. // 字典数据转换
  486. const getDict = (data, model) => {
  487. if (data) {
  488. let res
  489. if (model == 'status') res = statusList.value.find((f) => f.value == data)
  490. return get(res, 'label')
  491. }
  492. }
  493. // 添加
  494. const toAdd = () => {
  495. dialog.value = { type: '1', show: true, title: '发布赛事' }
  496. }
  497. // 修改
  498. const toEdit = async (data) => {
  499. let res = await store.fetch(data.id)
  500. if (res.errcode == '0') {
  501. res.data.time = [data.start_time, data.end_time]
  502. form.value = res.data
  503. if (res.data.ext_info && res.data.ext_info.length > 0) investigateList.value = res.data.ext_info
  504. if (res.data.ext_finals && res.data.ext_finals.length > 0) finalsList.value = res.data.ext_finals
  505. await searchProcess()
  506. dialog.value = { type: '1', show: true, title: '修改赛事' }
  507. }
  508. }
  509. // 报名
  510. const toSign = (data) => {
  511. form.value = data
  512. dialog.value = { type: '2', show: true, title: '报名管理' }
  513. }
  514. // 修改赛事状态
  515. const toMatch = (data) => {
  516. form.value = data
  517. dialog.value = { type: '3', show: true, title: '赛事状态' }
  518. }
  519. // 分数管理
  520. const toScore = (data) => {
  521. form.value = data
  522. dialog.value = { type: '4', show: true, title: '分数管理' }
  523. }
  524. // 查看初审信息
  525. const toPreliminary = (data) => {
  526. form.value = data
  527. dialog.value = { type: '5', show: true, title: '报名信息' }
  528. }
  529. // 赛事设置
  530. const toExtOne = (data) => {
  531. form.value = data
  532. window.open(`/cxyyMatch/home/?id=${data.id || data._id}`)
  533. }
  534. // 删除
  535. const toDelete = (data) => {
  536. ElMessageBox.confirm(`您确认删除${data.name}该数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
  537. .then(async () => {
  538. const res = await store.del(data.id)
  539. if ($checkRes(res, true)) {
  540. search({ skip, limit })
  541. }
  542. })
  543. .catch(() => {})
  544. }
  545. const toSave = async (formEl) => {
  546. if (!formEl) return
  547. await formEl.validate(async (valid) => {
  548. if (valid) {
  549. const data = cloneDeep(form.value)
  550. const other = { status: '0', user: user.value.id }
  551. if (data.time && data.time.length > 1) {
  552. data.start_time = data.time[0]
  553. data.end_time = data.time[1]
  554. }
  555. delete data.time
  556. if (investigateList.value && investigateList.value.length > 0) data.ext_info = investigateList.value
  557. if (finalsList.value && finalsList.value.length > 0) data.ext_finals = finalsList.value
  558. let res
  559. if (get(data, 'id')) res = await store.update({ ...data, ...other })
  560. else res = await store.create({ ...data, ...other })
  561. if (res.errcode == 0) {
  562. ElMessageBox.alert('赛事发布成功', '赛事发布', {
  563. confirmButtonText: '确定',
  564. callback: async () => {
  565. if (res.data && res.data.id) match_id.value = res.data.id
  566. await toProcessSave()
  567. await toClose()
  568. }
  569. })
  570. }
  571. } else {
  572. ElMessage({
  573. message: '有相关必填项没有填写',
  574. type: 'warning'
  575. })
  576. }
  577. })
  578. }
  579. const toDraftSave = async (formEl) => {
  580. if (!formEl) return
  581. await formEl.validate(async (valid) => {
  582. if (valid) {
  583. const data = cloneDeep(form.value)
  584. const other = { status: '-2', user: user.value.id }
  585. if (data.time && data.time.length > 1) {
  586. data.start_time = data.time[0]
  587. data.end_time = data.time[1]
  588. }
  589. delete data.time
  590. if (investigateList.value && investigateList.value.length > 0) data.ext_info = investigateList.value
  591. if (finalsList.value && finalsList.value.length > 0) data.ext_finals = finalsList.value
  592. let res
  593. if (get(data, 'id')) res = await store.update({ ...data, ...other })
  594. else res = await store.create({ ...data, ...other })
  595. if (res.errcode == 0) {
  596. ElMessageBox.alert('赛事发布成功', '赛事发布', {
  597. confirmButtonText: '确定',
  598. callback: async () => {
  599. if (res.data && res.data.id) match_id.value = res.data.id
  600. await toProcessSave()
  601. await toClose()
  602. }
  603. })
  604. }
  605. } else {
  606. ElMessage({
  607. message: '有相关必填项没有填写',
  608. type: 'warning'
  609. })
  610. }
  611. })
  612. }
  613. // 审核保存
  614. const toExam = async (row) => {
  615. ElMessageBox.confirm(`您确认保存并提交审核该数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
  616. .then(async () => {
  617. const data = cloneDeep(row)
  618. let res = await store.update({ id: data.id, status: '0', user: user.value.id })
  619. if ($checkRes(res, true)) {
  620. toClose()
  621. }
  622. })
  623. .catch(() => {})
  624. }
  625. // 修改赛事状态
  626. const toMatchSave = async (row) => {
  627. const data = cloneDeep(row)
  628. console.log(data)
  629. if (data.form == '4' && data.match_status == '2') {
  630. const res = await store.step1({ match_id: data.id })
  631. if ($checkRes(res, true)) {
  632. toClose()
  633. }
  634. } else {
  635. const res = await store.update({ id: data.id, match_status: data.match_status })
  636. if ($checkRes(res, true)) {
  637. toClose()
  638. }
  639. }
  640. }
  641. const toClose = async () => {
  642. form.value = { time: [], video: [], rules: {} }
  643. dialog.value = { show: false }
  644. investigateList.value = []
  645. finalsList.value = []
  646. processList.value = []
  647. activeName.value = 'first'
  648. await search({ skip, limit })
  649. }
  650. // 上传图片
  651. const onUpload = (e) => {
  652. const { model, value } = e
  653. form.value[model] = value
  654. }
  655. // 流程添加
  656. const toProcessSave = async () => {
  657. for (const val of processList.value) {
  658. const data = cloneDeep(val)
  659. delete data.sid
  660. if (!data.match) data.match = match_id.value
  661. if (get(data, 'id')) await processStore.update(data)
  662. else await processStore.create(data)
  663. }
  664. }
  665. // 流程添加
  666. const addProcess = () => {
  667. let list = processList.value || []
  668. list.push({ sid: moment().valueOf(), name: '', time: '', is_use: '', match: form.value.id })
  669. processList.value = list
  670. }
  671. // 流程删除
  672. const delProcess = async (e) => {
  673. if (e.sid) {
  674. let list = processList.value.filter((i) => i.sid != e.sid)
  675. processList.value = list
  676. } else {
  677. let list = processList.value.filter((i) => i.id != e.id)
  678. processList.value = list
  679. }
  680. if (e.id) await processStore.del(e.id)
  681. }
  682. // 分页
  683. const changePage = (page = currentPage.value) => {
  684. search({ skip: (page - 1) * limit, limit: limit })
  685. }
  686. const sizeChange = (limits) => {
  687. limit = limits
  688. currentPage.value = 1
  689. search({ skip: 0, limit: limit })
  690. }
  691. // 调查问卷填写
  692. const addInvest = () => {
  693. dialogVisible.value = true
  694. investigateForm.value = { sid: moment().valueOf(), problem: '', type: '', is_must: '', reply: '', answer: '', remark: '' }
  695. }
  696. // 调查问卷修改
  697. const updateInvest = (e) => {
  698. dialogVisible.value = true
  699. if (e.answer && e.answer.length > 0) {
  700. if (e.type == '8') answerFile.value = e.answer
  701. else answerList.value = e.answer
  702. }
  703. investigateForm.value = e
  704. }
  705. // 删除调查问卷
  706. const delInvest = async (e) => {
  707. let list = investigateList.value.filter((i) => i.sid != e.sid)
  708. investigateList.value = list
  709. }
  710. // 保存
  711. const toInvestigateSave = (data) => {
  712. if (answerList.value && answerList.value.length > 0) data.answer = answerList.value
  713. else data.answer = answerFile.value
  714. let investigate = investigateList.value.find((i) => i.sid == data.sid)
  715. if (investigate) {
  716. investigateList.value = investigateList.value.map((i) => {
  717. if (i.sid == data.sid) return data
  718. else return i
  719. })
  720. } else investigateList.value.push(data)
  721. toInvestClose()
  722. }
  723. const toInvestClose = () => {
  724. investigateForm.value = {}
  725. answerList.value = []
  726. dialogVisible.value = false
  727. }
  728. // 答案添加
  729. const addAnswer = () => {
  730. let list = answerList.value || []
  731. list.push({ sid: moment().valueOf(), text: '' })
  732. answerList.value = list
  733. }
  734. // 答案删除
  735. const delAnswer = async (e) => {
  736. let list = answerList.value.filter((i) => i.sid != e.sid)
  737. answerList.value = list
  738. }
  739. // 维度添加
  740. const addFinals = () => {
  741. let list = finalsList.value || []
  742. list.push({ sid: moment().valueOf(), name: '' })
  743. finalsList.value = list
  744. }
  745. // 维度删除
  746. const delFinals = async (e) => {
  747. let list = finalsList.value.filter((i) => i.sid != e.sid)
  748. finalsList.value = list
  749. }
  750. // 上传图片
  751. const onaUpload = (e) => {
  752. const { value } = e
  753. answerFile.value = value
  754. }
  755. </script>
  756. <style scoped lang="scss">
  757. .main {
  758. .one {
  759. margin: 0 0 10px 0;
  760. .one_1 {
  761. height: 50px;
  762. }
  763. .one_2 {
  764. height: 50px;
  765. display: flex;
  766. justify-content: space-between;
  767. align-items: center;
  768. .one_left {
  769. background: #1875df;
  770. padding: 0 10px;
  771. height: 30px;
  772. color: #fff;
  773. line-height: 30px;
  774. text-align: center;
  775. font-size: 16px;
  776. cursor: default;
  777. }
  778. }
  779. }
  780. .thr {
  781. display: flex;
  782. justify-content: center;
  783. margin: 20px 0 0 0;
  784. }
  785. }
  786. .add {
  787. margin: 0 0 10px 0;
  788. }
  789. .button {
  790. text-align: center;
  791. margin: 10px 0 0 0;
  792. }
  793. .tables {
  794. .tables_1 {
  795. margin: 0 0 10px 0;
  796. }
  797. }
  798. </style>