el-table动态行和列及多级表头

news2025/1/5 18:24:17

主页面 

<template>
    <div class="result-wrapper">
      <dynamic-table :table-data="tableData" :table-header="tableConfig" :tableTitle="tableTitle" :flowParams="flowParams"></dynamic-table>
    </div>
</template>

<script>
import DynamicTable from './components/DynamicTable'
import dataInfo from "./data.json";
export default {
  props: {},
  components: {
    DynamicTable
  },
  data() {
    return {
      tableTitle: '邮政企业三级领导人员2024年7月绩效考核指标得分数据库',
      tableData: [],
      tableConfig: []
    }
  },
  computed: {
  },
  async created() {
  },
  methods: {
    openFlowPage() {
      let respData = dataInfo.data;
      if (respData.evalPerformanceRecordDetailList && respData.evalPerformanceRecordDetailList.length) {
        let list = JSON.parse(JSON.stringify(respData.evalPerformanceRecordDetailList)) // 表格业务数据
        let tableData = JSON.parse(JSON.stringify(respData.evalPerformanceRecordDetailList)) // 表格业务数据
        this.tableData = list
        this.tableConfigDeal(list[0].evalFormIndicatorBlocks)
        this.gettableData(tableData);
        console.log(this.tableConfig, 'tableConfig')
        console.log(this.tableData, 'tableData')
      }
    },
    tableDataFormat () {
      const data = JSON.parse(JSON.stringify([...this.tableData]));
      data.forEach((item) => {
        const newArray = [];
        for (const key in item.value) {
          // console.log(item.value, 'item.value');
          // console.log(key, 'key');
          if (item.value[key]) {
            delete item.value[key].children
            newArray.push(item.value[key])
          }
        }
        item.newArray = newArray
        delete item.value
      })
      return data
    },
    getForData(array, count) {
      if (count) {
        count++
      } else {
        count = 1
      }
      array.forEach((item) => {
          item.floor = count;
        if (item.children && item.children.length) {
          this.getForData(item.children, count)
        } else {
          item.children = [
            {
              label: '标杆值',
              prop: 'benchmarkVal', 
              valueData: item.id,
              formIndicatorBlockId: item.formIndicatorBlockId
            },
            {
              label: '完成值',
              prop: 'completionVal',
              valueData: item.id,
              formIndicatorBlockId: item.formIndicatorBlockId
            },
            {
              label: '建议得分',
              prop: 'scoreVal',
              valueData: item.id,
              formIndicatorBlockId: item.formIndicatorBlockId,
            }
          ]
        }
        if (item.floor === 2 && item && !this.hasLabelData(item.children, '建议得分合计')) { 
          item.children.push({
            label: '建议得分合计',
            prop: 'suggestScoreTotal',
            valueData: item.id,
            type: true,
            formIndicatorBlockId: item.formIndicatorBlockId
          })
          if (item.isShowLeaderMarkScore) {
            item.children.push( { 
              label: '领导评分',
              prop: 'leaderScore',
              valueData: item.id,
              type: false,
              formIndicatorBlockId: item.formIndicatorBlockId
            })
          }
        }
      })
    },
    getTablejson(array, json, personObj, count) {
      if (count) {
        count++
      } else {
        count = 1
      }
      array.forEach((obj) => {
        if (obj.hasOwnProperty('suggestScoreTotal')) {
          json[obj.id] = {
            ...obj,
          };
        } 
        obj.floor = count;
        if (obj.children && obj.children.length) {
          this.getTablejson(obj.children, json, obj, count)
        } else {
          json[obj.id] = {
            ...obj,
           originDataNoChild: true
          };
        }
      });
    },
    gettableData(array) {
      const tableData = [];
      array.forEach((item) => {
        const json = {
          value: {}
        };
        json.id = item.empNumber;
        json.company = item.company;
        if (item.evalFormIndicatorBlocks && item.evalFormIndicatorBlocks.length) {
          item.evalFormIndicatorBlocks.forEach((list) => {
            this.getTablejson(list.children, json.value, list, 0);
          })
        }
        tableData.push(json);
      });
      this.tableData = tableData;
    },
    tableConfigDeal(array) {
      // console.log(array, 'array');
      this.getForData(array, 0);
      let tableConfig = [
        {
          id: 10,
          label: '单位',
          prop: 'company'
        }
      ]
      this.tableConfig = tableConfig.concat(array);
    },
    hasLabelData (children, key) {
      let flag = false
      for(let i = 0; i < children.length; i++) {
        if (children[i].label === key) {
          flag = true
          break
        }
      }
      return flag
    }
  }                 
}
</script>
<style scoped lang="scss">
::v-deep .el-table--border th, ::v-deep .el-table__fixed-right-patch {
  border-bottom: 1px solid #666666;
}
::v-deep .el-table--border td, .el-table--border th, ::v-deep .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
  border-right: 1px solid #666666;
}
::v-deep .el-table--border, ::v-deep .el-table--group {
  border: 1px solid #666666;
}
::v-deep .el-table--border td, ::v-deep .el-table--border th, ::v-deep .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
  border-right: 1px solid #666666;
}
::v-deep .el-table td, ::v-deep .el-table th.is-leaf {
  border-bottom: 1px solid #666666;
}
</style>

