Commit c7f83cba authored by daniel's avatar daniel

fix(gunRule): 发枪预约完善

parent 1ca11816
...@@ -170,14 +170,17 @@ ...@@ -170,14 +170,17 @@
size="small" size="small"
> >
<n-form-item label="组别名称" path="roadName"> <n-form-item label="组别名称" path="roadName">
<n-input v-model:value="gunRuleValue.roadName" placeholder="请输入组别名称" /> <div class="flex flex-col w-full">
<n-input v-model:value="gunRuleValue.roadName" placeholder="请输入组别名称" />
<span class="text-red">组别名仅支持数字和字母</span>
</div>
</n-form-item> </n-form-item>
<n-form-item label="出发日期" path="startTime"> <n-form-item label="出发日期" path="startTime">
<n-date-picker value-format="yyyy-MM-dd" date-format="yyyy-MM-dd" :value="gunRuleValue.startTime" type="date" clearable @update:formatted-value="updateFormattedValue" /> <n-date-picker value-format="yyyy-MM-dd HH:mm:ss" date-format="yyyy-MM-dd HH:mm:ss" :value="gunRuleValue.startTime" type="datetime" clearable @update:formatted-value="updateFormattedValue" />
</n-form-item> </n-form-item>
<n-form-item label="关门时间" path="closeTime"> <n-form-item label="关门时间" path="cutOffTime">
<n-input-number :min="1" <n-input-number :min="1"
:max="200" v-model:value="gunRuleValue.closeTime" placeholder="请输入关门时间"> :max="200" v-model:value="gunRuleValue.cutOffTime" placeholder="请输入关门时间">
<template #suffix> <template #suffix>
小时 小时
</template> </template>
...@@ -189,22 +192,29 @@ ...@@ -189,22 +192,29 @@
<template #header-extra> <template #header-extra>
<n-button type='primary' :loading="loading" @click="addWave">新增</n-button> <n-button type='primary' :loading="loading" @click="addWave">新增</n-button>
</template> </template>
<n-data-table size="small" :columns="waveColumns" :loading="loading" :data="gunRuleValue.waves" :pagination="false" <n-data-table size="small" :columns="waveColumns" :loading="loading" :data="gunRuleValue.details" :pagination="false"
:bordered="false"/> :bordered="false"/>
</n-card> </n-card>
<n-card title="人员列表" :bordered="false" v-if="activeMenu!=menuOptions[0].value"> <n-card title="人员列表" :bordered="false" v-if="activeMenu!=menuOptions[0].value">
<template #header-extra> <template #header-extra>
<n-space> <n-space>
<n-button type="error"> <!-- <n-button type="error">
清空名单 清空名单
</n-button> -->
<n-button type="primary" @click="downloadImportList">
下载导入名单模板
</n-button> </n-button>
<n-button type="primary"> <n-upload
导入名单 v-if="gunRuleValue?.id"
</n-button> @change="onFileUpload"
</n-space> v-model:file-list="fileList"
>
<n-button>上传文件</n-button>
</n-upload>
</n-space>
</template> </template>
<n-data-table :columns="columns" :loading="loading" :data="players" :pagination="pagination" <n-data-table :columns="columns" :loading="loading" :data="players" :pagination="pagination"
:bordered="false" @update:page="handlePageChange"/> :bordered="false" @update:page="handlePageChange" @update:page-size="onUpdatePageSize" />
</n-card> </n-card>
<div class="flex flex-row items-center gap-x-2 w-full" v-if="activeMenu==menuOptions[0].value"> <div class="flex flex-row items-center gap-x-2 w-full" v-if="activeMenu==menuOptions[0].value">
<div class="flex-1"> <div class="flex-1">
...@@ -397,14 +407,17 @@ ...@@ -397,14 +407,17 @@
<script> <script>
const { createApp, defineComponent, onBeforeUnmount, reactive, ref, onMounted, h } = Vue; const { createApp, defineComponent, onBeforeUnmount, reactive, ref, onMounted, h } = Vue;
const { useMessage, useNotification, dateZhCN, NButton, NTag, zhCN, NSpace, NImageGroup, NImage, NText, NInputNumber, NSelect, NInput, NDatePicker } = naive const { useMessage, useNotification, dateZhCN, NButton, NTag, zhCN, NSpace, NImageGroup, NImage, NText, NInputNumber, NSelect, NInput, NDatePicker } = naive
const uploadUrl = window.location.origin + '/api-common/v1/upload?folder=gk/markNoRule' + '&cmptId=' + getCId() const uploadUrl = window.location.origin + '/api-common/v1/upload?folder=gk/gunApply' + '&cmptId=' + getCId()
const downloadWeChatImgUrl = window.location.origin + '/api-common/v1/download-wechat-image' const downloadWeChatImgUrl = window.location.origin + '/api-common/v1/download-wechat-image'
// 添加全局 loading 指令 // 添加全局 loading 指令
const ECC_BASE_URL = "https://ecc.geexek.com" const ECC_BASE_URL = "https://ecc.geexek.com"
const SAVE_OR_UPDATE = ECC_BASE_URL + "/api-pick/v1/save-or-update" const SAVE_OR_UPDATE = ECC_BASE_URL + "/api-pick/v1/save-or-update-wave"
const RULE_LIST = ECC_BASE_URL + "/api-pick/v1/rule-list?" const RULE_LIST = ECC_BASE_URL + "/api-pick/v1/wave-reserve-list?"
const ENROLL_PAGE = ECC_BASE_URL + "/api-pick/v1/enroll-page?"
const DELETE_RULE = ECC_BASE_URL + "/api-pick/v1/delete-rule?" const DELETE_RULE = ECC_BASE_URL + "/api-pick/v1/delete-rule?"
const IMPORT_MARK_ENROLL = ECC_BASE_URL + "/api-pick/v1/import-mark-enroll"
// 下载导入名单
const DOWNLOAD_IMPORT_LIST = "https://geexekimgoss-sxk.oss-cn-hangzhou.aliyuncs.com/gk/common/markNoSelect/%E9%80%89%E5%8F%B7%E5%90%8D%E5%8D%95%E8%A1%A8%E6%A8%A1%E7%89%88v1.xlsx"
// 发枪的map // 发枪的map
const NO_MAP = { const NO_MAP = {
...@@ -477,8 +490,11 @@ ...@@ -477,8 +490,11 @@
/***---------------- 人员列表 start -----------------*/ /***---------------- 人员列表 start -----------------*/
const keyword = ref('') const keyword = ref('')
const fileList = ref([])
// 分页 // 分页
const pagination = ref({ pageSize: 20, page: 1 }) const pagination = ref({
pageSize: 10, page: 1, itemCount: 0, showQuickJumper: true, showSizePicker: true, pageSizes: [10, 50, 200, 500],
})
// seg // seg
const menuOptions = [ const menuOptions = [
{ name: '发枪规则', value: 'gunRule' }, { name: '发枪规则', value: 'gunRule' },
...@@ -486,54 +502,34 @@ ...@@ -486,54 +502,34 @@
] ]
// 人员列表 // 人员列表
const players = ref([ const players = ref([
{
name: '张三',
markNo: '13888888888',
gunNo: '第一枪',
roadName: 'A组',
},
{
name: '李四',
markNo: '13999999999',
gunNo: '第二枪',
roadName: 'B组',
},
{
name: '王五',
markNo: '14000000000',
gunNo: '第三枪',
roadName: 'C组',
},
{
name: '赵六',
markNo: '14111111111',
gunNo: '第四枪',
roadName: 'D组',
},
{
name: '周七',
markNo: '14222222222',
gunNo: '第五枪',
roadName: 'E组',
},
]) ])
const columns = [ const columns = [
{ {
title: '姓名', title: '姓名',
key: 'name', key: 'name',
}, },
{
title: '性别',
key: 'genderName',
},
{ {
title: '参赛号', title: '参赛号',
key: 'markNo', key: 'markNo',
}, },
{ {
title: '枪次', title: '枪次',
key: 'gunNo', key: 'waveName',
}, },
{ {
title: '组别', title: '组别',
key: 'roadName', key: 'roadName',
}, },
{
title: '更新时间',
key: 'updateTime',
align: 'center',
},
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
...@@ -565,20 +561,90 @@ ...@@ -565,20 +561,90 @@
// 分页切换 // 分页切换
const handlePageChange = (page) => { const handlePageChange = (page) => {
pagination.value.page = page pagination.value.page = page
getFeedBacks() getPlayers()
} }
// 分页大小切换
const onUpdatePageSize = (pageSize) => {
pagination.value.pageSize = pageSize
getPlayers()
}
// 获取分枪组别列表
const getPlayers = async () => {
if (!gunRuleValue.value.roadName) {
message.error('请先选择分枪组别')
players.value = []
return
}
const params = {
cmptId: getCId(),
roadName: gunRuleValue.value.roadName,
current: pagination.value.page,
size: pagination.value.pageSize,
}
loading.value = true;
// 发起请求
const [err, res] = await to(fetch(ENROLL_PAGE, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json()))
loading.value = false
if (err) {
message.error(err.message)
}
if (res.code === 200) {
players.value = res.data.records
pagination.value.itemCount = res.data.total
} else {
message.error(res.msg)
}
}
// 文件上传
const onFileUpload = async (e) => {
const gtCmptId = getCId()
const formData = new FormData();
formData.append('file', e.file.file);
formData.append('cmptId', gtCmptId);
loading.value = true
const messageReactive = message.loading('文件导入中', {
duration: 0
})
// 通过fetch发起请求
const [err, data] = await to(fetch(IMPORT_MARK_ENROLL, {
method: "POST",
body: formData
}).then(res => res.json()))
loading.value = false
messageReactive.destroy()
if (data.code === 200) {
message.success('操作成功')
fileList.value = []
getPlayers()
} else {
message.error(data.message)
}
}
// 下载导入名单
const downloadImportList = () => {
// 在新窗口打卡
window.open(DOWNLOAD_IMPORT_LIST)
}
/***---------------- 人员列表 end -----------------*/ /***---------------- 人员列表 end -----------------*/
/***---------------- 发枪规则 start -----------------*/ /***---------------- 发枪规则 start -----------------*/
const gunRuleRef = ref(null) const gunRuleRef = ref(null)
const gunRules = ref([]) const gunRules = ref([])
// 规则初始化 // 规则初始化
const initialValue = { const initialValue = {
createTime: undefined, // 组别开始时间 startTime: undefined, // 组别开始时间
roadName: "", // 组别名 roadName: "", // 组别名
waves: [], // 枪次 details: [], // 枪次
id: undefined, id: undefined,
closeTime: undefined // 关门时间 cutOffTime: undefined // 关门时间
} }
// 选号规则 // 选号规则
const gunRuleValue = ref(initialValue) const gunRuleValue = ref(initialValue)
...@@ -595,12 +661,12 @@ ...@@ -595,12 +661,12 @@
}, },
startTime: { startTime: {
required: true, required: true,
message: '请输入规则描述', message: '请选择出发日期',
trigger: 'blur' trigger: 'blur'
}, },
closeTime: { cutOffTime: {
required: true, required: true,
message: '请输入选号长度', message: '请输入关门时间',
trigger: 'blur', trigger: 'blur',
type: 'number', type: 'number',
} }
...@@ -609,41 +675,48 @@ ...@@ -609,41 +675,48 @@
const changeGunRule = (index) => { const changeGunRule = (index) => {
ruleIndex.value = index ruleIndex.value = index
gunRuleValue.value = gunRules.value[index] gunRuleValue.value = gunRules.value[index]
// todo 获取名单 getPlayers()
} }
// 获取分枪组别列表 // 获取分枪组别列表
const getGunRules = async () => { const getGunRules = async () => {
const params = { const params = {
cmptId: getCId() cmptId: getCId()
} }
// loading.value = true; loading.value = true;
// // 发起请求 // 发起请求
// const [err, res] = await to(fetch(RULE_LIST + new URLSearchParams(params).toString(), { const [err, res] = await to(fetch(RULE_LIST + new URLSearchParams(params).toString(), {
// method: "GET", method: "GET",
// headers: { headers: {
// 'Content-Type': 'application/json' 'Content-Type': 'application/json'
// } },
// }).then(res => res.json())) }).then(res => res.json()))
// loading.value = false loading.value = false
// if (err) { if (err) {
// message.error(err.message) message.error(err.message)
// } }
// if (res.code === 200) { if (res.code === 200) {
// gunRules.value = res.data gunRules.value = res.data.map(v => ({
// if (res.data.length) { ...v,
// changeGunRule(ruleIndex.value === -1 ? 0 : ruleIndex.value) startTime: v.startTime.slice(0, -2),
// if (quillEditor.value && gunRuleValue.value.description) { details: v.details.map(d => ({
// quillEditor.value.root.innerHTML = gunRuleValue.value.description; ...d,
// } // 移除最后的两位 .0 我需要移除的是最后两位
// } else { waveStart: d.waveStart.slice(0, -2),
// gunRuleValue.value = initialValue waveEnd: d.waveStart.slice(0, -2),
// } }))
// } else { }))
// message.error(res.msg) if (res.data.length) {
// } changeGunRule(ruleIndex.value === -1 ? 0 : ruleIndex.value)
} else {
gunRuleValue.value = initialValue
}
} else {
message.error(res.msg)
}
} }
// 提交 // 提交
const submit = (e) => { const submit = (e) => {
e.preventDefault() e.preventDefault()
...@@ -655,29 +728,29 @@ ...@@ -655,29 +728,29 @@
gtCmptId: getCId(), gtCmptId: getCId(),
} }
loading.value = true loading.value = true
const messageReactive = message.loading(gunRuleValue.value.id ? '规则更新中...' : '规则添加中...', {
duration: 0
})
// 发起请求 // 发起请求
// const [err, data] = await to(fetch(SAVE_OR_UPDATE, { const [err, data] = await to(fetch(SAVE_OR_UPDATE, {
// method: 'POST', method: 'POST',
// headers: { headers: {
// 'Content-Type': 'application/json' 'Content-Type': 'application/json'
// }, },
// body: JSON.stringify(params) body: JSON.stringify(params)
// }).then(res => res.json())) }).then(res => res.json()))
gunRules.value.push({ ...params, id: gunRules.value.length + 1 })
loading.value = false loading.value = false
messageReactive.destroy() messageReactive.destroy()
message.success('操作成功') if (data.code === 200) {
// if (data.code === 200) { message.success('操作成功')
// message.success('操作成功') getGunRules()
// getGunRules() } else {
// } else { message.error(data.message)
// message.error(data.message) }
// }
}) })
} }
// 日期处理 // 日期处理
const updateFormattedValue = (val) => { const updateFormattedValue = (val) => {
console.log({ val })
gunRuleValue.value.startTime = val gunRuleValue.value.startTime = val
} }
// 新增规则 // 新增规则
...@@ -713,31 +786,31 @@ ...@@ -713,31 +786,31 @@
const waveColumns = [ const waveColumns = [
{ {
title: '枪次', title: '枪次',
key: 'name', key: 'waveName',
align: 'center', align: 'center',
width: 100, width: 100,
render(row, index) { render(row, index) {
return h(NInput, { return h(NInput, {
value: row.name, value: row.waveName,
onUpdateValue(v) { onUpdateValue(v) {
gunRuleValue.value.waves[index].name = v gunRuleValue.value.details[index].waveName = v
} }
}) })
} }
}, },
{ {
title: '发枪时间', title: '发枪时间',
key: 'startTime', key: 'waveStart',
align: 'center', align: 'center',
render(row, index) { render(row, index) {
return h(NDatePicker, { return h(NDatePicker, {
formattedValue: row.startTime, defaultValue: row.waveStart,
valueFormat: "yyyy-MM-dd HH:mm:ss", 'value-format': "yyyy-MM-dd HH:mm:ss",
dateFormat: "yyyy-MM-dd HH:mm:ss", 'date-format': "yyyy-MM-dd HH:mm:ss",
type: "datetime", type: "datetime",
clearable: true, clearable: true,
updateFormatValue(_, formatValue) { 'on-update:formatted-value': (res) => {
gunRuleValue.value.waves[index].startTime = formatValue gunRuleValue.value.details[index].waveStart = res
} }
}) })
} }
...@@ -748,28 +821,28 @@ ...@@ -748,28 +821,28 @@
align: 'center', align: 'center',
render(row, index) { render(row, index) {
return h(NDatePicker, { return h(NDatePicker, {
formattedValue: row.endTime, defaultValue: row.waveEnd,
valueFormat: "yyyy-MM-dd HH:mm:ss", 'value-format': "yyyy-MM-dd HH:mm:ss",
dateFormat: "yyyy-MM-dd HH:mm:ss", 'date-format': "yyyy-MM-dd HH:mm:ss",
type: "datetime", type: "datetime",
clearable: true, clearable: true,
updateFormatValue(_, formatValue) { 'on-update:formatted-value': (res) => {
gunRuleValue.value.waves[index].endTime = formatValue gunRuleValue.value.details[index].waveEnd = res
} }
}) })
} }
}, },
{ {
title: '人数', title: '人数',
key: 'total', key: 'capacity',
align: 'center', align: 'center',
width: 150, width: 150,
render(row, index) { render(row, index) {
return h(NInputNumber, { return h(NInputNumber, {
value: row.total, value: row.capacity,
min: 1, min: 1,
onUpdateValue(v) { onUpdateValue(v) {
gunRuleValue.value.waves[index].total = v gunRuleValue.value.details[index].capacity = v
} }
}) })
} }
...@@ -784,7 +857,7 @@ ...@@ -784,7 +857,7 @@
type: 'error', type: 'error',
size: 'small', size: 'small',
onClick: () => { onClick: () => {
gunRuleValue.value.waves.splice(index, 1) gunRuleValue.value.details.splice(index, 1)
} }
}, '删除') }, '删除')
} }
...@@ -793,20 +866,21 @@ ...@@ -793,20 +866,21 @@
// 新增枪次 // 新增枪次
const addWave = () => { const addWave = () => {
let index = gunRuleValue.value.waves.length let index = gunRuleValue.value.details.length
gunRuleValue.value.waves.push({ gunRuleValue.value.details.push({
id: undefined, id: undefined,
name: NO_MAP[index], waveName: NO_MAP[index],
startTime: undefined, waveNumber: index + 1,
endTime: undefined, waveStart: undefined,
total: undefined, waveEnd: undefined,
capacity: undefined,
}) })
} }
/***---------------- 枪次表 end-----------------*/ /***---------------- 枪次表 end-----------------*/
// 页面加载 // 页面加载
onMounted(() => { onMounted(() => {
// getGunRules() getGunRules()
}) })
return { return {
...@@ -823,6 +897,7 @@ ...@@ -823,6 +897,7 @@
handlePageChange, handlePageChange,
columns, columns,
players, players,
onUpdatePageSize,
// 枪次表相关 // 枪次表相关
waveColumns, waveColumns,
addWave, addWave,
...@@ -843,6 +918,10 @@ ...@@ -843,6 +918,10 @@
menuOptions, menuOptions,
activeMenu, activeMenu,
updateMenu, updateMenu,
uploadUrl,
onFileUpload,
downloadImportList,
fileList,
} }
} }
}) })
......
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