char字段聚焦全选功能已完成

This commit is contained in:
mgw
2023-08-11 12:22:59 +08:00
parent fc490f1612
commit 68805fee4a
3 changed files with 166 additions and 1 deletions

View File

@@ -0,0 +1,81 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { Many2OneField } from '@web/views/fields/many2one/many2one_field';
// 继承FieldMany2One组件实现自定义组件:当光标聚焦于输入框时,选中输入框内容
class CustomMany2One extends Many2OneField {
/**
* @override
* @private
* @param {MouseEvent} ev
* @returns {Promise}
*/
setup() {
console.log('CustomMany2One.setup11111111111111');
super.setup();
}
onMounted() {
console.log('CustomMany2One.onMounted1');
// 当光标聚焦于输入框时,选中输入框内容
this.input.el.addEventListener('focus', function () {
this.select();
})
}
}
registry.category("fields").add("custom_many2one", CustomMany2One);
// /** @odoo-module **/
//
// import { registry } from "@web/core/registry";
// // import { field_registry } from '@web/legacy/js/fields/field_registry';
// // import { FieldMany2One } from '@web/legacy/js/fields/relational_fields';
// import { Many2OneField } from '@web/views/fields/many2one/many2one_field';
//
//
// // 继承FieldMany2One组件实现自定义组件:当光标聚焦于输入框时,选中输入框内容
// class CustomMany2One extends Many2OneField {
// /**
// * @override
// * @private
// * @param {MouseEvent} ev
// * @returns {Promise}
// */
// setup() {
// console.log('CustomMany2One.setup11111111111111');
// super.setup();
// }
// onClick(ev) {
// super.onClick(ev);
// console.log('CustomMany2One._onInputClick');
//
// this.$input.select();
// }
//
// }
//
// // field_registry.add('custom_many2one', CustomMany2One);
// registry.category("fields").add("custom_many2one", CustomMany2One);
// const CustomMany2One = FieldMany2One.extend({
// /**
// * @override
// * @private
// * @param {MouseEvent} ev
// * @returns {Promise}
// */
// _onInputClick: function (ev) {
// console.log('CustomMany2One._onInputClick');
// this._super.apply(this, arguments);
// this.$input.select();
// }
// });
//
// field_registry.add('custom_many2one', CustomMany2One);
// export default CustomMany2One;