82 lines
2.2 KiB
JavaScript
82 lines
2.2 KiB
JavaScript
/** @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;
|
|
|