@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.cjs.js CHANGED
@@ -2999,15 +2999,8 @@ async function getTableApi(mainObject, fields, options){
2999
2999
  }
3000
3000
  });
3001
3001
  };
3002
- let isTreeOptionsComputed = false;
3003
- if(records.length === 1 && records[0].children){
3004
- isTreeOptionsComputed = true;
3005
- }
3006
- if(!isTreeOptionsComputed){
3007
- // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
3008
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
3009
- assignIndexToTreeRecords(payload.data.rows, '');
3010
- }
3002
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
3003
+ assignIndexToTreeRecords(payload.data.rows, '');
3011
3004
  }
3012
3005
 
3013
3006
 
@@ -4903,9 +4896,16 @@ const getSchema$2 = (uiSchema) => {
4903
4896
  "form": {
4904
4897
  debug: false,
4905
4898
  resetAfterSubmit: false,
4899
+ data: {
4900
+ editFormInited: true,
4901
+ },
4906
4902
  initApi: {
4903
+ method: 'GET',
4907
4904
  url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
4908
4905
  sendOn: 'this.recordId',
4906
+ data: null,
4907
+ requestAdaptor: "return api;",
4908
+ adaptor: "return payload;",
4909
4909
  responseData: {
4910
4910
  importState: "${state}"
4911
4911
  }
@@ -9027,7 +9027,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
9027
9027
  * @Author: baozhoutao@steedos.com
9028
9028
  * @Date: 2022-07-05 15:55:39
9029
9029
  * @LastEditors: baozhoutao@steedos.com
9030
- * @LastEditTime: 2024-01-15 10:34:46
9030
+ * @LastEditTime: 2024-01-24 10:18:17
9031
9031
  * @Description:
9032
9032
  */
9033
9033
 
@@ -9126,7 +9126,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9126
9126
  const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9127
9127
  mainRelated[arr[0]] = foreign_key_value;
9128
9128
  }
9129
- }else {
9129
+ }
9130
+ // 防止related_lists中没有相关子表,但是details中有相关子表的情况
9131
+ if(!mainRelated[relatedObjectName]){
9130
9132
  const details = _$1.union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
9131
9133
  for (const detail of details) {
9132
9134
  const arr = detail.split(".");
@@ -10753,6 +10755,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10753
10755
  }
10754
10756
  },
10755
10757
  "label": "",
10758
+ "mode": "normal",
10756
10759
  "name": "organizations",
10757
10760
  "multiple": false,
10758
10761
  "joinValues": false,
@@ -12980,10 +12983,10 @@ function uuidv4() {
12980
12983
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12981
12984
  * @Date: 2023-11-15 09:50:22
12982
12985
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12983
- * @LastEditTime: 2024-01-22 15:59:32
12986
+ * @LastEditTime: 2024-01-24 14:56:03
12984
12987
  */
12985
12988
 
12986
- function getTablePrimaryKey(props){
12989
+ function getTablePrimaryKey(props) {
12987
12990
  return props.primaryKey || "_id";
12988
12991
  }
12989
12992
 
@@ -12993,22 +12996,22 @@ function getTablePrimaryKey(props){
12993
12996
  * @param {*} primaryKey 主键字段名,一般为_id
12994
12997
  * @returns 转换后的子表组件字段值
12995
12998
  */
12996
- function getTableValueWithPrimaryKeyValue(value, primaryKey){
12997
- if(!primaryKey){
12999
+ function getTableValueWithPrimaryKeyValue(value, primaryKey) {
13000
+ if (!primaryKey) {
12998
13001
  return value;
12999
13002
  }
13000
- return (value || []).map((itemValue)=>{
13003
+ return (value || []).map((itemValue) => {
13001
13004
  //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
13002
13005
  const newItemValue = _$1.clone(itemValue);
13003
- if(newItemValue[primaryKey]){
13004
- if(newItemValue.children){
13006
+ if (newItemValue[primaryKey]) {
13007
+ if (newItemValue.children) {
13005
13008
  newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13006
13009
  }
13007
13010
  return newItemValue;
13008
13011
  }
13009
13012
  else {
13010
13013
  newItemValue[primaryKey] = uuidv4();
13011
- if(newItemValue.children){
13014
+ if (newItemValue.children) {
13012
13015
  newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13013
13016
  }
13014
13017
  return newItemValue;
@@ -13022,14 +13025,14 @@ function getTableValueWithPrimaryKeyValue(value, primaryKey){
13022
13025
  * @param {*} primaryKey 主键字段名,一般为_id
13023
13026
  * @returns 转换后的子表组件字段值
13024
13027
  */
13025
- function getTableValueWithoutPrimaryKeyValue(value, primaryKey){
13026
- if(!primaryKey){
13028
+ function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
13029
+ if (!primaryKey) {
13027
13030
  return value;
13028
13031
  }
13029
- return (value || []).map((itemValue)=>{
13032
+ return (value || []).map((itemValue) => {
13030
13033
  //这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
13031
13034
  const newItemValue = _$1.clone(itemValue);
13032
- if(newItemValue.children){
13035
+ if (newItemValue.children) {
13033
13036
  newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
13034
13037
  }
13035
13038
  delete newItemValue[primaryKey];
@@ -13043,12 +13046,12 @@ function getTableValueWithoutPrimaryKeyValue(value, primaryKey){
13043
13046
  * @param {*} fieldPrefix 字段前缀
13044
13047
  * @returns 转换后的子表组件字段值
13045
13048
  */
13046
- function getTableValueWithoutFieldPrefix(value, fieldPrefix){
13049
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
13047
13050
  let convertedValue = [];
13048
- (value || []).forEach((itemValue)=>{
13051
+ (value || []).forEach((itemValue) => {
13049
13052
  var newItemValue = {};
13050
- for(let n in itemValue){
13051
- if(itemValue.hasOwnProperty(n)){
13053
+ for (let n in itemValue) {
13054
+ if (itemValue.hasOwnProperty(n)) {
13052
13055
  newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13053
13056
  }
13054
13057
  }
@@ -13063,16 +13066,16 @@ function getTableValueWithoutFieldPrefix(value, fieldPrefix){
13063
13066
  * @param {*} fieldPrefix 字段前缀
13064
13067
  * @returns 转换后的子表组件字段值
13065
13068
  */
13066
- function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey){
13069
+ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
13067
13070
  let convertedValue = [];
13068
- (value || []).forEach((itemValue)=>{
13071
+ (value || []).forEach((itemValue) => {
13069
13072
  var newItemValue = {};
13070
- for(let n in itemValue){
13071
- if(itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey){
13073
+ for (let n in itemValue) {
13074
+ if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
13072
13075
  newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13073
13076
  }
13074
13077
  }
13075
- if(primaryKey && itemValue[primaryKey]){
13078
+ if (primaryKey && itemValue[primaryKey]) {
13076
13079
  newItemValue[primaryKey] = itemValue[primaryKey];
13077
13080
  }
13078
13081
  convertedValue.push(newItemValue);
@@ -13086,7 +13089,7 @@ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey){
13086
13089
  * @param {*} fieldPrefix 字段前缀
13087
13090
  * @returns 转换后的子表组件字段值
13088
13091
  */
13089
- function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
13092
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
13090
13093
  return (fields || []).map((item) => {
13091
13094
  const newItem = _$1.clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
13092
13095
  newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
@@ -13124,6 +13127,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
13124
13127
  name: field.name,
13125
13128
  quickEdit: {
13126
13129
  "type": "steedos-field",
13130
+ "mode": "inline",
13127
13131
  "config": Object.assign({}, field, {
13128
13132
  label: false
13129
13133
  })
@@ -13203,7 +13207,9 @@ async function getInputTableColumns(props) {
13203
13207
  }
13204
13208
  }
13205
13209
  if (field) {
13206
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13210
+ let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
13211
+ extendColumnProps.inlineEditMode : showAsInlineEditMode;
13212
+ let tableCell = getInputTableCell(field, mode);
13207
13213
  return Object.assign({}, tableCell, extendColumnProps);
13208
13214
  }
13209
13215
  else {
@@ -13226,7 +13232,7 @@ async function getInputTableColumns(props) {
13226
13232
  */
13227
13233
  function getFormPagination(props, mode) {
13228
13234
  let showPagination = true;
13229
- if(mode === "new" && !!!props.editable){
13235
+ if (mode === "new" && !!!props.editable) {
13230
13236
  //不允许编辑只允许新建时不应该让用户操作翻页
13231
13237
  showPagination = false;
13232
13238
  }
@@ -13666,7 +13672,7 @@ async function getButtonActions(props, mode) {
13666
13672
  let formPaginationId = getComponentId("form_pagination", props.id);
13667
13673
  let parentFormData = "${__super.__super.__super.__super || {}}";
13668
13674
  let amisVersion = getComparableAmisVersion();
13669
- if(amisVersion < 3.6){
13675
+ if (amisVersion < 3.6) {
13670
13676
  parentFormData = "${__super.__super || {}}";
13671
13677
  }
13672
13678
  if (mode == "new" || mode == "edit") {
@@ -13830,13 +13836,13 @@ async function getButtonActions(props, mode) {
13830
13836
  `;
13831
13837
  let dialogButtons = [
13832
13838
  {
13833
- "type": "button",
13834
- "label": "完成",
13835
- "actionType": "confirm",
13836
- "level": "primary"
13839
+ "type": "button",
13840
+ "label": "完成",
13841
+ "actionType": "confirm",
13842
+ "level": "primary"
13837
13843
  }
13838
13844
  ];
13839
- if(props.addable){
13845
+ if (props.addable) {
13840
13846
  // 有新增行权限时额外添加新增和复制按钮
13841
13847
  dialogButtons = [
13842
13848
  {
@@ -13909,7 +13915,7 @@ async function getButtonActions(props, mode) {
13909
13915
  // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13910
13916
  // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13911
13917
  "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13912
- },
13918
+ },
13913
13919
  "actions": dialogButtons,
13914
13920
  "onEvent": {
13915
13921
  "confirm": {
@@ -14147,7 +14153,7 @@ const getAmisInputTableSchema = async (props) => {
14147
14153
  }
14148
14154
  let primaryKey = getTablePrimaryKey(props);
14149
14155
  let showOperation = props.showOperation;
14150
- if(showOperation !== false){
14156
+ if (showOperation !== false) {
14151
14157
  showOperation = true;
14152
14158
  }
14153
14159
  let fieldPrefix = props.fieldPrefix;
@@ -14159,7 +14165,7 @@ const getAmisInputTableSchema = async (props) => {
14159
14165
  let buttonsForColumnOperations = [];
14160
14166
  let inlineEditMode = props.inlineEditMode;
14161
14167
  let showAsInlineEditMode = inlineEditMode && props.editable;
14162
- if(showOperation){
14168
+ if (showOperation) {
14163
14169
  if (props.editable) {
14164
14170
  let showEditButton = true;
14165
14171
  if (showAsInlineEditMode) {
@@ -14210,31 +14216,31 @@ const getAmisInputTableSchema = async (props) => {
14210
14216
  "showFooterAddBtn": false,
14211
14217
  "className": props.tableClassName,
14212
14218
  "pipeIn": (value, data) => {
14213
- if(fieldPrefix){
14219
+ if (fieldPrefix) {
14214
14220
  value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
14215
14221
  }
14216
- if(primaryKey){
14222
+ if (primaryKey) {
14217
14223
  // 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
14218
14224
  // 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
14219
14225
  // 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
14220
14226
  value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14221
14227
  }
14222
- if(amis.pipeIn){
14223
- if(typeof amis.pipeIn === 'function'){
14228
+ if (amis.pipeIn) {
14229
+ if (typeof amis.pipeIn === 'function') {
14224
14230
  return amis.pipeIn(value, data);
14225
14231
  }
14226
14232
  }
14227
14233
  return value;
14228
14234
  },
14229
14235
  "pipeOut": (value, data) => {
14230
- value = (value || []).map(function(item){
14236
+ value = (value || []).map(function (item) {
14231
14237
  delete item.__fix_rerender_after_children_modified_tag;
14232
14238
  return item;
14233
14239
  });
14234
- if(fieldPrefix){
14240
+ if (fieldPrefix) {
14235
14241
  value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
14236
14242
  }
14237
- if(props.autoGeneratePrimaryKeyValue === true){
14243
+ if (props.autoGeneratePrimaryKeyValue === true) {
14238
14244
  // 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
14239
14245
  // 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
14240
14246
  value = getTableValueWithPrimaryKeyValue(value, primaryKey);
@@ -14246,8 +14252,8 @@ const getAmisInputTableSchema = async (props) => {
14246
14252
  // 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
14247
14253
  value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
14248
14254
  }
14249
- if(amis.pipeOut){
14250
- if(typeof amis.pipeOut === 'function'){
14255
+ if (amis.pipeOut) {
14256
+ if (typeof amis.pipeOut === 'function') {
14251
14257
  return amis.pipeOut(value, data);
14252
14258
  }
14253
14259
  }
@@ -14262,9 +14268,6 @@ const getAmisInputTableSchema = async (props) => {
14262
14268
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
14263
14269
  });
14264
14270
  }
14265
- if (showAsInlineEditMode) {
14266
- inputTableSchema.needConfirm = false;
14267
- }
14268
14271
  if (amis) {
14269
14272
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
14270
14273
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
@@ -14306,19 +14309,19 @@ const getAmisInputTableSchema = async (props) => {
14306
14309
  });
14307
14310
  }
14308
14311
  let schema = {
14309
- "type": "service",
14310
- "body": [
14311
- {
14312
- "type": "control",
14313
- "body": schemaBody,
14314
- "label": props.label,
14315
- "labelClassName": props.label ? props.labelClassName : "none",
14316
- "labelRemark": props.labelRemark,
14317
- "labelAlign": props.labelAlign
14318
- }
14319
- ],
14320
- "className": props.className,
14321
- "id": serviceId
14312
+ "type": "control",
14313
+ "body": {
14314
+ "type": "service",
14315
+ "body": schemaBody,
14316
+ "id": serviceId
14317
+ },
14318
+ "label": props.label,
14319
+ "labelClassName": props.label ? props.labelClassName : "none",
14320
+ "labelRemark": props.labelRemark,
14321
+ "labelAlign": props.labelAlign,
14322
+ //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14323
+ "mode": props.mode || null,
14324
+ "className": props.className
14322
14325
  };
14323
14326
  // console.log("===schema===", schema);
14324
14327
  return schema;