Skip to content

Commit

Permalink
fix: 系统配置中新增短信配置窗口
Browse files Browse the repository at this point in the history
  • Loading branch information
ktianc committed Oct 18, 2023
1 parent 54f8671 commit 572f494
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 8 deletions.
4 changes: 2 additions & 2 deletions kinit-admin/src/api/vadmin/system/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import request from '@/config/axios'

export const getSystemSettingsTabsApi = (params: any): Promise<IResponse> => {
return request.get({ url: '/vadmin/system/settings/tabs', params })
export const getSystemSettingsTabsApi = (data: any): Promise<IResponse> => {
return request.post({ url: '/vadmin/system/settings/tabs', data })
}

export const getSystemSettingsApi = (params: any): Promise<IResponse> => {
Expand Down
2 changes: 1 addition & 1 deletion kinit-admin/src/views/Vadmin/System/Dict/Type/DictType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const save = async () => {
const emit = defineEmits(['updateDictTypeId'])
const handleCurrentChange = async (val: any | undefined) => {
emit('updateDictTypeId', val.id)
emit('updateDictTypeId', val ? val.id : val)
}
const clearCurrentRow = async () => {
Expand Down
4 changes: 3 additions & 1 deletion kinit-admin/src/views/Vadmin/System/Settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Privacy from './components/Privacy.vue'
import Agreement from './components/Agreement.vue'
import WXClient from './components/WechatServer.vue'
import Email from './components/Email.vue'
import SMS from './components/SMS.vue'
import { ContentWrap } from '@/components/ContentWrap'
import { getSystemSettingsTabsApi } from '@/api/vadmin/system/settings'
Expand All @@ -18,7 +19,7 @@ const activeName = ref('web_basic')
const tabs = ref([] as Recordable[])
const getList = async () => {
const res = await getSystemSettingsTabsApi({ classify: 'web' })
const res = await getSystemSettingsTabsApi(['web', 'aliyun'])
if (res) {
tabs.value = res.data
}
Expand All @@ -37,6 +38,7 @@ getList()
<Agreement v-else-if="item.tab_name === 'web_agreement'" :tab-id="item.id" />
<WXClient v-else-if="item.tab_name === 'wx_server'" :tab-id="item.id" />
<Email v-else-if="item.tab_name === 'web_email'" :tab-id="item.id" />
<SMS v-else-if="item.tab_name === 'aliyun_sms'" :tab-id="item.id" />
</ElTabPane>
</template>
</ElTabs>
Expand Down
197 changes: 197 additions & 0 deletions kinit-admin/src/views/Vadmin/System/Settings/components/SMS.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<script setup lang="tsx">
import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm'
import { ElButton } from 'element-plus'
import { getSystemSettingsApi, putSystemSettingsApi } from '@/api/vadmin/system/settings'
import { reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { propTypes } from '@/utils/propTypes'
import { useValidator } from '@/hooks/web/useValidator'
const { required } = useValidator()
const props = defineProps({
tabId: propTypes.number
})
const formSchema = reactive<FormSchema[]>([
{
field: 'sms_access_key',
label: 'AccessKey',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_access_key_secret',
label: 'AccessKeySecret',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_sign_name_1',
label: '短信验证码签名',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_template_code_1',
label: '短信验证码模板',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_sign_name_2',
label: '重置密码签名',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_template_code_2',
label: '重置密码模板',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_send_interval',
label: '发送频率',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'sms_valid_time',
label: '有效时间',
colProps: {
span: 24
},
component: 'Input',
componentProps: {
style: {
width: '500px'
}
}
},
{
field: 'active',
label: '',
colProps: {
span: 24
},
formItemProps: {
slots: {
default: () => {
return (
<>
<ElButton loading={loading.value} type="primary" onClick={save}>
立即提交
</ElButton>
</>
)
}
}
}
}
])
const rules = reactive({
sms_access_key: [required()],
sms_access_key_secret: [required()],
sms_send_interval: [required()],
sms_valid_time: [required()]
})
const { formRegister, formMethods } = useForm()
const { setValues, getFormData, getElFormExpose } = formMethods
let formData = ref({} as Recordable)
const getData = async () => {
const res = await getSystemSettingsApi({ tab_id: props.tabId })
if (res) {
await setValues(res.data)
formData.value = res.data
const elForm = await getElFormExpose()
elForm?.clearValidate()
}
}
const loading = ref(false)
const save = async () => {
const elForm = await getElFormExpose()
const valid = await elForm?.validate()
if (valid) {
const formData = await getFormData()
loading.value = true
if (!formData) {
loading.value = false
return ElMessage.error('未获取到数据')
}
try {
const res = await putSystemSettingsApi(formData)
if (res) {
getData()
return ElMessage.success('更新成功')
}
} finally {
loading.value = false
}
}
}
getData()
</script>

<template>
<Form :rules="rules" @register="formRegister" :schema="formSchema" />
</template>

<style lang="less"></style>
3 changes: 2 additions & 1 deletion kinit-api/application/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
系统版本
"""
VERSION = "3.1.0"
VERSION = "3.2.0"

"""安全警告: 不要在生产中打开调试运行!"""
DEBUG = False
Expand All @@ -24,6 +24,7 @@
"/auth/token/refresh",
"/auth/wx/login",
"/vadmin/system/dict/types/details",
"/vadmin/system/settings/tabs",
"/vadmin/resource/images",
"/vadmin/auth/user/export/query/list/to/excel"
]
Expand Down
6 changes: 3 additions & 3 deletions kinit-api/apps/vadmin/system/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ async def sms_send(telephone: str, rd: Redis = Depends(redis_getter), auth: Auth
###########################################################
# 系统配置管理
###########################################################
@app.get("/settings/tabs", summary="获取系统配置标签列表")
async def get_settings_tabs(classify: str, auth: Auth = Depends(FullAdminAuth())):
return SuccessResponse(await crud.SettingsTabDal(auth.db).get_datas(limit=0, classify=classify))
@app.post("/settings/tabs", summary="获取系统配置标签列表")
async def get_settings_tabs(classifys: list[str] = Body(...), auth: Auth = Depends(FullAdminAuth())):
return SuccessResponse(await crud.SettingsTabDal(auth.db).get_datas(limit=0, classify=("in", classifys)))


@app.get("/settings/tabs/values", summary="获取系统配置标签下的信息")
Expand Down
2 changes: 2 additions & 0 deletions kinit-api/core/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE
msg = f"类型错误,提交参数应该为整数!"
elif msg == "value could not be parsed to a boolean":
msg = f"类型错误,提交参数应该为布尔值!"
elif msg == "Input should be a valid list":
msg = f"类型错误,输入应该是一个有效的列表!"
return JSONResponse(
status_code=200,
content=jsonable_encoder(
Expand Down
Binary file modified kinit-api/scripts/initialize/data/init.xlsx
Binary file not shown.

0 comments on commit 572f494

Please sign in to comment.