ElementsMapping.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div>
  3. <el-button v-for="(i,index) in getCellList" @click="i.click()" :key="index" v-bind="i.attrs" v-debounce
  4. v-show="index < 2">{{ i.attrs.label }}</el-button>
  5. <el-dropdown v-show="getCellList && getCellList.length>2">
  6. <span class="el-dropdown-link">
  7. <span class="more-btn">更多</span>
  8. </span>
  9. <template #dropdown>
  10. <el-dropdown-menu>
  11. <el-dropdown-item :class="index > 1 ? '' : 'dn'" @click="i.click()" v-for="(i,index) in getCellList" :key="index">
  12. <span :style="i.attrs.type == 'danger' ? 'color:#f56c6c' : 'color:#409eff'">{{ i.attrs.label}}</span>
  13. </el-dropdown-item>
  14. </el-dropdown-menu>
  15. </template>
  16. </el-dropdown>
  17. </div>
  18. </template>
  19. <script>
  20. import {
  21. defineComponent,
  22. getCurrentInstance,
  23. computed,
  24. ref,
  25. h,
  26. withDirectives,
  27. resolveDirective,
  28. resolveComponent,
  29. } from "vue";
  30. export default defineComponent({
  31. props: {
  32. parent: {
  33. type: Object,
  34. default() {
  35. return {};
  36. },
  37. },
  38. row: {
  39. type: Object,
  40. default() {
  41. return {};
  42. },
  43. },
  44. cellList: {
  45. type: Array,
  46. default() {
  47. return [];
  48. },
  49. },
  50. },
  51. setup(props) {
  52. const { proxy } = getCurrentInstance();
  53. const getCellList = computed(() => {
  54. return props.cellList.filter((cell) => cell && Object.keys(cell).length);
  55. });
  56. return {
  57. getCellList,
  58. };
  59. },
  60. });
  61. </script>
  62. <style scoped>
  63. .more-btn {
  64. line-height: 34px;
  65. font-size: 14px;
  66. color: #ff9315;
  67. padding: 6px;
  68. }
  69. .dn {
  70. display: none !important;
  71. }
  72. :deep(.el-dropdown-link) {
  73. margin-left: 0px !important;
  74. }
  75. </style>