页面表格表头和表内容数据 

{
    "code": "0",
    "msg": "成功",
    "data": [
        {
            "id": "8837445335765553152",
            "empNumber": "LXZT00002",
            "company": "石家庄",
            "evalFormIndicatorBlocks": [
                {
                    "id": "8837445339947274240",
                    "performanceRecordId": "8837445334637285376",
                    "sectionType": "quality",
                    "children": [
                        {
                            "id": "8837445434885345280",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445339947274240",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "80",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT00008",
                            "itemLevel": "/战略绩效得分",
                            "children": null,
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": null,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": true,
                            "label": "战略绩效得分"
                        }
                    ],
                    "score": "80",
                    "label": "战略绩效指标"
                },
                {
                    "id": "8837445391839203328",
                    "performanceRecordId": "8837445334637285376",
                    "sectionType": "quantity",
                    "children": [
                        {
                            "id": "8837445436214939648",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445391839203328",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "6",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT00006",
                            "itemLevel": "/“两集中”改革",
                            "children": [
                                {
                                    "id": "8837445437431287808",
                                    "parentId": "8837445436214939648",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "3",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00006",
                                    "itemLevel": "/“两集中”改革/组织管理架构和质量指标体系建设情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "组织管理架构和质量指标体系建设情况"
                                },
                                {
                                    "id": "8837445440002396160",
                                    "parentId": "8837445436214939648",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "3",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00006",
                                    "itemLevel": "/“两集中”改革/处理中心人均处理效率",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "处理中心人均处理效率"
                                }
                            ],
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": null,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": false,
                            "label": "“两集中”改革"
                        },
                        {
                            "id": "8837445442326040576",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445391839203328",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "7",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT00007",
                            "itemLevel": "/协同与服务乡村振兴",
                            "children": [
                                {
                                    "id": "8837445443424948224",
                                    "parentId": "8837445442326040576",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "3",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00006",
                                    "itemLevel": "/协同与服务乡村振兴/服务乡村振兴重点指标完成情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "服务乡村振兴重点指标完成情况"
                                },
                                {
                                    "id": "8837445445991862272",
                                    "parentId": "8837445442326040576",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "2",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00007",
                                    "itemLevel": "/协同与服务乡村振兴/协同项目重点目标完成情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "协同项目重点目标完成情况"
                                },
                                {
                                    "id": "8837445448374226944",
                                    "parentId": "8837445442326040576",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "2",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00007",
                                    "itemLevel": "/协同与服务乡村振兴/营销体系建设落实情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "营销体系建设落实情况"
                                }
                            ],
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": true,
                            "isCanLeaderMarkScore": true,
                            "isCanScore": false,
                            "label": "协同与服务乡村振兴"
                        },
                        {
                            "id": "8837445451129884672",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445391839203328",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "7",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT000016",
                            "itemLevel": "/三级物流体系、“网点+站点”",
                            "children": [
                                {
                                    "id": "8837445452400758784",
                                    "parentId": "8837445451129884672",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "5",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT000015",
                                    "itemLevel": "/三级物流体系、“网点+站点”/三级物流体系",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "三级物流体系"
                                },
                                {
                                    "id": "8837445454976061440",
                                    "parentId": "8837445451129884672",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "2",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT000016",
                                    "itemLevel": "/三级物流体系、“网点+站点”/“网点+站点”",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "“网点+站点”"
                                }
                            ],
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": true,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": false,
                            "label": "三级物流体系、“网点+站点”"
                        }
                    ],
                    "score": "20",
                    "label": "重点任务指标"
                }
            ]
        },
        {
            "id": "8837445336914792448",
            "empNumber": "LXZT00001",
            "company": "唐山",
            "evalFormIndicatorBlocks": [
                {
                    "id": "8837445339947274240",
                    "performanceRecordId": "8837445334637285376",
                    "sectionType": "quality",
                    "children": [
                        {
                            "id": "8837445434885345280",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445339947274240",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "80",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT00008",
                            "itemLevel": "/战略绩效得分",
                            "children": null,
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": null,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": null,
                            "label": "战略绩效得分"
                        }
                    ],
                    "score": "80",
                    "label": "战略绩效指标"
                },
                {
                    "id": "8837445391839203328",
                    "performanceRecordId": "8837445334637285376",
                    "sectionType": "quantity",
                    "children": [
                        {
                            "id": "8837445436214939648",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445391839203328",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "6",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT00006",
                            "itemLevel": "/“两集中”改革",
                            "children": [
                                {
                                    "id": "8837445437431287808",
                                    "parentId": "8837445436214939648",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "3",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00006",
                                    "itemLevel": "/“两集中”改革/组织管理架构和质量指标体系建设情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "组织管理架构和质量指标体系建设情况"
                                },
                                {
                                    "id": "8837445440002396160",
                                    "parentId": "8837445436214939648",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "3",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00006",
                                    "itemLevel": "/“两集中”改革/处理中心人均处理效率",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "处理中心人均处理效率"
                                }
                            ],
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": null,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": false,
                            "label": "“两集中”改革"
                        },
                        {
                            "id": "8837445442326040576",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445391839203328",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "7",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT00007",
                            "itemLevel": "/协同与服务乡村振兴",
                            "children": [
                                {
                                    "id": "8837445443424948224",
                                    "parentId": "8837445442326040576",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "3",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00006",
                                    "itemLevel": "/协同与服务乡村振兴/服务乡村振兴重点指标完成情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "服务乡村振兴重点指标完成情况"
                                },
                                {
                                    "id": "8837445445991862272",
                                    "parentId": "8837445442326040576",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "2",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00007",
                                    "itemLevel": "/协同与服务乡村振兴/协同项目重点目标完成情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "协同项目重点目标完成情况"
                                },
                                {
                                    "id": "8837445448374226944",
                                    "parentId": "8837445442326040576",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "2",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT00007",
                                    "itemLevel": "/协同与服务乡村振兴/营销体系建设落实情况",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "营销体系建设落实情况"
                                }
                            ],
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": null,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": false,
                            "label": "协同与服务乡村振兴"
                        },
                        {
                            "id": "8837445451129884672",
                            "parentId": null,
                            "performanceRecordId": "8837445334637285376",
                            "formIndicatorBlockId": "8837445391839203328",
                            "scoreVal": null,
                            "empNumber": "LXZT00001",
                            "company": "唐山",
                            "benchmarkVal": null,
                            "completionVal": null,
                            "score": "7",
                            "suggestScoreTotal": null,
                            "leaderScore": null,
                            "informantNumber": "LXZT000016",
                            "itemLevel": "/三级物流体系、“网点+站点”",
                            "children": [
                                {
                                    "id": "8837445452400758784",
                                    "parentId": "8837445451129884672",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "5",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT000015",
                                    "itemLevel": "/三级物流体系、“网点+站点”/三级物流体系",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "三级物流体系"
                                },
                                {
                                    "id": "8837445454976061440",
                                    "parentId": "8837445451129884672",
                                    "performanceRecordId": "8837445334637285376",
                                    "formIndicatorBlockId": "8837445391839203328",
                                    "scoreVal": null,
                                    "empNumber": "LXZT00001",
                                    "company": "唐山",
                                    "benchmarkVal": null,
                                    "completionVal": null,
                                    "score": "2",
                                    "suggestScoreTotal": null,
                                    "leaderScore": null,
                                    "informantNumber": "LXZT000016",
                                    "itemLevel": "/三级物流体系、“网点+站点”/“网点+站点”",
                                    "children": null,
                                    "leaderMarkScoreList": null,
                                    "isShowLeaderMarkScore": null,
                                    "isCanLeaderMarkScore": null,
                                    "isCanScore": null,
                                    "label": "“网点+站点”"
                                }
                            ],
                            "leaderMarkScoreList": null,
                            "isShowLeaderMarkScore": null,
                            "isCanLeaderMarkScore": null,
                            "isCanScore": false,
                            "label": "三级物流体系、“网点+站点”"
                        }
                    ],
                    "score": "20",
                    "label": "重点任务指标"
                }
            ]
        }
    ]
}

