index.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. import XEUtils from 'xe-utils';
  2. import { VxeUI } from '../../ui';
  3. import { getCellValue, setCellValue } from '../src/util';
  4. import { getFuncText, formatText, isEmptyValue } from '../../ui/src/utils';
  5. import { getOnName, getModelEvent, getChangeEvent, hasInputType } from '../../ui/src/vn';
  6. import { errLog } from '../../ui/src/log';
  7. const { getConfig, renderer, getI18n, getComponent } = VxeUI;
  8. const componentDefaultModelProp = 'value';
  9. const defaultCompProps = {};
  10. function handleDefaultValue(value, defaultVal, initVal) {
  11. return XEUtils.eqNull(value) ? (XEUtils.eqNull(defaultVal) ? initVal : defaultVal) : value;
  12. }
  13. function parseDate(value, props) {
  14. return value && props.valueFormat ? XEUtils.toStringDate(value, props.valueFormat) : value;
  15. }
  16. function getFormatDate(value, props, defaultFormat) {
  17. const { dateConfig = {} } = props;
  18. return XEUtils.toDateString(parseDate(value, props), dateConfig.labelFormat || defaultFormat);
  19. }
  20. function getLabelFormatDate(value, props) {
  21. return getFormatDate(value, props, getI18n(`vxe.input.date.labelFormat.${props.type || 'date'}`));
  22. }
  23. /**
  24. * 已废弃
  25. * @deprecated
  26. */
  27. function getOldComponentName(name) {
  28. return `vxe-${name.replace('$', '')}`;
  29. }
  30. /**
  31. * 已废弃
  32. * @deprecated
  33. */
  34. function getOldComponent({ name }) {
  35. return getOldComponentName(name);
  36. }
  37. function getDefaultComponent({ name }) {
  38. return getComponent(name) || name;
  39. }
  40. function updateFilterChangeOption(params, checked, option) {
  41. const { $table } = params;
  42. $table.updateFilterOptionStatus(option, checked);
  43. }
  44. function saveFilterEvent(params) {
  45. const { $table, column } = params;
  46. $table.saveFilterByEvent(new Event('change'), column);
  47. }
  48. function getNativeAttrs(renderOpts) {
  49. let { name, attrs } = renderOpts;
  50. if (name === 'input') {
  51. attrs = Object.assign({ type: 'text' }, attrs);
  52. }
  53. return attrs;
  54. }
  55. function getInputImmediateModel(renderOpts) {
  56. const { name, immediate, props } = renderOpts;
  57. if (!immediate) {
  58. if (name === 'VxeInput' || name === '$input') {
  59. const { type } = props || {};
  60. return !(!type || type === 'text' || type === 'number' || type === 'integer' || type === 'float');
  61. }
  62. if (name === 'input' || name === 'textarea' || name === '$textarea') {
  63. return false;
  64. }
  65. return true;
  66. }
  67. return immediate;
  68. }
  69. function getCellEditProps(renderOpts, params, value, defaultProps) {
  70. return XEUtils.assign({ immediate: getInputImmediateModel(renderOpts) }, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value });
  71. }
  72. function getCellEditFilterProps(renderOpts, params, value, defaultProps) {
  73. return XEUtils.assign({}, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value });
  74. }
  75. function isImmediateCell(renderOpts, params) {
  76. return params.$type === 'cell' || getInputImmediateModel(renderOpts);
  77. }
  78. function getCellLabelVNs(h, renderOpts, params, cellLabel, opts) {
  79. const { placeholder } = renderOpts;
  80. return [
  81. h('span', {
  82. class: ['vxe-cell--label', opts ? opts.class : '']
  83. }, placeholder && isEmptyValue(cellLabel)
  84. ? [
  85. h('span', {
  86. class: 'vxe-cell--placeholder'
  87. }, formatText(getFuncText(placeholder), 1))
  88. ]
  89. : formatText(cellLabel, 1))
  90. ];
  91. }
  92. /**
  93. * 原生事件处理
  94. * @param renderOpts
  95. * @param params
  96. * @param modelFunc
  97. * @param changeFunc
  98. */
  99. function getNativeElementOns(renderOpts, params, eFns) {
  100. const { events } = renderOpts;
  101. const modelEvent = getModelEvent(renderOpts);
  102. const changeEvent = getChangeEvent(renderOpts);
  103. const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
  104. const isSameEvent = changeEvent === modelEvent;
  105. const ons = {};
  106. if (events) {
  107. XEUtils.objectEach(events, (func, key) => {
  108. ons[getOnName(key)] = function (...args) {
  109. func(params, ...args);
  110. };
  111. });
  112. }
  113. if (modelFunc) {
  114. ons[getOnName(modelEvent)] = function (targetEvnt) {
  115. modelFunc(targetEvnt);
  116. if (isSameEvent && changeFunc) {
  117. changeFunc(targetEvnt);
  118. }
  119. if (events && events[modelEvent]) {
  120. events[modelEvent](params, targetEvnt);
  121. }
  122. };
  123. }
  124. if (!isSameEvent && changeFunc) {
  125. ons[getOnName(changeEvent)] = function (evnt) {
  126. changeFunc(evnt);
  127. if (events && events[changeEvent]) {
  128. events[changeEvent](params, evnt);
  129. }
  130. };
  131. }
  132. if (blurFunc) {
  133. ons[getOnName(blurEvent)] = function (evnt) {
  134. blurFunc(evnt);
  135. if (events && events[blurEvent]) {
  136. events[blurEvent](params, evnt);
  137. }
  138. };
  139. }
  140. return ons;
  141. }
  142. const blurEvent = 'blur';
  143. const clearEvent = 'clear';
  144. /**
  145. * 组件事件处理
  146. * @param renderOpts
  147. * @param params
  148. * @param modelFunc
  149. * @param changeFunc
  150. */
  151. function getComponentOns(renderOpts, params, eFns, eventOns) {
  152. const { events } = renderOpts;
  153. const modelEvent = getModelEvent(renderOpts);
  154. const changeEvent = getChangeEvent(renderOpts);
  155. const { model: modelFunc, change: changeFunc, blur: blurFunc, clear: clearFunc } = eFns || {};
  156. const ons = {};
  157. XEUtils.objectEach(events, (func, key) => {
  158. ons[getOnName(key)] = function (...args) {
  159. if (!XEUtils.isFunction(func)) {
  160. errLog('vxe.error.errFunc', [func]);
  161. }
  162. func(params, ...args);
  163. };
  164. });
  165. if (modelFunc) {
  166. ons[getOnName(modelEvent)] = function (targetEvnt) {
  167. modelFunc(targetEvnt);
  168. if (events && events[modelEvent]) {
  169. events[modelEvent](params, targetEvnt);
  170. }
  171. };
  172. }
  173. if (changeFunc) {
  174. ons[getOnName(changeEvent)] = function (...args) {
  175. changeFunc(...args);
  176. if (events && events[changeEvent]) {
  177. events[changeEvent](params, ...args);
  178. }
  179. };
  180. }
  181. if (blurFunc) {
  182. ons[getOnName(blurEvent)] = function (...args) {
  183. blurFunc(...args);
  184. if (events && events[blurEvent]) {
  185. events[blurEvent](params, ...args);
  186. }
  187. };
  188. }
  189. if (clearFunc) {
  190. ons[getOnName(clearEvent)] = function (...args) {
  191. clearFunc(...args);
  192. if (events && events[clearEvent]) {
  193. events[clearEvent](params, ...args);
  194. }
  195. };
  196. }
  197. return eventOns ? Object.assign(ons, eventOns) : ons;
  198. }
  199. function getEditOns(renderOpts, params) {
  200. const { $table, row, column } = params;
  201. const { name } = renderOpts;
  202. const { model } = column;
  203. const isImmediate = isImmediateCell(renderOpts, params);
  204. return getComponentOns(renderOpts, params, {
  205. model(cellValue) {
  206. // 处理 model 值双向绑定
  207. model.update = true;
  208. model.value = cellValue;
  209. if (isImmediate) {
  210. setCellValue(row, column, cellValue);
  211. }
  212. },
  213. change(eventParams) {
  214. // 处理 change 事件相关逻辑
  215. if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
  216. const cellValue = eventParams.value;
  217. model.update = true;
  218. model.value = cellValue;
  219. $table.updateStatus(params, cellValue);
  220. }
  221. else {
  222. $table.updateStatus(params);
  223. }
  224. },
  225. blur() {
  226. if (isImmediate) {
  227. $table.handleCellRuleUpdateStatus('blur', params);
  228. }
  229. else {
  230. $table.handleCellRuleUpdateStatus('blur', params, model.value);
  231. }
  232. }
  233. });
  234. }
  235. function getFilterOns(renderOpts, params, option) {
  236. return getComponentOns(renderOpts, params, {
  237. model(value) {
  238. // 处理 model 值双向绑定
  239. option.data = value;
  240. },
  241. change() {
  242. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  243. },
  244. blur() {
  245. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  246. }
  247. });
  248. }
  249. function getFloatingFilterOns(renderOpts, params, option) {
  250. const { $table, column } = params;
  251. if (hasInputType(renderOpts)) {
  252. return getComponentOns(renderOpts, params, {
  253. model(value) {
  254. // 处理 model 值双向绑定
  255. option.data = value;
  256. },
  257. change() {
  258. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  259. },
  260. clear() {
  261. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  262. saveFilterEvent(params);
  263. },
  264. blur() {
  265. $table.saveFilterByEvent(new Event('change'), column);
  266. }
  267. }, renderOpts.name === 'VxeNumberInput'
  268. ? {
  269. [getOnName('plus-number')]() {
  270. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  271. saveFilterEvent(params);
  272. },
  273. [getOnName('minus-number')]() {
  274. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  275. saveFilterEvent(params);
  276. }
  277. }
  278. : {});
  279. }
  280. return getComponentOns(renderOpts, params, {
  281. model(value) {
  282. // 处理 model 值双向绑定
  283. option.data = value;
  284. },
  285. clear() {
  286. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  287. $table.saveFilterByEvent(new Event('change'), column);
  288. },
  289. change() {
  290. updateFilterChangeOption(params, !isEmptyValue(option.data), option);
  291. $table.saveFilterByEvent(new Event('change'), column);
  292. }
  293. });
  294. }
  295. function getNativeEditOns(renderOpts, params) {
  296. const { $table, row, column } = params;
  297. const { model } = column;
  298. return getNativeElementOns(renderOpts, params, {
  299. model(evnt) {
  300. // 处理 model 值双向绑定
  301. const targetEl = evnt.target;
  302. if (targetEl) {
  303. const cellValue = targetEl.value;
  304. if (isImmediateCell(renderOpts, params)) {
  305. setCellValue(row, column, cellValue);
  306. }
  307. else {
  308. model.update = true;
  309. model.value = cellValue;
  310. }
  311. }
  312. },
  313. change(evnt) {
  314. // 处理 change 事件相关逻辑
  315. const targetEl = evnt.target;
  316. if (targetEl) {
  317. const cellValue = targetEl.value;
  318. $table.updateStatus(params, cellValue);
  319. }
  320. },
  321. blur(evnt) {
  322. const targetEl = evnt.target;
  323. if (targetEl) {
  324. const cellValue = targetEl.value;
  325. $table.updateStatus(params, cellValue);
  326. }
  327. }
  328. });
  329. }
  330. function getNativeFilterOns(renderOpts, params, option) {
  331. return getNativeElementOns(renderOpts, params, {
  332. model(evnt) {
  333. // 处理 model 值双向绑定
  334. const targetEl = evnt.target;
  335. if (targetEl) {
  336. option.data = targetEl.value;
  337. }
  338. },
  339. change() {
  340. updateFilterChangeOption(params, !XEUtils.eqNull(option.data), option);
  341. },
  342. blur() {
  343. updateFilterChangeOption(params, !XEUtils.eqNull(option.data), option);
  344. }
  345. });
  346. }
  347. /**
  348. * 单元格可编辑渲染-原生的标签
  349. * input、textarea、select
  350. */
  351. function nativeEditRender(h, renderOpts, params) {
  352. const { row, column } = params;
  353. const { name } = renderOpts;
  354. const cellValue = isImmediateCell(renderOpts, params) ? getCellValue(row, column) : column.model.value;
  355. return [
  356. h(`${name}`, {
  357. class: `vxe-default-${name}`,
  358. attrs: getNativeAttrs(renderOpts),
  359. domProps: {
  360. value: cellValue
  361. },
  362. on: getNativeEditOns(renderOpts, params)
  363. })
  364. ];
  365. }
  366. function buttonCellRender(h, renderOpts, params) {
  367. return [
  368. h(getDefaultComponent(renderOpts), {
  369. props: getCellEditProps(renderOpts, params, null),
  370. on: getComponentOns(renderOpts, params)
  371. })
  372. ];
  373. }
  374. function defaultEditRender(h, renderOpts, params) {
  375. const { row, column } = params;
  376. const cellValue = getCellValue(row, column);
  377. return [
  378. h(getDefaultComponent(renderOpts), {
  379. props: getCellEditProps(renderOpts, params, cellValue),
  380. on: getEditOns(renderOpts, params)
  381. })
  382. ];
  383. }
  384. function checkboxEditRender(h, renderOpts, params) {
  385. const { row, column } = params;
  386. const cellValue = getCellValue(row, column);
  387. return [
  388. h(getDefaultComponent(renderOpts), {
  389. props: getCellEditProps(renderOpts, params, cellValue),
  390. on: getEditOns(renderOpts, params)
  391. })
  392. ];
  393. }
  394. function radioAndCheckboxGroupEditRender(h, renderOpts, params) {
  395. const { options } = renderOpts;
  396. const { row, column } = params;
  397. const cellValue = getCellValue(row, column);
  398. return [
  399. h(getDefaultComponent(renderOpts), {
  400. props: Object.assign({ options }, getCellEditProps(renderOpts, params, cellValue)),
  401. on: getEditOns(renderOpts, params)
  402. })
  403. ];
  404. }
  405. /**
  406. * 已废弃
  407. * @deprecated
  408. */
  409. function oldEditRender(h, renderOpts, params) {
  410. const { row, column } = params;
  411. const cellValue = getCellValue(row, column);
  412. return [
  413. h(getOldComponent(renderOpts), {
  414. props: getCellEditProps(renderOpts, params, cellValue),
  415. on: getEditOns(renderOpts, params)
  416. })
  417. ];
  418. }
  419. /**
  420. * 已废弃
  421. * @deprecated
  422. */
  423. function oldButtonEditRender(h, renderOpts, params) {
  424. return [
  425. h('vxe-button', {
  426. props: getCellEditProps(renderOpts, params, null),
  427. on: getComponentOns(renderOpts, params)
  428. })
  429. ];
  430. }
  431. /**
  432. * 已废弃
  433. * @deprecated
  434. */
  435. function oldButtonsEditRender(h, renderOpts, params) {
  436. const { children } = renderOpts;
  437. return children ? children.map((childRenderOpts) => oldButtonEditRender(h, childRenderOpts, params)[0]) : [];
  438. }
  439. function renderNativeOptgroups(h, renderOpts, params, renderOptionsMethods) {
  440. const { optionGroups, optionGroupProps = {} } = renderOpts;
  441. const groupOptions = optionGroupProps.options || 'options';
  442. const groupLabel = optionGroupProps.label || 'label';
  443. if (optionGroups) {
  444. return optionGroups.map((group, gIndex) => {
  445. return h('optgroup', {
  446. key: gIndex,
  447. attrs: {
  448. label: group[groupLabel]
  449. }
  450. }, renderOptionsMethods(h, group[groupOptions], renderOpts, params));
  451. });
  452. }
  453. return [];
  454. }
  455. /**
  456. * 渲染原生的 option 标签
  457. */
  458. function renderNativeOptions(h, options, renderOpts, params) {
  459. const { optionProps = {} } = renderOpts;
  460. const { row, column } = params;
  461. const labelProp = optionProps.label || 'label';
  462. const valueProp = optionProps.value || 'value';
  463. const disabledProp = optionProps.disabled || 'disabled';
  464. const cellValue = isImmediateCell(renderOpts, params) ? getCellValue(row, column) : column.model.value;
  465. if (options) {
  466. return options.map((option, oIndex) => {
  467. return h('option', {
  468. key: oIndex,
  469. attrs: {
  470. value: option[valueProp],
  471. disabled: option[disabledProp]
  472. },
  473. domProps: {
  474. /* eslint-disable eqeqeq */
  475. selected: option[valueProp] == cellValue
  476. }
  477. }, option[labelProp]);
  478. });
  479. }
  480. return [];
  481. }
  482. function nativeFilterRender(h, renderOpts, params) {
  483. const { column } = params;
  484. const { name } = renderOpts;
  485. const attrs = getNativeAttrs(renderOpts);
  486. return column.filters.map((option, oIndex) => {
  487. return h(`${name}`, {
  488. key: oIndex,
  489. class: `vxe-default-${name}`,
  490. attrs,
  491. domProps: {
  492. value: option.data
  493. },
  494. on: getNativeFilterOns(renderOpts, params, option)
  495. });
  496. });
  497. }
  498. function defaultFilterRender(h, renderOpts, params) {
  499. const { column } = params;
  500. return column.filters.map((option, oIndex) => {
  501. const optionValue = option.data;
  502. return h(getDefaultComponent(renderOpts), {
  503. key: oIndex,
  504. props: getCellEditFilterProps(renderOpts, renderOpts, optionValue),
  505. on: getFilterOns(renderOpts, params, option)
  506. });
  507. });
  508. }
  509. function defaultFloatingFilterRender(h, renderOpts, params) {
  510. const { option } = params;
  511. const optionValue = option.data;
  512. return [
  513. h(getDefaultComponent(renderOpts), {
  514. props: getCellEditFilterProps(renderOpts, renderOpts, optionValue),
  515. on: getFloatingFilterOns(renderOpts, params, option)
  516. })
  517. ];
  518. }
  519. function defaultFilterOptions() {
  520. return [
  521. { data: null }
  522. ];
  523. }
  524. /**
  525. * 已废弃
  526. * @deprecated
  527. */
  528. function oldFilterRender(h, renderOpts, params) {
  529. const { column } = params;
  530. return column.filters.map((option, oIndex) => {
  531. const optionValue = option.data;
  532. return h(getOldComponent(renderOpts), {
  533. key: oIndex,
  534. props: getCellEditFilterProps(renderOpts, renderOpts, optionValue),
  535. on: getFilterOns(renderOpts, params, option)
  536. });
  537. });
  538. }
  539. function handleFilterMethod({ option, row, column }) {
  540. const { data } = option;
  541. const cellValue = XEUtils.get(row, column.field);
  542. /* eslint-disable eqeqeq */
  543. return cellValue == data;
  544. }
  545. function handleInputFilterMethod({ option, row, column }) {
  546. const { data } = option;
  547. const cellValue = XEUtils.get(row, column.field);
  548. /* eslint-disable eqeqeq */
  549. return XEUtils.toValueString(cellValue).indexOf(data) > -1;
  550. }
  551. function nativeSelectEditRender(h, renderOpts, params) {
  552. return [
  553. h('select', {
  554. class: 'vxe-default-select',
  555. attrs: getNativeAttrs(renderOpts),
  556. on: getNativeEditOns(renderOpts, params)
  557. }, renderOpts.optionGroups ? renderNativeOptgroups(h, renderOpts, params, renderNativeOptions) : renderNativeOptions(h, renderOpts.options, renderOpts, params))
  558. ];
  559. }
  560. function defaultSelectEditRender(h, renderOpts, params) {
  561. const { row, column } = params;
  562. const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
  563. const cellValue = getCellValue(row, column);
  564. return [
  565. h(getDefaultComponent(renderOpts), {
  566. props: getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
  567. on: getEditOns(renderOpts, params)
  568. })
  569. ];
  570. }
  571. function defaultTableOrTreeSelectEditRender(h, renderOpts, params) {
  572. const { row, column } = params;
  573. const { options, optionProps } = renderOpts;
  574. const cellValue = getCellValue(row, column);
  575. return [
  576. h(getDefaultComponent(renderOpts), {
  577. props: getCellEditProps(renderOpts, params, cellValue, { options, optionProps }),
  578. on: getEditOns(renderOpts, params)
  579. })
  580. ];
  581. }
  582. /**
  583. * 已废弃
  584. * @deprecated
  585. */
  586. function oldSelectEditRender(h, renderOpts, params) {
  587. const { row, column } = params;
  588. const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
  589. const cellValue = getCellValue(row, column);
  590. return [
  591. h(getOldComponent(renderOpts), {
  592. props: getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
  593. on: getEditOns(renderOpts, params)
  594. })
  595. ];
  596. }
  597. function getSelectCellValue(renderOpts, { row, column }) {
  598. const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props = {} } = renderOpts;
  599. const cellValue = XEUtils.get(row, column.field);
  600. let selectItem;
  601. const labelProp = optionProps.label || 'label';
  602. const valueProp = optionProps.value || 'value';
  603. if (!(cellValue === null || cellValue === undefined)) {
  604. let vals = [];
  605. if (XEUtils.isArray(cellValue)) {
  606. vals = cellValue;
  607. }
  608. else {
  609. if (props.multiple && `${cellValue}`.indexOf(',') > -1) {
  610. vals = `${cellValue}`.split(',');
  611. }
  612. else {
  613. vals = [cellValue];
  614. }
  615. }
  616. return XEUtils.map(vals, optionGroups
  617. ? (value) => {
  618. const groupOptions = optionGroupProps.options || 'options';
  619. for (let index = 0; index < optionGroups.length; index++) {
  620. /* eslint-disable eqeqeq */
  621. selectItem = XEUtils.find(optionGroups[index][groupOptions], item => item[valueProp] == value);
  622. if (selectItem) {
  623. break;
  624. }
  625. }
  626. return selectItem ? selectItem[labelProp] : value;
  627. }
  628. : (value) => {
  629. /* eslint-disable eqeqeq */
  630. selectItem = XEUtils.find(options, item => item[valueProp] == value);
  631. return selectItem ? selectItem[labelProp] : value;
  632. }).join(', ');
  633. }
  634. return '';
  635. }
  636. function handleExportSelectMethod(params) {
  637. const { row, column, options } = params;
  638. return options.original ? getCellValue(row, column) : getSelectCellValue(column.editRender || column.cellRender, params);
  639. }
  640. function getTreeSelectCellValue(renderOpts, { row, column }) {
  641. const { options, optionProps = {} } = renderOpts;
  642. const cellValue = XEUtils.get(row, column.field);
  643. const labelProp = optionProps.label || 'label';
  644. const valueProp = optionProps.value || 'value';
  645. const childrenProp = optionProps.children || 'children';
  646. if (!(cellValue === null || cellValue === undefined)) {
  647. const keyMaps = {};
  648. XEUtils.eachTree(options, item => {
  649. keyMaps[XEUtils.get(item, valueProp)] = item;
  650. }, { children: childrenProp });
  651. return XEUtils.map(XEUtils.isArray(cellValue) ? cellValue : [cellValue], (value) => {
  652. const item = keyMaps[value];
  653. return item ? XEUtils.get(item, labelProp) : item;
  654. }).join(', ');
  655. }
  656. return '';
  657. }
  658. function handleExportTreeSelectMethod(params) {
  659. const { row, column, options } = params;
  660. return options.original ? getCellValue(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params);
  661. }
  662. function handleNumberCell(h, renderOpts, params) {
  663. const { props = {}, showNegativeStatus } = renderOpts;
  664. const { row, column } = params;
  665. const { type } = props;
  666. let cellValue = XEUtils.get(row, column.field);
  667. let isNegative = false;
  668. if (!isEmptyValue(cellValue)) {
  669. const numberInputConfig = getConfig().numberInput || {};
  670. if (type === 'float') {
  671. const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
  672. const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1);
  673. cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits);
  674. if (!autoFill) {
  675. cellValue = XEUtils.toNumber(cellValue);
  676. }
  677. if (showNegativeStatus) {
  678. if (cellValue < 0) {
  679. isNegative = true;
  680. }
  681. }
  682. }
  683. else if (type === 'amount') {
  684. const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
  685. const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2);
  686. const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false);
  687. cellValue = XEUtils.toNumber(cellValue);
  688. if (showNegativeStatus) {
  689. if (cellValue < 0) {
  690. isNegative = true;
  691. }
  692. }
  693. cellValue = XEUtils.commafy(cellValue, { digits });
  694. if (!autoFill) {
  695. const [iStr, dStr] = cellValue.split('.');
  696. if (dStr) {
  697. const dRest = dStr.replace(/0+$/, '');
  698. cellValue = dRest ? [iStr, '.', dRest].join('') : iStr;
  699. }
  700. }
  701. if (showCurrency) {
  702. cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`;
  703. }
  704. }
  705. else {
  706. if (showNegativeStatus) {
  707. if (XEUtils.toNumber(cellValue) < 0) {
  708. isNegative = true;
  709. }
  710. }
  711. }
  712. }
  713. return getCellLabelVNs(h, renderOpts, params, cellValue, isNegative
  714. ? {
  715. class: 'is--negative'
  716. }
  717. : {});
  718. }
  719. /**
  720. * 表格 - 渲染器
  721. */
  722. renderer.mixin({
  723. input: {
  724. tableAutoFocus: 'input',
  725. renderTableEdit: nativeEditRender,
  726. renderTableDefault: nativeEditRender,
  727. renderTableFilter: nativeFilterRender,
  728. tableFilterDefaultMethod: handleInputFilterMethod
  729. },
  730. textarea: {
  731. tableAutoFocus: 'textarea',
  732. renderTableEdit: nativeEditRender
  733. },
  734. select: {
  735. renderTableEdit: nativeSelectEditRender,
  736. renderTableDefault: nativeSelectEditRender,
  737. renderTableCell(h, renderOpts, params) {
  738. return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params));
  739. },
  740. renderTableFilter(h, renderOpts, params) {
  741. const { column } = params;
  742. return column.filters.map((option, oIndex) => {
  743. return h('select', {
  744. key: oIndex,
  745. class: 'vxe-default-select',
  746. attrs: getNativeAttrs(renderOpts),
  747. on: getNativeFilterOns(renderOpts, params, option)
  748. }, renderOpts.optionGroups ? renderNativeOptgroups(h, renderOpts, params, renderNativeOptions) : renderNativeOptions(h, renderOpts.options, renderOpts, params));
  749. });
  750. },
  751. tableFilterDefaultMethod: handleFilterMethod,
  752. tableExportMethod: handleExportSelectMethod
  753. },
  754. VxeInput: {
  755. tableAutoFocus: 'input',
  756. renderTableEdit: defaultEditRender,
  757. renderTableCell(h, renderOpts, params) {
  758. const { props = {} } = renderOpts;
  759. const { row, column } = params;
  760. const inputConfig = getConfig().input || {};
  761. const digits = props.digits || inputConfig.digits || 2;
  762. let cellValue = XEUtils.get(row, column.field);
  763. if (cellValue) {
  764. switch (props.type) {
  765. case 'date':
  766. case 'week':
  767. case 'month':
  768. case 'quarter':
  769. case 'year':
  770. cellValue = getLabelFormatDate(cellValue, props);
  771. break;
  772. case 'float':
  773. cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits);
  774. break;
  775. }
  776. }
  777. return getCellLabelVNs(h, renderOpts, params, cellValue);
  778. },
  779. renderTableDefault: defaultEditRender,
  780. createTableFilterOptions: defaultFilterOptions,
  781. renderTableFilter: defaultFilterRender,
  782. renderTableFloatingFilter: defaultFloatingFilterRender,
  783. tableFilterDefaultMethod: handleInputFilterMethod
  784. },
  785. FormatNumberInput: {
  786. renderTableDefault: handleNumberCell,
  787. tableFilterDefaultMethod: handleInputFilterMethod,
  788. tableExportMethod(params) {
  789. const { row, column } = params;
  790. const cellValue = XEUtils.get(row, column.field);
  791. return cellValue;
  792. }
  793. },
  794. VxeNumberInput: {
  795. tableAutoFocus: 'input',
  796. renderTableEdit: defaultEditRender,
  797. renderTableCell: handleNumberCell,
  798. renderTableFooter(h, renderOpts, params) {
  799. const { props = {} } = renderOpts;
  800. const { row, column, _columnIndex } = params;
  801. const { type } = props;
  802. // 兼容老模式
  803. const itemValue = XEUtils.isArray(row) ? row[_columnIndex] : XEUtils.get(row, column.field);
  804. if (XEUtils.isNumber(itemValue)) {
  805. const numberInputConfig = getConfig().numberInput || {};
  806. if (type === 'float') {
  807. const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
  808. const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1);
  809. let amountLabel = XEUtils.toFixed(XEUtils.floor(itemValue, digits), digits);
  810. if (!autoFill) {
  811. amountLabel = XEUtils.toNumber(amountLabel);
  812. }
  813. return amountLabel;
  814. }
  815. else if (type === 'amount') {
  816. const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
  817. const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2);
  818. const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false);
  819. let amountLabel = XEUtils.commafy(XEUtils.toNumber(itemValue), { digits });
  820. if (!autoFill) {
  821. const [iStr, dStr] = amountLabel.split('.');
  822. if (dStr) {
  823. const dRest = dStr.replace(/0+$/, '');
  824. amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr;
  825. }
  826. }
  827. if (showCurrency) {
  828. amountLabel = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${amountLabel}`;
  829. }
  830. return amountLabel;
  831. }
  832. }
  833. return getFuncText(itemValue, 1);
  834. },
  835. renderTableDefault: defaultEditRender,
  836. createTableFilterOptions: defaultFilterOptions,
  837. renderTableFilter: defaultFilterRender,
  838. renderTableFloatingFilter: defaultFloatingFilterRender,
  839. tableFilterDefaultMethod: handleInputFilterMethod,
  840. tableExportMethod(params) {
  841. const { row, column } = params;
  842. const cellValue = XEUtils.get(row, column.field);
  843. return cellValue;
  844. }
  845. },
  846. VxeDatePicker: {
  847. tableAutoFocus: 'input',
  848. renderTableEdit: defaultEditRender,
  849. renderTableCell(h, renderOpts, params) {
  850. const { props = {} } = renderOpts;
  851. const { row, column } = params;
  852. let cellValue = XEUtils.get(row, column.field);
  853. if (cellValue) {
  854. if (props.type !== 'time') {
  855. cellValue = getLabelFormatDate(cellValue, props);
  856. }
  857. }
  858. return getCellLabelVNs(h, renderOpts, params, cellValue);
  859. },
  860. renderTableDefault: defaultEditRender,
  861. createTableFilterOptions: defaultFilterOptions,
  862. renderTableFilter: defaultFilterRender,
  863. renderTableFloatingFilter: defaultFloatingFilterRender,
  864. tableFilterDefaultMethod: handleFilterMethod
  865. },
  866. VxeDateRangePicker: {
  867. tableAutoFocus: 'input',
  868. renderTableEdit(h, renderOpts, params) {
  869. const { startField, endField } = renderOpts;
  870. const { $table, row, column } = params;
  871. const { model } = column;
  872. const cellValue = getCellValue(row, column);
  873. const seProps = {};
  874. const seOs = {};
  875. if (startField && endField) {
  876. seProps.startValue = XEUtils.get(row, startField);
  877. seProps.endValue = XEUtils.get(row, endField);
  878. seOs['update:startValue'] = (value) => {
  879. if (startField) {
  880. XEUtils.set(row, startField, value);
  881. }
  882. };
  883. seOs['update:endValue'] = (value) => {
  884. if (endField) {
  885. XEUtils.set(row, endField, value);
  886. }
  887. };
  888. }
  889. return [
  890. h(getDefaultComponent(renderOpts), {
  891. props: getCellEditProps(renderOpts, params, cellValue, seProps),
  892. on: getComponentOns(renderOpts, params, {
  893. model(cellValue) {
  894. model.update = true;
  895. model.value = cellValue;
  896. setCellValue(row, column, cellValue);
  897. },
  898. change() {
  899. $table.updateStatus(params);
  900. },
  901. blur() {
  902. $table.handleCellRuleUpdateStatus('blur', params);
  903. }
  904. }, seOs)
  905. })
  906. ];
  907. },
  908. renderTableCell(h, renderOpts, params) {
  909. const { startField, endField } = renderOpts;
  910. const { row, column } = params;
  911. let startValue = '';
  912. let endValue = '';
  913. if (startField && endField) {
  914. startValue = XEUtils.get(row, startField);
  915. endValue = XEUtils.get(row, endField);
  916. }
  917. else {
  918. const cellValue = XEUtils.get(row, column.field);
  919. if (cellValue) {
  920. if (XEUtils.isArray(cellValue)) {
  921. startValue = cellValue[0];
  922. endValue = cellValue[1];
  923. }
  924. else {
  925. const strs = `${cellValue}`.split(',');
  926. startValue = strs[0];
  927. endValue = strs[1];
  928. }
  929. }
  930. }
  931. let cellLabel = '';
  932. if (startValue && endValue) {
  933. cellLabel = `${startValue} ~ ${endValue}`;
  934. }
  935. return getCellLabelVNs(h, renderOpts, params, cellLabel);
  936. }
  937. },
  938. VxeTextarea: {
  939. tableAutoFocus: 'textarea',
  940. renderTableEdit: defaultEditRender
  941. },
  942. VxeButton: {
  943. renderTableDefault: buttonCellRender
  944. },
  945. VxeButtonGroup: {
  946. renderTableDefault(h, renderOpts, params) {
  947. const { options } = renderOpts;
  948. return [
  949. h(getDefaultComponent(renderOpts), {
  950. props: Object.assign({ options }, getCellEditProps(renderOpts, params, null)),
  951. on: getComponentOns(renderOpts, params)
  952. })
  953. ];
  954. }
  955. },
  956. VxeSelect: {
  957. tableAutoFocus: 'input',
  958. renderTableEdit: defaultSelectEditRender,
  959. renderTableDefault: defaultSelectEditRender,
  960. renderTableCell(h, renderOpts, params) {
  961. return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params));
  962. },
  963. createTableFilterOptions: defaultFilterOptions,
  964. renderTableFilter(h, renderOpts, params) {
  965. const { column } = params;
  966. const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
  967. return column.filters.map((option, oIndex) => {
  968. const optionValue = option.data;
  969. return h(getDefaultComponent(renderOpts), {
  970. key: oIndex,
  971. props: getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
  972. on: getFilterOns(renderOpts, params, option)
  973. });
  974. });
  975. },
  976. renderTableFloatingFilter(h, renderOpts, params) {
  977. const { option } = params;
  978. const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
  979. const optionValue = option.data;
  980. return h(getDefaultComponent(renderOpts), {
  981. props: getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
  982. on: getFloatingFilterOns(renderOpts, params, option)
  983. });
  984. },
  985. tableFilterDefaultMethod: handleFilterMethod,
  986. tableExportMethod: handleExportSelectMethod
  987. },
  988. VxeText: {
  989. renderTableDefault(h, renderOpts, params) {
  990. const { $table, row, column } = params;
  991. const { props } = renderOpts;
  992. const cellLabel = $table.getCellLabel(row, column);
  993. return [
  994. h(getDefaultComponent(renderOpts), {
  995. props: Object.assign(Object.assign({}, (props || {})), { content: cellLabel }),
  996. on: getComponentOns(renderOpts, params)
  997. })
  998. ];
  999. }
  1000. },
  1001. VxeLink: {
  1002. renderTableDefault(h, renderOpts, params) {
  1003. const { $table, row, column } = params;
  1004. const { props } = renderOpts;
  1005. const { href } = props || {};
  1006. const cellLabel = $table.getCellLabel(row, column);
  1007. return [
  1008. h(getDefaultComponent(renderOpts), {
  1009. props: Object.assign(Object.assign({}, (props || {})), { content: cellLabel, href: XEUtils.toFormatString(href, params) }),
  1010. on: getComponentOns(renderOpts, params)
  1011. })
  1012. ];
  1013. }
  1014. },
  1015. /**
  1016. * 已废弃,被 FormatSelect 替换
  1017. * @deprecated
  1018. */
  1019. formatOption: {
  1020. renderTableDefault(h, renderOpts, params) {
  1021. return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params));
  1022. }
  1023. },
  1024. FormatSelect: {
  1025. renderTableDefault(h, renderOpts, params) {
  1026. return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params));
  1027. },
  1028. tableFilterDefaultMethod: handleFilterMethod,
  1029. tableExportMethod: handleExportSelectMethod
  1030. },
  1031. VxeTreeSelect: {
  1032. tableAutoFocus: 'input',
  1033. renderTableEdit: defaultTableOrTreeSelectEditRender,
  1034. renderTableCell(h, renderOpts, params) {
  1035. return getCellLabelVNs(h, renderOpts, params, getTreeSelectCellValue(renderOpts, params));
  1036. },
  1037. tableExportMethod: handleExportTreeSelectMethod
  1038. },
  1039. VxeTableSelect: {
  1040. tableAutoFocus: 'input',
  1041. renderTableEdit: defaultTableOrTreeSelectEditRender,
  1042. renderTableCell(h, renderOpts, params) {
  1043. return getCellLabelVNs(h, renderOpts, params, getTreeSelectCellValue(renderOpts, params));
  1044. },
  1045. tableExportMethod: handleExportTreeSelectMethod
  1046. },
  1047. /**
  1048. * 已废弃,被 FormatTreeSelect 替换
  1049. * @deprecated
  1050. */
  1051. formatTree: {
  1052. renderTableDefault(h, renderOpts, params) {
  1053. return getCellLabelVNs(h, renderOpts, params, getTreeSelectCellValue(renderOpts, params));
  1054. }
  1055. },
  1056. FormatTreeSelect: {
  1057. renderTableDefault(h, renderOpts, params) {
  1058. return getCellLabelVNs(h, renderOpts, params, getTreeSelectCellValue(renderOpts, params));
  1059. },
  1060. tableExportMethod: handleExportTreeSelectMethod
  1061. },
  1062. VxeColorPicker: {
  1063. tableAutoFocus: 'input',
  1064. renderTableEdit(h, renderOpts, params) {
  1065. const { row, column } = params;
  1066. const { options } = renderOpts;
  1067. const cellValue = getCellValue(row, column);
  1068. return [
  1069. h(getDefaultComponent(renderOpts), {
  1070. props: getCellEditProps(renderOpts, params, cellValue, { colors: options }),
  1071. on: getEditOns(renderOpts, params)
  1072. })
  1073. ];
  1074. },
  1075. renderTableCell(h, renderOpts, params) {
  1076. const { row, column } = params;
  1077. const cellValue = XEUtils.get(row, column.field);
  1078. return h('span', {
  1079. class: 'vxe-color-picker--readonly'
  1080. }, [
  1081. h('div', {
  1082. class: 'vxe-color-picker--readonly-color',
  1083. style: {
  1084. backgroundColor: cellValue
  1085. }
  1086. })
  1087. ]);
  1088. }
  1089. },
  1090. VxeIconPicker: {
  1091. tableAutoFocus: 'input',
  1092. renderTableEdit(h, renderOpts, params) {
  1093. const { row, column } = params;
  1094. const { options } = renderOpts;
  1095. const cellValue = getCellValue(row, column);
  1096. return [
  1097. h(getDefaultComponent(renderOpts), {
  1098. props: getCellEditProps(renderOpts, params, cellValue, { icons: options }),
  1099. on: getEditOns(renderOpts, params)
  1100. })
  1101. ];
  1102. },
  1103. renderTableCell(h, renderOpts, params) {
  1104. const { row, column } = params;
  1105. const cellValue = XEUtils.get(row, column.field);
  1106. return h('i', {
  1107. class: cellValue
  1108. });
  1109. }
  1110. },
  1111. VxeRadioGroup: {
  1112. renderTableDefault: radioAndCheckboxGroupEditRender
  1113. },
  1114. VxeCheckbox: {
  1115. renderTableDefault: checkboxEditRender
  1116. },
  1117. VxeCheckboxGroup: {
  1118. renderTableDefault: radioAndCheckboxGroupEditRender
  1119. },
  1120. VxeSwitch: {
  1121. tableAutoFocus: 'button',
  1122. renderTableEdit: defaultEditRender,
  1123. renderTableDefault: defaultEditRender
  1124. },
  1125. VxeUpload: {
  1126. renderTableEdit: defaultEditRender,
  1127. renderTableCell: defaultEditRender,
  1128. renderTableDefault: defaultEditRender
  1129. },
  1130. VxeImage: {
  1131. renderTableDefault(h, renderOpts, params) {
  1132. const { row, column } = params;
  1133. const { props } = renderOpts;
  1134. const cellValue = getCellValue(row, column);
  1135. return [
  1136. h(getDefaultComponent(renderOpts), {
  1137. props: Object.assign(Object.assign({}, props), { src: cellValue }),
  1138. on: getEditOns(renderOpts, params)
  1139. })
  1140. ];
  1141. }
  1142. },
  1143. VxeImageGroup: {
  1144. renderTableDefault(h, renderOpts, params) {
  1145. const { row, column } = params;
  1146. const { props } = renderOpts;
  1147. const cellValue = getCellValue(row, column);
  1148. return [
  1149. h(getDefaultComponent(renderOpts), {
  1150. props: Object.assign(Object.assign({}, props), { urlList: cellValue }),
  1151. on: getEditOns(renderOpts, params)
  1152. })
  1153. ];
  1154. }
  1155. },
  1156. VxeTextEllipsis: {
  1157. renderTableDefault(h, renderOpts, params) {
  1158. const { row, column } = params;
  1159. const { props } = renderOpts;
  1160. const cellValue = getCellValue(row, column);
  1161. return [
  1162. h(getDefaultComponent(renderOpts), {
  1163. props: Object.assign(Object.assign({}, props), { content: cellValue }),
  1164. on: getEditOns(renderOpts, params)
  1165. })
  1166. ];
  1167. }
  1168. },
  1169. VxeRate: {
  1170. renderTableDefault: defaultEditRender
  1171. },
  1172. VxeSlider: {
  1173. renderTableDefault: defaultEditRender
  1174. },
  1175. // 以下已废弃
  1176. $input: {
  1177. tableAutoFocus: '.vxe-input--inner',
  1178. renderTableEdit: oldEditRender,
  1179. renderTableCell(h, renderOpts, params) {
  1180. var _a;
  1181. const { props = {} } = renderOpts;
  1182. const { row, column } = params;
  1183. const digits = props.digits || ((_a = getConfig().input) === null || _a === void 0 ? void 0 : _a.digits) || 2;
  1184. let cellValue = XEUtils.get(row, column.field);
  1185. if (cellValue) {
  1186. switch (props.type) {
  1187. case 'date':
  1188. case 'week':
  1189. case 'month':
  1190. case 'year':
  1191. cellValue = getLabelFormatDate(cellValue, props);
  1192. break;
  1193. case 'float':
  1194. cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits);
  1195. break;
  1196. }
  1197. }
  1198. return getCellLabelVNs(h, renderOpts, params, cellValue);
  1199. },
  1200. renderTableDefault: oldEditRender,
  1201. renderTableFilter: oldFilterRender,
  1202. tableFilterDefaultMethod: handleInputFilterMethod
  1203. },
  1204. $textarea: {
  1205. tableAutoFocus: '.vxe-textarea--inner'
  1206. },
  1207. $button: {
  1208. renderTableDefault: oldButtonEditRender
  1209. },
  1210. $buttons: {
  1211. renderTableDefault: oldButtonsEditRender
  1212. },
  1213. $select: {
  1214. tableAutoFocus: '.vxe-input--inner',
  1215. renderTableEdit: oldSelectEditRender,
  1216. renderTableDefault: oldSelectEditRender,
  1217. renderTableCell(h, renderOpts, params) {
  1218. return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params));
  1219. },
  1220. renderTableFilter(h, renderOpts, params) {
  1221. const { column } = params;
  1222. const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
  1223. return column.filters.map((option, oIndex) => {
  1224. const optionValue = option.data;
  1225. return h(getOldComponent(renderOpts), {
  1226. key: oIndex,
  1227. props: getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
  1228. on: getFilterOns(renderOpts, params, option)
  1229. });
  1230. });
  1231. },
  1232. tableFilterDefaultMethod: handleFilterMethod,
  1233. tableExportMethod: handleExportSelectMethod
  1234. },
  1235. $radio: {
  1236. tableAutoFocus: '.vxe-radio--input'
  1237. },
  1238. $checkbox: {
  1239. tableAutoFocus: '.vxe-checkbox--input'
  1240. },
  1241. $switch: {
  1242. tableAutoFocus: '.vxe-switch--button',
  1243. renderTableEdit: oldEditRender,
  1244. renderTableDefault: oldEditRender
  1245. }
  1246. // 以上已废弃
  1247. });