Skip to content

Commit

Permalink
feat: 租户管理员初始密码设置 & 数据源校验优化 (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri0528 authored Sep 14, 2023
1 parent b23d557 commit 11df769
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 102 deletions.
4 changes: 3 additions & 1 deletion src/pages/src/components/layouts/MainBreadcrumbsDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const handleBack = () => {
const { back } = window.history.state;
if (back) {
router.go(-1);
store.customBreadcrumbs = false;
if (!window.changeInput) {
store.customBreadcrumbs = false;
}
} else {
const { matched } = route;
const count = matched.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const expiredSms = findMethodScene('sms', props.expiredSmsKey);

<style lang="less" scoped>
.tab-box {
width: 860px;
width: 800px;
border: 1px solid #3A84FF;
}
Expand Down
16 changes: 0 additions & 16 deletions src/pages/src/css/tenantEditStyle.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@
}
}

.item-style {
:deep(.bk-form-label) {
float: unset;
width: 100%;
text-align: left;
}

:deep(.bk-form-content) {
margin-left: 0 !important;

.bk-form-error {
left: 145px;
}
}
}

.operation-content-table {
margin-top: 16px;

Expand Down
57 changes: 40 additions & 17 deletions src/pages/src/views/data-source/new-data/NewLocalData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<div class="content-item">
<p class="item-title">基础信息</p>
<bk-form-item label="数据源名称" property="name" required>
<bk-input style="width: 560px;" v-model="formData.name" :disabled="isDisabled" />
<bk-input style="width: 560px;" v-model="formData.name" :disabled="isDisabled" @change="handleChange" />
</bk-form-item>
<bk-form-item label="" required>
<bk-checkbox v-model="formData.config.enable_account_password_login">
<bk-checkbox v-model="formData.config.enable_account_password_login" @change="handleChange">
开启账密登录
</bk-checkbox>
</bk-form-item>
Expand All @@ -38,6 +38,7 @@
:min="10"
:max="31"
v-model="formData.config.password_rule.min_length"
@change="handleChange"
/>
</bk-form-item>
<bk-form-item label="密码必须包含" required>
Expand All @@ -58,15 +59,15 @@
/>
<span>位 出现</span>
</div>
<p class="error-text" v-show="passwordCountError">不能小于5位,大于10位</p>
<p class="error-text" v-show="passwordCountError">可选值范围:5-10</p>
<bk-checkbox v-model="formData.config.password_rule.not_keyboard_order">键盘序</bk-checkbox>
<bk-checkbox v-model="formData.config.password_rule.not_continuous_letter">连续字母序</bk-checkbox>
<bk-checkbox v-model="formData.config.password_rule.not_continuous_digit">连续数字序</bk-checkbox>
<bk-checkbox v-model="formData.config.password_rule.not_repeated_symbol">重复字母、数字、特殊符号</bk-checkbox>
<p class="error-text" v-show="passwordConfigError">密码规则不得为空</p>
</bk-form-item>
<bk-form-item label="密码有效期" required>
<bk-radio-group v-model="formData.config.password_rule.valid_time">
<bk-radio-group v-model="formData.config.password_rule.valid_time" @change="handleChange">
<bk-radio-button
v-for="(item, index) in passwordValidDaysList"
:key="index"
Expand All @@ -77,7 +78,7 @@
</bk-radio-group>
</bk-form-item>
<bk-form-item label="密码试错次数" required>
<bk-radio-group v-model="formData.config.password_rule.max_retries">
<bk-radio-group v-model="formData.config.password_rule.max_retries" @change="handleChange">
<bk-radio-button
v-for="(item, index) in maxTrailTimesList"
:key="index"
Expand All @@ -94,33 +95,40 @@
suffix=""
:min="0"
v-model="formData.config.password_rule.lock_time"
@change="handleChange"
/>
</bk-form-item>
</div>
<div class="content-item">
<p class="item-title">初始密码设置</p>
<bk-form-item label="" required>
<bk-checkbox v-model="formData.config.password_initial.force_change_at_first_login">
<bk-checkbox
v-model="formData.config.password_initial.force_change_at_first_login"
@change="handleChange">
首次登录强制修改密码
</bk-checkbox>
</bk-form-item>
<bk-form-item label="" required>
<div>
<bk-checkbox v-model="formData.config.password_initial.cannot_use_previous_password">
<bk-checkbox
v-model="formData.config.password_initial.cannot_use_previous_password"
@change="handleChange">
修改密码时不能重复前
</bk-checkbox>
<bk-input
style="width: 85px;"
type="number"
behavior="simplicity"
:min="5"
:min="0"
:max="5"
v-model="formData.config.password_initial.reserved_previous_password_count"
@change="handleChange"
/>
<span>次 用过的密码</span>
</div>
</bk-form-item>
<bk-form-item class="form-item-flex" label="密码生成方式" required>
<bk-radio-group v-model="formData.config.password_initial.generate_method">
<bk-radio-group v-model="formData.config.password_initial.generate_method" @change="handleChange">
<bk-radio label="random">随机</bk-radio>
<bk-radio label="fixed">固定</bk-radio>
</bk-radio-group>
Expand All @@ -136,7 +144,7 @@
<p class="fixed-password-error" v-show="fixedPasswordError">密码长度至少12位,必须包含大小写字母、数字</p>
</div>
</bk-form-item>
<bk-form-item label="通知方式" required>
<bk-form-item label="通知方式" property="config.password_initial.notification.enabled_methods" required>
<NotifyEditorTemplate
:active-methods="activeMethods"
:checkbox-info="checkboxInfo"
Expand All @@ -155,7 +163,8 @@
<div class="password-header">
<bk-checkbox-group
class="checkbox-zh"
v-model="formData.config.password_initial.notification.enabled_methods">
v-model="formData.config.password_initial.notification.enabled_methods"
@change="handleChange">
<bk-checkbox
v-for="(item, index) in checkboxInfo" :key="index"
:class="['password-tab', item.status ? 'active-tab' : '']"
Expand All @@ -166,7 +175,7 @@
</bk-checkbox-group>
<div class="edit-info" @click="passwordInitialTemplate">
<span style="font-size:14px">编辑通知模板</span>
<AngleUp v-if="isDropdownPasswordExpire" />
<AngleUp v-if="isDropdownPasswordInitial" />
<AngleDown v-else />
</div>
</div>
Expand All @@ -177,7 +186,7 @@
<div class="content-item">
<p class="item-title">密码到期提醒</p>
<bk-form-item label="提醒时间" property="config.password_expire.remind_before_expire" required>
<bk-checkbox-group v-model="formData.config.password_expire.remind_before_expire">
<bk-checkbox-group v-model="formData.config.password_expire.remind_before_expire" @change="handleChange">
<bk-checkbox
v-for="(item, index) in noticeTimeList"
:key="index"
Expand All @@ -186,7 +195,7 @@
>
</bk-checkbox-group>
</bk-form-item>
<bk-form-item label="通知方式" required>
<bk-form-item label="通知方式" property="config.password_expire.notification.enabled_methods" required>
<NotifyEditorTemplate
:active-methods="activeMethods"
:checkbox-info="checkboxInfo"
Expand All @@ -201,7 +210,8 @@
<div class="password-header">
<bk-checkbox-group
class="checkbox-zh"
v-model="formData.config.password_expire.notification.enabled_methods">
v-model="formData.config.password_expire.notification.enabled_methods"
@change="handleChange">
<bk-checkbox
v-for="(item, index) in checkboxInfo" :key="index"
:class="['password-tab', item.status ? 'active-tab' : '']"
Expand Down Expand Up @@ -334,14 +344,19 @@ watch(() => formData.config?.password_rule, (value) => {
if (!passwordConfigError.value && isCountInRange) {
passwordCountError.value = false;
} else if (!passwordConfigError.value && !isCountInRange) {
passwordCountError.value = !isCountInRange;
} else {
passwordCountError.value = count === 0 && !passwordConfigError.value;
passwordConfigError.value = count !== 0 && passwordConfigError.value;
}
}, { deep: true });
watch(() => formData.config?.password_rule?.not_continuous_count, (value) => {
watch(() => formData.config?.password_rule?.not_continuous_count, (value, oldVal) => {
if (!value) return;
if (value !== oldVal) {
window.changeInput = true;
}
const list = Object.entries(formData.config?.password_rule)
.filter(([key, val]) => passwordNotAllowed[key] && val)
.map(val => val);
Expand All @@ -351,7 +366,7 @@ watch(() => formData.config?.password_rule?.not_continuous_count, (value) => {
const isValueInRange = value >= 5 && value <= 10;
passwordCountError.value = !isValueInRange;
passwordConfigError.value = !!list.every(v => !v);
}, { deep: true });
});
watch(() => formData.config?.password_initial?.generate_method, (value) => {
if (value === 'random') {
Expand Down Expand Up @@ -417,6 +432,8 @@ const handleClickCancel = () => {
const btnLoading = ref(false);
const handleSubmit = async () => {
try {
fixedPasswordError.value = formData.config?.password_initial?.generate_method === 'fixed'
&& !formData.config.password_initial.fixed_password;
if (passwordRuleError.value
|| passwordCountError.value
|| passwordConfigError.value
Expand Down Expand Up @@ -458,6 +475,7 @@ const updateDataSource = async (params) => {
plugin_config: params.plugin_config,
};
await putDataSourceDetails(data);
window.changeInput = false;
router.push({ name: 'local' });
Message({
theme: 'success',
Expand All @@ -467,6 +485,7 @@ const updateDataSource = async (params) => {
const getDataSource = async (params) => {
await newDataSource(params);
window.changeInput = false;
router.push({ name: 'local' });
Message({
theme: 'success',
Expand All @@ -482,6 +501,10 @@ const handleBlur = () => {
const handleFocus = () => {
fixedPasswordError.value = false;
};
const handleChange = () => {
window.changeInput = true;
};
</script>

<style lang="less" scoped>
Expand Down
29 changes: 1 addition & 28 deletions src/pages/src/views/setting/FieldSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<bk-table-column prop="name" label="字段名称">
<template #default="{ row }">
<div class="field-name">
<i class="user-icon icon-drag move" />
<span class="name">{{ row.name }}</span>
<bk-tag theme="info" v-if="row.builtin">内置</bk-tag>
</div>
Expand Down Expand Up @@ -76,8 +75,7 @@
<script setup lang="ts">
import { Message } from 'bkui-vue';
import InfoBox from 'bkui-vue/lib/info-box';
import Sortable from 'sortablejs';
import { inject, nextTick, reactive } from 'vue';
import { inject, reactive } from 'vue';
import FieldsAdd from './FieldsAdd.vue';
Expand Down Expand Up @@ -164,25 +162,6 @@ const fieldStatus = (type: boolean) => {
}
};
const initSortable = (className: string) => {
// 获取表格row的父节点
const table = document.querySelector(`.${className} .bk-table-body tbody`);
// 创建拖拽实例
Sortable.create(table, {
handle: '.move',
group: table,
ghostClass: 'blue-background-class',
animation: 150,
onUpdate: (event: any) => {
console.log('event', event);
},
});
};
nextTick(() => {
initSortable('field-setting-table');
});
const addField = () => {
fieldData.currentEditorData = {};
fieldData.title = '添加字段';
Expand Down Expand Up @@ -241,12 +220,6 @@ const fetchFieldList = () => {};
:deep(.field-setting-table) {
.field-name {
.move {
font-size: 16px;
color: #c8c8c8;
cursor: move;
}
.name {
margin: 0 8px;
color: #63656e;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/src/views/setting/FieldsAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
</template>

<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue';
import { computed, defineEmits, defineProps, reactive, ref, watch } from 'vue';
const props = defineProps({
currentEditorData: {
Expand Down
Loading

0 comments on commit 11df769

Please sign in to comment.