DynamicTable.vue

n<template>
  <div>
    <el-table :data="tableData" border :height="height">
        <template v-for="(item) in tableHeader">
            <table-column v-if="item.children && item.children.length" :key="item.id" :coloumn-header="item" :flowParams="flowParams"></table-column>
            <el-table-column v-else :key="item.id" :label="item.label" :prop="item.prop" align="center">
            </el-table-column>
        </template>
    </el-table>
  </div>
   
  </template>
  
  <script>
  import TableColumn from './TableColumn'
  export default {
    props: {
      tableTitle: {
        type: String,
        require: true
      },
      // 表格的数据
      tableData: {
        type: Array,
        required: true
      },
      // 多级表头的数据
      tableHeader: {
        type: Array,
        required: true
      },
      // 表格的高度
      height: {
        type: String,
        // default: '300'
      },
      // 流程数据
      flowParams: {
        type: Object,
        default: ()=>{ return {} } 
      }
    },
    data () {
      return {
      }
    },
    watch: {
    },
    components: {
      TableColumn
    },
    methods: {
      
    }
  }
  </script>
  
  <style scoped>
  
  </style>

 TableColumn.vue

<template>
    <el-table-column :label="`${coloumnHeader.label}(${coloumnHeader.score}分)`" :prop="coloumnHeader.label" align="center">
      <template v-for="item in coloumnHeader.children">
        <tableColumn v-if="item.children && item.children.length" :key="item.id" :coloumn-header="item" :flowParams="flowParams"></tableColumn>
        <el-table-column v-else :key="item.label" :label="item.label" :prop="item.prop" align="center">
          <template slot-scope="{row}">
              <template v-if="item.type">
                {{getScope1(item, row)}}
              </template>
              <template v-else>
                <!-- isCanLeaderMarkScore为true领导可编辑 isCanScore 固定三项可编辑 已办不可编辑 -->
                <el-input v-model="row.value[item.valueData][item.prop]" @input="handleIpt(row.value, item)" :title="row.value[item.valueData][item.prop]" :disabled="(flowParams && flowParams.isView === 'true') || (item.prop === 'leaderScore' ? !row.value[item.valueData].isCanLeaderMarkScore : !row.value[item.valueData].isCanScore)"></el-input>
              </template>
          </template> 
        </el-table-column>
      </template>
    </el-table-column>
  </template>
  ;
  <script>
  export default {
    name: 'tableColumn',
    props: {
      coloumnHeader: {
        type: Object,
        required: true
      },
      // 流程数据
      flowParams: {
        type: Object,
        default: ()=>{ return {} } 
      }
    },
    methods: {
      handleIpt(value, item) {
       console.log('进来了。。。')
        if (item.prop === 'scoreVal' && value[item.valueData].score && value[item.valueData][item.prop]) {
          value[item.valueData][item.prop] = this.isNumber(value[item.valueData][item.prop])
          if (Number(value[item.valueData][item.prop]) > Number(value[item.valueData].score)) {
            this.$message({ type: "onfo", message: `建议得分不能超出设定的分值(${Number(value[item.valueData].score)}分) `});
            value[item.valueData][item.prop] = ''
          }
        }
      },
      isNumber(num, decimalPlace) {
        num = num.replace(/[^\d\.]+/g, "");
        var len1 = num.substr(0, 1);
        var len2 = num.substr(1, 1);
        //如果第一位是0,第二位不是点,就用数字把点替换掉
        if (num.length > 1 && len1 == 0 && len2 != ".") {
          num = num.substr(1, 1);
        }
        //第一位不能是.
        if (len1 == ".") {
          num = "";
        }
        //限制只能输入一个小数点
        if (num.indexOf(".") != -1) {
          var str_ = num.substr(num.indexOf(".") + 1);
          if (str_.indexOf(".") != -1) {
            num = num.substr(0, num.indexOf(".") + str_.indexOf(".") + 1);
          }
        }
        //动态位数
        num = num.replace(
          /\.\d{2,}$/,
          num.substr(num.indexOf("."), decimalPlace + 1)
        );
        return num;
      },
      getScope1(item, row) {
        let total = 0;
        if (row.value[item.valueData].children && row.value[item.valueData].children) {
          row.value[item.valueData].children.forEach((item) => {
            total = total + Number(row.value[item.id].scoreVal || 0)
          });
        } else {
          total = Number(row.value[item.valueData].scoreVal || 0);
        }
        console.log(total, 0)
        row.value[item.valueData][item.prop] = total.toFixed(2);
        return total.toFixed(2);
      }
    }
  }
  </script>
  
  <style scoped>
  
  </style>

