@steedos-widgets/amis-lib 3.6.2-beta.12 → 3.6.2-beta.13

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
@@ -2972,15 +2972,8 @@ async function getTableApi(mainObject, fields, options){
2972
2972
  }
2973
2973
  });
2974
2974
  };
2975
- let isTreeOptionsComputed = false;
2976
- if(records.length === 1 && records[0].children){
2977
- isTreeOptionsComputed = true;
2978
- }
2979
- if(!isTreeOptionsComputed){
2980
- // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2981
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2982
- assignIndexToTreeRecords(payload.data.rows, '');
2983
- }
2975
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2976
+ assignIndexToTreeRecords(payload.data.rows, '');
2984
2977
  }
2985
2978
 
2986
2979
 
@@ -4876,9 +4869,16 @@ const getSchema$2 = (uiSchema) => {
4876
4869
  "form": {
4877
4870
  debug: false,
4878
4871
  resetAfterSubmit: false,
4872
+ data: {
4873
+ editFormInited: true,
4874
+ },
4879
4875
  initApi: {
4876
+ method: 'GET',
4880
4877
  url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
4881
4878
  sendOn: 'this.recordId',
4879
+ data: null,
4880
+ requestAdaptor: "return api;",
4881
+ adaptor: "return payload;",
4882
4882
  responseData: {
4883
4883
  importState: "${state}"
4884
4884
  }
@@ -9000,7 +9000,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
9000
9000
  * @Author: baozhoutao@steedos.com
9001
9001
  * @Date: 2022-07-05 15:55:39
9002
9002
  * @LastEditors: baozhoutao@steedos.com
9003
- * @LastEditTime: 2024-01-15 10:34:46
9003
+ * @LastEditTime: 2024-01-24 10:18:17
9004
9004
  * @Description:
9005
9005
  */
9006
9006
 
@@ -9099,7 +9099,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9099
9099
  const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9100
9100
  mainRelated[arr[0]] = foreign_key_value;
9101
9101
  }
9102
- }else {
9102
+ }
9103
+ // 防止related_lists中没有相关子表,但是details中有相关子表的情况
9104
+ if(!mainRelated[relatedObjectName]){
9103
9105
  const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
9104
9106
  for (const detail of details) {
9105
9107
  const arr = detail.split(".");
@@ -10726,6 +10728,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10726
10728
  }
10727
10729
  },
10728
10730
  "label": "",
10731
+ "mode": "normal",
10729
10732
  "name": "organizations",
10730
10733
  "multiple": false,
10731
10734
  "joinValues": false,
@@ -12953,10 +12956,10 @@ function uuidv4() {
12953
12956
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12954
12957
  * @Date: 2023-11-15 09:50:22
12955
12958
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12956
- * @LastEditTime: 2024-01-22 15:59:32
12959
+ * @LastEditTime: 2024-01-24 14:56:03
12957
12960
  */
12958
12961
 
12959
- function getTablePrimaryKey(props){
12962
+ function getTablePrimaryKey(props) {
12960
12963
  return props.primaryKey || "_id";
12961
12964
  }
12962
12965
 
@@ -12966,22 +12969,22 @@ function getTablePrimaryKey(props){
12966
12969
  * @param {*} primaryKey 主键字段名,一般为_id
12967
12970
  * @returns 转换后的子表组件字段值
12968
12971
  */
12969
- function getTableValueWithPrimaryKeyValue(value, primaryKey){
12970
- if(!primaryKey){
12972
+ function getTableValueWithPrimaryKeyValue(value, primaryKey) {
12973
+ if (!primaryKey) {
12971
12974
  return value;
12972
12975
  }
12973
- return (value || []).map((itemValue)=>{
12976
+ return (value || []).map((itemValue) => {
12974
12977
  //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
12975
12978
  const newItemValue = clone(itemValue);
12976
- if(newItemValue[primaryKey]){
12977
- if(newItemValue.children){
12979
+ if (newItemValue[primaryKey]) {
12980
+ if (newItemValue.children) {
12978
12981
  newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
12979
12982
  }
12980
12983
  return newItemValue;
12981
12984
  }
12982
12985
  else {
12983
12986
  newItemValue[primaryKey] = uuidv4();
12984
- if(newItemValue.children){
12987
+ if (newItemValue.children) {
12985
12988
  newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
12986
12989
  }
12987
12990
  return newItemValue;
@@ -12995,14 +12998,14 @@ function getTableValueWithPrimaryKeyValue(value, primaryKey){
12995
12998
  * @param {*} primaryKey 主键字段名,一般为_id
12996
12999
  * @returns 转换后的子表组件字段值
12997
13000
  */
12998
- function getTableValueWithoutPrimaryKeyValue(value, primaryKey){
12999
- if(!primaryKey){
13001
+ function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
13002
+ if (!primaryKey) {
13000
13003
  return value;
13001
13004
  }
13002
- return (value || []).map((itemValue)=>{
13005
+ return (value || []).map((itemValue) => {
13003
13006
  //这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
13004
13007
  const newItemValue = clone(itemValue);
13005
- if(newItemValue.children){
13008
+ if (newItemValue.children) {
13006
13009
  newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
13007
13010
  }
13008
13011
  delete newItemValue[primaryKey];
@@ -13016,12 +13019,12 @@ function getTableValueWithoutPrimaryKeyValue(value, primaryKey){
13016
13019
  * @param {*} fieldPrefix 字段前缀
13017
13020
  * @returns 转换后的子表组件字段值
13018
13021
  */
13019
- function getTableValueWithoutFieldPrefix(value, fieldPrefix){
13022
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
13020
13023
  let convertedValue = [];
13021
- (value || []).forEach((itemValue)=>{
13024
+ (value || []).forEach((itemValue) => {
13022
13025
  var newItemValue = {};
13023
- for(let n in itemValue){
13024
- if(itemValue.hasOwnProperty(n)){
13026
+ for (let n in itemValue) {
13027
+ if (itemValue.hasOwnProperty(n)) {
13025
13028
  newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13026
13029
  }
13027
13030
  }
@@ -13036,16 +13039,16 @@ function getTableValueWithoutFieldPrefix(value, fieldPrefix){
13036
13039
  * @param {*} fieldPrefix 字段前缀
13037
13040
  * @returns 转换后的子表组件字段值
13038
13041
  */
13039
- function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey){
13042
+ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
13040
13043
  let convertedValue = [];
13041
- (value || []).forEach((itemValue)=>{
13044
+ (value || []).forEach((itemValue) => {
13042
13045
  var newItemValue = {};
13043
- for(let n in itemValue){
13044
- if(itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey){
13046
+ for (let n in itemValue) {
13047
+ if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
13045
13048
  newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13046
13049
  }
13047
13050
  }
13048
- if(primaryKey && itemValue[primaryKey]){
13051
+ if (primaryKey && itemValue[primaryKey]) {
13049
13052
  newItemValue[primaryKey] = itemValue[primaryKey];
13050
13053
  }
13051
13054
  convertedValue.push(newItemValue);
@@ -13059,7 +13062,7 @@ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey){
13059
13062
  * @param {*} fieldPrefix 字段前缀
13060
13063
  * @returns 转换后的子表组件字段值
13061
13064
  */
13062
- function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
13065
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
13063
13066
  return (fields || []).map((item) => {
13064
13067
  const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
13065
13068
  newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
@@ -13097,6 +13100,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
13097
13100
  name: field.name,
13098
13101
  quickEdit: {
13099
13102
  "type": "steedos-field",
13103
+ "mode": "inline",
13100
13104
  "config": Object.assign({}, field, {
13101
13105
  label: false
13102
13106
  })
@@ -13176,7 +13180,9 @@ async function getInputTableColumns(props) {
13176
13180
  }
13177
13181
  }
13178
13182
  if (field) {
13179
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13183
+ let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
13184
+ extendColumnProps.inlineEditMode : showAsInlineEditMode;
13185
+ let tableCell = getInputTableCell(field, mode);
13180
13186
  return Object.assign({}, tableCell, extendColumnProps);
13181
13187
  }
13182
13188
  else {
@@ -13199,7 +13205,7 @@ async function getInputTableColumns(props) {
13199
13205
  */
13200
13206
  function getFormPagination(props, mode) {
13201
13207
  let showPagination = true;
13202
- if(mode === "new" && !!!props.editable){
13208
+ if (mode === "new" && !!!props.editable) {
13203
13209
  //不允许编辑只允许新建时不应该让用户操作翻页
13204
13210
  showPagination = false;
13205
13211
  }
@@ -13639,7 +13645,7 @@ async function getButtonActions(props, mode) {
13639
13645
  let formPaginationId = getComponentId("form_pagination", props.id);
13640
13646
  let parentFormData = "${__super.__super.__super.__super || {}}";
13641
13647
  let amisVersion = getComparableAmisVersion();
13642
- if(amisVersion < 3.6){
13648
+ if (amisVersion < 3.6) {
13643
13649
  parentFormData = "${__super.__super || {}}";
13644
13650
  }
13645
13651
  if (mode == "new" || mode == "edit") {
@@ -13803,13 +13809,13 @@ async function getButtonActions(props, mode) {
13803
13809
  `;
13804
13810
  let dialogButtons = [
13805
13811
  {
13806
- "type": "button",
13807
- "label": "完成",
13808
- "actionType": "confirm",
13809
- "level": "primary"
13812
+ "type": "button",
13813
+ "label": "完成",
13814
+ "actionType": "confirm",
13815
+ "level": "primary"
13810
13816
  }
13811
13817
  ];
13812
- if(props.addable){
13818
+ if (props.addable) {
13813
13819
  // 有新增行权限时额外添加新增和复制按钮
13814
13820
  dialogButtons = [
13815
13821
  {
@@ -13882,7 +13888,7 @@ async function getButtonActions(props, mode) {
13882
13888
  // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13883
13889
  // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13884
13890
  "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13885
- },
13891
+ },
13886
13892
  "actions": dialogButtons,
13887
13893
  "onEvent": {
13888
13894
  "confirm": {
@@ -14120,7 +14126,7 @@ const getAmisInputTableSchema = async (props) => {
14120
14126
  }
14121
14127
  let primaryKey = getTablePrimaryKey(props);
14122
14128
  let showOperation = props.showOperation;
14123
- if(showOperation !== false){
14129
+ if (showOperation !== false) {
14124
14130
  showOperation = true;
14125
14131
  }
14126
14132
  let fieldPrefix = props.fieldPrefix;
@@ -14132,7 +14138,7 @@ const getAmisInputTableSchema = async (props) => {
14132
14138
  let buttonsForColumnOperations = [];
14133
14139
  let inlineEditMode = props.inlineEditMode;
14134
14140
  let showAsInlineEditMode = inlineEditMode && props.editable;
14135
- if(showOperation){
14141
+ if (showOperation) {
14136
14142
  if (props.editable) {
14137
14143
  let showEditButton = true;
14138
14144
  if (showAsInlineEditMode) {
@@ -14183,31 +14189,31 @@ const getAmisInputTableSchema = async (props) => {
14183
14189
  "showFooterAddBtn": false,
14184
14190
  "className": props.tableClassName,
14185
14191
  "pipeIn": (value, data) => {
14186
- if(fieldPrefix){
14192
+ if (fieldPrefix) {
14187
14193
  value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
14188
14194
  }
14189
- if(primaryKey){
14195
+ if (primaryKey) {
14190
14196
  // 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
14191
14197
  // 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
14192
14198
  // 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
14193
14199
  value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14194
14200
  }
14195
- if(amis.pipeIn){
14196
- if(typeof amis.pipeIn === 'function'){
14201
+ if (amis.pipeIn) {
14202
+ if (typeof amis.pipeIn === 'function') {
14197
14203
  return amis.pipeIn(value, data);
14198
14204
  }
14199
14205
  }
14200
14206
  return value;
14201
14207
  },
14202
14208
  "pipeOut": (value, data) => {
14203
- value = (value || []).map(function(item){
14209
+ value = (value || []).map(function (item) {
14204
14210
  delete item.__fix_rerender_after_children_modified_tag;
14205
14211
  return item;
14206
14212
  });
14207
- if(fieldPrefix){
14213
+ if (fieldPrefix) {
14208
14214
  value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
14209
14215
  }
14210
- if(props.autoGeneratePrimaryKeyValue === true){
14216
+ if (props.autoGeneratePrimaryKeyValue === true) {
14211
14217
  // 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
14212
14218
  // 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
14213
14219
  value = getTableValueWithPrimaryKeyValue(value, primaryKey);
@@ -14219,8 +14225,8 @@ const getAmisInputTableSchema = async (props) => {
14219
14225
  // 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
14220
14226
  value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
14221
14227
  }
14222
- if(amis.pipeOut){
14223
- if(typeof amis.pipeOut === 'function'){
14228
+ if (amis.pipeOut) {
14229
+ if (typeof amis.pipeOut === 'function') {
14224
14230
  return amis.pipeOut(value, data);
14225
14231
  }
14226
14232
  }
@@ -14235,9 +14241,6 @@ const getAmisInputTableSchema = async (props) => {
14235
14241
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
14236
14242
  });
14237
14243
  }
14238
- if (showAsInlineEditMode) {
14239
- inputTableSchema.needConfirm = false;
14240
- }
14241
14244
  if (amis) {
14242
14245
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
14243
14246
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
@@ -14279,19 +14282,19 @@ const getAmisInputTableSchema = async (props) => {
14279
14282
  });
14280
14283
  }
14281
14284
  let schema = {
14282
- "type": "service",
14283
- "body": [
14284
- {
14285
- "type": "control",
14286
- "body": schemaBody,
14287
- "label": props.label,
14288
- "labelClassName": props.label ? props.labelClassName : "none",
14289
- "labelRemark": props.labelRemark,
14290
- "labelAlign": props.labelAlign
14291
- }
14292
- ],
14293
- "className": props.className,
14294
- "id": serviceId
14285
+ "type": "control",
14286
+ "body": {
14287
+ "type": "service",
14288
+ "body": schemaBody,
14289
+ "id": serviceId
14290
+ },
14291
+ "label": props.label,
14292
+ "labelClassName": props.label ? props.labelClassName : "none",
14293
+ "labelRemark": props.labelRemark,
14294
+ "labelAlign": props.labelAlign,
14295
+ //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14296
+ "mode": props.mode || null,
14297
+ "className": props.className
14295
14298
  };
14296
14299
  // console.log("===schema===", schema);
14297
14300
  return schema;