<template>
|
<div class="app-container">
|
<el-card class="box-card" shadow="never">
|
<template #header>
|
<div class="card-header">
|
<span>业务参数设置</span>
|
</div>
|
</template>
|
<el-form
|
ref="configFormRef"
|
:model="form"
|
:rules="rules"
|
label-width="240px"
|
style="max-width: 600px; margin-top: 20px;"
|
>
|
<el-form-item label="合同原件约定回传提前提醒天数" prop="contractReturnReminderDays">
|
<el-input-number
|
v-model="form.contractReturnReminderDays"
|
:min="1"
|
:max="365"
|
:step="1"
|
placeholder="请输入天数"
|
style="width: 200px"
|
/>
|
<span style="margin-left: 10px; color: #999;">天</span>
|
</el-form-item>
|
|
<el-form-item>
|
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">保存设置</el-button>
|
<el-button @click="handleReset">重置</el-button>
|
</el-form-item>
|
</el-form>
|
</el-card>
|
</div>
|
</template>
|
|
<script setup name="ProjectConfig">
|
import { ref, reactive, onMounted } from 'vue'
|
import { ElMessage } from 'element-plus'
|
import { getConfig, updateConfig } from '@/api/projectManagement/config'
|
|
const configFormRef = ref(null)
|
const submitLoading = ref(false)
|
const originalData = ref({})
|
|
const form = reactive({
|
id: undefined,
|
contractReturnReminderDays: 3
|
})
|
|
const rules = {
|
contractReturnReminderDays: [
|
{ required: true, message: '提前提醒天数不能为空', trigger: 'blur' }
|
]
|
}
|
|
const loadData = async () => {
|
try {
|
const res = await getConfig()
|
if (res.code === 200 && res.data) {
|
Object.assign(form, res.data)
|
originalData.value = JSON.parse(JSON.stringify(res.data))
|
}
|
} catch (error) {
|
console.error('获取配置失败:', error)
|
}
|
}
|
|
const handleSubmit = async () => {
|
if (!configFormRef.value) return
|
await configFormRef.value.validate(async (valid) => {
|
if (valid) {
|
submitLoading.value = true
|
try {
|
const res = await updateConfig(form)
|
if (res.code === 200) {
|
ElMessage.success('配置更新成功')
|
loadData()
|
}
|
} catch (error) {
|
console.error('更新配置失败:', error)
|
} finally {
|
submitLoading.value = false
|
}
|
}
|
})
|
}
|
|
const handleReset = () => {
|
if (originalData.value.id) {
|
Object.assign(form, originalData.value)
|
} else {
|
form.contractReturnReminderDays = 3
|
}
|
}
|
|
onMounted(() => {
|
loadData()
|
})
|
</script>
|
|
<style scoped>
|
.app-container {
|
padding: 20px;
|
}
|
.box-card {
|
min-height: calc(100vh - 124px);
|
}
|
</style>
|