Commit 3c86a56a authored by daniel's avatar daniel

feat(markNoSelect): 自助选号处理+预约发枪保留1位小数

parent 415faf80
...@@ -154,6 +154,38 @@ public class CommonController { ...@@ -154,6 +154,38 @@ public class CommonController {
return Result.fail().setMsg("文件上传失败"); return Result.fail().setMsg("文件上传失败");
} }
@PostMapping("uploadSelectMarkNoBg")
@ApiOperation(value = "选号背景上传")
public Result<?> uploadGunRuleBg(@RequestPart @RequestParam("file") MultipartFile file,@RequestParam(value = "gCmptId") Integer gCmptId) {
try {
// 检查文件大小是否超过1MB
long maxFileSize = 5 * 1024 * 1024; // 1MB
if (file.getSize() > maxFileSize) {
return Result.fail().setMsg("上传文件大小不能超过5MB");
}
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || originalFilename.isEmpty()) {
return Result.fail().setMsg("文件名不能为空");
}
assert originalFilename != null;
// 检查文件名中是否包含点号
int lastIndex = originalFilename.lastIndexOf(".");
if (lastIndex == -1) {
// 如果没有后缀名,直接返回报错信息
return Result.fail().setMsg("上传的文件没有后缀名,请检查文件");
}
String objectName = "micro/" +gCmptId+ "_cmptId/mark_no_bg.png";
String filePath = aliOssUtil.upload(file.getBytes(), objectName);
log.info("文件上传名: {} 保存的文件名:{}", originalFilename,filePath);
return Result.success().setContent(filePath);
} catch (IOException e) {
log.error("文件上传失败:{}", e);
}
return Result.fail().setMsg("文件上传失败");
}
/** /**
* 检查文件的魔数是否与扩展名匹配 * 检查文件的魔数是否与扩展名匹配
......
...@@ -241,7 +241,8 @@ ...@@ -241,7 +241,8 @@
</n-form-item> </n-form-item>
<n-form-item label="关门时间" path="cutOffTime"> <n-form-item label="关门时间" path="cutOffTime">
<n-input-number :min="1" <n-input-number :min="1"
:max="200" v-model:value="gunRuleValue.cutOffTime" placeholder="请输入关门时间"> :precision="1"
:max="500" v-model:value="gunRuleValue.cutOffTime" placeholder="请输入关门时间">
<template #suffix> <template #suffix>
小时 小时
</template> </template>
......
...@@ -106,12 +106,12 @@ ...@@ -106,12 +106,12 @@
<!-- 顶部的搜索框 --> <!-- 顶部的搜索框 -->
<n-card :bordered="false"> <n-card :bordered="false">
<div class="w-full flex flex-row items-center gap-x-2"> <div class="w-full flex flex-row items-center gap-x-2">
<div style="min-width: 200px"> <div style="min-width: 250px">
<n-tabs type="segment" @update:value="updateTab":value="tabIndex" animated pane-style="padding:0;"> <n-tabs type="segment" @update:value="updateTab":value="tabIndex" animated pane-style="padding:0;">
<n-tab-pane v-for="item in ListEnum.data" :name="item.value" :tab="item.name"/> <n-tab-pane v-for="item in ListEnum.data" :name="item.value" :tab="item.name"/>
</n-tabs> </n-tabs>
</div> </div>
<div style="min-width: 300px"> <div style="min-width: 300px" v-if="tabIndex != 3">
<n-tabs type="segment" @update:value="updateStatus" :value="query.status" animated pane-style="padding:0;"> <n-tabs type="segment" @update:value="updateStatus" :value="query.status" animated pane-style="padding:0;">
<n-tab-pane <n-tab-pane
v-for="item in statusOptions" v-for="item in statusOptions"
...@@ -119,11 +119,11 @@ ...@@ -119,11 +119,11 @@
:tab="item.name+'('+item.total+')'"/> :tab="item.name+'('+item.total+')'"/>
</n-tabs> </n-tabs>
</div> </div>
<div class="ml-auto"> <div class="ml-auto" v-if="tabIndex != 3">
<n-input v-model:value="keyword" placeholder="请输入关键字进行搜索" :clearable="true" @change="fetchData" /> <n-input v-model:value="keyword" placeholder="请输入关键字进行搜索" :clearable="true" @change="fetchData" />
</div> </div>
</div> </div>
<div class="w-full flex flex-row items-center mt-3"> <div class="w-full flex flex-row items-center mt-3" v-if="tabIndex != 3">
<n-space> <n-space>
<n-upload <n-upload
:max="1" :max="1"
...@@ -153,9 +153,37 @@ ...@@ -153,9 +153,37 @@
</div> </div>
</n-card> </n-card>
<!-- 搜索框 --> <!-- 搜索框 -->
<n-data-table :columns="isPlayerList?playersColumns:markNoColumns" :loading="loading" :data="list" :pagination="pagination" <n-data-table v-if="tabIndex != 3" :columns="isPlayerList?playersColumns:markNoColumns" :loading="loading" :data="list" :pagination="pagination"
:bordered="false" :bordered="false"
:remote="true"/> :remote="true"/>
<n-space v-else>
<!-- 只允许上传png -->
<n-card>
<div class="flex flex-col gap-y-3">
<n-alert title="图片要求" type="warning">
建议上传350x350png (1:1)格式 2MB以内
</n-alert>
<n-upload
:max="1"
@before-upload="beforeUploadBg"
:action="uploadBgUrl"
@finish="onFileUploadBg"
v-model:file-list="bgFileList"
accept="image/png"
>
<n-button type="primary" block>
上传自助选号背景
</n-button>
</n-upload>
</div>
</n-card>
<n-card title="免责图片">
<n-image
width="300"
:src="bgImage"
/>
</n-card>
</n-space>
<n-modal <n-modal
v-model:show="showModal" v-model:show="showModal"
preset="dialog" preset="dialog"
...@@ -319,6 +347,7 @@ ...@@ -319,6 +347,7 @@
{ key: 'PLAYERS', name: '选手名单', color: 'warning', value: 1 }, { key: 'PLAYERS', name: '选手名单', color: 'warning', value: 1 },
// 增值 // 增值
{ key: 'MARK_NO', name: '参赛号列表', color: 'success', value: 2 }, { key: 'MARK_NO', name: '参赛号列表', color: 'success', value: 2 },
{ key: 'SETTING', name: '设置', color: 'success', value: 3 },
]) ])
</script> </script>
<script> <script>
...@@ -326,6 +355,7 @@ ...@@ -326,6 +355,7 @@
const { useMessage, useNotification, dateZhCN, NButton, NTag, zhCN, NSpace, NImageGroup, NImage, NText } = naive const { useMessage, useNotification, dateZhCN, NButton, NTag, zhCN, NSpace, NImageGroup, NImage, NText } = naive
// 添加全局 loading 指令 // 添加全局 loading 指令
const uploadUrl = window.location.origin + '/api-common/v1/upload?folder=' + 'gk/invoice' + '&cmptId=' + getCId() const uploadUrl = window.location.origin + '/api-common/v1/upload?folder=' + 'gk/invoice' + '&cmptId=' + getCId()
const uploadBgUrl = window.location.origin + '/api-common/v1/uploadSelectMarkNoBg' + '?gCmptId=' + getCId()
const BASE_ECC_URL = "https://ecc.geexek.com" const BASE_ECC_URL = "https://ecc.geexek.com"
// 人员列表 // 人员列表
const PLAYERS_URL = BASE_ECC_URL + '/api-pick/v1/enroll-page' const PLAYERS_URL = BASE_ECC_URL + '/api-pick/v1/enroll-page'
...@@ -478,7 +508,11 @@ ...@@ -478,7 +508,11 @@
// 状态tab // 状态tab
const updateTab = (value) => { const updateTab = (value) => {
tabIndex.value = value tabIndex.value = value
fetchData() if (value !== 3) {
fetchData()
} else {
checkCert()
}
} }
// 上传完成 // 上传完成
const uploadFinish = ({ const uploadFinish = ({
...@@ -632,6 +666,45 @@ ...@@ -632,6 +666,45 @@
window.location.href = url window.location.href = url
} }
/***---------------- 自助选号相关 end -----------------*/ /***---------------- 自助选号相关 end -----------------*/
/***---------------- 自助选号背景 start -----------------*/
const certExit = ref(false)
const bgFileList = ref([])
// 证书地址
const bgImage = "https://geexekimgoss-sxk.oss-cn-hangzhou.aliyuncs.com/micro/" + getCId() + "_cmptId/mark_no_bg.png" + "?t=" + new Date().getTime()
// 检查证书是否存在
const checkCert = () => {
// 判断图片是否存在
const img = new Image()
img.src = bgImage
img.onload = function () {
certExit.value = true
}
img.onerror = function () {
certExit.value = false
}
}
const onFileUploadBg = (file) => {
bgFileList.value = []
checkCert()
// window.location.reload()
loading.value = false
}
// 文件上传前回调
const beforeUploadBg = (data) => {
// 限制类型
if (data.file.file?.type !== 'image/png') {
message.error('只能上传png格式的图片文件,请重新上传')
return false
}
// 限制大小为1M
if (data.file.file.size > 2 * 1024 * 1024) {
message.error('文件大小不能超过1M,请重新上传')
return false
}
loading.value = true
return true
}
/***---------------- 自助选号背景 end -----------------*/
onMounted(() => { onMounted(() => {
fetchData() fetchData()
}) })
...@@ -665,6 +738,13 @@ ...@@ -665,6 +738,13 @@
onChange, onChange,
PLAYER, PLAYER,
MARK_NO, MARK_NO,
// 背景上传
uploadBgUrl,
certExit,
bgFileList,
bgImage,
onFileUploadBg,
beforeUploadBg
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment