|
@ -1,6 +1,5 @@ |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { syncSendCmd } from 'apis/system' |
|
|
import { syncSendCmd } from 'apis/system' |
|
|
import SoftKeyboard from 'components/common/SoftKeyboard/index.vue' |
|
|
|
|
|
import type { FormInstance, FormRules } from 'element-plus' |
|
|
import type { FormInstance, FormRules } from 'element-plus' |
|
|
import { FtMessage } from 'libs/message' |
|
|
import { FtMessage } from 'libs/message' |
|
|
import { reactive, ref, watchEffect } from 'vue' |
|
|
import { reactive, ref, watchEffect } from 'vue' |
|
@ -12,9 +11,6 @@ const settingStore = useSettingStore() |
|
|
const visible = ref(settingStore.addUserVisible) |
|
|
const visible = ref(settingStore.addUserVisible) |
|
|
const modalType = ref(settingStore.userModalState) |
|
|
const modalType = ref(settingStore.userModalState) |
|
|
const inputValue = ref<string>('') |
|
|
const inputValue = ref<string>('') |
|
|
const keyboardVisible = ref(false) |
|
|
|
|
|
const keyboardType = ref<'text' | 'number'>('text') |
|
|
|
|
|
const softKeyboardRef = ref() |
|
|
|
|
|
const userFormRef = ref() |
|
|
const userFormRef = ref() |
|
|
const focusedInput = ref<string | null>(null) |
|
|
const focusedInput = ref<string | null>(null) |
|
|
const modalTitle = ref('新增用户') |
|
|
const modalTitle = ref('新增用户') |
|
@ -31,6 +27,7 @@ watchEffect(() => { |
|
|
modalTitle.value = '修改密码' |
|
|
modalTitle.value = '修改密码' |
|
|
if (settingStore.currentEditUser) { |
|
|
if (settingStore.currentEditUser) { |
|
|
userForm.value = settingStore.currentEditUser |
|
|
userForm.value = settingStore.currentEditUser |
|
|
|
|
|
userForm.value.passwd = '' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -60,17 +57,8 @@ const onSave = (formRef: FormInstance | undefined) => { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
const openKeyboard = (e: any) => { |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
keyboardVisible.value = true |
|
|
|
|
|
const labelName = e.target.name |
|
|
|
|
|
const formValue = userForm.value[labelName] |
|
|
|
|
|
inputValue.value = formValue ? formValue.toString() : '' |
|
|
|
|
|
focusedInput.value = e.target.name |
|
|
|
|
|
}, 100) |
|
|
|
|
|
} |
|
|
|
|
|
const doEdit = () => { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const doEdit = () => {} |
|
|
const doSave = () => { |
|
|
const doSave = () => { |
|
|
const name = userForm.value.name |
|
|
const name = userForm.value.name |
|
|
const passwd = userForm.value.passwd |
|
|
const passwd = userForm.value.passwd |
|
@ -111,9 +99,7 @@ const onClose = () => { |
|
|
focusedInput.value = null |
|
|
focusedInput.value = null |
|
|
settingStore.updateVisible(false) |
|
|
settingStore.updateVisible(false) |
|
|
} |
|
|
} |
|
|
const handleConfirm = (value: string) => { |
|
|
|
|
|
console.log('确认输入:', value) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface UserForm { |
|
|
interface UserForm { |
|
|
name: string |
|
|
name: string |
|
|
passwd: string |
|
|
passwd: string |
|
@ -160,57 +146,67 @@ const validateConfirmPasswd = (rule: any, value: string, callback: any) => { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
const rules = reactive<FormRules<UserForm>>({ |
|
|
const rules = reactive<FormRules<UserForm>>({ |
|
|
name: [{ required: true, message: '输入登录名', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validateUser, trigger: 'blur' }], |
|
|
|
|
|
passwd: [{ required: true, message: '输入密码', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validatePasswd, trigger: 'blur' }], |
|
|
|
|
|
confirmPasswd: [{ required: true, message: '输入密码', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validateConfirmPasswd, trigger: 'blur' }], |
|
|
|
|
|
|
|
|
name: [ |
|
|
|
|
|
{ required: true, message: '输入登录名', trigger: 'blur' }, |
|
|
|
|
|
{ min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, |
|
|
|
|
|
{ validator: validateUser, trigger: 'blur' }, |
|
|
|
|
|
], |
|
|
|
|
|
passwd: [ |
|
|
|
|
|
{ required: true, message: '输入密码', trigger: 'blur' }, |
|
|
|
|
|
{ min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, |
|
|
|
|
|
{ validator: validatePasswd, trigger: 'blur' }, |
|
|
|
|
|
], |
|
|
|
|
|
confirmPasswd: [ |
|
|
|
|
|
{ required: true, message: '输入密码', trigger: 'blur' }, |
|
|
|
|
|
{ min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, |
|
|
|
|
|
{ validator: validateConfirmPasswd, trigger: 'blur' }, |
|
|
|
|
|
], |
|
|
}) |
|
|
}) |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<template> |
|
|
<template> |
|
|
<FtDialog v-if="visible" v-model="visible" :title="modalTitle" :ok-handle="() => { onSave(userFormRef) }" @cancel="onClose"> |
|
|
|
|
|
|
|
|
<FtDialog |
|
|
|
|
|
v-if="visible" |
|
|
|
|
|
v-model="visible" |
|
|
|
|
|
:title="modalTitle" |
|
|
|
|
|
:ok-handle=" |
|
|
|
|
|
() => { |
|
|
|
|
|
onSave(userFormRef); |
|
|
|
|
|
} |
|
|
|
|
|
" |
|
|
|
|
|
@cancel="onClose" |
|
|
|
|
|
> |
|
|
<div> |
|
|
<div> |
|
|
<el-form ref="userFormRef" :model="userForm" :rules="rules" label-width="auto" style="max-width: 400px"> |
|
|
<el-form ref="userFormRef" :model="userForm" :rules="rules" label-width="auto" style="max-width: 400px"> |
|
|
<el-form-item |
|
|
|
|
|
v-if="!userForm.id" |
|
|
|
|
|
label="登录名:" |
|
|
|
|
|
prop="name" |
|
|
|
|
|
> |
|
|
|
|
|
<el-input v-model="userForm.name" v-prevent-keyboard name="name" placeholder="登录名" @focus="openKeyboard" /> |
|
|
|
|
|
|
|
|
<el-form-item v-if="!userForm.id" label="登录名:" prop="name"> |
|
|
|
|
|
<ft-input v-model="userForm.name" name="name" placeholder="登录名" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<div> |
|
|
<div> |
|
|
<el-form-item |
|
|
|
|
|
label="密码:" |
|
|
|
|
|
prop="passwd" |
|
|
|
|
|
> |
|
|
|
|
|
<el-input v-model="userForm.passwd" v-prevent-keyboard name="passwd" type="password" placeholder="密码" @focus="openKeyboard" /> |
|
|
|
|
|
|
|
|
<el-form-item label="密码:" prop="passwd"> |
|
|
|
|
|
<ft-input |
|
|
|
|
|
v-model="userForm.passwd" |
|
|
|
|
|
autocomplete="new-password" |
|
|
|
|
|
name="passwd" |
|
|
|
|
|
type="password" |
|
|
|
|
|
placeholder="密码" |
|
|
|
|
|
/> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item |
|
|
|
|
|
label="确认密码:" |
|
|
|
|
|
prop="confirmPasswd" |
|
|
|
|
|
> |
|
|
|
|
|
<el-input v-model="userForm.confirmPasswd" v-prevent-keyboard name="confirmPasswd" type="password" placeholder="确认密码" @focus="openKeyboard" /> |
|
|
|
|
|
|
|
|
<el-form-item label="确认密码:" prop="confirmPasswd"> |
|
|
|
|
|
<ft-input |
|
|
|
|
|
v-model="userForm.confirmPasswd" |
|
|
|
|
|
autocomplete="new-password" |
|
|
|
|
|
name="confirmPasswd" |
|
|
|
|
|
type="password" |
|
|
|
|
|
placeholder="确认密码" |
|
|
|
|
|
/> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</div> |
|
|
</div> |
|
|
<el-form-item |
|
|
|
|
|
label="是否管理员:" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
<el-form-item label="是否管理员:"> |
|
|
<el-checkbox v-model="userForm.roleType" size="small" /> |
|
|
<el-checkbox v-model="userForm.roleType" size="small" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
<Teleport to="body"> |
|
|
|
|
|
<SoftKeyboard |
|
|
|
|
|
ref="softKeyboardRef" |
|
|
|
|
|
v-model="inputValue" |
|
|
|
|
|
:is-visible="keyboardVisible" |
|
|
|
|
|
:keyboard-type="keyboardType" |
|
|
|
|
|
@update-keyboard-visible="(visible) => keyboardVisible = visible" |
|
|
|
|
|
@confirm="handleConfirm" |
|
|
|
|
|
@close="keyboardVisible = false" |
|
|
|
|
|
/> |
|
|
|
|
|
</Teleport> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</FtDialog> |
|
|
</FtDialog> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|
|
</style> |
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style> |