@steedos-widgets/amis-lib 3.6.4-beta.6 → 3.6.4-beta.8

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/dist/index.esm.js CHANGED
@@ -13436,7 +13436,7 @@ function uuidv4() {
13436
13436
  * @Author: 殷亮辉 yinlianghui@hotoa.com
13437
13437
  * @Date: 2023-11-15 09:50:22
13438
13438
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13439
- * @LastEditTime: 2024-01-26 17:47:16
13439
+ * @LastEditTime: 2024-03-02 16:07:17
13440
13440
  */
13441
13441
 
13442
13442
  /**
@@ -13553,7 +13553,12 @@ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
13553
13553
  var newItemValue = {};
13554
13554
  for (let n in itemValue) {
13555
13555
  if (itemValue.hasOwnProperty(n)) {
13556
- newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13556
+ if(n === "children"){
13557
+ newItemValue.children = getTableValueWithoutFieldPrefix(itemValue.children, fieldPrefix);
13558
+ }
13559
+ else {
13560
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13561
+ }
13557
13562
  }
13558
13563
  }
13559
13564
  convertedValue.push(newItemValue);
@@ -13574,7 +13579,12 @@ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
13574
13579
  var newItemValue = {};
13575
13580
  for (let n in itemValue) {
13576
13581
  if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
13577
- newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13582
+ if(n === "children"){
13583
+ newItemValue.children = getTableValuePrependFieldPrefix(itemValue.children, fieldPrefix, primaryKey);
13584
+ }
13585
+ else {
13586
+ newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13587
+ }
13578
13588
  }
13579
13589
  }
13580
13590
  if (primaryKey && itemValue[primaryKey]) {
@@ -13599,6 +13609,23 @@ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
13599
13609
  });
13600
13610
  }
13601
13611
 
13612
+ /**
13613
+ * 子表组件字段集合属性中每个字段name补上指定前缀
13614
+ * 因amis存在bug:input-table内的字段在行编辑模式时会受到外层相同name的字段的影响 https://github.com/baidu/amis/issues/9653
13615
+ * 在渲染input table组件时统一调用此函数加上前缀来避开同名字段问题
13616
+ * @param {*} fields 子表组件字段集合,数组
13617
+ * @param {*} fieldPrefix 字段前缀
13618
+ * @returns 转换后的子表组件字段值
13619
+ */
13620
+ // function getTableFieldsPrependFieldPrefix(fields, fieldPrefix) {
13621
+ // return (fields || []).map((item) => {
13622
+ // const newItem = clone(item);
13623
+ // newItem.name = `${fieldPrefix}${item.name}`;
13624
+ // newItem.__originalName = item.name;
13625
+ // return newItem;
13626
+ // });
13627
+ // }
13628
+
13602
13629
  /**
13603
13630
  * @param {*} props
13604
13631
  * @param {*} mode edit/new/readonly
@@ -13624,16 +13651,21 @@ function getFormFields(props, mode = "edit") {
13624
13651
 
13625
13652
  function getInputTableCell(field, showAsInlineEditMode) {
13626
13653
  if (showAsInlineEditMode) {
13654
+ // 这里不可以用quickEdit,因为amis存在bug:input-table内的字段在行编辑模式时会受到外层相同name的字段的影响 https://github.com/baidu/amis/issues/9653
13627
13655
  return {
13656
+ "type": "steedos-field",
13657
+ "config": Object.assign({}, field, {
13658
+ label: false
13659
+ }),
13660
+ // quickEdit: {
13661
+ // "type": "steedos-field",
13662
+ // "mode": "inline",
13663
+ // "config": Object.assign({}, field, {
13664
+ // label: false
13665
+ // })
13666
+ // },
13628
13667
  label: field.label,
13629
- name: field.name,
13630
- quickEdit: {
13631
- "type": "steedos-field",
13632
- "mode": "inline",
13633
- "config": Object.assign({}, field, {
13634
- label: false
13635
- })
13636
- }
13668
+ name: field.name
13637
13669
  }
13638
13670
  }
13639
13671
  else {
@@ -13677,7 +13709,7 @@ function getComponentId(name, tag) {
13677
13709
  * @param {*} props
13678
13710
  * @param {*} mode edit/new/readonly
13679
13711
  */
13680
- async function getInputTableColumns(props) {
13712
+ async function getInputTableColumns(props, buttonsForColumnOperations) {
13681
13713
  let columns = props.columns || [];
13682
13714
  let inlineEditMode = props.inlineEditMode;
13683
13715
  let showAsInlineEditMode = inlineEditMode && props.editable;
@@ -13711,7 +13743,7 @@ async function getInputTableColumns(props) {
13711
13743
  }
13712
13744
 
13713
13745
  if (columns && columns.length) {
13714
- return columns.map(function (column) {
13746
+ return columns.map(function (column, index) {
13715
13747
  let field, extendColumnProps = {};
13716
13748
  if (typeof column === "string") {
13717
13749
  // 如果字符串,则取出要显示的列配置
@@ -13737,9 +13769,13 @@ async function getInputTableColumns(props) {
13737
13769
  let className = "";
13738
13770
  //判断是否换行,目前规则默认换行
13739
13771
  if(extendColumnProps.wrap != true){
13740
- className += " whitespace-nowrap ";
13772
+ className += " whitespace-nowrap";
13741
13773
  }else {
13742
- className += " break-words ";
13774
+ className += " break-words";
13775
+ }
13776
+
13777
+ if(buttonsForColumnOperations.length == 0 && !props.showIndex && index == 0) {
13778
+ className += " antd-Table-primayCell";
13743
13779
  }
13744
13780
  //合并classname
13745
13781
  if (typeof extendColumnProps.className == "object") {
@@ -13758,9 +13794,12 @@ async function getInputTableColumns(props) {
13758
13794
  });
13759
13795
  }
13760
13796
  else {
13761
- return fields.map(function (field) {
13797
+ return fields.map(function (field, index) {
13762
13798
  let tableCell = getInputTableCell(field, showAsInlineEditMode);
13763
13799
  tableCell.className = " whitespace-nowrap ";
13800
+ if(buttonsForColumnOperations.length == 0 && !props.showIndex && index == 0) {
13801
+ tableCell.className += " antd-Table-primayCell";
13802
+ }
13764
13803
  return tableCell;
13765
13804
  }) || [];
13766
13805
  }
@@ -14835,7 +14874,7 @@ const getAmisInputTableSchema = async (props) => {
14835
14874
  "showIndex": props.showIndex,
14836
14875
  "perPage": props.perPage,
14837
14876
  "id": props.id,
14838
- "columns": await getInputTableColumns(props),
14877
+ "columns": await getInputTableColumns(props, buttonsForColumnOperations),
14839
14878
  // "needConfirm": false, //不可以配置为false,否则,单元格都是可编辑状态,且很多static类型无法正常显示,比如static-mapping
14840
14879
  "strictMode": props.strictMode,
14841
14880
  "showTableAddBtn": false,