Commit 554d5132 authored by daniel's avatar daniel

feat(gpsDeposit): gps押金完善

parent 703f7049
...@@ -182,8 +182,8 @@ ...@@ -182,8 +182,8 @@
<n-form-item label="组别" path="roadIds"> <n-form-item label="组别" path="roadIds">
<n-select v-model:value="depositForm.roadIds" multiple :options="roadOptions" /> <n-select v-model:value="depositForm.roadIds" multiple :options="roadOptions" />
</n-form-item> </n-form-item>
<n-form-item label="押金金额" path="money"> <n-form-item label="押金金额" path="amount">
<n-input-number v-model:value="depositForm.money" placeholder="请输入押金金额" /> <n-input-number v-model:value="depositForm.amount" placeholder="请输入押金金额" />
</n-form-item> </n-form-item>
<n-form-item label="状态"> <n-form-item label="状态">
<n-switch <n-switch
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
</n-form> </n-form>
<template #header-extra> <template #header-extra>
<n-button class="flex-1" <n-button class="flex-1"
:loading="loading" type='primary' @click="onSubmit"> :loading="loading" type='primary' @click="saveDeposit">
保存 保存
</n-button> </n-button>
</template> </template>
...@@ -410,8 +410,9 @@ ...@@ -410,8 +410,9 @@
const RANDOM_ASSIGN_URL = BASE_ECC_URL + '/api-pick/v1/pick-up-batch?cmptId=' + getCId() const RANDOM_ASSIGN_URL = BASE_ECC_URL + '/api-pick/v1/pick-up-batch?cmptId=' + getCId()
// TODO 保存押金配置 // TODO 保存押金配置
const SAVE_DEPOSIT_URL = "" const SAVE_DEPOSIT_URL = "http://localhost:8081/api-gps-config/v1/save"
const GET_DEPOSIT_URL = "" const GET_DEPOSIT_URL = "http://localhost:8081/api-gps-config/v1//getByCmptId?cmptId=" + getCId()
const GET_CMPT_URL = "https://timerbackend.geexek.com/getCmpt.do?cmptId=" + getCId()
const MyApp = defineComponent({ const MyApp = defineComponent({
name: 'MyApp', name: 'MyApp',
...@@ -597,35 +598,23 @@ ...@@ -597,35 +598,23 @@
// ref 押金表单 // ref 押金表单
const depositFormRef = ref() const depositFormRef = ref()
// 组别选项 // 组别选项
const roadOptions = ref([ const roadOptions = ref([])
{
label: '组别一',
value: 'song0',
disabled: true
},
{
label: '组别二',
value: 'song1'
},
{
label: '组别三',
value: 'song2'
},
])
// 押金表单 // 押金表单
const depositForm = reactive({ const depositForm = ref({
money: 500, // 金额 amount: 300, // 金额
id: undefined,
cmptId: getCmptId(),
notice: '', // 公告 notice: '', // 公告
content: '', // 富文本 content: '', // 富文本
status: 0,// 0 关闭,1开启 status: 0,// 0 关闭,1开启
roadIds: [],
}) })
// 押金配置规则 // 押金配置规则
const depositRules = { const depositRules = {
money: [{ amount: {
required: true, required: true,
message: '请输入押金金额', message: '请输入押金金额',
trigger: ['blur', 'change'] },
}],
} }
// 状态更新 // 状态更新
...@@ -803,7 +792,11 @@ ...@@ -803,7 +792,11 @@
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(depositForm.value) body: JSON.stringify({
...depositForm.value,
roadIds: depositForm.value.roadIds.join(','),
content: editor.getContent()
})
}).then(res => res.json())) }).then(res => res.json()))
loading.value = false loading.value = false
if (err) { if (err) {
...@@ -820,7 +813,30 @@ ...@@ -820,7 +813,30 @@
}) })
} }
// todo 获取押金配置
// 获取赛事信息
const getCmptInfo = async () => {
loading.value = true
const [err, res] = await to(fetch(GET_CMPT_URL, {
method: "GET",
}).then(res => res.json()))
loading.value = false
if (err) {
message.error(err)
return
}
if (res.status === 0) {
if (res.cmpt) {
roadOptions.value = res.cmpt.roads.filter(v => v.enable).map(v => ({
label: v.name,
value: v.id
}))
}
} else {
message.error(res.message)
}
}
// 获取押金配置
const getDeposit = async () => { const getDeposit = async () => {
loading.value = true loading.value = true
const [err, res] = await to(fetch(GET_DEPOSIT_URL, { const [err, res] = await to(fetch(GET_DEPOSIT_URL, {
...@@ -835,8 +851,16 @@ ...@@ -835,8 +851,16 @@
return return
} }
if (res.code === 200) { if (res.code === 200) {
depositForm.value = res.data if (res.data) {
// depositForm.value = res.data
depositForm.value.id = res.data.id
depositForm.value.amount = res.data.amount
depositForm.value.status = res.data.status
depositForm.value.notice = res.data.notice
depositForm.value.content = res.data.content
depositForm.value.roadIds = res.data.roadIds.split(',').map(v => Number(v))
editor.setContent(res.data.content) editor.setContent(res.data.content)
}
} else { } else {
message.error(res.message) message.error(res.message)
} }
...@@ -851,6 +875,8 @@ ...@@ -851,6 +875,8 @@
onMounted(() => { onMounted(() => {
fetchData() fetchData()
getDeposit()
getCmptInfo()
editor = UE.getEditor('rich-text-container'); editor = UE.getEditor('rich-text-container');
}) })
......
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