char字段聚焦全选功能已完成
This commit is contained in:
84
sf_warehouse/static/src/js/cust_char.js
Normal file
84
sf_warehouse/static/src/js/cust_char.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { CharField } from '@web/views/fields/char/char_field';
|
||||
|
||||
|
||||
|
||||
// 继承CharField组件实现自定义组件:当光标聚焦于输入框时,选中输入框内容
|
||||
class CustomChar extends CharField {
|
||||
/**
|
||||
* @override
|
||||
* @private
|
||||
* @param {MouseEvent} ev
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
onMounted() {
|
||||
super.onMounted();
|
||||
console.log('CustomChar.onMounted1');
|
||||
// 当光标聚焦于输入框时,选中输入框内容
|
||||
this.input.el.addEventListener('focus', function () {
|
||||
this.select();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// setup() {
|
||||
// console.log('CustomChar.setup1');
|
||||
// alert('CustomChar.setup1');
|
||||
// super.setup();
|
||||
// console.log(this)
|
||||
// console.log('this.input', typeof this.input.el)
|
||||
// console.log('this.props', this.props)
|
||||
// console.log('this.props', this.props['value'])
|
||||
// console.log('this.instanse', this.instance)
|
||||
// console.log('this.el', this.el)
|
||||
// console.log('9999999999',this)
|
||||
// // this.input.el.addEventListener('focus', function() {
|
||||
// // console.log('1233333333333')
|
||||
// // })
|
||||
// }
|
||||
//
|
||||
// async willStart() {
|
||||
// console.log('CustomChar.willStart1');
|
||||
// alert('CustomChar.willStart1');
|
||||
// await super.willStart();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// mounted() {
|
||||
// console.log('CustomChar.mounted1');
|
||||
// // Now, the component's DOM element should be available
|
||||
// const inputElement = this.el.querySelector('input');
|
||||
// // if (inputElement) {
|
||||
// // inputElement.addEventListener('focus', function() {
|
||||
// // this.select();
|
||||
// // });
|
||||
// // }
|
||||
// }
|
||||
|
||||
// setup() {
|
||||
// console.log('CustomChar.setup1');
|
||||
// alert('CustomChar.setup1');
|
||||
// super.setup();
|
||||
//
|
||||
// // 查找输入元素
|
||||
// const inputElement = this.el.querySelector('input');
|
||||
// if (inputElement) {
|
||||
// inputElement.addEventListener('focus', function() {
|
||||
// this.select();
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// this.$input.on('focus', function () {
|
||||
// $(this).select();
|
||||
// });
|
||||
|
||||
|
||||
// 当光标聚焦于输入框时,选中输入框内容
|
||||
|
||||
}
|
||||
|
||||
registry.category("fields").add("custom_char", CustomChar);
|
||||
Reference in New Issue
Block a user