|
@@ -528,6 +528,23 @@ export function normId(value: string) {
|
|
return _.replace(value, /[^\w]/g, '_')
|
|
return _.replace(value, /[^\w]/g, '_')
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ * @param sender
|
|
|
|
+ * @param propertyName
|
|
|
|
+ * @param gridRefName
|
|
|
|
+ */
|
|
|
|
+export function clearViewModelReloadGrid(sender, propertyName, gridRefName){
|
|
|
|
+ const scope = lookupScope(sender)
|
|
|
|
+ clearViewModelValues(scope.viewModel, propertyName)
|
|
|
|
+ if (!gridRefName) {
|
|
|
|
+ scope.down('grid')?.reload()
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ scope.refs[gridRefName]?.reload()
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
export class SystemEventFu {
|
|
export class SystemEventFu {
|
|
@Lib({
|
|
@Lib({
|
|
title: '弹出确认对话框,回答 YES 之后调用某方法',
|
|
title: '弹出确认对话框,回答 YES 之后调用某方法',
|
|
@@ -783,14 +800,7 @@ export class SystemEventFu {
|
|
clearViewModelReloadGrid(@LibParam('清空的属性', 'viewModel')propertyName: string,
|
|
clearViewModelReloadGrid(@LibParam('清空的属性', 'viewModel')propertyName: string,
|
|
@LibParam('要刷新的表格', 'refs', true)gridRefName?: string) {
|
|
@LibParam('要刷新的表格', 'refs', true)gridRefName?: string) {
|
|
return function (sender) {
|
|
return function (sender) {
|
|
- const scope = lookupScope(sender)
|
|
|
|
- clearViewModelValues(scope.viewModel, propertyName)
|
|
|
|
- if (!gridRefName) {
|
|
|
|
- scope.down('grid')?.reload()
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- scope.refs[gridRefName]?.reload()
|
|
|
|
- }
|
|
|
|
|
|
+ clearViewModelReloadGrid(sender, propertyName, gridRefName)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1021,4 +1031,62 @@ export function evalFunction(data, express) {
|
|
} catch (e) {
|
|
} catch (e) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 获取表格编辑的行数据
|
|
|
|
+ */
|
|
|
|
+export function getGridEditRows(grid) {
|
|
|
|
+ const store = grid.getStore()
|
|
|
|
+ const rows = []
|
|
|
|
+ const modifyRows = []
|
|
|
|
+ const newRows = []
|
|
|
|
+ let err = ""
|
|
|
|
+ const records = store.getModifiedRecords()
|
|
|
|
+ const newRecords = store.getNewRecords()
|
|
|
|
+ _.forEach(records, (record) => {
|
|
|
|
+ const colums = grid.columns
|
|
|
|
+ let errFunc = undefined
|
|
|
|
+ _.forEach(colums, (col) => {
|
|
|
|
+ const name = col.dataIndex
|
|
|
|
+ const value = record.data[name]
|
|
|
|
+ const colIndex = col.getIndex()//获得列号
|
|
|
|
+ const rowIndex = store.indexOfId(record.id)//获得行号
|
|
|
|
+ const editor = col.getEditor()//使用的编辑器
|
|
|
|
+ let tmpErrFunc = () => {
|
|
|
|
+ grid.findPlugin('cellediting').startEdit(rowIndex, colIndex - 1)//如果不通过激活当前编辑状态
|
|
|
|
+ }
|
|
|
|
+ if (editor && !editor.allowBlank && !value) {
|
|
|
|
+ errFunc = tmpErrFunc
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if (editor && value && !editor.validateValue(value)) {
|
|
|
|
+ errFunc = tmpErrFunc
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if (errFunc) {
|
|
|
|
+ err = "1"
|
|
|
|
+ _.remove(rows, (n) => {
|
|
|
|
+ return true;
|
|
|
|
+ });
|
|
|
|
+ msg("请确保输入的数据正确")
|
|
|
|
+ errFunc()
|
|
|
|
+ // Ext.Msg.alert('提示', '请确保输入的数据正确', errFunc)
|
|
|
|
+ return false
|
|
|
|
+ } else {
|
|
|
|
+ if (_.findIndex(newRecords, (item)=>{return item === record}) >= 0) {
|
|
|
|
+ newRows.push(record.data)
|
|
|
|
+ } else {
|
|
|
|
+ modifyRows.push(record.data)
|
|
|
|
+ }
|
|
|
|
+ rows.push(record.data)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return {
|
|
|
|
+ rows: rows,
|
|
|
|
+ newRows,
|
|
|
|
+ modifyRows,
|
|
|
|
+ err: err
|
|
|
|
+ }
|
|
}
|
|
}
|