Commit 554d5132 authored by daniel's avatar daniel

feat(gpsDeposit): gps押金完善

parent 703f7049
......@@ -182,8 +182,8 @@
<n-form-item label="组别" path="roadIds">
<n-select v-model:value="depositForm.roadIds" multiple :options="roadOptions" />
</n-form-item>
<n-form-item label="押金金额" path="money">
<n-input-number v-model:value="depositForm.money" placeholder="请输入押金金额" />
<n-form-item label="押金金额" path="amount">
<n-input-number v-model:value="depositForm.amount" placeholder="请输入押金金额" />
</n-form-item>
<n-form-item label="状态">
<n-switch
......@@ -209,7 +209,7 @@
</n-form>
<template #header-extra>
<n-button class="flex-1"
:loading="loading" type='primary' @click="onSubmit">
:loading="loading" type='primary' @click="saveDeposit">
保存
</n-button>
</template>
......@@ -410,8 +410,9 @@
const RANDOM_ASSIGN_URL = BASE_ECC_URL + '/api-pick/v1/pick-up-batch?cmptId=' + getCId()
// TODO 保存押金配置
const SAVE_DEPOSIT_URL = ""
const GET_DEPOSIT_URL = ""
const SAVE_DEPOSIT_URL = "http://localhost:8081/api-gps-config/v1/save"
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({
name: 'MyApp',
......@@ -597,35 +598,23 @@
// ref 押金表单
const depositFormRef = ref()
// 组别选项
const roadOptions = ref([
{
label: '组别一',
value: 'song0',
disabled: true
},
{
label: '组别二',
value: 'song1'
},
{
label: '组别三',
value: 'song2'
},
])
const roadOptions = ref([])
// 押金表单
const depositForm = reactive({
money: 500, // 金额
const depositForm = ref({
amount: 300, // 金额
id: undefined,
cmptId: getCmptId(),
notice: '', // 公告
content: '', // 富文本
status: 0,// 0 关闭,1开启
roadIds: [],
})
// 押金配置规则
const depositRules = {
money: [{
amount: {
required: true,
message: '请输入押金金额',
trigger: ['blur', 'change']
}],
},
}
// 状态更新
......@@ -803,7 +792,11 @@
headers: {
'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()))
loading.value = false
if (err) {
......@@ -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 () => {
loading.value = true
const [err, res] = await to(fetch(GET_DEPOSIT_URL, {
......@@ -835,8 +851,16 @@
return
}
if (res.code === 200) {
depositForm.value = res.data
editor.setContent(res.data.content)
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)
}
} else {
message.error(res.message)
}
......@@ -851,6 +875,8 @@
onMounted(() => {
fetchData()
getDeposit()
getCmptInfo()
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