|
@@ -1,6 +1,7 @@
|
|
|
import _ from 'lodash'
|
|
|
import {comboGrid, comboGridPicker} from '../../Defaults'
|
|
|
import {calcObjectFlat, clearViewModelByLookup, lookupScope, stopEvent, tryWriteByExpress, tryWriteObject} from "../..";
|
|
|
+import {msg} from "../../message";
|
|
|
|
|
|
export default function () {
|
|
|
|
|
@@ -42,19 +43,36 @@ export default function () {
|
|
|
},
|
|
|
afterrender(sender) {
|
|
|
const $dom = $(sender.inputEl.dom)
|
|
|
- $dom.on('keyup', (e) => {
|
|
|
- if (e.key === 'Enter') {
|
|
|
- that.onTriggerClick(that, that.getPickerTrigger(), e);
|
|
|
- return
|
|
|
- }
|
|
|
- // 取消 keyup 事件,让 ext 不要吧当前输入的值记录到 value 中
|
|
|
- stopEvent(e)
|
|
|
- })
|
|
|
+ if (sender.column) {
|
|
|
+ // 列模式,拦截 keydown
|
|
|
+ $dom.on('keydown', (e) => {
|
|
|
+ if (e.key === 'Enter') {
|
|
|
+ stopEvent(e)
|
|
|
+ that.onTriggerClick(that, that.getPickerTrigger(), e);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 常规模式,拦截 keyup
|
|
|
+ $dom.on('keyup', (e) => {
|
|
|
+ if (e.key === 'Enter') {
|
|
|
+ stopEvent(e)
|
|
|
+ that.onTriggerClick(that, that.getPickerTrigger(), e);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 取消 keyup 事件,让 ext 不要吧当前输入的值记录到 value 中
|
|
|
+ stopEvent(e)
|
|
|
+ })
|
|
|
+ }
|
|
|
$dom.on('input', e => {
|
|
|
- that.filterChange(that, e.target.value)
|
|
|
+ // that.filterChange(that, e.target.value)
|
|
|
stopEvent(e)
|
|
|
})
|
|
|
$dom.on('change', e => {
|
|
|
+ if (that.isExpanded) {
|
|
|
+ that.filterChange(that, e.target.value)
|
|
|
+ }
|
|
|
stopEvent(e)
|
|
|
})
|
|
|
},
|
|
@@ -113,8 +131,17 @@ export default function () {
|
|
|
me.setFocus()
|
|
|
})
|
|
|
},
|
|
|
+ keydown(sender, e) {
|
|
|
+ if (me.column) {
|
|
|
+ // 列模式,拦截 keydown
|
|
|
+ me.processKey(e)
|
|
|
+ }
|
|
|
+ },
|
|
|
keyup(sender, e) {
|
|
|
- me.processKey(e)
|
|
|
+ if (!me.column) {
|
|
|
+ // 常规模式,拦截 keyup
|
|
|
+ me.processKey(e)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -174,11 +201,22 @@ export default function () {
|
|
|
if (record.isModel) {
|
|
|
record = record.data
|
|
|
}
|
|
|
+
|
|
|
tryWriteObject(lookup, record, (path, value) => {
|
|
|
if (path === 'queryValue') {
|
|
|
me.setValue(value)
|
|
|
} else {
|
|
|
- scope.viewModel.set(path, value)
|
|
|
+ if (me.column) {
|
|
|
+ // 列模式下,写当前编辑行
|
|
|
+ const parentGrid = me.column.up('grid')
|
|
|
+ const parentRecord = parentGrid.getSelectionModel().getLastSelected()
|
|
|
+ // Ext.data.Record / Ext.data.Model
|
|
|
+ parentRecord.set(path, value)
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 常规模式下,写 viewModel
|
|
|
+ scope.viewModel.set(path, value)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -189,20 +227,30 @@ export default function () {
|
|
|
// 展开时,根据 lookup 带入查询参数
|
|
|
const {param} = this
|
|
|
const scope = lookupScope(this)
|
|
|
+ const queryValue = this.getRawValue()
|
|
|
+
|
|
|
const reloadParam = calcObjectFlat({
|
|
|
...scope.viewModel.data,
|
|
|
- queryValue: this.getRawValue()
|
|
|
+ queryValue
|
|
|
}, param)
|
|
|
|
|
|
+ console.log('reload', reloadParam)
|
|
|
this.grid.reload(reloadParam)
|
|
|
},
|
|
|
|
|
|
onTriggerClick() {
|
|
|
- const {isExpanded, readOnly, disabled} = this
|
|
|
+ const {isExpanded, readOnly, disabled, grid} = this
|
|
|
+
|
|
|
+ if (!grid) {
|
|
|
+ msg('正在初始化,请稍后')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (isExpanded || readOnly || disabled) {
|
|
|
// 已弹出、只读、禁用状态下,不允许弹出
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
this._superBlur = true
|
|
|
this.superclass.onTriggerClick.apply(this, arguments)
|
|
|
this._superBlur = false
|