效果图

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2268747.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

✨✨vue3自定义动态不同UI组件筛选框案例✨

✨1. 实现功能 &#x1f31f;添加条件进行数据筛选 根据筛选数据条件不同&#xff0c;显示不同的UI组件&#xff1a;包含datetime、select、input等筛选完条件可继续添加与取消条件当然可以在条件列表中进行直接删除&#xff0c;当删除完所有条件之后&#xff0c;回到添加条件…

Go+chromedp实现Web UI自动化测试

1.为什么使用go进行UI自动化测试&#xff1f; 速度&#xff1a;Go速度很快&#xff0c;这在运行包含数百个UI测试的测试套件时是一个巨大的优势 并发性&#xff1a;可以利用Go的内置并发性(goroutines)来并行化测试执行 简单&#xff1a;Go的简约语法允许您编写可读且可维护…

总结TCP/IP四层模型

总结TCP/IP四层模型 阅读目录(Content) 一、TCP/IP参考模型概述 1.1、TCP/IP参考模型的层次结构二、TCP/IP四层功能概述 2.1、主机到网络层  2.2、网络互连层  2.3、传输层  2.3、应用层 三、TCP/IP报文格式 3.1、IP报文格式3.2、TCP数据段格式3.3、UDP数据段格式3.4、套…

