operateTable.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div style="width: 100%;">
  3. <selsetHeader :options="optionsValue" @change="cascaderChangeFun"></selsetHeader>
  4. <el-table class="sysDictInfoTable" :data="data" style="width: 100%;margin-top: 20px" row-key="id" lazy
  5. ref="tableTree" v-loading="loading" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
  6. <el-table-column :prop="options[0].value" :label="options[0].label"
  7. align="center" width="180">
  8. </el-table-column>
  9. <el-table-column v-for="(item, index) in optionsData" :key="index" :prop="item.value" :label="item.label"
  10. align="center">
  11. </el-table-column>
  12. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  13. <template slot-scope="scope">
  14. <el-dropdown @command="(command) => { handleCommand(command, scope.row) }">
  15. <el-button type="warning">
  16. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  17. </el-button>
  18. <el-dropdown-menu slot="dropdown">
  19. <el-dropdown-item icon="el-icon-circle-plus-outline" command="handleAdd">新增</el-dropdown-item>
  20. <el-dropdown-item icon="el-icon-edit" command="handleUpdate">修改</el-dropdown-item>
  21. <el-dropdown-item icon="el-icon-delete" command="handleDelete">删除</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </div>
  28. </template>
  29. <script>
  30. import selsetHeader from './selsetHeader.vue'
  31. export default {
  32. name: 'operateTable',
  33. components: { selsetHeader },
  34. props: {
  35. options: {
  36. type: Array,
  37. default: () => {
  38. return [];
  39. },
  40. },
  41. data: {
  42. type: Array,
  43. default: () => {
  44. return [];
  45. }
  46. }
  47. },
  48. data() {
  49. return {
  50. optionsValue: [],
  51. optionsData: [],
  52. loading: false
  53. }
  54. },
  55. watch: {
  56. options() {
  57. this.setData();
  58. }
  59. },
  60. mounted() {
  61. this.setData();
  62. },
  63. methods: {
  64. cascaderChangeFun(e) {
  65. console.log('slect', e)
  66. // this.loading = true
  67. this.optionsData = e
  68. this.$nextTick(() => {
  69. // 在数据加载完,重新渲染表格
  70. this.$refs['tableTree'].doLayout();
  71. });
  72. // setTimeout(function (){
  73. // this.loading = false
  74. // },200)
  75. },
  76. setData() {
  77. console.log('setData', this.options)
  78. this.optionsValue = this.options.slice(1, this.options.length - 1)
  79. // this.optionsData = this.options.slice(1, 6)
  80. this.loading = false
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped lang='scss'></style>