mixin.js 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _xeUtils = _interopRequireDefault(require("xe-utils"));
  7. var _ui = require("../../../ui");
  8. var _utils = require("../../../ui/src/utils");
  9. var _util = require("../../src/util");
  10. var _dom = require("../../../ui/src/dom");
  11. var _log = require("../../../ui/src/log");
  12. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  13. const {
  14. getConfig,
  15. renderer,
  16. getI18n
  17. } = _ui.VxeUI;
  18. const browseObj = _xeUtils.default.browse();
  19. function getEditColumnModel(row, column) {
  20. const {
  21. model,
  22. editRender
  23. } = column;
  24. if (editRender) {
  25. model.value = (0, _util.getCellValue)(row, column);
  26. model.update = false;
  27. }
  28. }
  29. function setEditColumnModel(row, column) {
  30. const {
  31. model,
  32. editRender
  33. } = column;
  34. if (editRender && model.update) {
  35. (0, _util.setCellValue)(row, column, model.value);
  36. model.update = false;
  37. model.value = null;
  38. }
  39. }
  40. function removeCellSelectedClass($xeTable) {
  41. const el = $xeTable.$refs.refElem;
  42. if (el) {
  43. const cell = el.querySelector('.col--selected');
  44. if (cell) {
  45. (0, _dom.removeClass)(cell, 'col--selected');
  46. }
  47. }
  48. }
  49. function syncActivedCell($xeTable) {
  50. const reactData = $xeTable;
  51. const {
  52. editStore,
  53. tableColumn
  54. } = reactData;
  55. const editOpts = $xeTable.computeEditOpts;
  56. const {
  57. actived
  58. } = editStore;
  59. const {
  60. row,
  61. column
  62. } = actived;
  63. if (row || column) {
  64. if (editOpts.mode === 'row') {
  65. tableColumn.forEach(column => setEditColumnModel(row, column));
  66. } else {
  67. setEditColumnModel(row, column);
  68. }
  69. }
  70. }
  71. function insertTreeRow($xeTable, newRecords, isAppend) {
  72. const internalData = $xeTable;
  73. const {
  74. tableFullTreeData,
  75. afterFullData,
  76. fullDataRowIdData,
  77. fullAllDataRowIdData
  78. } = internalData;
  79. const treeOpts = $xeTable.computeTreeOpts;
  80. const {
  81. rowField,
  82. parentField,
  83. mapChildrenField
  84. } = treeOpts;
  85. const childrenField = treeOpts.children || treeOpts.childrenField;
  86. const funcName = isAppend ? 'push' : 'unshift';
  87. newRecords.forEach(item => {
  88. const parentRowId = item[parentField];
  89. const rowid = (0, _util.getRowid)($xeTable, item);
  90. const matchObj = parentRowId ? _xeUtils.default.findTree(tableFullTreeData, item => parentRowId === item[rowField], {
  91. children: mapChildrenField
  92. }) : null;
  93. if (matchObj) {
  94. const {
  95. item: parentRow
  96. } = matchObj;
  97. const parentRest = fullAllDataRowIdData[(0, _util.getRowid)($xeTable, parentRow)];
  98. const parentLevel = parentRest ? parentRest.level : 0;
  99. let parentChilds = parentRow[childrenField];
  100. let mapChilds = parentRow[mapChildrenField];
  101. if (!_xeUtils.default.isArray(parentChilds)) {
  102. parentChilds = parentRow[childrenField] = [];
  103. }
  104. if (!_xeUtils.default.isArray(mapChilds)) {
  105. mapChilds = parentRow[childrenField] = [];
  106. }
  107. parentChilds[funcName](item);
  108. mapChilds[funcName](item);
  109. const rest = {
  110. row: item,
  111. rowid,
  112. seq: -1,
  113. index: -1,
  114. _index: -1,
  115. $index: -1,
  116. treeIndex: -1,
  117. _tIndex: -1,
  118. items: parentChilds,
  119. parent: parentRow,
  120. level: parentLevel + 1,
  121. height: 0,
  122. resizeHeight: 0,
  123. oTop: 0,
  124. expandHeight: 0
  125. };
  126. fullDataRowIdData[rowid] = rest;
  127. fullAllDataRowIdData[rowid] = rest;
  128. } else {
  129. if (parentRowId) {
  130. (0, _log.warnLog)('vxe.error.unableInsert');
  131. }
  132. afterFullData[funcName](item);
  133. tableFullTreeData[funcName](item);
  134. const rest = {
  135. row: item,
  136. rowid,
  137. seq: -1,
  138. index: -1,
  139. _index: -1,
  140. $index: -1,
  141. treeIndex: -1,
  142. _tIndex: -1,
  143. items: tableFullTreeData,
  144. parent: null,
  145. level: 0,
  146. height: 0,
  147. resizeHeight: 0,
  148. oTop: 0,
  149. expandHeight: 0
  150. };
  151. fullDataRowIdData[rowid] = rest;
  152. fullAllDataRowIdData[rowid] = rest;
  153. }
  154. });
  155. }
  156. // function insertGroupRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, newRecords: any[], isAppend: boolean) {
  157. // }
  158. function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
  159. const props = $xeTable;
  160. const reactData = $xeTable;
  161. const internalData = $xeTable;
  162. const {
  163. treeConfig
  164. } = props;
  165. const {
  166. isRowGroupStatus
  167. } = reactData;
  168. const {
  169. tableFullTreeData,
  170. afterFullData,
  171. mergeBodyList,
  172. tableFullData,
  173. fullDataRowIdData,
  174. fullAllDataRowIdData,
  175. insertRowMaps,
  176. removeRowMaps
  177. } = internalData;
  178. const treeOpts = $xeTable.computeTreeOpts;
  179. const {
  180. transform,
  181. parentField,
  182. rowField,
  183. mapChildrenField
  184. } = treeOpts;
  185. const childrenField = treeOpts.children || treeOpts.childrenField;
  186. if (!_xeUtils.default.isArray(records)) {
  187. records = [records];
  188. }
  189. const newRecords = $xeTable.defineField(records.map(record => Object.assign(treeConfig && transform ? {
  190. [mapChildrenField]: [],
  191. [childrenField]: []
  192. } : {}, record)));
  193. let treeRecords = [];
  194. if (treeConfig && transform) {
  195. treeRecords = _xeUtils.default.toArrayTree(newRecords, {
  196. key: rowField,
  197. parentKey: parentField,
  198. children: childrenField
  199. });
  200. }
  201. if (_xeUtils.default.eqNull(targetRow)) {
  202. // 如果为虚拟树
  203. if (treeConfig && transform) {
  204. insertTreeRow($xeTable, newRecords, false);
  205. } else if (isRowGroupStatus) {
  206. // 如果分组
  207. if (treeConfig) {
  208. throw new Error(getI18n('vxe.error.noTree', ['insert']));
  209. }
  210. (0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
  211. // insertGroupRow($xeTable, newRecords, false)
  212. } else {
  213. newRecords.forEach(item => {
  214. const rowid = (0, _util.getRowid)($xeTable, item);
  215. const rest = {
  216. row: item,
  217. rowid,
  218. seq: -1,
  219. index: -1,
  220. _index: -1,
  221. $index: -1,
  222. treeIndex: -1,
  223. _tIndex: -1,
  224. items: afterFullData,
  225. parent: null,
  226. level: 0,
  227. height: 0,
  228. resizeHeight: 0,
  229. oTop: 0,
  230. expandHeight: 0
  231. };
  232. fullDataRowIdData[rowid] = rest;
  233. fullAllDataRowIdData[rowid] = rest;
  234. afterFullData.unshift(item);
  235. tableFullData.unshift(item);
  236. });
  237. // 刷新单元格合并
  238. mergeBodyList.forEach(mergeItem => {
  239. const {
  240. row: mergeRowIndex
  241. } = mergeItem;
  242. if (mergeRowIndex >= 0) {
  243. mergeItem.row = mergeRowIndex + newRecords.length;
  244. }
  245. });
  246. }
  247. } else {
  248. if (targetRow === -1) {
  249. // 如果为虚拟树
  250. if (treeConfig && transform) {
  251. insertTreeRow($xeTable, newRecords, true);
  252. } else if (isRowGroupStatus) {
  253. // 如果分组
  254. if (treeConfig) {
  255. throw new Error(getI18n('vxe.error.noTree', ['insert']));
  256. }
  257. (0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
  258. // insertGroupRow($xeTable, newRecords, true)
  259. } else {
  260. newRecords.forEach(item => {
  261. const rowid = (0, _util.getRowid)($xeTable, item);
  262. const rest = {
  263. row: item,
  264. rowid,
  265. seq: -1,
  266. index: -1,
  267. _index: -1,
  268. $index: -1,
  269. treeIndex: -1,
  270. _tIndex: -1,
  271. items: afterFullData,
  272. parent: null,
  273. level: 0,
  274. height: 0,
  275. resizeHeight: 0,
  276. oTop: 0,
  277. expandHeight: 0
  278. };
  279. fullDataRowIdData[rowid] = rest;
  280. fullAllDataRowIdData[rowid] = rest;
  281. afterFullData.push(item);
  282. tableFullData.push(item);
  283. });
  284. }
  285. } else {
  286. // 如果为虚拟树
  287. if (treeConfig && transform) {
  288. const matchMapObj = _xeUtils.default.findTree(tableFullTreeData, item => targetRow[rowField] === item[rowField], {
  289. children: mapChildrenField
  290. });
  291. if (matchMapObj) {
  292. const {
  293. parent: parentRow
  294. } = matchMapObj;
  295. const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData;
  296. const parentRest = fullAllDataRowIdData[(0, _util.getRowid)($xeTable, parentRow)];
  297. const parentLevel = parentRest ? parentRest.level : 0;
  298. treeRecords.forEach((row, i) => {
  299. if (parentRow) {
  300. if (row[parentField] !== parentRow[rowField]) {
  301. row[parentField] = parentRow[rowField];
  302. (0, _log.errLog)('vxe.error.errProp', [`${parentField}=${row[parentField]}`, `${parentField}=${parentRow[rowField]}`]);
  303. }
  304. } else {
  305. if (row[parentField] !== null) {
  306. row[parentField] = null;
  307. (0, _log.errLog)('vxe.error.errProp', [`${parentField}=${row[parentField]}`, 'null']);
  308. }
  309. }
  310. let targetIndex = matchMapObj.index + i;
  311. if (isInsertNextRow) {
  312. targetIndex = targetIndex + 1;
  313. }
  314. parentMapChilds.splice(targetIndex, 0, row);
  315. });
  316. _xeUtils.default.eachTree(treeRecords, item => {
  317. const rowid = (0, _util.getRowid)($xeTable, item);
  318. const rest = {
  319. row: item,
  320. rowid,
  321. seq: -1,
  322. index: -1,
  323. _index: -1,
  324. $index: -1,
  325. treeIndex: -1,
  326. _tIndex: -1,
  327. items: parentMapChilds,
  328. parent: parentRow,
  329. level: parentLevel + 1,
  330. height: 0,
  331. resizeHeight: 0,
  332. oTop: 0,
  333. expandHeight: 0
  334. };
  335. if (item[childrenField]) {
  336. item[mapChildrenField] = item[childrenField];
  337. }
  338. fullDataRowIdData[rowid] = rest;
  339. fullAllDataRowIdData[rowid] = rest;
  340. }, {
  341. children: childrenField
  342. });
  343. // 源
  344. if (parentRow) {
  345. const matchObj = _xeUtils.default.findTree(tableFullTreeData, item => targetRow[rowField] === item[rowField], {
  346. children: childrenField
  347. });
  348. if (matchObj) {
  349. const parentChilds = matchObj.items;
  350. let targetIndex = matchObj.index;
  351. if (isInsertNextRow) {
  352. targetIndex = targetIndex + 1;
  353. }
  354. parentChilds.splice(targetIndex, 0, ...treeRecords);
  355. }
  356. }
  357. } else {
  358. (0, _log.warnLog)('vxe.error.unableInsert');
  359. insertTreeRow($xeTable, newRecords, true);
  360. }
  361. } else if (isRowGroupStatus) {
  362. // 如果分组
  363. if (treeConfig) {
  364. throw new Error(getI18n('vxe.error.noTree', ['insert']));
  365. }
  366. (0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
  367. } else {
  368. if (treeConfig) {
  369. throw new Error(getI18n('vxe.error.noTree', ['insert']));
  370. }
  371. let afIndex = -1;
  372. // 如果是可视索引
  373. if (_xeUtils.default.isNumber(targetRow)) {
  374. if (targetRow < afterFullData.length) {
  375. afIndex = targetRow;
  376. }
  377. } else {
  378. afIndex = $xeTable.findRowIndexOf(afterFullData, targetRow);
  379. }
  380. // 如果是插入指定行的下一行
  381. if (isInsertNextRow) {
  382. afIndex = Math.min(afterFullData.length, afIndex + 1);
  383. }
  384. if (afIndex === -1) {
  385. throw new Error(getI18n('vxe.error.unableInsert'));
  386. }
  387. afterFullData.splice(afIndex, 0, ...newRecords);
  388. const tfIndex = $xeTable.findRowIndexOf(tableFullData, targetRow);
  389. if (tfIndex > -1) {
  390. tableFullData.splice(tfIndex + (isInsertNextRow ? 1 : 0), 0, ...newRecords);
  391. } else {
  392. tableFullData.push(...newRecords);
  393. }
  394. // 刷新单元格合并
  395. mergeBodyList.forEach(mergeItem => {
  396. const {
  397. row: mergeRowIndex,
  398. rowspan: mergeRowspan
  399. } = mergeItem;
  400. if (mergeRowIndex >= afIndex) {
  401. mergeItem.row = mergeRowIndex + newRecords.length;
  402. } else if (isInsertNextRow ? mergeRowIndex + mergeRowspan >= afIndex : mergeRowIndex + mergeRowspan > afIndex) {
  403. mergeItem.rowspan = mergeRowspan + newRecords.length;
  404. }
  405. });
  406. }
  407. }
  408. }
  409. const handleStatus = newRow => {
  410. const rowid = (0, _util.getRowid)($xeTable, newRow);
  411. // 如果是被删除的数据,则还原状态
  412. if (removeRowMaps[rowid]) {
  413. delete removeRowMaps[rowid];
  414. if (insertRowMaps[rowid]) {
  415. delete insertRowMaps[rowid];
  416. }
  417. } else {
  418. insertRowMaps[rowid] = newRow;
  419. }
  420. };
  421. // 如果为虚拟树
  422. if (treeConfig && transform) {
  423. _xeUtils.default.eachTree(treeRecords, handleStatus, {
  424. children: mapChildrenField
  425. });
  426. } else {
  427. newRecords.forEach(handleStatus);
  428. }
  429. reactData.removeRowFlag++;
  430. reactData.insertRowFlag++;
  431. $xeTable.cacheRowMap(false);
  432. $xeTable.updateScrollYStatus();
  433. $xeTable.handleTableData(treeConfig && transform);
  434. if (!(treeConfig && transform)) {
  435. $xeTable.updateAfterDataIndex();
  436. }
  437. $xeTable.updateFooter();
  438. $xeTable.handleUpdateBodyMerge();
  439. $xeTable.checkSelectionStatus();
  440. if (reactData.scrollYLoad) {
  441. $xeTable.updateScrollYSpace();
  442. }
  443. return $xeTable.$nextTick().then(() => {
  444. $xeTable.updateCellAreas();
  445. return $xeTable.recalculate(true);
  446. }).then(() => {
  447. return {
  448. row: newRecords.length ? newRecords[newRecords.length - 1] : null,
  449. rows: newRecords
  450. };
  451. });
  452. }
  453. function handleInsertChildRowAt($xeTable, records, parentRow, targetRow, isInsertNextRow) {
  454. const props = $xeTable;
  455. const {
  456. treeConfig
  457. } = props;
  458. const treeOpts = $xeTable.computeTreeOpts;
  459. const {
  460. transform,
  461. rowField,
  462. parentField
  463. } = treeOpts;
  464. if (treeConfig && transform) {
  465. if (!_xeUtils.default.isArray(records)) {
  466. records = [records];
  467. }
  468. return handleInsertRowAt($xeTable, records.map(item => Object.assign({}, item, {
  469. [parentField]: parentRow[rowField]
  470. })), targetRow, isInsertNextRow);
  471. } else {
  472. (0, _log.errLog)('vxe.error.errProp', ['tree-config.transform=false', 'tree-config.transform=true']);
  473. }
  474. return Promise.resolve({
  475. row: null,
  476. rows: []
  477. });
  478. }
  479. function handleClearEdit($xeTable, evnt, targetRow) {
  480. const reactData = $xeTable;
  481. const {
  482. editStore
  483. } = reactData;
  484. const {
  485. actived,
  486. focused
  487. } = editStore;
  488. const {
  489. row,
  490. column
  491. } = actived;
  492. const validOpts = $xeTable.computeValidOpts;
  493. if (row || column) {
  494. if (targetRow && (0, _util.getRowid)($xeTable, targetRow) !== (0, _util.getRowid)($xeTable, row)) {
  495. return $xeTable.$nextTick();
  496. }
  497. syncActivedCell($xeTable);
  498. actived.args = null;
  499. actived.row = null;
  500. actived.column = null;
  501. $xeTable.updateFooter();
  502. $xeTable.dispatchEvent('edit-closed', {
  503. row,
  504. rowIndex: $xeTable.getRowIndex(row),
  505. $rowIndex: $xeTable.getVMRowIndex(row),
  506. column,
  507. columnIndex: $xeTable.getColumnIndex(column),
  508. $columnIndex: $xeTable.getVMColumnIndex(column)
  509. }, evnt || null);
  510. }
  511. focused.row = null;
  512. focused.column = null;
  513. if (validOpts.autoClear) {
  514. if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
  515. if ($xeTable.clearValidate) {
  516. return $xeTable.clearValidate();
  517. }
  518. }
  519. }
  520. return $xeTable.$nextTick().then(() => $xeTable.updateCellAreas());
  521. }
  522. function handleEditActive($xeTable, params, evnt, isFocus, isPos) {
  523. const props = $xeTable;
  524. const reactData = $xeTable;
  525. const $xeGrid = $xeTable.$xeGrid;
  526. const {
  527. editConfig,
  528. mouseConfig
  529. } = props;
  530. const {
  531. editStore,
  532. tableColumn
  533. } = reactData;
  534. const editOpts = $xeTable.computeEditOpts;
  535. const {
  536. mode
  537. } = editOpts;
  538. const {
  539. actived,
  540. focused
  541. } = editStore;
  542. const {
  543. row,
  544. column
  545. } = params;
  546. const {
  547. editRender
  548. } = column;
  549. const cell = params.cell || $xeTable.getCellElement(row, column);
  550. const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
  551. params.cell = cell;
  552. if (cell && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(editRender)) {
  553. // 激活编辑
  554. if (!$xeTable.isPendingByRow(row) && !$xeTable.isAggregateRecord(row)) {
  555. if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
  556. // 判断是否禁用编辑
  557. let type = 'edit-disabled';
  558. if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), {
  559. $table: $xeTable,
  560. $grid: $xeGrid
  561. }))) {
  562. if (mouseConfig) {
  563. $xeTable.clearSelected();
  564. if ($xeTable.clearCellAreas) {
  565. $xeTable.clearCellAreas();
  566. $xeTable.clearCopyCellArea();
  567. }
  568. }
  569. $xeTable.closeTooltip();
  570. if (actived.column) {
  571. handleClearEdit($xeTable, evnt);
  572. }
  573. type = 'edit-activated';
  574. column.renderHeight = cell.offsetHeight;
  575. actived.args = params;
  576. actived.row = row;
  577. actived.column = column;
  578. if (mode === 'row') {
  579. tableColumn.forEach(column => getEditColumnModel(row, column));
  580. } else {
  581. getEditColumnModel(row, column);
  582. }
  583. const afterEditMethod = editOpts.afterEditMethod;
  584. $xeTable.$nextTick(() => {
  585. if (isFocus) {
  586. $xeTable.handleFocus(params, evnt);
  587. }
  588. if (afterEditMethod) {
  589. afterEditMethod(Object.assign(Object.assign({}, params), {
  590. $table: $xeTable,
  591. $grid: $xeGrid
  592. }));
  593. }
  594. });
  595. }
  596. $xeTable.dispatchEvent(type, {
  597. row,
  598. rowIndex: $xeTable.getRowIndex(row),
  599. $rowIndex: $xeTable.getVMRowIndex(row),
  600. column,
  601. columnIndex: $xeTable.getColumnIndex(column),
  602. $columnIndex: $xeTable.getVMColumnIndex(column)
  603. }, evnt);
  604. // v4已废弃
  605. if (type === 'edit-activated') {
  606. $xeTable.dispatchEvent('edit-actived', {
  607. row,
  608. rowIndex: $xeTable.getRowIndex(row),
  609. $rowIndex: $xeTable.getVMRowIndex(row),
  610. column,
  611. columnIndex: $xeTable.getColumnIndex(column),
  612. $columnIndex: $xeTable.getVMColumnIndex(column)
  613. }, evnt);
  614. }
  615. } else {
  616. const {
  617. column: oldColumn
  618. } = actived;
  619. if (mouseConfig) {
  620. $xeTable.clearSelected();
  621. if ($xeTable.clearCellAreas) {
  622. $xeTable.clearCellAreas();
  623. $xeTable.clearCopyCellArea();
  624. }
  625. }
  626. if (oldColumn !== column) {
  627. const {
  628. model: oldModel
  629. } = oldColumn;
  630. if (oldModel.update) {
  631. (0, _util.setCellValue)(row, oldColumn, oldModel.value);
  632. }
  633. if ($xeTable.clearValidate) {
  634. $xeTable.clearValidate(row, column);
  635. }
  636. }
  637. column.renderHeight = cell.offsetHeight;
  638. actived.args = params;
  639. actived.column = column;
  640. if (isPos) {
  641. setTimeout(() => {
  642. $xeTable.handleFocus(params, evnt);
  643. });
  644. }
  645. }
  646. focused.column = null;
  647. focused.row = null;
  648. $xeTable.focus();
  649. }
  650. }
  651. return $xeTable.$nextTick();
  652. }
  653. function handleEditCell($xeTable, row, fieldOrColumn, isPos) {
  654. const props = $xeTable;
  655. const internalData = $xeTable;
  656. const {
  657. editConfig
  658. } = props;
  659. const column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
  660. if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender) && !$xeTable.isAggregateRecord(row)) {
  661. return Promise.resolve(isPos ? $xeTable.scrollToRow(row, column) : null).then(() => {
  662. const cell = $xeTable.getCellElement(row, column);
  663. if (cell) {
  664. handleEditActive($xeTable, {
  665. row,
  666. rowIndex: $xeTable.getRowIndex(row),
  667. column,
  668. columnIndex: $xeTable.getColumnIndex(column),
  669. cell,
  670. $table: $xeTable
  671. }, null, isPos, isPos);
  672. internalData._lastCallTime = Date.now();
  673. }
  674. return $xeTable.$nextTick();
  675. });
  676. }
  677. return $xeTable.$nextTick();
  678. }
  679. var _default = exports.default = {
  680. methods: {
  681. /**
  682. * 往表格中插入临时数据
  683. *
  684. * @param {*} records
  685. */
  686. _insert(records) {
  687. return handleInsertRowAt(this, records, null);
  688. },
  689. /**
  690. * 往表格指定行中插入临时数据
  691. * 如果 row 为空则从插入到顶部
  692. * 如果 row 为 -1 则从插入到底部
  693. * 如果 row 为有效行则插入到该行的位置
  694. * @param {Object/Array} records 新的数据
  695. * @param {Row} targetRow 指定行
  696. * @returns
  697. */
  698. _insertAt(records, targetRow) {
  699. return handleInsertRowAt(this, records, targetRow);
  700. },
  701. _insertNextAt(records, targetRow) {
  702. return handleInsertRowAt(this, records, targetRow, true);
  703. },
  704. _insertChild(records, parentRow) {
  705. return handleInsertChildRowAt(this, records, parentRow, null);
  706. },
  707. _insertChildAt(records, parentRow, targetRow) {
  708. return handleInsertChildRowAt(this, records, parentRow, targetRow);
  709. },
  710. _insertChildNextAt(records, parentRow, targetRow) {
  711. return handleInsertChildRowAt(this, records, parentRow, targetRow, true);
  712. },
  713. /**
  714. * 删除指定行数据
  715. * 如果传 row 则删除一行
  716. * 如果传 rows 则删除多行
  717. * 如果为空则删除所有
  718. */
  719. _remove(rows) {
  720. const $xeTable = this;
  721. const props = $xeTable;
  722. const reactData = $xeTable;
  723. const internalData = $xeTable;
  724. const {
  725. treeConfig
  726. } = props;
  727. const {
  728. editStore,
  729. isRowGroupStatus
  730. } = reactData;
  731. const {
  732. tableFullTreeData,
  733. selectCheckboxMaps,
  734. afterFullData,
  735. mergeBodyList,
  736. tableFullData,
  737. pendingRowMaps,
  738. insertRowMaps,
  739. removeRowMaps
  740. } = internalData;
  741. const checkboxOpts = $xeTable.computeCheckboxOpts;
  742. const treeOpts = $xeTable.computeTreeOpts;
  743. const {
  744. transform,
  745. mapChildrenField
  746. } = treeOpts;
  747. const childrenField = treeOpts.children || treeOpts.childrenField;
  748. const {
  749. actived
  750. } = editStore;
  751. const {
  752. checkField
  753. } = checkboxOpts;
  754. let delList = [];
  755. if (!rows) {
  756. rows = tableFullData;
  757. } else if (!_xeUtils.default.isArray(rows)) {
  758. rows = [rows];
  759. }
  760. // 如果是新增,则保存记录
  761. rows.forEach(row => {
  762. if (!$xeTable.isInsertByRow(row)) {
  763. const rowid = (0, _util.getRowid)($xeTable, row);
  764. removeRowMaps[rowid] = row;
  765. }
  766. });
  767. // 如果绑定了多选属性,则更新状态
  768. if (!checkField) {
  769. rows.forEach(row => {
  770. const rowid = (0, _util.getRowid)(this, row);
  771. if (selectCheckboxMaps[rowid]) {
  772. delete selectCheckboxMaps[rowid];
  773. }
  774. });
  775. reactData.updateCheckboxFlag++;
  776. }
  777. // 从数据源中移除
  778. if (tableFullData === rows) {
  779. rows = delList = tableFullData.slice(0);
  780. this.tableFullData = [];
  781. this.afterFullData = [];
  782. this.clearMergeCells();
  783. } else {
  784. // 如果为虚拟树
  785. if (treeConfig && transform) {
  786. rows.forEach(row => {
  787. const rowid = (0, _util.getRowid)(this, row);
  788. const matchMapObj = _xeUtils.default.findTree(tableFullTreeData, item => rowid === (0, _util.getRowid)(this, item), {
  789. children: mapChildrenField
  790. });
  791. if (matchMapObj) {
  792. const rItems = matchMapObj.items.splice(matchMapObj.index, 1);
  793. delList.push(rItems[0]);
  794. }
  795. const matchObj = _xeUtils.default.findTree(tableFullTreeData, item => rowid === (0, _util.getRowid)(this, item), {
  796. children: childrenField
  797. });
  798. if (matchObj) {
  799. matchObj.items.splice(matchObj.index, 1);
  800. }
  801. const afIndex = this.findRowIndexOf(afterFullData, row);
  802. if (afIndex > -1) {
  803. afterFullData.splice(afIndex, 1);
  804. }
  805. });
  806. } else if (isRowGroupStatus) {
  807. // 如果分组
  808. (0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
  809. } else {
  810. rows.forEach(row => {
  811. const tfIndex = this.findRowIndexOf(tableFullData, row);
  812. if (tfIndex > -1) {
  813. const rItems = tableFullData.splice(tfIndex, 1);
  814. delList.push(rItems[0]);
  815. }
  816. const afIndex = this.findRowIndexOf(afterFullData, row);
  817. if (afIndex > -1) {
  818. // 刷新单元格合并
  819. mergeBodyList.forEach(mergeItem => {
  820. const {
  821. row: mergeRowIndex,
  822. rowspan: mergeRowspan
  823. } = mergeItem;
  824. if (mergeRowIndex > afIndex) {
  825. mergeItem.row = mergeRowIndex - 1;
  826. } else if (mergeRowIndex + mergeRowspan > afIndex) {
  827. mergeItem.rowspan = mergeRowspan - 1;
  828. }
  829. });
  830. afterFullData.splice(afIndex, 1);
  831. }
  832. });
  833. }
  834. }
  835. // 如果当前行被激活编辑,则清除激活状态
  836. if (actived.row && $xeTable.findRowIndexOf(rows, actived.row) > -1) {
  837. $xeTable.clearEdit();
  838. }
  839. // 从新增中移除已删除的数据
  840. rows.forEach(row => {
  841. const rowid = (0, _util.getRowid)($xeTable, row);
  842. if (insertRowMaps[rowid]) {
  843. delete insertRowMaps[rowid];
  844. }
  845. if (pendingRowMaps[rowid]) {
  846. delete pendingRowMaps[rowid];
  847. }
  848. });
  849. reactData.removeRowFlag++;
  850. reactData.insertRowFlag++;
  851. reactData.pendingRowFlag++;
  852. $xeTable.cacheRowMap(false);
  853. $xeTable.handleTableData(treeConfig && transform);
  854. $xeTable.updateFooter();
  855. $xeTable.handleUpdateBodyMerge();
  856. if (!(treeConfig && transform)) {
  857. $xeTable.updateAfterDataIndex();
  858. }
  859. $xeTable.checkSelectionStatus();
  860. if (reactData.scrollYLoad) {
  861. $xeTable.updateScrollYSpace();
  862. }
  863. return this.$nextTick().then(() => {
  864. this.updateCellAreas();
  865. return this.recalculate(true);
  866. }).then(() => {
  867. return {
  868. row: delList.length ? delList[delList.length - 1] : null,
  869. rows: delList
  870. };
  871. });
  872. },
  873. /**
  874. * 删除复选框选中的数据
  875. */
  876. _removeCheckboxRow() {
  877. return this.remove(this.getCheckboxRecords()).then(params => {
  878. this.clearCheckboxRow();
  879. return params;
  880. });
  881. },
  882. /**
  883. * 删除单选框选中的数据
  884. */
  885. _removeRadioRow() {
  886. const radioRecord = this.getRadioRecord();
  887. return this.remove(radioRecord || []).then(params => {
  888. this.clearRadioRow();
  889. return params;
  890. });
  891. },
  892. /**
  893. * 删除当前行选中的数据
  894. */
  895. _removeCurrentRow() {
  896. const currentRecord = this.getCurrentRecord();
  897. return this.remove(currentRecord || []).then(params => {
  898. this.clearCurrentRow();
  899. return params;
  900. });
  901. },
  902. /**
  903. * 获取表格数据集,包含新增、删除、修改
  904. */
  905. _getRecordset() {
  906. const removeRecords = this.getRemoveRecords();
  907. const pendingRecords = this.getPendingRecords();
  908. const delRecords = removeRecords.concat(pendingRecords);
  909. // 如果已经被删除,则无需放到更新数组
  910. const updateRecords = this.getUpdateRecords().filter(row => {
  911. return !delRecords.some(item => this.eqRow(item, row));
  912. });
  913. return {
  914. insertRecords: this.getInsertRecords(),
  915. removeRecords,
  916. updateRecords,
  917. pendingRecords
  918. };
  919. },
  920. /**
  921. * 获取新增的临时数据
  922. */
  923. _getInsertRecords() {
  924. const $xeTable = this;
  925. const internalData = $xeTable;
  926. const {
  927. fullAllDataRowIdData,
  928. insertRowMaps
  929. } = internalData;
  930. const insertRecords = [];
  931. _xeUtils.default.each(insertRowMaps, (row, rowid) => {
  932. if (fullAllDataRowIdData[rowid]) {
  933. insertRecords.push(row);
  934. }
  935. });
  936. return insertRecords;
  937. },
  938. /**
  939. * 获取已删除的数据
  940. */
  941. _getRemoveRecords() {
  942. const $xeTable = this;
  943. const internalData = $xeTable;
  944. const {
  945. removeRowMaps
  946. } = internalData;
  947. const removeRecords = [];
  948. _xeUtils.default.each(removeRowMaps, row => {
  949. removeRecords.push(row);
  950. });
  951. return removeRecords;
  952. },
  953. /**
  954. * 获取更新数据
  955. * 只精准匹配 row 的更改
  956. * 如果是树表格,子节点更改状态不会影响父节点的更新状态
  957. */
  958. _getUpdateRecords() {
  959. const $xeTable = this;
  960. const props = $xeTable;
  961. const internalData = $xeTable;
  962. const {
  963. keepSource,
  964. treeConfig
  965. } = props;
  966. const {
  967. tableFullData
  968. } = internalData;
  969. const treeOpts = $xeTable.computeTreeOpts;
  970. if (keepSource) {
  971. syncActivedCell($xeTable);
  972. if (treeConfig) {
  973. return _xeUtils.default.filterTree(tableFullData, row => $xeTable.isUpdateByRow(row), treeOpts);
  974. }
  975. return tableFullData.filter(row => $xeTable.isUpdateByRow(row));
  976. }
  977. return [];
  978. },
  979. /**
  980. * 处理激活编辑
  981. */
  982. handleEdit(params, evnt) {
  983. const $xeTable = this;
  984. return handleEditActive($xeTable, params, evnt, true, true);
  985. },
  986. /**
  987. * @deprecated
  988. */
  989. handleActived(params, evnt) {
  990. return this.handleEdit(params, evnt);
  991. },
  992. _getColumnModel(row, column) {
  993. getEditColumnModel(row, column);
  994. },
  995. _setColumnModel(row, column) {
  996. setEditColumnModel(row, column);
  997. },
  998. _syncActivedCell() {
  999. const $xeTable = this;
  1000. syncActivedCell($xeTable);
  1001. },
  1002. _clearActived(row) {
  1003. (0, _log.warnLog)('vxe.error.delFunc', ['clearActived', 'clearEdit']);
  1004. // 即将废弃
  1005. return this.clearEdit(row);
  1006. },
  1007. /**
  1008. * 清除激活的编辑
  1009. */
  1010. _clearEdit(row) {
  1011. const $xeTable = this;
  1012. return handleClearEdit($xeTable, null, row);
  1013. },
  1014. /**
  1015. * 取消编辑
  1016. */
  1017. handleClearEdit(evnt, targetRow) {
  1018. const $xeTable = this;
  1019. return handleClearEdit($xeTable, evnt, targetRow);
  1020. },
  1021. _getActiveRecord() {
  1022. const $xeTable = this;
  1023. const reactData = $xeTable;
  1024. const internalData = $xeTable;
  1025. (0, _log.warnLog)('vxe.error.delFunc', ['getActiveRecord', 'getEditCell']);
  1026. const {
  1027. editStore
  1028. } = reactData;
  1029. const {
  1030. fullAllDataRowIdData
  1031. } = internalData;
  1032. const {
  1033. args,
  1034. row
  1035. } = editStore.actived;
  1036. if (args && row && fullAllDataRowIdData[(0, _util.getRowid)($xeTable, row)]) {
  1037. return Object.assign({}, args, {
  1038. row
  1039. });
  1040. }
  1041. return null;
  1042. },
  1043. _getEditRecord() {
  1044. const $xeTable = this;
  1045. const reactData = $xeTable;
  1046. const internalData = $xeTable;
  1047. (0, _log.warnLog)('vxe.error.delFunc', ['getEditRecord', 'getEditCell']);
  1048. const {
  1049. editStore
  1050. } = reactData;
  1051. const {
  1052. fullAllDataRowIdData
  1053. } = internalData;
  1054. const {
  1055. args,
  1056. row
  1057. } = editStore.actived;
  1058. if (args && row && fullAllDataRowIdData[(0, _util.getRowid)($xeTable, row)]) {
  1059. return Object.assign({}, args, {
  1060. row
  1061. });
  1062. }
  1063. return null;
  1064. },
  1065. _getEditCell() {
  1066. const $xeTable = this;
  1067. const reactData = $xeTable;
  1068. const {
  1069. editStore
  1070. } = reactData;
  1071. const {
  1072. row,
  1073. column
  1074. } = editStore.actived;
  1075. if (column && row) {
  1076. return {
  1077. row,
  1078. rowIndex: $xeTable.getRowIndex(row),
  1079. column,
  1080. columnIndex: $xeTable.getColumnIndex(column)
  1081. };
  1082. }
  1083. return null;
  1084. },
  1085. _isActiveByRow(row) {
  1086. const $xeTable = this;
  1087. (0, _log.warnLog)('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow']);
  1088. // 即将废弃
  1089. return $xeTable.isEditByRow(row);
  1090. },
  1091. /**
  1092. * 判断行是否为激活编辑状态
  1093. * @param {Row} row 行对象
  1094. */
  1095. _isEditByRow(row) {
  1096. const $xeTable = this;
  1097. const reactData = $xeTable;
  1098. const {
  1099. editStore
  1100. } = reactData;
  1101. return editStore.actived.row === row;
  1102. },
  1103. /**
  1104. * 处理聚焦
  1105. */
  1106. handleFocus(params) {
  1107. const $xeTable = this;
  1108. const {
  1109. row,
  1110. column,
  1111. cell
  1112. } = params;
  1113. const {
  1114. editRender
  1115. } = column;
  1116. const editOpts = $xeTable.computeEditOpts;
  1117. if ((0, _utils.isEnableConf)(editRender)) {
  1118. const compRender = renderer.get(editRender.name);
  1119. let autoFocus = editRender.autofocus || editRender.autoFocus;
  1120. let autoSelect = editRender.autoSelect || editRender.autoselect;
  1121. let inputElem;
  1122. // 是否启用聚焦
  1123. if (editOpts.autoFocus) {
  1124. if (!autoFocus && compRender) {
  1125. autoFocus = compRender.tableAutoFocus || compRender.tableAutofocus || compRender.autoFocus || compRender.autofocus;
  1126. }
  1127. if (!autoSelect && compRender) {
  1128. autoSelect = compRender.tableAutoSelect || compRender.autoSelect || compRender.autoselect;
  1129. }
  1130. // 如果指定了聚焦 class
  1131. if (_xeUtils.default.isFunction(autoFocus)) {
  1132. inputElem = autoFocus.call($xeTable, params);
  1133. } else if (autoFocus) {
  1134. if (autoFocus === true) {
  1135. // 自动匹配模式,会自动匹配第一个可输入元素
  1136. inputElem = cell.querySelector('input,textarea');
  1137. } else {
  1138. inputElem = cell.querySelector(autoFocus);
  1139. }
  1140. if (inputElem) {
  1141. inputElem.focus();
  1142. }
  1143. }
  1144. }
  1145. if (inputElem) {
  1146. if (autoSelect) {
  1147. inputElem.select();
  1148. } else {
  1149. // 保持一致行为,光标移到末端
  1150. if (browseObj.msie) {
  1151. const textRange = inputElem.createTextRange();
  1152. textRange.collapse(false);
  1153. textRange.select();
  1154. }
  1155. }
  1156. } else {
  1157. // 是否自动定位
  1158. if (editOpts.autoPos) {
  1159. if (!column.fixed) {
  1160. // 显示到可视区中
  1161. $xeTable.scrollToRow(row, column);
  1162. }
  1163. }
  1164. }
  1165. }
  1166. },
  1167. _setActiveRow(row) {
  1168. const $xeTable = this;
  1169. (0, _log.warnLog)('vxe.error.delFunc', ['setActiveRow', 'setEditRow']);
  1170. // 即将废弃
  1171. return $xeTable.setEditRow(row);
  1172. },
  1173. /**
  1174. * 激活行编辑
  1175. */
  1176. _setEditRow(row, fieldOrColumn) {
  1177. const $xeTable = this;
  1178. let column = _xeUtils.default.find(this.visibleColumn, column => (0, _utils.isEnableConf)(column.editRender));
  1179. let isPos = false;
  1180. if (fieldOrColumn) {
  1181. isPos = true;
  1182. if (fieldOrColumn !== true) {
  1183. column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
  1184. }
  1185. }
  1186. return handleEditCell($xeTable, row, column, isPos);
  1187. },
  1188. _setActiveCell(row, fieldOrColumn) {
  1189. (0, _log.warnLog)('vxe.error.delFunc', ['setActiveCell', 'setEditCell']);
  1190. // 即将废弃
  1191. return this.setEditCell(row, fieldOrColumn);
  1192. },
  1193. /**
  1194. * 激活单元格编辑
  1195. */
  1196. _setEditCell(row, fieldOrColumn) {
  1197. const $xeTable = this;
  1198. return handleEditCell($xeTable, row, fieldOrColumn, true);
  1199. },
  1200. /**
  1201. * 只对 trigger=dblclick 有效,选中单元格
  1202. */
  1203. _setSelectCell(row, fieldOrColumn) {
  1204. const $xeTable = this;
  1205. const reactData = $xeTable;
  1206. const {
  1207. tableData
  1208. } = reactData;
  1209. const editOpts = $xeTable.computeEditOpts;
  1210. const column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
  1211. if (row && column && editOpts.trigger !== 'manual') {
  1212. const rowIndex = $xeTable.findRowIndexOf(tableData, row);
  1213. if (rowIndex > -1) {
  1214. const cell = $xeTable.getCellElement(row, column);
  1215. const params = {
  1216. row,
  1217. rowIndex,
  1218. column,
  1219. columnIndex: $xeTable.getColumnIndex(column),
  1220. cell
  1221. };
  1222. $xeTable.handleSelected(params, {});
  1223. }
  1224. }
  1225. return $xeTable.$nextTick();
  1226. },
  1227. /**
  1228. * 处理选中源
  1229. */
  1230. handleSelected(params, evnt) {
  1231. const $xeTable = this;
  1232. const props = $xeTable;
  1233. const reactData = $xeTable;
  1234. const {
  1235. mouseConfig
  1236. } = props;
  1237. const {
  1238. editStore
  1239. } = reactData;
  1240. const mouseOpts = $xeTable.computeMouseOpts;
  1241. const editOpts = $xeTable.computeEditOpts;
  1242. const {
  1243. actived,
  1244. selected
  1245. } = editStore;
  1246. const {
  1247. row,
  1248. column
  1249. } = params;
  1250. const isMouseSelected = mouseConfig && mouseOpts.selected;
  1251. const selectMethod = () => {
  1252. if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
  1253. if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
  1254. handleClearEdit($xeTable, evnt);
  1255. $xeTable.clearSelected();
  1256. if ($xeTable.clearCellAreas) {
  1257. $xeTable.clearCellAreas();
  1258. $xeTable.clearCopyCellArea();
  1259. }
  1260. selected.args = params;
  1261. selected.row = row;
  1262. selected.column = column;
  1263. if (isMouseSelected) {
  1264. this.addCellSelectedClass();
  1265. }
  1266. $xeTable.focus();
  1267. if (evnt) {
  1268. $xeTable.dispatchEvent('cell-selected', params, evnt);
  1269. }
  1270. }
  1271. }
  1272. return $xeTable.$nextTick();
  1273. };
  1274. return selectMethod();
  1275. },
  1276. /**
  1277. * 获取选中的单元格
  1278. */
  1279. _getSelectedCell() {
  1280. const $xeTable = this;
  1281. const reactData = $xeTable;
  1282. const {
  1283. editStore
  1284. } = reactData;
  1285. const {
  1286. row,
  1287. column
  1288. } = editStore.selected;
  1289. if (row && column) {
  1290. return {
  1291. row,
  1292. column
  1293. };
  1294. }
  1295. return null;
  1296. },
  1297. /**
  1298. * 清除所选中源状态
  1299. */
  1300. _clearSelected() {
  1301. const $xeTable = this;
  1302. const reactData = $xeTable;
  1303. const {
  1304. editStore
  1305. } = reactData;
  1306. const {
  1307. selected
  1308. } = editStore;
  1309. selected.row = null;
  1310. selected.column = null;
  1311. removeCellSelectedClass($xeTable);
  1312. return $xeTable.$nextTick();
  1313. },
  1314. reColTitleSdCls() {
  1315. const headerElem = this.elemStore['main-header-list'];
  1316. if (headerElem) {
  1317. _xeUtils.default.arrayEach(headerElem.querySelectorAll('.col--title-selected'), elem => (0, _dom.removeClass)(elem, 'col--title-selected'));
  1318. }
  1319. },
  1320. addCellSelectedClass() {
  1321. const $xeTable = this;
  1322. const reactData = $xeTable;
  1323. const {
  1324. editStore
  1325. } = reactData;
  1326. const {
  1327. selected
  1328. } = editStore;
  1329. const {
  1330. row,
  1331. column
  1332. } = selected;
  1333. removeCellSelectedClass($xeTable);
  1334. if (row && column) {
  1335. const cell = $xeTable.getCellElement(row, column);
  1336. if (cell) {
  1337. (0, _dom.addClass)(cell, 'col--selected');
  1338. }
  1339. }
  1340. }
  1341. }
  1342. };