• elementUI的table使用展开功能( type=“expand“ ),展开时合起上一次展开的内容,始终保持展开内容为一个,并且再次点击合起自身


    直接上代码了没什么可讲的,主要是用到

    row-key="id"

    :expand-row-keys="expands

    @row-click="handleRowClick"

    1. <script>
    2. import rectifyEdit from './components/rectify-edit.vue';
    3. import rectifyCorrectEdit from './components/rectify-correct-edit.vue';
    4. import rectifySearch from './components/rectify-search.vue';
    5. import { pageDisposalOrders } from '@/api/disposal/disposal-order';
    6. export default {
    7. name: 'rectify',
    8. components: {
    9. rectifySearch,
    10. rectifyCorrectEdit,
    11. rectifyEdit
    12. },
    13. data() {
    14. return {
    15. showEdit: false,
    16. showCorrectEdit: false,
    17. columns: [
    18. {
    19. width: 45,
    20. type: 'expand',
    21. columnKey: 'expand',
    22. align: 'center',
    23. slot: 'expand'
    24. },
    25. {
    26. prop: 'code',
    27. label: '处置单编号',
    28. sortable: 'custom',
    29. showOverflowTooltip: true,
    30. width: 220
    31. },
    32. {
    33. prop: 'orderType',
    34. label: '任务类型',
    35. showOverflowTooltip: true,
    36. minWidth: 110,
    37. slot: 'orderType',
    38. formatter: (_row, _column, cellValue) => {
    39. return this.$globalDictName('order_type', cellValue);
    40. }
    41. },
    42. {
    43. prop: 'superviseType',
    44. label: '监督方式',
    45. sortable: 'custom',
    46. slot: 'superviseType',
    47. minWidth: 140
    48. },
    49. {
    50. prop: 'orgName',
    51. label: '监督站',
    52. sortable: 'custom',
    53. showOverflowTooltip: true,
    54. minWidth: 140
    55. },
    56. {
    57. prop: 'unitCode',
    58. label: '生产单位',
    59. sortable: 'custom',
    60. showOverflowTooltip: true,
    61. width: 180,
    62. formatter: (_row, _column, cellValue) => {
    63. return this.$globalOrgName(cellValue);
    64. }
    65. },
    66. {
    67. prop: 'description',
    68. label: '任务描述',
    69. sortable: 'custom',
    70. showOverflowTooltip: true,
    71. minWidth: 140
    72. },
    73. {
    74. prop: 'findDate',
    75. label: '监督日期',
    76. sortable: 'custom',
    77. showOverflowTooltip: true,
    78. width: 180,
    79. formatter: (_row, _column, cellValue) => {
    80. return this.$util.toDateString(cellValue, 'yyyy-MM-dd');
    81. }
    82. }
    83. ],
    84. current: {},
    85. currentCorrect: {},
    86. expands: [],
    87. currentRow: null
    88. };
    89. },
    90. created() {},
    91. methods: {
    92. handleRowClick(row) {
    93. if (this.expands.includes(row.id)) {
    94. this.expands = this.expands.filter((val) => val !== row.id);
    95. } else {
    96. this.expands = [];
    97. this.expands.push(row.id);
    98. }
    99. },
    100. handleCurrentChange(val) {
    101. this.currentRow = val;
    102. },
    103. /* 表格数据源 */
    104. datasource({ page, limit, where, order }) {
    105. let statusList = null; //'(0,-1,-2)';
    106. return pageDisposalOrders({
    107. ...where,
    108. ...order,
    109. page,
    110. limit,
    111. auditStatus: 0,
    112. rectifyStatus: 0,
    113. statusIds: statusList
    114. });
    115. // return data;
    116. },
    117. getDictName(type, code) {
    118. return this.$globalDictName(type, code);
    119. },
    120. /* 刷新表格 */
    121. reload(where) {
    122. this.$refs.table.reload({ where: where });
    123. },
    124. /* 打开所有记录 */
    125. openEdit(row) {
    126. this.current = row;
    127. this.showEdit = true;
    128. },
    129. toCorrect(row) {
    130. this.currentCorrect = row;
    131. this.showCorrectEdit = true;
    132. }
    133. }
    134. };
    135. script>

  • 相关阅读:
    按照Gartner的概念,国内所谓低代码产品都是“伪低代码”——到底什么才是“低代码”?
    【通信原理课设--基于MATLAB/Simulink的2ASK数字带通传输系统建模与仿真】Simulink的使用介绍以及在本实验中的使用
    金额转大写查询易语言代码
    实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
    js:对dom元素class属性进行读取、更新、移除操作
    win10彻底禁用wsappx的方法
    GPTZero:论文打假神器
    uniapp 触底加载
    flash-linear-attention CUDA算子成功实现(但限制极多。。)
    Etcd 常用命令与备份恢复
  • 原文地址:https://blog.csdn.net/weixin_54930261/article/details/139826679