730c4af62f009dc5677219ac8cce5e002f0b431fb84813a604488c6b3181f12fd2b1257761174c59f781bebabf571935772178a788999e4d4439a0fad23820 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. @import "mixins/mixins";
  2. @import "checkbox";
  3. @import "tag";
  4. @import "tooltip";
  5. @import "common/var";
  6. @include b(table) {
  7. position: relative;
  8. overflow: hidden;
  9. box-sizing: border-box;
  10. flex: 1;
  11. width: 100%;
  12. max-width: 100%;
  13. background-color: $--color-white;
  14. font-size: 14px;
  15. color: $--table-font-color;
  16. // 数据为空
  17. @include e(empty-block) {
  18. min-height: 60px;
  19. text-align: center;
  20. width: 100%;
  21. display: flex;
  22. justify-content: center;
  23. align-items: center;
  24. }
  25. @include e(empty-text) {
  26. // min-height doesn't work in IE10 and IE11 https://github.com/philipwalton/flexbugs#3-min-height-on-a-flex-container-wont-apply-to-its-flex-items
  27. // set empty text line height up to contrainer min-height as workaround.
  28. line-height: 60px;
  29. width: 50%;
  30. color: $--color-text-secondary;
  31. }
  32. // 展开行
  33. @include e(expand-column) {
  34. .cell {
  35. padding: 0;
  36. text-align: center;
  37. }
  38. }
  39. @include e(expand-icon) {
  40. position: relative;
  41. cursor: pointer;
  42. color: #666;
  43. font-size: 12px;
  44. transition: transform 0.2s ease-in-out;
  45. height: 20px;
  46. @include m(expanded) {
  47. transform: rotate(90deg);
  48. }
  49. > .el-icon {
  50. position: absolute;
  51. left: 50%;
  52. top: 50%;
  53. margin-left: -5px;
  54. margin-top: -5px;
  55. }
  56. }
  57. @include e(expanded-cell) {
  58. background-color: $--color-white;
  59. // 纯属为了增加权重
  60. &[class*=cell] {
  61. padding: 20px 50px;
  62. }
  63. &:hover {
  64. background-color: transparent !important;
  65. }
  66. }
  67. @include e(placeholder) {
  68. display: inline-block;
  69. width: 20px;
  70. }
  71. @include e(append-wrapper) {
  72. // 避免外边距重合 https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
  73. overflow: hidden;
  74. }
  75. @include m(fit) {
  76. border-right: 0;
  77. border-bottom: 0;
  78. .el-table__cell.gutter {
  79. border-right-width: 1px;
  80. }
  81. }
  82. @include m(scrollable-x) {
  83. .el-table__body-wrapper {
  84. overflow-x: auto;
  85. }
  86. }
  87. @include m(scrollable-y) {
  88. .el-table__body-wrapper {
  89. overflow-y: auto;
  90. }
  91. }
  92. thead {
  93. color: $--table-header-font-color;
  94. font-weight: 500;
  95. &.is-group {
  96. th.el-table__cell {
  97. background: $--background-color-base;
  98. }
  99. }
  100. }
  101. .el-table__cell {
  102. padding: 12px 0;
  103. min-width: 0;
  104. box-sizing: border-box;
  105. text-overflow: ellipsis;
  106. vertical-align: middle;
  107. position: relative;
  108. text-align: left;
  109. @include when(center) {
  110. text-align: center;
  111. }
  112. @include when(right) {
  113. text-align: right;
  114. }
  115. &.gutter {
  116. width: 15px;
  117. border-right-width: 0;
  118. border-bottom-width: 0;
  119. padding: 0;
  120. }
  121. &.is-hidden {
  122. > * {
  123. visibility: hidden;
  124. }
  125. }
  126. }
  127. @include m(medium) {
  128. .el-table__cell {
  129. padding: 10px 0;
  130. }
  131. }
  132. @include m(small) {
  133. font-size: 12px;
  134. .el-table__cell {
  135. padding: 8px 0;
  136. }
  137. }
  138. @include m(mini) {
  139. font-size: 12px;
  140. .el-table__cell {
  141. padding: 6px 0;
  142. }
  143. }
  144. tr {
  145. background-color: $--color-white;
  146. input[type="checkbox"] {
  147. margin: 0;
  148. }
  149. }
  150. th.el-table__cell.is-leaf,
  151. td.el-table__cell {
  152. border-bottom: $--table-border;
  153. }
  154. th.el-table__cell.is-sortable {
  155. cursor: pointer;
  156. }
  157. th.el-table__cell {
  158. overflow: hidden;
  159. user-select: none;
  160. background-color: $--table-header-background-color;
  161. > .cell {
  162. display: inline-block;
  163. box-sizing: border-box;
  164. position: relative;
  165. vertical-align: middle;
  166. padding-left: 10px;
  167. padding-right: 10px;
  168. width: 100%;
  169. &.highlight {
  170. color: $--color-primary;
  171. }
  172. }
  173. &.required > div::before {
  174. display: inline-block;
  175. content: "";
  176. width: 8px;
  177. height: 8px;
  178. border-radius: 50%;
  179. background: #ff4d51;
  180. margin-right: 5px;
  181. vertical-align: middle;
  182. }
  183. }
  184. td.el-table__cell {
  185. div {
  186. box-sizing: border-box;
  187. }
  188. &.gutter {
  189. width: 0;
  190. }
  191. }
  192. .cell {
  193. box-sizing: border-box;
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. white-space: normal;
  197. word-break: break-all;
  198. line-height: 23px;
  199. padding-left: 10px;
  200. padding-right: 10px;
  201. &.el-tooltip {
  202. white-space: nowrap;
  203. min-width: 50px;
  204. }
  205. }
  206. // 拥有多级表头
  207. @include m((group, border)) {
  208. border: $--table-border;
  209. @include share-rule(border-pseudo) {
  210. content: '';
  211. position: absolute;
  212. background-color: $--table-border-color;
  213. z-index: 1;
  214. }
  215. // 表格右部伪 border
  216. &::after {
  217. @include extend-rule(border-pseudo);
  218. top: 0;
  219. right: 0;
  220. width: 1px;
  221. height: 100%;
  222. }
  223. }
  224. // 表格底部伪 border,总是有的
  225. &::before {
  226. @include extend-rule(border-pseudo);
  227. left: 0;
  228. bottom: 0;
  229. width: 100%;
  230. height: 1px;
  231. }
  232. // table--border
  233. @include m(border) {
  234. border-right: none;
  235. border-bottom: none;
  236. &.el-loading-parent--relative {
  237. border-color: transparent;
  238. }
  239. .el-table__cell {
  240. border-right: $--table-border;
  241. &:first-child .cell {
  242. padding-left: 10px;
  243. }
  244. }
  245. th.el-table__cell.gutter:last-of-type {
  246. border-bottom: $--table-border;
  247. border-bottom-width: 1px;
  248. }
  249. & th.el-table__cell {
  250. border-bottom: $--table-border;
  251. }
  252. }
  253. @include m(hidden) {
  254. visibility: hidden;
  255. }
  256. @include e((fixed, fixed-right)) {
  257. position: absolute;
  258. top: 0;
  259. left: 0;
  260. overflow-x: hidden;
  261. overflow-y: hidden;
  262. box-shadow: $--table-fixed-box-shadow;
  263. &::before {
  264. content: '';
  265. position: absolute;
  266. left: 0;
  267. bottom: 0;
  268. width: 100%;
  269. height: 1px;
  270. background-color: $--border-color-lighter;
  271. z-index: 4;
  272. }
  273. }
  274. @include e(fixed-right-patch) {
  275. position: absolute;
  276. top: -1px;
  277. right: 0;
  278. background-color: $--color-white;
  279. border-bottom: $--table-border;
  280. }
  281. @include e(fixed-right) {
  282. top: 0;
  283. left: auto;
  284. right: 0;
  285. .el-table__fixed-header-wrapper,
  286. .el-table__fixed-body-wrapper,
  287. .el-table__fixed-footer-wrapper {
  288. left: auto;
  289. right: 0;
  290. }
  291. }
  292. @include e(fixed-header-wrapper) {
  293. position: absolute;
  294. left: 0;
  295. top: 0;
  296. z-index: 3;
  297. }
  298. @include e(fixed-footer-wrapper) {
  299. position: absolute;
  300. left: 0;
  301. bottom: 0;
  302. z-index: 3;
  303. & tbody td.el-table__cell {
  304. border-top: $--table-border;
  305. background-color: $--table-row-hover-background-color;
  306. color: $--table-font-color;
  307. }
  308. }
  309. @include e(fixed-body-wrapper) {
  310. position: absolute;
  311. left: 0;
  312. top: 37px;
  313. overflow: hidden;
  314. z-index: 3;
  315. }
  316. @include e((header-wrapper, body-wrapper, footer-wrapper)) {
  317. width: 100%;
  318. }
  319. @include e(footer-wrapper) {
  320. margin-top: -1px;
  321. td.el-table__cell {
  322. border-top: $--table-border;
  323. }
  324. }
  325. @include e((header, body, footer)) {
  326. table-layout: fixed;
  327. border-collapse: separate;
  328. }
  329. @include e((header-wrapper, footer-wrapper)) {
  330. overflow: hidden;
  331. & tbody td.el-table__cell {
  332. background-color: $--table-row-hover-background-color;
  333. color: $--table-font-color;
  334. }
  335. }
  336. @include e(body-wrapper) {
  337. overflow: hidden;
  338. position: relative;
  339. @include when(scrolling-none) {
  340. ~ .el-table__fixed,
  341. ~ .el-table__fixed-right {
  342. box-shadow: none;
  343. }
  344. }
  345. @include when(scrolling-left) {
  346. ~ .el-table__fixed {
  347. box-shadow: none;
  348. }
  349. }
  350. @include when(scrolling-right) {
  351. ~ .el-table__fixed-right {
  352. box-shadow: none;
  353. }
  354. }
  355. .el-table--border {
  356. @include when(scrolling-right) {
  357. ~ .el-table__fixed-right {
  358. border-left: $--table-border;
  359. }
  360. }
  361. @include when(scrolling-left) {
  362. ~ .el-table__fixed {
  363. border-right: $--table-border;
  364. }
  365. }
  366. }
  367. }
  368. .caret-wrapper {
  369. display: inline-flex;
  370. flex-direction: column;
  371. align-items: center;
  372. height: 34px;
  373. width: 24px;
  374. vertical-align: middle;
  375. cursor: pointer;
  376. overflow: initial;
  377. position: relative;
  378. }
  379. .sort-caret {
  380. width: 0;
  381. height: 0;
  382. border: solid 5px transparent;
  383. position: absolute;
  384. left: 7px;
  385. &.ascending {
  386. border-bottom-color: $--color-text-placeholder;
  387. top: 5px;
  388. }
  389. &.descending {
  390. border-top-color: $--color-text-placeholder;
  391. bottom: 7px;
  392. }
  393. }
  394. .ascending .sort-caret.ascending {
  395. border-bottom-color: $--color-primary;
  396. }
  397. .descending .sort-caret.descending {
  398. border-top-color: $--color-primary;
  399. }
  400. .hidden-columns {
  401. visibility: hidden;
  402. position: absolute;
  403. z-index: -1;
  404. }
  405. @include m(striped) {
  406. & .el-table__body {
  407. & tr.el-table__row--striped {
  408. td.el-table__cell {
  409. background: #FAFAFA;
  410. }
  411. &.current-row td.el-table__cell, &.selection-row td.el-table__cell {
  412. background-color: $--table-current-row-background-color;
  413. }
  414. }
  415. }
  416. }
  417. @include e(body) {
  418. tr.hover-row {
  419. &, &.el-table__row--striped {
  420. &, &.current-row, &.selection-row {
  421. > td.el-table__cell {
  422. background-color: $--table-row-hover-background-color;
  423. }
  424. }
  425. }
  426. }
  427. tr.current-row > td.el-table__cell, tr.selection-row > td.el-table__cell {
  428. background-color: $--table-current-row-background-color;
  429. }
  430. }
  431. @include e(column-resize-proxy) {
  432. position: absolute;
  433. left: 200px;
  434. top: 0;
  435. bottom: 0;
  436. width: 0;
  437. border-left: $--table-border;
  438. z-index: 10;
  439. }
  440. @include e(column-filter-trigger) {
  441. display: inline-block;
  442. line-height: 34px;
  443. cursor: pointer;
  444. & i {
  445. color: $--color-info;
  446. font-size: 12px;
  447. transform: scale(.75);
  448. }
  449. }
  450. @include m(enable-row-transition) {
  451. .el-table__body td.el-table__cell {
  452. transition: background-color .25s ease;
  453. }
  454. }
  455. @include m(enable-row-hover) {
  456. .el-table__body tr:hover > td.el-table__cell {
  457. background-color: $--table-row-hover-background-color;
  458. }
  459. }
  460. @include m(fluid-height) {
  461. .el-table__fixed,
  462. .el-table__fixed-right {
  463. bottom: 0;
  464. overflow: hidden;
  465. }
  466. }
  467. [class*=el-table__row--level] {
  468. .el-table__expand-icon {
  469. display: inline-block;
  470. width: 20px;
  471. line-height: 20px;
  472. height: 20px;
  473. text-align: center;
  474. margin-right: 3px;
  475. }
  476. }
  477. }