checkDetailEle.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <el-dialog
  3. title="选择元素表"
  4. :visible.sync="dialogVisible"
  5. width="800px"
  6. append-to-body
  7. :close-on-click-modal="false"
  8. >
  9. <div class="flex mg-b-10">
  10. <el-input
  11. v-model="formulaInput"
  12. placeholder="请输入名称"
  13. size="samll" clearable
  14. ></el-input>
  15. <el-button type="primary" class="mg-l-10" @click="searchFormulaName">搜索</el-button>
  16. </div>
  17. <el-table
  18. :data="editEleListFilter"
  19. border
  20. style="width: 100%"
  21. height="400px"
  22. >
  23. <el-table-column align="center" prop="eName" label="字段信息">
  24. </el-table-column>
  25. <el-table-column align="center" label="操作" width="200">
  26. <template slot-scope="scope">
  27. <el-link v-if="!scope.row.select" @click="selectElement(scope.row,scope.$index)"
  28. type="primary"
  29. >选择</el-link
  30. >
  31. <el-link
  32. @click="canlSelect(scope.row,scope.$index)"
  33. v-else
  34. type="danger"
  35. >取消选择</el-link
  36. >
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <span slot="footer" class="dialog-footer">
  41. <el-button @click="dialogVisible = false">取消</el-button>
  42. <el-button type="primary" @click="confirmSelection">确定</el-button>
  43. </span>
  44. </el-dialog>
  45. </template>
  46. <script>
  47. import {getTableElments} from "@/api/manager/wbstree";
  48. import { log } from "@antv/g2plot/lib/utils";
  49. export default {
  50. data() {
  51. return {
  52. dialogVisible: false,
  53. formulaInput:'',
  54. editEleListFilter:[],
  55. editEleListAll:[],
  56. selectedDataValue:[]
  57. };
  58. },
  59. methods: {
  60. show(id,selectedData) {
  61. this.dialogVisible = true;
  62. this.selectedDataValue = selectedData;
  63. console.log(this.selectedDataValue,'this.selectedDataValue');
  64. getTableElments(id).then((res) => {
  65. this.editEleListFilter = res.data.data;
  66. this.editEleListAll = [].concat(this.editEleListFilter);
  67. this.updateSelectStatus();
  68. })
  69. },
  70. updateSelectStatus() {
  71. const selectedIds = new Set(this.selectedDataValue.map(item => item.id));
  72. this.editEleListFilter.forEach(item => {
  73. if (selectedIds.has(item.id)) {
  74. // item.select = true;
  75. this.$set(item, 'select', true)
  76. }
  77. });
  78. },
  79. //搜索 筛选
  80. searchFormulaName(){
  81. this.editEleListFilter = this.editEleListAll.filter((ele)=>{
  82. return ele.eName.indexOf(this.formulaInput) > -1;
  83. })
  84. },
  85. selectElement(row,index){
  86. // row.select =true
  87. this.$set(row, "select", true)
  88. console.log(row,'row');
  89. },
  90. canlSelect(row,index){
  91. this.$set(row, "select", false)
  92. },
  93. /**
  94. * 确认用户选择的操作,并将选中的数据传递给父组件
  95. */
  96. confirmSelection() {
  97. // 过滤出 select 为 true 的数据
  98. const selectedData = this.editEleListFilter.filter(item => item.select === true);
  99. const combinedData = [...this.selectedDataValue, ...selectedData];
  100. // 使用 Map 来过滤掉重复的 id
  101. const uniqueData = Array.from(new Map(combinedData.map(item => [item.id, item])).values());
  102. // 触发事件将选中的数据传递给父组件
  103. this.$emit('confirm-selection', uniqueData);
  104. this.dialogVisible = false;
  105. }
  106. }
  107. }
  108. </script>