Browse Source

fix: 新的键盘事件

master
guoapeng 2 weeks ago
parent
commit
ad37cc514b
  1. 14
      src/components/common/FTInput/index.vue
  2. 71
      src/components/formula/FormulaConfig.vue
  3. 10
      src/main.ts

14
src/components/common/FTKeyboard/index.vue → src/components/common/FTInput/index.vue

@ -19,11 +19,6 @@ const props = defineProps({
type: Number, type: Number,
default: 2, default: 2,
}, },
//
isOpen: {
type: Boolean,
default: true,
},
}) })
const emits = defineEmits(['onChange', 'enter', 'close', 'focus']) const emits = defineEmits(['onChange', 'enter', 'close', 'focus'])
const deviceStore = useDeviceStore() const deviceStore = useDeviceStore()
@ -64,25 +59,18 @@ const open = () => {
const focusInput = (e: any) => { const focusInput = (e: any) => {
const rect = e.target.getBoundingClientRect() const rect = e.target.getBoundingClientRect()
console.log('元素位置信息:', {
top: rect.top + window.scrollY,
left: rect.left + window.scrollX,
width: rect.width,
height: rect.height,
})
if (rect.top + window.scrollY > 800) { if (rect.top + window.scrollY > 800) {
placement.value = 'top' placement.value = 'top'
} }
else { else {
placement.value = 'bottom' placement.value = 'bottom'
} }
console.log(rect)
if (visible.value) if (visible.value)
return return
emits('focus')
if (deviceType.value !== deviceStore.deviceTypeMap.LargeSpaceDM_B) if (deviceType.value !== deviceStore.deviceTypeMap.LargeSpaceDM_B)
visible.value = true visible.value = true
} }
emits('focus')
// const blurInput = debounce(() => { // const blurInput = debounce(() => {
// if (!entering.value) { // if (!entering.value) {

71
src/components/formula/FormulaConfig.vue

@ -105,23 +105,21 @@ watch(
}, },
{ deep: true }, { deep: true },
) )
const formRef = ref(null)
const formRef = ref()
/** /**
* 处理表单提交 * 处理表单提交
* 根据不同的type属性值执行不同的保存逻辑 * 根据不同的type属性值执行不同的保存逻辑
*/ */
const handleSubmit = () => {
const handleSubmit = async () => {
// //
if (formData.value.name === '') {
FtMessage.warning('请输入配方名称')
try {
const valid = await formRef.value.validate()
if (!valid) {
return return
} }
if (formData.value.name && formData.value.name.length > 20) {
FtMessage.warning('配方名称1-20字符')
return
}
if (formData.value.formula_id) { //
if (formData.value.formula_id) {
//
// //
if (!deviceState.value && formulaStore.selectedFormulaInfo?.formula_id === formData.value.formula_id) { if (!deviceState.value && formulaStore.selectedFormulaInfo?.formula_id === formData.value.formula_id) {
ElMessage.warning('禁止修改正在执行的配方信息!') ElMessage.warning('禁止修改正在执行的配方信息!')
@ -130,7 +128,8 @@ const handleSubmit = () => {
const formulaForm: Record<string, any> = convertValuesToString(formData.value, 'name') const formulaForm: Record<string, any> = convertValuesToString(formData.value, 'name')
formulaStore.editFormula(formulaForm.formula_id, formulaForm as Formula.FormulaItem) formulaStore.editFormula(formulaForm.formula_id, formulaForm as Formula.FormulaItem)
} }
else { //
else {
//
formulaStore.onAddFormula().then((res) => { formulaStore.onAddFormula().then((res) => {
if (res.ackcode === 0) { if (res.ackcode === 0) {
const item = res.rely const item = res.rely
@ -144,6 +143,10 @@ const handleSubmit = () => {
}) })
} }
} }
catch (e) {
console.log(e)
}
}
/** /**
* @computed 计算属性 - 设备状态判断 * @computed 计算属性 - 设备状态判断
* @returns {boolean} - 设备是否处于空闲或已完成状态 * @returns {boolean} - 设备是否处于空闲或已完成状态
@ -192,16 +195,12 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
<template> <template>
<transition name="slide-right"> <transition name="slide-right">
<div v-if="isFlip" class="formula-form"> <div v-if="isFlip" class="formula-form">
<el-form
ref="formRef"
:model="formData"
label-width="auto"
label-position="right"
:size="size"
inline
>
<el-form ref="formRef" :model="formData" label-width="auto" label-position="right" :size="size" inline>
<el-form-item <el-form-item
label="配方名称" style="width: 93%" prop="name" :rules="[
label="配方名称"
style="width: 93%"
prop="name"
:rules="[
{ {
required: true, required: true,
message: '请输入配方名称', message: '请输入配方名称',
@ -215,15 +214,10 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
}, },
]" ]"
> >
<el-input
v-model="formData.name"
v-prevent-keyboard
name="name"
placeholder="配方名称"
/>
<ft-input v-model="formData.name" name="name" placeholder="配方名称" />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-for="item in formulaConfigList.filter((data) => data.is_visible_in_formula_page)"
v-for="item in formulaConfigList.filter(data => data.is_visible_in_formula_page)"
:key="item.setting_id" :key="item.setting_id"
:label="formulaNameMap[item.setting_id]" :label="formulaNameMap[item.setting_id]"
style="width: 50%" style="width: 50%"
@ -237,32 +231,18 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
]" ]"
> >
<template v-if="item.val_type === 'int'"> <template v-if="item.val_type === 'int'">
<el-input
v-model.number="formData[item.setting_id]"
v-prevent-keyboard
style="width: 80%"
type="number"
:name="item.setting_id"
:controls="false"
>
<ft-input v-model="formData[item.setting_id]" style="width: 80%" layout-name="number">
<template v-if="labelUnitMap[item.setting_id]" #append> <template v-if="labelUnitMap[item.setting_id]" #append>
{{ labelUnitMap[item.setting_id] }} {{ labelUnitMap[item.setting_id] }}
</template> </template>
</el-input>
</ft-input>
</template> </template>
<template v-if="item.val_type === 'float'"> <template v-if="item.val_type === 'float'">
<el-input
v-model.number="formData[item.setting_id]"
v-prevent-keyboard
style="width: 80%"
type="number"
:name="item.setting_id"
:controls="false"
>
<ft-input v-model.number="formData[item.setting_id]" layout-name="number" style="width: 80%" type="number">
<template v-if="labelUnitMap[item.setting_id]" #append> <template v-if="labelUnitMap[item.setting_id]" #append>
{{ labelUnitMap[item.setting_id] }} {{ labelUnitMap[item.setting_id] }}
</template> </template>
</el-input>
</ft-input>
</template> </template>
<template v-else-if="item.val_type === 'enum'"> <template v-else-if="item.val_type === 'enum'">
<el-select <el-select
@ -339,6 +319,9 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
text-align: left; text-align: left;
height: 40px; height: 40px;
} }
:deep(.el-select__wrapper) {
height: 40px;
}
:deep(.el-form-item) { :deep(.el-form-item) {
margin-right: 0; margin-right: 0;
align-items: center; align-items: center;

10
src/main.ts

@ -5,6 +5,7 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import BTButton from 'components/common/BTButton/index.vue' import BTButton from 'components/common/BTButton/index.vue'
import FtButton from 'components/common/FTButton/index.vue' import FtButton from 'components/common/FTButton/index.vue'
import FtDialog from 'components/common/FTDialog/index.vue' import FtDialog from 'components/common/FTDialog/index.vue'
import FtInput from 'components/common/FTInput/index.vue'
import FtTable from 'components/common/FTTable/index.vue' import FtTable from 'components/common/FTTable/index.vue'
import ElementPlus from 'element-plus' import ElementPlus from 'element-plus'
import locale from 'element-plus/es/locale/lang/zh-cn' import locale from 'element-plus/es/locale/lang/zh-cn'
@ -27,7 +28,7 @@ const i18n = createI18n<{
} }
}>({ }>({
legacy: false, legacy: false,
locale: localStorage.getItem('locale') as LocaleType || defaultLocale,
locale: (localStorage.getItem('locale') as LocaleType) || defaultLocale,
fallbackLocale: 'en', fallbackLocale: 'en',
messages, messages,
}) })
@ -50,8 +51,5 @@ app.component('BtButton', BTButton)
app.component('FtTable', FtTable) app.component('FtTable', FtTable)
app.component('FtButton', FtButton) app.component('FtButton', FtButton)
app.component('FtDialog', FtDialog) app.component('FtDialog', FtDialog)
app
.use(router)
.use(i18n)
.use(ElementPlus, { locale, zIndex: 3000 })
.mount('#app')
app.component('FtInput', FtInput)
app.use(router).use(i18n).use(ElementPlus, { locale, zIndex: 3000 }).mount('#app')
Loading…
Cancel
Save