怎么在家访问公司服务器?

在日常工作中&#xff0c;特别是对信息技术从业者而言&#xff0c;工作往往离不开公司的服务器。他们需要定期访问服务器&#xff0c;获取一些关键的机密文件或数据。如果您在家办公&#xff0c;并且需要处理未完成的任务&#xff0c;同时需要从公司服务器获取所需的数据&#…

自动化文档处理:Azure AI Document Intelligence

Azure AI Document Intelligence支持多种文件格式&#xff0c;包括PDF、JPEG、PNG等。其核心功能是将这些文档按页进行内容提取&#xff0c;并转化为LangChain文档。其默认输出格式是Markdown&#xff0c;这使得文档可以通过MarkdownHeaderTextSplitter进行语义分片。您也可以使…

ubuntu快速入门

1.进入某个文件夹 cd workspace/2.tab自动补全 3.列出当前文件夹所有文件 ls列出所有文件包括隐藏文件 ls -a 4.创建文件夹 mkdir linuxLearn 5.创建文件 gedit command.sh在commmand.sh键入 echo hello echo hi? echo how are you? PS:touch hello.txt(也可以创建新…

在虚幻引擎4(UE4)中使用蓝图的详细教程

在虚幻引擎4&#xff08;UE4&#xff09;中使用蓝图的详细教程 虚幻引擎4&#xff08;Unreal Engine 4&#xff0c;简称UE4&#xff09;是一款功能强大的游戏引擎&#xff0c;广泛应用于游戏开发、虚拟现实、建筑可视化等领域。UE4 提供了一个强大的可视化脚本工具——蓝图&am…

修改网络ip地址方法有哪些?常用的有这四种

在数字时代&#xff0c;IP地址作为网络设备的唯一标识&#xff0c;对于网络连接和通信至关重要。然而&#xff0c;有时候我们可能需要修改设备的IP地址&#xff0c;以满足特定的网络需求或解决网络问题。本文将为您详细介绍几种修改网络IP地址的常用方法&#xff0c;无论是对于…

你了解DNS吗?

你了解DNS吗&#xff1f; 一. 介绍二. DNS的工作原理三. DNS查询流程示意图四. DNS 记录类型五. DNS的安全问题与 DNSSEC 前言 这是我在这个网站整理的笔记,有错误的地方请指出&#xff0c;关注我&#xff0c;接下来还会持续更新。 作者&#xff1a;神的孩子都在歌唱 一. 介绍 …

Android笔试面试题AI答之非技术问题(3)

Android入门请看《Android应用开发项目式教程》 文章目录 1.你是如何应付项目经理的&#xff1f;**1. 建立清晰的沟通机制****2. 明确项目目标与优先级****3. 制定合理的开发计划****4. 管理项目风险****5. 推动敏捷开发****6. 管理需求变更****7. 提升团队协作****8. 关注项目…

TestMAX/DFT Compiler:时序单元的类型、连接顺序和后DFT优化

相关阅读 TestMAX/DFT Compilerhttps://blog.csdn.net/weixin_45791458/category_12865937.html?spm1001.2014.3001.5482 时序单元的状态 未映射的时序单元(Unmapped Sequential Cell) 在Design Compiler读取了一个RTL设计后&#xff0c;Design Compiler内置的HDL Compiler工…

操作012:延迟插件

文章目录 操作012&#xff1a;延迟插件一、插件简介二、插件安装1、确定卷映射目录2、下载延迟插件3、启用插件4、确认 三、创建交换机四、代码测试1、生产者端代码2、消费者端代码①情况A&#xff1a;资源已创建②情况B&#xff1a;资源未创建 3、执行效果①交换机类型②生产者…

Kafka 性能提升秘籍:涵盖配置、迁移与深度巡检的综合方案

文章目录 1.1.网络和io操作线程配置优化1.2.log数据文件刷盘策略1.3.日志保留策略配置1.4.replica复制配置1.5.配置jmx服务1.6.系统I/O参数优化1.6.1.网络性能优化1.6.2.常见痛点以及优化方案1.6.4.优化参数 1.7.版本升级1.8.数据迁移1.8.1.同集群broker之间迁移1.8.2.跨集群迁…

【文献精读笔记】Explainability for Large Language Models: A Survey (大语言模型的可解释性综述)(二)

****非斜体正文为原文献内容&#xff08;也包含笔者的补充&#xff09;&#xff0c;灰色块中是对文章细节的进一步详细解释&#xff01; 3.1.2 基于注意力的解释&#xff08;Attention-Based Explanation&#xff09; 注意力机制可以揭示输入数据中各个部分之间的关系&#…

音视频采集推流时间戳记录方案

音视频同步更多文章 深入理解音视频pts&#xff0c;dts&#xff0c;time_base以及时间数学公式_视频pts计算-CSDN博客 ffplay音视频同步分析_ffplay 音视频同步-CSDN博客 音视频采集打时间戳设计 实时音视频数据的采集和处理场景。具体来说: 采集阶段: 在音视频数据采集过…

「numpy」numpy初步、ndarray、创建数组

Numpy 初步、ndarray、创建数组 【目录】 简介 ndarray介绍 ndarray用法 ndarray基本操作 一、numpy简介 Numpy&#xff08;Numerical Python&#xff09;是一个开源的Python科学计算库&#xff0c;用于快速处理任意维度的数组。 Numpy支持常见的数组和矩阵操作。对于同样…

FFmpeg 编码和解码

文章目录 音频格式AACADIF音频数据交换格式ADTS音频数据传输流 音频解码音频编码 视频格式H264GOP图像组I帧&#xff0c;P帧&#xff0c;B帧H264压缩技术H264压缩级别H264视频级别H264码流结构SPSPPS 解码视频编码视频 音频格式 AAC AAC全称 Advanced Audio Coding&#xff0…

游戏引擎学习第67天

reviewing “apron”概念以更新区域 我们正在进行模拟区域的扩展工作&#xff0c;目标是通过增加一个更大的区域来支持更丰富的互动&#xff0c;尤其是那些可能超出摄像机视野的内容。现有的模拟区域包括摄像机能看到的区域和其周围的环境区域&#xff0c;但为了保证更高效的游…

3D线上艺术展:艺术与技术的完美融合

随着数字技术的飞速发展&#xff0c;未来的艺术展览正逐步迈向线上线下融合的新阶段。其中&#xff0c;3D线上展览以其独特的魅力&#xff0c;成为线下展览的延伸与拓展&#xff0c;为艺术爱好者们开辟了全新的观赏途径。 对于艺术家和策展人而言&#xff0c;3D线上展览不仅打…

Qt制作一个简单闹钟

增加testtospeech模块 QT core gui texttospeech 头文件 #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include <QTimerEvent> #include <QTimer> #include <QTime> #include <QMouseEvent> #include <QTextToSpeech>…