@leevan/jtui 2.0.54-beta.6 → 2.0.54-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leevan/jtui",
3
- "version": "2.0.54-beta.6",
3
+ "version": "2.0.54-beta.7",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -77,7 +77,6 @@
77
77
  @radio-change="radioSelectChangeEvent"
78
78
  @cell-click="cellClickEvent"
79
79
  @keydown="keyEnter"
80
- @edit-actived="handleEditActived"
81
80
  >
82
81
  <!-- 复选框列 -->
83
82
  <vxe-table-column
@@ -250,7 +249,6 @@
250
249
  @radio-change="radioSelectChangeEvent"
251
250
  @cell-click="cellClickEvent"
252
251
  @keydown="keyEnter"
253
- @edit-actived="handleEditActived"
254
252
  >
255
253
  <!-- 复选框列 -->
256
254
  <vxe-table-column
@@ -561,7 +559,6 @@
561
559
  :loading="loading"
562
560
  @keydown="keyEnter"
563
561
  @scroll="scroll1"
564
- @edit-actived="handleEditActived"
565
562
  :expand-config="{
566
563
  visibleMethod,
567
564
  loadMethod: expandConfig.loadMethod,
@@ -978,6 +975,7 @@ export default {
978
975
  setTimeout(() => {
979
976
  const temp = this.$refs[this.id].getTableData()
980
977
  if(temp.fullData.length > 0){
978
+ this.initRowFields(temp.fullData);
981
979
  this.isShowEmpty = false
982
980
  }else{
983
981
  if(n){
@@ -1654,12 +1652,52 @@ export default {
1654
1652
  syncData() {
1655
1653
  this.$refs[this.id].syncData();
1656
1654
  },
1657
- // 编辑激活时,确保 row 对象中有对应的字段
1658
- handleEditActived({ row, column }) {
1659
- const prop = column.property;
1660
- if (prop && !(prop in row)) {
1661
- this.$set(row, prop, '');
1655
+ // 收集所有表头字段(包括嵌套表头)
1656
+ getAllHeaderFields(headers) {
1657
+ const fields = [];
1658
+ const collect = (items) => {
1659
+ items.forEach(item => {
1660
+ if (item.children && item.children.length) {
1661
+ collect(item.children);
1662
+ } else if (item.prop) {
1663
+ fields.push(item.prop);
1664
+ }
1665
+ });
1666
+ };
1667
+ collect(headers);
1668
+ return fields;
1669
+ },
1670
+ // 初始化所有行的字段,确保每个行对象都有所有表头字段
1671
+ initRowFields(dataArray) {
1672
+ console.log('=== initRowFields 开始执行 ===');
1673
+ const rows = dataArray || this.data?.DataArray;
1674
+ console.log('传入的 dataArray:', dataArray);
1675
+ console.log('使用的 rows:', rows);
1676
+ if (!rows || !rows.length || !this.data?.retjson?.header) {
1677
+ console.log('数据不完整,跳过初始化');
1678
+ return;
1662
1679
  }
1680
+ const fields = this.getAllHeaderFields(this.data.retjson.header);
1681
+ console.log('收集到的表头字段:', fields);
1682
+ console.log('初始化前的第一行数据:', rows[0]);
1683
+ // 递归处理行(包括树形结构的子节点)
1684
+ const processRow = (row, rowIndex) => {
1685
+ console.log(`处理第 ${rowIndex} 行,处理前:`, { ...row });
1686
+ fields.forEach(field => {
1687
+ if (!(field in row)) {
1688
+ console.log(` 字段 ${field} 不存在,用 $set 添加`);
1689
+ this.$set(row, field, '');
1690
+ }
1691
+ });
1692
+ console.log(` 处理后:`, { ...row });
1693
+ // 处理子节点
1694
+ if (row.children && row.children.length) {
1695
+ row.children.forEach((child, idx) => processRow(child, `${rowIndex}-${idx}`));
1696
+ }
1697
+ };
1698
+ rows.forEach((row, idx) => processRow(row, idx));
1699
+ console.log('初始化后的第一行数据:', rows[0]);
1700
+ console.log('=== initRowFields 执行完成 ===');
1663
1701
  },
1664
1702
  },
1665
1703
  };