Skip to content

Commit

Permalink
feat: 账号有效期接口联调
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri0528 committed Nov 14, 2023
1 parent 3389fe5 commit 37bf586
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/pages/src/http/settingFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import http from './fetch';
import type {
NewCustomFieldsParams,
PutCustomFieldsParams,
PutUserValidityParams,
} from './types/settingFiles';

/**
Expand All @@ -27,9 +28,9 @@ export const deleteCustomFields = (id: string) => http.delete(`/api/v1/web/tenan
/**
* 获取当前租户的账户有效期设置
*/
export const getTenantSetting = () => http.get('/api/v1/web/tenant-setting/settings/tenant-user-validity-period/');
export const getTenantUserValidityPeriod = () => http.get('/api/v1/web/tenant-setting/settings/tenant-user-validity-period/');

/**
* 更新当前租户的账户有效期设置
*/
export const putTenantSetting = () => http.put('/api/v1/web/tenant-setting/settings/tenant-user-validity-period/');
export const putTenantUserValidityPeriod = (params: PutUserValidityParams) => http.put('/api/v1/web/tenant-setting/settings/tenant-user-validity-period/', params);
11 changes: 11 additions & 0 deletions src/pages/src/http/types/settingFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ export interface PutCustomFieldsParams {
default: {},
options: {},
}

/**
* 更新当前租户账户有效期设置字段
*/
export interface PutUserValidityParams {
enabled: boolean
validity_period: number,
remind_before_expire: number[],
enabled_notification_methods: string[],
notification_templates: [],
}
44 changes: 31 additions & 13 deletions src/pages/src/views/setting/AccountSetting.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<bk-loading :loading="isLoading" :z-index="9" class="account-setting-wrapper user-scroll-y">
<bk-form class="account-setting-content" form-type="vertical" v-model="formData">
<bk-form class="account-setting-content" form-type="vertical" :model="formData" ref="formRef">
<bk-form-item label="账号有效期开启">
<bk-switcher v-model="formData.enabled" theme="primary" size="large" @change="handleChange" />
</bk-form-item>
<div v-if="formData.enabled">
<bk-form-item label="账号有效期">
<bk-radio-group v-model="formData.valid_time" @change="handleChange">
<bk-radio-group v-model="formData.validity_period" @change="handleChange">
<bk-radio-button
v-for="(item, index) in VALID_TIME"
:key="index"
Expand All @@ -16,7 +16,7 @@
</bk-radio-button>
</bk-radio-group>
</bk-form-item>
<bk-form-item label="提醒时间" required>
<bk-form-item label="提醒时间" property="remind_before_expire" required>
<bk-checkbox-group v-model="formData.remind_before_expire" @change="handleChange">
<bk-checkbox
v-for="(item, index) in REMIND_DAYS"
Expand All @@ -33,10 +33,10 @@
:checkbox-info="NOTIFICATION_METHODS"
:data-list="formData.notification_templates"
:is-template="isAccountExpire"
:expiring-email-key="'account_expiring'"
:expired-email-key="'account_expired'"
:expiring-sms-key="'account_expiring'"
:expired-sms-key="'account_expired'"
:expiring-email-key="'tenant_user_expiring'"
:expired-email-key="'tenant_user_expired'"
:expiring-sms-key="'tenant_user_expiring'"
:expired-sms-key="'tenant_user_expired'"
@handleEditorText="handleEditorText">
<template #label>
<div class="password-header">
Expand Down Expand Up @@ -64,35 +64,41 @@
</div>
</bk-form>
<div class="account-setting-footer">
<bk-button theme="primary">应用</bk-button>
<bk-button theme="primary" @click="changeApplication">应用</bk-button>
</div>
</bk-loading>
</template>

<script setup lang="ts">
import { Message } from 'bkui-vue';
import { AngleDown, AngleUp } from 'bkui-vue/lib/icon';
import { onMounted, ref } from 'vue';
import NotifyEditorTemplate from '@/components/notify-editor/NotifyEditorTemplate.vue';
import { getTenantUserValidityPeriod, putTenantUserValidityPeriod } from '@/http/settingFiles';
import { NOTIFICATION_METHODS, REMIND_DAYS, VALID_TIME } from '@/utils';
// import { getTenantSetting } from '@/http/settingFiles'
const isLoading = ref(false);
const formData = ref({});
const isAccountExpire = ref(false);
const isDropdownAccountExpire = ref(false);
const formRef = ref();
onMounted(async () => {
onMounted(() => {
getAccountCongif();
});
const getAccountCongif = async () => {
try {
isLoading.value = true;
// const res = await getTenantSetting();
// formData.value = res.data;
const res = await getTenantUserValidityPeriod();
formData.value = res.data;
} catch (e) {
console.warn(e);
} finally {
isLoading.value = false;
}
});
};
const handleEditorText = (html, text, key, type) => {
formData.value.notification_templates.forEach((item) => {
Expand All @@ -117,6 +123,18 @@ const accountExpireTemplate = () => {
const handleChange = () => {
window.changeInput = true;
};
const changeApplication = async () => {
try {
await formRef.value.validate();
await putTenantUserValidityPeriod(formData.value);
Message({ theme: 'success', message: '更新成功' });
getAccountCongif();
window.changeInput = false;
} catch (e) {
console.warn(e);
}
};
</script>

<style lang="less" scoped>
Expand Down

0 comments on commit 37bf586

Please sign in to comment.