|
@@ -1031,4 +1031,62 @@ export function evalFunction(data, express) {
|
|
|
} catch (e) {
|
|
|
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
|
|
|
+ }
|
|
|
}
|